babylon.module.d.ts 6.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002
  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. */
  23121. loadFromSerialization(source: any, rootUrl?: string): void;
  23122. /**
  23123. * Makes a duplicate of the current material.
  23124. * @param name - name to use for the new material.
  23125. */
  23126. clone(name: string): NodeMaterial;
  23127. /**
  23128. * Creates a node material from parsed material data
  23129. * @param source defines the JSON representation of the material
  23130. * @param scene defines the hosting scene
  23131. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23132. * @returns a new node material
  23133. */
  23134. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23135. /**
  23136. * Creates a node material from a snippet saved in a remote file
  23137. * @param name defines the name of the material to create
  23138. * @param url defines the url to load from
  23139. * @param scene defines the hosting scene
  23140. * @returns a promise that will resolve to the new node material
  23141. */
  23142. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23143. /**
  23144. * Creates a node material from a snippet saved by the node material editor
  23145. * @param snippetId defines the snippet to load
  23146. * @param scene defines the hosting scene
  23147. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23148. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23149. * @returns a promise that will resolve to the new node material
  23150. */
  23151. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23152. /**
  23153. * Creates a new node material set to default basic configuration
  23154. * @param name defines the name of the material
  23155. * @param scene defines the hosting scene
  23156. * @returns a new NodeMaterial
  23157. */
  23158. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23159. }
  23160. }
  23161. declare module "babylonjs/PostProcesses/postProcess" {
  23162. import { Nullable } from "babylonjs/types";
  23163. import { SmartArray } from "babylonjs/Misc/smartArray";
  23164. import { Observable } from "babylonjs/Misc/observable";
  23165. import { Vector2 } from "babylonjs/Maths/math.vector";
  23166. import { Camera } from "babylonjs/Cameras/camera";
  23167. import { Effect } from "babylonjs/Materials/effect";
  23168. import "babylonjs/Shaders/postprocess.vertex";
  23169. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23170. import { Engine } from "babylonjs/Engines/engine";
  23171. import { Color4 } from "babylonjs/Maths/math.color";
  23172. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23173. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23174. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23175. /**
  23176. * Size options for a post process
  23177. */
  23178. export type PostProcessOptions = {
  23179. width: number;
  23180. height: number;
  23181. };
  23182. /**
  23183. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23184. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23185. */
  23186. export class PostProcess {
  23187. /** Name of the PostProcess. */
  23188. name: string;
  23189. /**
  23190. * Gets or sets the unique id of the post process
  23191. */
  23192. uniqueId: number;
  23193. /**
  23194. * Width of the texture to apply the post process on
  23195. */
  23196. width: number;
  23197. /**
  23198. * Height of the texture to apply the post process on
  23199. */
  23200. height: number;
  23201. /**
  23202. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23203. */
  23204. nodeMaterialSource: Nullable<NodeMaterial>;
  23205. /**
  23206. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23207. * @hidden
  23208. */
  23209. _outputTexture: Nullable<InternalTexture>;
  23210. /**
  23211. * Sampling mode used by the shader
  23212. * See https://doc.babylonjs.com/classes/3.1/texture
  23213. */
  23214. renderTargetSamplingMode: number;
  23215. /**
  23216. * Clear color to use when screen clearing
  23217. */
  23218. clearColor: Color4;
  23219. /**
  23220. * If the buffer needs to be cleared before applying the post process. (default: true)
  23221. * Should be set to false if shader will overwrite all previous pixels.
  23222. */
  23223. autoClear: boolean;
  23224. /**
  23225. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23226. */
  23227. alphaMode: number;
  23228. /**
  23229. * Sets the setAlphaBlendConstants of the babylon engine
  23230. */
  23231. alphaConstants: Color4;
  23232. /**
  23233. * Animations to be used for the post processing
  23234. */
  23235. animations: import("babylonjs/Animations/animation").Animation[];
  23236. /**
  23237. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23238. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23239. */
  23240. enablePixelPerfectMode: boolean;
  23241. /**
  23242. * Force the postprocess to be applied without taking in account viewport
  23243. */
  23244. forceFullscreenViewport: boolean;
  23245. /**
  23246. * List of inspectable custom properties (used by the Inspector)
  23247. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23248. */
  23249. inspectableCustomProperties: IInspectable[];
  23250. /**
  23251. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23252. *
  23253. * | Value | Type | Description |
  23254. * | ----- | ----------------------------------- | ----------- |
  23255. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23256. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23257. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23258. *
  23259. */
  23260. scaleMode: number;
  23261. /**
  23262. * Force textures to be a power of two (default: false)
  23263. */
  23264. alwaysForcePOT: boolean;
  23265. private _samples;
  23266. /**
  23267. * Number of sample textures (default: 1)
  23268. */
  23269. get samples(): number;
  23270. set samples(n: number);
  23271. /**
  23272. * Modify the scale of the post process to be the same as the viewport (default: false)
  23273. */
  23274. adaptScaleToCurrentViewport: boolean;
  23275. private _camera;
  23276. private _scene;
  23277. private _engine;
  23278. private _options;
  23279. private _reusable;
  23280. private _textureType;
  23281. private _textureFormat;
  23282. /**
  23283. * Smart array of input and output textures for the post process.
  23284. * @hidden
  23285. */
  23286. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23287. /**
  23288. * The index in _textures that corresponds to the output texture.
  23289. * @hidden
  23290. */
  23291. _currentRenderTextureInd: number;
  23292. private _effect;
  23293. private _samplers;
  23294. private _fragmentUrl;
  23295. private _vertexUrl;
  23296. private _parameters;
  23297. private _scaleRatio;
  23298. protected _indexParameters: any;
  23299. private _shareOutputWithPostProcess;
  23300. private _texelSize;
  23301. private _forcedOutputTexture;
  23302. /**
  23303. * Returns the fragment url or shader name used in the post process.
  23304. * @returns the fragment url or name in the shader store.
  23305. */
  23306. getEffectName(): string;
  23307. /**
  23308. * An event triggered when the postprocess is activated.
  23309. */
  23310. onActivateObservable: Observable<Camera>;
  23311. private _onActivateObserver;
  23312. /**
  23313. * A function that is added to the onActivateObservable
  23314. */
  23315. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23316. /**
  23317. * An event triggered when the postprocess changes its size.
  23318. */
  23319. onSizeChangedObservable: Observable<PostProcess>;
  23320. private _onSizeChangedObserver;
  23321. /**
  23322. * A function that is added to the onSizeChangedObservable
  23323. */
  23324. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23325. /**
  23326. * An event triggered when the postprocess applies its effect.
  23327. */
  23328. onApplyObservable: Observable<Effect>;
  23329. private _onApplyObserver;
  23330. /**
  23331. * A function that is added to the onApplyObservable
  23332. */
  23333. set onApply(callback: (effect: Effect) => void);
  23334. /**
  23335. * An event triggered before rendering the postprocess
  23336. */
  23337. onBeforeRenderObservable: Observable<Effect>;
  23338. private _onBeforeRenderObserver;
  23339. /**
  23340. * A function that is added to the onBeforeRenderObservable
  23341. */
  23342. set onBeforeRender(callback: (effect: Effect) => void);
  23343. /**
  23344. * An event triggered after rendering the postprocess
  23345. */
  23346. onAfterRenderObservable: Observable<Effect>;
  23347. private _onAfterRenderObserver;
  23348. /**
  23349. * A function that is added to the onAfterRenderObservable
  23350. */
  23351. set onAfterRender(callback: (efect: Effect) => void);
  23352. /**
  23353. * 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
  23354. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23355. */
  23356. get inputTexture(): InternalTexture;
  23357. set inputTexture(value: InternalTexture);
  23358. /**
  23359. * Gets the camera which post process is applied to.
  23360. * @returns The camera the post process is applied to.
  23361. */
  23362. getCamera(): Camera;
  23363. /**
  23364. * Gets the texel size of the postprocess.
  23365. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23366. */
  23367. get texelSize(): Vector2;
  23368. /**
  23369. * Creates a new instance PostProcess
  23370. * @param name The name of the PostProcess.
  23371. * @param fragmentUrl The url of the fragment shader to be used.
  23372. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23373. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23374. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23375. * @param camera The camera to apply the render pass to.
  23376. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23377. * @param engine The engine which the post process will be applied. (default: current engine)
  23378. * @param reusable If the post process can be reused on the same frame. (default: false)
  23379. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23380. * @param textureType Type of textures used when performing the post process. (default: 0)
  23381. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23382. * @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
  23383. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23384. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23385. */
  23386. constructor(
  23387. /** Name of the PostProcess. */
  23388. 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);
  23389. /**
  23390. * Gets a string idenfifying the name of the class
  23391. * @returns "PostProcess" string
  23392. */
  23393. getClassName(): string;
  23394. /**
  23395. * Gets the engine which this post process belongs to.
  23396. * @returns The engine the post process was enabled with.
  23397. */
  23398. getEngine(): Engine;
  23399. /**
  23400. * The effect that is created when initializing the post process.
  23401. * @returns The created effect corresponding the the postprocess.
  23402. */
  23403. getEffect(): Effect;
  23404. /**
  23405. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23406. * @param postProcess The post process to share the output with.
  23407. * @returns This post process.
  23408. */
  23409. shareOutputWith(postProcess: PostProcess): PostProcess;
  23410. /**
  23411. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23412. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23413. */
  23414. useOwnOutput(): void;
  23415. /**
  23416. * Updates the effect with the current post process compile time values and recompiles the shader.
  23417. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23418. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23419. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23420. * @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
  23421. * @param onCompiled Called when the shader has been compiled.
  23422. * @param onError Called if there is an error when compiling a shader.
  23423. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23424. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23425. */
  23426. 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;
  23427. /**
  23428. * The post process is reusable if it can be used multiple times within one frame.
  23429. * @returns If the post process is reusable
  23430. */
  23431. isReusable(): boolean;
  23432. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23433. markTextureDirty(): void;
  23434. /**
  23435. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23436. * 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.
  23437. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23438. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23439. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23440. * @returns The target texture that was bound to be written to.
  23441. */
  23442. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23443. /**
  23444. * If the post process is supported.
  23445. */
  23446. get isSupported(): boolean;
  23447. /**
  23448. * The aspect ratio of the output texture.
  23449. */
  23450. get aspectRatio(): number;
  23451. /**
  23452. * Get a value indicating if the post-process is ready to be used
  23453. * @returns true if the post-process is ready (shader is compiled)
  23454. */
  23455. isReady(): boolean;
  23456. /**
  23457. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23458. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23459. */
  23460. apply(): Nullable<Effect>;
  23461. private _disposeTextures;
  23462. /**
  23463. * Disposes the post process.
  23464. * @param camera The camera to dispose the post process on.
  23465. */
  23466. dispose(camera?: Camera): void;
  23467. }
  23468. }
  23469. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23470. /** @hidden */
  23471. export var kernelBlurVaryingDeclaration: {
  23472. name: string;
  23473. shader: string;
  23474. };
  23475. }
  23476. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23477. /** @hidden */
  23478. export var kernelBlurFragment: {
  23479. name: string;
  23480. shader: string;
  23481. };
  23482. }
  23483. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23484. /** @hidden */
  23485. export var kernelBlurFragment2: {
  23486. name: string;
  23487. shader: string;
  23488. };
  23489. }
  23490. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23491. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23492. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23493. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23494. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23495. /** @hidden */
  23496. export var kernelBlurPixelShader: {
  23497. name: string;
  23498. shader: string;
  23499. };
  23500. }
  23501. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23502. /** @hidden */
  23503. export var kernelBlurVertex: {
  23504. name: string;
  23505. shader: string;
  23506. };
  23507. }
  23508. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23509. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23510. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23511. /** @hidden */
  23512. export var kernelBlurVertexShader: {
  23513. name: string;
  23514. shader: string;
  23515. };
  23516. }
  23517. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23518. import { Vector2 } from "babylonjs/Maths/math.vector";
  23519. import { Nullable } from "babylonjs/types";
  23520. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23521. import { Camera } from "babylonjs/Cameras/camera";
  23522. import { Effect } from "babylonjs/Materials/effect";
  23523. import { Engine } from "babylonjs/Engines/engine";
  23524. import "babylonjs/Shaders/kernelBlur.fragment";
  23525. import "babylonjs/Shaders/kernelBlur.vertex";
  23526. /**
  23527. * The Blur Post Process which blurs an image based on a kernel and direction.
  23528. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23529. */
  23530. export class BlurPostProcess extends PostProcess {
  23531. /** The direction in which to blur the image. */
  23532. direction: Vector2;
  23533. private blockCompilation;
  23534. protected _kernel: number;
  23535. protected _idealKernel: number;
  23536. protected _packedFloat: boolean;
  23537. private _staticDefines;
  23538. /**
  23539. * Sets the length in pixels of the blur sample region
  23540. */
  23541. set kernel(v: number);
  23542. /**
  23543. * Gets the length in pixels of the blur sample region
  23544. */
  23545. get kernel(): number;
  23546. /**
  23547. * Sets wether or not the blur needs to unpack/repack floats
  23548. */
  23549. set packedFloat(v: boolean);
  23550. /**
  23551. * Gets wether or not the blur is unpacking/repacking floats
  23552. */
  23553. get packedFloat(): boolean;
  23554. /**
  23555. * Creates a new instance BlurPostProcess
  23556. * @param name The name of the effect.
  23557. * @param direction The direction in which to blur the image.
  23558. * @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.
  23559. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23560. * @param camera The camera to apply the render pass to.
  23561. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23562. * @param engine The engine which the post process will be applied. (default: current engine)
  23563. * @param reusable If the post process can be reused on the same frame. (default: false)
  23564. * @param textureType Type of textures used when performing the post process. (default: 0)
  23565. * @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)
  23566. */
  23567. constructor(name: string,
  23568. /** The direction in which to blur the image. */
  23569. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23570. /**
  23571. * Updates the effect with the current post process compile time values and recompiles the shader.
  23572. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23573. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23574. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23575. * @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
  23576. * @param onCompiled Called when the shader has been compiled.
  23577. * @param onError Called if there is an error when compiling a shader.
  23578. */
  23579. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23580. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23581. /**
  23582. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23583. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23584. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23585. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23586. * The gaps between physical kernels are compensated for in the weighting of the samples
  23587. * @param idealKernel Ideal blur kernel.
  23588. * @return Nearest best kernel.
  23589. */
  23590. protected _nearestBestKernel(idealKernel: number): number;
  23591. /**
  23592. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23593. * @param x The point on the Gaussian distribution to sample.
  23594. * @return the value of the Gaussian function at x.
  23595. */
  23596. protected _gaussianWeight(x: number): number;
  23597. /**
  23598. * Generates a string that can be used as a floating point number in GLSL.
  23599. * @param x Value to print.
  23600. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23601. * @return GLSL float string.
  23602. */
  23603. protected _glslFloat(x: number, decimalFigures?: number): string;
  23604. }
  23605. }
  23606. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23607. import { Scene } from "babylonjs/scene";
  23608. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23609. import { Plane } from "babylonjs/Maths/math.plane";
  23610. /**
  23611. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23612. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23613. * You can then easily use it as a reflectionTexture on a flat surface.
  23614. * In case the surface is not a plane, please consider relying on reflection probes.
  23615. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23616. */
  23617. export class MirrorTexture extends RenderTargetTexture {
  23618. private scene;
  23619. /**
  23620. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23621. * 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.
  23622. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23623. */
  23624. mirrorPlane: Plane;
  23625. /**
  23626. * Define the blur ratio used to blur the reflection if needed.
  23627. */
  23628. set blurRatio(value: number);
  23629. get blurRatio(): number;
  23630. /**
  23631. * Define the adaptive blur kernel used to blur the reflection if needed.
  23632. * This will autocompute the closest best match for the `blurKernel`
  23633. */
  23634. set adaptiveBlurKernel(value: number);
  23635. /**
  23636. * Define the blur kernel used to blur the reflection if needed.
  23637. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23638. */
  23639. set blurKernel(value: number);
  23640. /**
  23641. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23642. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23643. */
  23644. set blurKernelX(value: number);
  23645. get blurKernelX(): number;
  23646. /**
  23647. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23648. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23649. */
  23650. set blurKernelY(value: number);
  23651. get blurKernelY(): number;
  23652. private _autoComputeBlurKernel;
  23653. protected _onRatioRescale(): void;
  23654. private _updateGammaSpace;
  23655. private _imageProcessingConfigChangeObserver;
  23656. private _transformMatrix;
  23657. private _mirrorMatrix;
  23658. private _savedViewMatrix;
  23659. private _blurX;
  23660. private _blurY;
  23661. private _adaptiveBlurKernel;
  23662. private _blurKernelX;
  23663. private _blurKernelY;
  23664. private _blurRatio;
  23665. /**
  23666. * Instantiates a Mirror Texture.
  23667. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23668. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23669. * You can then easily use it as a reflectionTexture on a flat surface.
  23670. * In case the surface is not a plane, please consider relying on reflection probes.
  23671. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23672. * @param name
  23673. * @param size
  23674. * @param scene
  23675. * @param generateMipMaps
  23676. * @param type
  23677. * @param samplingMode
  23678. * @param generateDepthBuffer
  23679. */
  23680. constructor(name: string, size: number | {
  23681. width: number;
  23682. height: number;
  23683. } | {
  23684. ratio: number;
  23685. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23686. private _preparePostProcesses;
  23687. /**
  23688. * Clone the mirror texture.
  23689. * @returns the cloned texture
  23690. */
  23691. clone(): MirrorTexture;
  23692. /**
  23693. * Serialize the texture to a JSON representation you could use in Parse later on
  23694. * @returns the serialized JSON representation
  23695. */
  23696. serialize(): any;
  23697. /**
  23698. * Dispose the texture and release its associated resources.
  23699. */
  23700. dispose(): void;
  23701. }
  23702. }
  23703. declare module "babylonjs/Materials/Textures/texture" {
  23704. import { Observable } from "babylonjs/Misc/observable";
  23705. import { Nullable } from "babylonjs/types";
  23706. import { Matrix } from "babylonjs/Maths/math.vector";
  23707. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23708. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23709. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23710. import { Scene } from "babylonjs/scene";
  23711. /**
  23712. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23713. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23714. */
  23715. export class Texture extends BaseTexture {
  23716. /**
  23717. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23718. */
  23719. static SerializeBuffers: boolean;
  23720. /** @hidden */
  23721. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  23722. /** @hidden */
  23723. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  23724. /** @hidden */
  23725. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  23726. /** nearest is mag = nearest and min = nearest and mip = linear */
  23727. static readonly NEAREST_SAMPLINGMODE: number;
  23728. /** nearest is mag = nearest and min = nearest and mip = linear */
  23729. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23730. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23731. static readonly BILINEAR_SAMPLINGMODE: number;
  23732. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23733. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23734. /** Trilinear is mag = linear and min = linear and mip = linear */
  23735. static readonly TRILINEAR_SAMPLINGMODE: number;
  23736. /** Trilinear is mag = linear and min = linear and mip = linear */
  23737. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23738. /** mag = nearest and min = nearest and mip = nearest */
  23739. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23740. /** mag = nearest and min = linear and mip = nearest */
  23741. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23742. /** mag = nearest and min = linear and mip = linear */
  23743. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23744. /** mag = nearest and min = linear and mip = none */
  23745. static readonly NEAREST_LINEAR: number;
  23746. /** mag = nearest and min = nearest and mip = none */
  23747. static readonly NEAREST_NEAREST: number;
  23748. /** mag = linear and min = nearest and mip = nearest */
  23749. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23750. /** mag = linear and min = nearest and mip = linear */
  23751. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23752. /** mag = linear and min = linear and mip = none */
  23753. static readonly LINEAR_LINEAR: number;
  23754. /** mag = linear and min = nearest and mip = none */
  23755. static readonly LINEAR_NEAREST: number;
  23756. /** Explicit coordinates mode */
  23757. static readonly EXPLICIT_MODE: number;
  23758. /** Spherical coordinates mode */
  23759. static readonly SPHERICAL_MODE: number;
  23760. /** Planar coordinates mode */
  23761. static readonly PLANAR_MODE: number;
  23762. /** Cubic coordinates mode */
  23763. static readonly CUBIC_MODE: number;
  23764. /** Projection coordinates mode */
  23765. static readonly PROJECTION_MODE: number;
  23766. /** Inverse Cubic coordinates mode */
  23767. static readonly SKYBOX_MODE: number;
  23768. /** Inverse Cubic coordinates mode */
  23769. static readonly INVCUBIC_MODE: number;
  23770. /** Equirectangular coordinates mode */
  23771. static readonly EQUIRECTANGULAR_MODE: number;
  23772. /** Equirectangular Fixed coordinates mode */
  23773. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23774. /** Equirectangular Fixed Mirrored coordinates mode */
  23775. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23776. /** Texture is not repeating outside of 0..1 UVs */
  23777. static readonly CLAMP_ADDRESSMODE: number;
  23778. /** Texture is repeating outside of 0..1 UVs */
  23779. static readonly WRAP_ADDRESSMODE: number;
  23780. /** Texture is repeating and mirrored */
  23781. static readonly MIRROR_ADDRESSMODE: number;
  23782. /**
  23783. * 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
  23784. */
  23785. static UseSerializedUrlIfAny: boolean;
  23786. /**
  23787. * Define the url of the texture.
  23788. */
  23789. url: Nullable<string>;
  23790. /**
  23791. * Define an offset on the texture to offset the u coordinates of the UVs
  23792. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  23793. */
  23794. uOffset: number;
  23795. /**
  23796. * Define an offset on the texture to offset the v coordinates of the UVs
  23797. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  23798. */
  23799. vOffset: number;
  23800. /**
  23801. * Define an offset on the texture to scale the u coordinates of the UVs
  23802. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23803. */
  23804. uScale: number;
  23805. /**
  23806. * Define an offset on the texture to scale the v coordinates of the UVs
  23807. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23808. */
  23809. vScale: number;
  23810. /**
  23811. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23812. * @see http://doc.babylonjs.com/how_to/more_materials
  23813. */
  23814. uAng: number;
  23815. /**
  23816. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23817. * @see http://doc.babylonjs.com/how_to/more_materials
  23818. */
  23819. vAng: number;
  23820. /**
  23821. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23822. * @see http://doc.babylonjs.com/how_to/more_materials
  23823. */
  23824. wAng: number;
  23825. /**
  23826. * Defines the center of rotation (U)
  23827. */
  23828. uRotationCenter: number;
  23829. /**
  23830. * Defines the center of rotation (V)
  23831. */
  23832. vRotationCenter: number;
  23833. /**
  23834. * Defines the center of rotation (W)
  23835. */
  23836. wRotationCenter: number;
  23837. /**
  23838. * Are mip maps generated for this texture or not.
  23839. */
  23840. get noMipmap(): boolean;
  23841. /**
  23842. * List of inspectable custom properties (used by the Inspector)
  23843. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23844. */
  23845. inspectableCustomProperties: Nullable<IInspectable[]>;
  23846. private _noMipmap;
  23847. /** @hidden */
  23848. _invertY: boolean;
  23849. private _rowGenerationMatrix;
  23850. private _cachedTextureMatrix;
  23851. private _projectionModeMatrix;
  23852. private _t0;
  23853. private _t1;
  23854. private _t2;
  23855. private _cachedUOffset;
  23856. private _cachedVOffset;
  23857. private _cachedUScale;
  23858. private _cachedVScale;
  23859. private _cachedUAng;
  23860. private _cachedVAng;
  23861. private _cachedWAng;
  23862. private _cachedProjectionMatrixId;
  23863. private _cachedCoordinatesMode;
  23864. /** @hidden */
  23865. protected _initialSamplingMode: number;
  23866. /** @hidden */
  23867. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23868. private _deleteBuffer;
  23869. protected _format: Nullable<number>;
  23870. private _delayedOnLoad;
  23871. private _delayedOnError;
  23872. private _mimeType?;
  23873. /**
  23874. * Observable triggered once the texture has been loaded.
  23875. */
  23876. onLoadObservable: Observable<Texture>;
  23877. protected _isBlocking: boolean;
  23878. /**
  23879. * Is the texture preventing material to render while loading.
  23880. * If false, a default texture will be used instead of the loading one during the preparation step.
  23881. */
  23882. set isBlocking(value: boolean);
  23883. get isBlocking(): boolean;
  23884. /**
  23885. * Get the current sampling mode associated with the texture.
  23886. */
  23887. get samplingMode(): number;
  23888. /**
  23889. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23890. */
  23891. get invertY(): boolean;
  23892. /**
  23893. * Instantiates a new texture.
  23894. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23895. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23896. * @param url defines the url of the picture to load as a texture
  23897. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23898. * @param noMipmap defines if the texture will require mip maps or not
  23899. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23900. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23901. * @param onLoad defines a callback triggered when the texture has been loaded
  23902. * @param onError defines a callback triggered when an error occurred during the loading session
  23903. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23904. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23905. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23906. * @param mimeType defines an optional mime type information
  23907. */
  23908. 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);
  23909. /**
  23910. * Update the url (and optional buffer) of this texture if url was null during construction.
  23911. * @param url the url of the texture
  23912. * @param buffer the buffer of the texture (defaults to null)
  23913. * @param onLoad callback called when the texture is loaded (defaults to null)
  23914. */
  23915. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23916. /**
  23917. * Finish the loading sequence of a texture flagged as delayed load.
  23918. * @hidden
  23919. */
  23920. delayLoad(): void;
  23921. private _prepareRowForTextureGeneration;
  23922. /**
  23923. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23924. * @returns the transform matrix of the texture.
  23925. */
  23926. getTextureMatrix(uBase?: number): Matrix;
  23927. /**
  23928. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23929. * @returns The reflection texture transform
  23930. */
  23931. getReflectionTextureMatrix(): Matrix;
  23932. /**
  23933. * Clones the texture.
  23934. * @returns the cloned texture
  23935. */
  23936. clone(): Texture;
  23937. /**
  23938. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23939. * @returns The JSON representation of the texture
  23940. */
  23941. serialize(): any;
  23942. /**
  23943. * Get the current class name of the texture useful for serialization or dynamic coding.
  23944. * @returns "Texture"
  23945. */
  23946. getClassName(): string;
  23947. /**
  23948. * Dispose the texture and release its associated resources.
  23949. */
  23950. dispose(): void;
  23951. /**
  23952. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23953. * @param parsedTexture Define the JSON representation of the texture
  23954. * @param scene Define the scene the parsed texture should be instantiated in
  23955. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23956. * @returns The parsed texture if successful
  23957. */
  23958. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23959. /**
  23960. * Creates a texture from its base 64 representation.
  23961. * @param data Define the base64 payload without the data: prefix
  23962. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23963. * @param scene Define the scene the texture should belong to
  23964. * @param noMipmap Forces the texture to not create mip map information if true
  23965. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23966. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23967. * @param onLoad define a callback triggered when the texture has been loaded
  23968. * @param onError define a callback triggered when an error occurred during the loading session
  23969. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23970. * @returns the created texture
  23971. */
  23972. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23973. /**
  23974. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23975. * @param data Define the base64 payload without the data: prefix
  23976. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23977. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23978. * @param scene Define the scene the texture should belong to
  23979. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23980. * @param noMipmap Forces the texture to not create mip map information if true
  23981. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23982. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23983. * @param onLoad define a callback triggered when the texture has been loaded
  23984. * @param onError define a callback triggered when an error occurred during the loading session
  23985. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23986. * @returns the created texture
  23987. */
  23988. 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;
  23989. }
  23990. }
  23991. declare module "babylonjs/PostProcesses/postProcessManager" {
  23992. import { Nullable } from "babylonjs/types";
  23993. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23994. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  23995. import { Scene } from "babylonjs/scene";
  23996. /**
  23997. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23998. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23999. */
  24000. export class PostProcessManager {
  24001. private _scene;
  24002. private _indexBuffer;
  24003. private _vertexBuffers;
  24004. /**
  24005. * Creates a new instance PostProcess
  24006. * @param scene The scene that the post process is associated with.
  24007. */
  24008. constructor(scene: Scene);
  24009. private _prepareBuffers;
  24010. private _buildIndexBuffer;
  24011. /**
  24012. * Rebuilds the vertex buffers of the manager.
  24013. * @hidden
  24014. */
  24015. _rebuild(): void;
  24016. /**
  24017. * Prepares a frame to be run through a post process.
  24018. * @param sourceTexture The input texture to the post procesess. (default: null)
  24019. * @param postProcesses An array of post processes to be run. (default: null)
  24020. * @returns True if the post processes were able to be run.
  24021. * @hidden
  24022. */
  24023. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24024. /**
  24025. * Manually render a set of post processes to a texture.
  24026. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24027. * @param postProcesses An array of post processes to be run.
  24028. * @param targetTexture The target texture to render to.
  24029. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24030. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24031. * @param lodLevel defines which lod of the texture to render to
  24032. */
  24033. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  24034. /**
  24035. * Finalize the result of the output of the postprocesses.
  24036. * @param doNotPresent If true the result will not be displayed to the screen.
  24037. * @param targetTexture The target texture to render to.
  24038. * @param faceIndex The index of the face to bind the target texture to.
  24039. * @param postProcesses The array of post processes to render.
  24040. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24041. * @hidden
  24042. */
  24043. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24044. /**
  24045. * Disposes of the post process manager.
  24046. */
  24047. dispose(): void;
  24048. }
  24049. }
  24050. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24051. import { Observable } from "babylonjs/Misc/observable";
  24052. import { SmartArray } from "babylonjs/Misc/smartArray";
  24053. import { Nullable, Immutable } from "babylonjs/types";
  24054. import { Camera } from "babylonjs/Cameras/camera";
  24055. import { Scene } from "babylonjs/scene";
  24056. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24057. import { Color4 } from "babylonjs/Maths/math.color";
  24058. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24060. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24061. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24062. import { Texture } from "babylonjs/Materials/Textures/texture";
  24063. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24064. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24065. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24066. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24067. import { Engine } from "babylonjs/Engines/engine";
  24068. /**
  24069. * This Helps creating a texture that will be created from a camera in your scene.
  24070. * It is basically a dynamic texture that could be used to create special effects for instance.
  24071. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24072. */
  24073. export class RenderTargetTexture extends Texture {
  24074. isCube: boolean;
  24075. /**
  24076. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24077. */
  24078. static readonly REFRESHRATE_RENDER_ONCE: number;
  24079. /**
  24080. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24081. */
  24082. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24083. /**
  24084. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24085. * the central point of your effect and can save a lot of performances.
  24086. */
  24087. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24088. /**
  24089. * Use this predicate to dynamically define the list of mesh you want to render.
  24090. * If set, the renderList property will be overwritten.
  24091. */
  24092. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24093. private _renderList;
  24094. /**
  24095. * Use this list to define the list of mesh you want to render.
  24096. */
  24097. get renderList(): Nullable<Array<AbstractMesh>>;
  24098. set renderList(value: Nullable<Array<AbstractMesh>>);
  24099. /**
  24100. * Use this function to overload the renderList array at rendering time.
  24101. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24102. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24103. * the cube (if the RTT is a cube, else layerOrFace=0).
  24104. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24105. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24106. * hold dummy elements!
  24107. */
  24108. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24109. private _hookArray;
  24110. /**
  24111. * Define if particles should be rendered in your texture.
  24112. */
  24113. renderParticles: boolean;
  24114. /**
  24115. * Define if sprites should be rendered in your texture.
  24116. */
  24117. renderSprites: boolean;
  24118. /**
  24119. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24120. */
  24121. coordinatesMode: number;
  24122. /**
  24123. * Define the camera used to render the texture.
  24124. */
  24125. activeCamera: Nullable<Camera>;
  24126. /**
  24127. * Override the mesh isReady function with your own one.
  24128. */
  24129. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24130. /**
  24131. * Override the render function of the texture with your own one.
  24132. */
  24133. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24134. /**
  24135. * Define if camera post processes should be use while rendering the texture.
  24136. */
  24137. useCameraPostProcesses: boolean;
  24138. /**
  24139. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24140. */
  24141. ignoreCameraViewport: boolean;
  24142. private _postProcessManager;
  24143. private _postProcesses;
  24144. private _resizeObserver;
  24145. /**
  24146. * An event triggered when the texture is unbind.
  24147. */
  24148. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24149. /**
  24150. * An event triggered when the texture is unbind.
  24151. */
  24152. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24153. private _onAfterUnbindObserver;
  24154. /**
  24155. * Set a after unbind callback in the texture.
  24156. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24157. */
  24158. set onAfterUnbind(callback: () => void);
  24159. /**
  24160. * An event triggered before rendering the texture
  24161. */
  24162. onBeforeRenderObservable: Observable<number>;
  24163. private _onBeforeRenderObserver;
  24164. /**
  24165. * Set a before render callback in the texture.
  24166. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24167. */
  24168. set onBeforeRender(callback: (faceIndex: number) => void);
  24169. /**
  24170. * An event triggered after rendering the texture
  24171. */
  24172. onAfterRenderObservable: Observable<number>;
  24173. private _onAfterRenderObserver;
  24174. /**
  24175. * Set a after render callback in the texture.
  24176. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24177. */
  24178. set onAfterRender(callback: (faceIndex: number) => void);
  24179. /**
  24180. * An event triggered after the texture clear
  24181. */
  24182. onClearObservable: Observable<Engine>;
  24183. private _onClearObserver;
  24184. /**
  24185. * Set a clear callback in the texture.
  24186. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24187. */
  24188. set onClear(callback: (Engine: Engine) => void);
  24189. /**
  24190. * An event triggered when the texture is resized.
  24191. */
  24192. onResizeObservable: Observable<RenderTargetTexture>;
  24193. /**
  24194. * Define the clear color of the Render Target if it should be different from the scene.
  24195. */
  24196. clearColor: Color4;
  24197. protected _size: number | {
  24198. width: number;
  24199. height: number;
  24200. layers?: number;
  24201. };
  24202. protected _initialSizeParameter: number | {
  24203. width: number;
  24204. height: number;
  24205. } | {
  24206. ratio: number;
  24207. };
  24208. protected _sizeRatio: Nullable<number>;
  24209. /** @hidden */
  24210. _generateMipMaps: boolean;
  24211. protected _renderingManager: RenderingManager;
  24212. /** @hidden */
  24213. _waitingRenderList: string[];
  24214. protected _doNotChangeAspectRatio: boolean;
  24215. protected _currentRefreshId: number;
  24216. protected _refreshRate: number;
  24217. protected _textureMatrix: Matrix;
  24218. protected _samples: number;
  24219. protected _renderTargetOptions: RenderTargetCreationOptions;
  24220. /**
  24221. * Gets render target creation options that were used.
  24222. */
  24223. get renderTargetOptions(): RenderTargetCreationOptions;
  24224. protected _onRatioRescale(): void;
  24225. /**
  24226. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24227. * It must define where the camera used to render the texture is set
  24228. */
  24229. boundingBoxPosition: Vector3;
  24230. private _boundingBoxSize;
  24231. /**
  24232. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24233. * When defined, the cubemap will switch to local mode
  24234. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24235. * @example https://www.babylonjs-playground.com/#RNASML
  24236. */
  24237. set boundingBoxSize(value: Vector3);
  24238. get boundingBoxSize(): Vector3;
  24239. /**
  24240. * In case the RTT has been created with a depth texture, get the associated
  24241. * depth texture.
  24242. * Otherwise, return null.
  24243. */
  24244. get depthStencilTexture(): Nullable<InternalTexture>;
  24245. /**
  24246. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24247. * or used a shadow, depth texture...
  24248. * @param name The friendly name of the texture
  24249. * @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)
  24250. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24251. * @param generateMipMaps True if mip maps need to be generated after render.
  24252. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24253. * @param type The type of the buffer in the RTT (int, half float, float...)
  24254. * @param isCube True if a cube texture needs to be created
  24255. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24256. * @param generateDepthBuffer True to generate a depth buffer
  24257. * @param generateStencilBuffer True to generate a stencil buffer
  24258. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24259. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24260. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24261. */
  24262. constructor(name: string, size: number | {
  24263. width: number;
  24264. height: number;
  24265. layers?: number;
  24266. } | {
  24267. ratio: number;
  24268. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24269. /**
  24270. * Creates a depth stencil texture.
  24271. * This is only available in WebGL 2 or with the depth texture extension available.
  24272. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24273. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24274. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24275. */
  24276. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24277. private _processSizeParameter;
  24278. /**
  24279. * Define the number of samples to use in case of MSAA.
  24280. * It defaults to one meaning no MSAA has been enabled.
  24281. */
  24282. get samples(): number;
  24283. set samples(value: number);
  24284. /**
  24285. * Resets the refresh counter of the texture and start bak from scratch.
  24286. * Could be useful to regenerate the texture if it is setup to render only once.
  24287. */
  24288. resetRefreshCounter(): void;
  24289. /**
  24290. * Define the refresh rate of the texture or the rendering frequency.
  24291. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24292. */
  24293. get refreshRate(): number;
  24294. set refreshRate(value: number);
  24295. /**
  24296. * Adds a post process to the render target rendering passes.
  24297. * @param postProcess define the post process to add
  24298. */
  24299. addPostProcess(postProcess: PostProcess): void;
  24300. /**
  24301. * Clear all the post processes attached to the render target
  24302. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24303. */
  24304. clearPostProcesses(dispose?: boolean): void;
  24305. /**
  24306. * Remove one of the post process from the list of attached post processes to the texture
  24307. * @param postProcess define the post process to remove from the list
  24308. */
  24309. removePostProcess(postProcess: PostProcess): void;
  24310. /** @hidden */
  24311. _shouldRender(): boolean;
  24312. /**
  24313. * Gets the actual render size of the texture.
  24314. * @returns the width of the render size
  24315. */
  24316. getRenderSize(): number;
  24317. /**
  24318. * Gets the actual render width of the texture.
  24319. * @returns the width of the render size
  24320. */
  24321. getRenderWidth(): number;
  24322. /**
  24323. * Gets the actual render height of the texture.
  24324. * @returns the height of the render size
  24325. */
  24326. getRenderHeight(): number;
  24327. /**
  24328. * Gets the actual number of layers of the texture.
  24329. * @returns the number of layers
  24330. */
  24331. getRenderLayers(): number;
  24332. /**
  24333. * Get if the texture can be rescaled or not.
  24334. */
  24335. get canRescale(): boolean;
  24336. /**
  24337. * Resize the texture using a ratio.
  24338. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24339. */
  24340. scale(ratio: number): void;
  24341. /**
  24342. * Get the texture reflection matrix used to rotate/transform the reflection.
  24343. * @returns the reflection matrix
  24344. */
  24345. getReflectionTextureMatrix(): Matrix;
  24346. /**
  24347. * Resize the texture to a new desired size.
  24348. * Be carrefull as it will recreate all the data in the new texture.
  24349. * @param size Define the new size. It can be:
  24350. * - a number for squared texture,
  24351. * - an object containing { width: number, height: number }
  24352. * - or an object containing a ratio { ratio: number }
  24353. */
  24354. resize(size: number | {
  24355. width: number;
  24356. height: number;
  24357. } | {
  24358. ratio: number;
  24359. }): void;
  24360. private _defaultRenderListPrepared;
  24361. /**
  24362. * Renders all the objects from the render list into the texture.
  24363. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24364. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24365. */
  24366. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24367. private _bestReflectionRenderTargetDimension;
  24368. private _prepareRenderingManager;
  24369. /**
  24370. * @hidden
  24371. * @param faceIndex face index to bind to if this is a cubetexture
  24372. * @param layer defines the index of the texture to bind in the array
  24373. */
  24374. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24375. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24376. private renderToTarget;
  24377. /**
  24378. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24379. * This allowed control for front to back rendering or reversly depending of the special needs.
  24380. *
  24381. * @param renderingGroupId The rendering group id corresponding to its index
  24382. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24383. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24384. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24385. */
  24386. 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;
  24387. /**
  24388. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24389. *
  24390. * @param renderingGroupId The rendering group id corresponding to its index
  24391. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24392. */
  24393. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24394. /**
  24395. * Clones the texture.
  24396. * @returns the cloned texture
  24397. */
  24398. clone(): RenderTargetTexture;
  24399. /**
  24400. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24401. * @returns The JSON representation of the texture
  24402. */
  24403. serialize(): any;
  24404. /**
  24405. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24406. */
  24407. disposeFramebufferObjects(): void;
  24408. /**
  24409. * Dispose the texture and release its associated resources.
  24410. */
  24411. dispose(): void;
  24412. /** @hidden */
  24413. _rebuild(): void;
  24414. /**
  24415. * Clear the info related to rendering groups preventing retention point in material dispose.
  24416. */
  24417. freeRenderingGroups(): void;
  24418. /**
  24419. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24420. * @returns the view count
  24421. */
  24422. getViewCount(): number;
  24423. }
  24424. }
  24425. declare module "babylonjs/Misc/guid" {
  24426. /**
  24427. * Class used to manipulate GUIDs
  24428. */
  24429. export class GUID {
  24430. /**
  24431. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24432. * Be aware Math.random() could cause collisions, but:
  24433. * "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"
  24434. * @returns a pseudo random id
  24435. */
  24436. static RandomId(): string;
  24437. }
  24438. }
  24439. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24440. import { Nullable } from "babylonjs/types";
  24441. import { Scene } from "babylonjs/scene";
  24442. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24443. import { Material } from "babylonjs/Materials/material";
  24444. import { Effect } from "babylonjs/Materials/effect";
  24445. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24446. /**
  24447. * Options to be used when creating a shadow depth material
  24448. */
  24449. export interface IIOptionShadowDepthMaterial {
  24450. /** Variables in the vertex shader code that need to have their names remapped.
  24451. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24452. * "var_name" should be either: worldPos or vNormalW
  24453. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24454. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24455. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24456. */
  24457. remappedVariables?: string[];
  24458. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24459. standalone?: boolean;
  24460. }
  24461. /**
  24462. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24463. */
  24464. export class ShadowDepthWrapper {
  24465. private _scene;
  24466. private _options?;
  24467. private _baseMaterial;
  24468. private _onEffectCreatedObserver;
  24469. private _subMeshToEffect;
  24470. private _subMeshToDepthEffect;
  24471. private _meshes;
  24472. /** @hidden */
  24473. _matriceNames: any;
  24474. /** Gets the standalone status of the wrapper */
  24475. get standalone(): boolean;
  24476. /** Gets the base material the wrapper is built upon */
  24477. get baseMaterial(): Material;
  24478. /**
  24479. * Instantiate a new shadow depth wrapper.
  24480. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24481. * generate the shadow depth map. For more information, please refer to the documentation:
  24482. * https://doc.babylonjs.com/babylon101/shadows
  24483. * @param baseMaterial Material to wrap
  24484. * @param scene Define the scene the material belongs to
  24485. * @param options Options used to create the wrapper
  24486. */
  24487. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24488. /**
  24489. * Gets the effect to use to generate the depth map
  24490. * @param subMesh subMesh to get the effect for
  24491. * @param shadowGenerator shadow generator to get the effect for
  24492. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24493. */
  24494. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24495. /**
  24496. * Specifies that the submesh is ready to be used for depth rendering
  24497. * @param subMesh submesh to check
  24498. * @param defines the list of defines to take into account when checking the effect
  24499. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24500. * @param useInstances specifies that instances should be used
  24501. * @returns a boolean indicating that the submesh is ready or not
  24502. */
  24503. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24504. /**
  24505. * Disposes the resources
  24506. */
  24507. dispose(): void;
  24508. private _makeEffect;
  24509. }
  24510. }
  24511. declare module "babylonjs/Materials/material" {
  24512. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24513. import { SmartArray } from "babylonjs/Misc/smartArray";
  24514. import { Observable } from "babylonjs/Misc/observable";
  24515. import { Nullable } from "babylonjs/types";
  24516. import { Scene } from "babylonjs/scene";
  24517. import { Matrix } from "babylonjs/Maths/math.vector";
  24518. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24520. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24521. import { Effect } from "babylonjs/Materials/effect";
  24522. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24523. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24524. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24525. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24526. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  24527. import { Mesh } from "babylonjs/Meshes/mesh";
  24528. import { Animation } from "babylonjs/Animations/animation";
  24529. /**
  24530. * Options for compiling materials.
  24531. */
  24532. export interface IMaterialCompilationOptions {
  24533. /**
  24534. * Defines whether clip planes are enabled.
  24535. */
  24536. clipPlane: boolean;
  24537. /**
  24538. * Defines whether instances are enabled.
  24539. */
  24540. useInstances: boolean;
  24541. }
  24542. /**
  24543. * Options passed when calling customShaderNameResolve
  24544. */
  24545. export interface ICustomShaderNameResolveOptions {
  24546. /**
  24547. * 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
  24548. */
  24549. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24550. }
  24551. /**
  24552. * Base class for the main features of a material in Babylon.js
  24553. */
  24554. export class Material implements IAnimatable {
  24555. /**
  24556. * Returns the triangle fill mode
  24557. */
  24558. static readonly TriangleFillMode: number;
  24559. /**
  24560. * Returns the wireframe mode
  24561. */
  24562. static readonly WireFrameFillMode: number;
  24563. /**
  24564. * Returns the point fill mode
  24565. */
  24566. static readonly PointFillMode: number;
  24567. /**
  24568. * Returns the point list draw mode
  24569. */
  24570. static readonly PointListDrawMode: number;
  24571. /**
  24572. * Returns the line list draw mode
  24573. */
  24574. static readonly LineListDrawMode: number;
  24575. /**
  24576. * Returns the line loop draw mode
  24577. */
  24578. static readonly LineLoopDrawMode: number;
  24579. /**
  24580. * Returns the line strip draw mode
  24581. */
  24582. static readonly LineStripDrawMode: number;
  24583. /**
  24584. * Returns the triangle strip draw mode
  24585. */
  24586. static readonly TriangleStripDrawMode: number;
  24587. /**
  24588. * Returns the triangle fan draw mode
  24589. */
  24590. static readonly TriangleFanDrawMode: number;
  24591. /**
  24592. * Stores the clock-wise side orientation
  24593. */
  24594. static readonly ClockWiseSideOrientation: number;
  24595. /**
  24596. * Stores the counter clock-wise side orientation
  24597. */
  24598. static readonly CounterClockWiseSideOrientation: number;
  24599. /**
  24600. * The dirty texture flag value
  24601. */
  24602. static readonly TextureDirtyFlag: number;
  24603. /**
  24604. * The dirty light flag value
  24605. */
  24606. static readonly LightDirtyFlag: number;
  24607. /**
  24608. * The dirty fresnel flag value
  24609. */
  24610. static readonly FresnelDirtyFlag: number;
  24611. /**
  24612. * The dirty attribute flag value
  24613. */
  24614. static readonly AttributesDirtyFlag: number;
  24615. /**
  24616. * The dirty misc flag value
  24617. */
  24618. static readonly MiscDirtyFlag: number;
  24619. /**
  24620. * The all dirty flag value
  24621. */
  24622. static readonly AllDirtyFlag: number;
  24623. /**
  24624. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24625. */
  24626. static readonly MATERIAL_OPAQUE: number;
  24627. /**
  24628. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24629. */
  24630. static readonly MATERIAL_ALPHATEST: number;
  24631. /**
  24632. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24633. */
  24634. static readonly MATERIAL_ALPHABLEND: number;
  24635. /**
  24636. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24637. * They are also discarded below the alpha cutoff threshold to improve performances.
  24638. */
  24639. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24640. /**
  24641. * The Whiteout method is used to blend normals.
  24642. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24643. */
  24644. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24645. /**
  24646. * The Reoriented Normal Mapping method is used to blend normals.
  24647. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24648. */
  24649. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24650. /**
  24651. * Custom callback helping to override the default shader used in the material.
  24652. */
  24653. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24654. /**
  24655. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24656. */
  24657. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24658. /**
  24659. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24660. * This means that the material can keep using a previous shader while a new one is being compiled.
  24661. * This is mostly used when shader parallel compilation is supported (true by default)
  24662. */
  24663. allowShaderHotSwapping: boolean;
  24664. /**
  24665. * The ID of the material
  24666. */
  24667. id: string;
  24668. /**
  24669. * Gets or sets the unique id of the material
  24670. */
  24671. uniqueId: number;
  24672. /**
  24673. * The name of the material
  24674. */
  24675. name: string;
  24676. /**
  24677. * Gets or sets user defined metadata
  24678. */
  24679. metadata: any;
  24680. /**
  24681. * For internal use only. Please do not use.
  24682. */
  24683. reservedDataStore: any;
  24684. /**
  24685. * Specifies if the ready state should be checked on each call
  24686. */
  24687. checkReadyOnEveryCall: boolean;
  24688. /**
  24689. * Specifies if the ready state should be checked once
  24690. */
  24691. checkReadyOnlyOnce: boolean;
  24692. /**
  24693. * The state of the material
  24694. */
  24695. state: string;
  24696. /**
  24697. * The alpha value of the material
  24698. */
  24699. protected _alpha: number;
  24700. /**
  24701. * List of inspectable custom properties (used by the Inspector)
  24702. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24703. */
  24704. inspectableCustomProperties: IInspectable[];
  24705. /**
  24706. * Sets the alpha value of the material
  24707. */
  24708. set alpha(value: number);
  24709. /**
  24710. * Gets the alpha value of the material
  24711. */
  24712. get alpha(): number;
  24713. /**
  24714. * Specifies if back face culling is enabled
  24715. */
  24716. protected _backFaceCulling: boolean;
  24717. /**
  24718. * Sets the back-face culling state
  24719. */
  24720. set backFaceCulling(value: boolean);
  24721. /**
  24722. * Gets the back-face culling state
  24723. */
  24724. get backFaceCulling(): boolean;
  24725. /**
  24726. * Stores the value for side orientation
  24727. */
  24728. sideOrientation: number;
  24729. /**
  24730. * Callback triggered when the material is compiled
  24731. */
  24732. onCompiled: Nullable<(effect: Effect) => void>;
  24733. /**
  24734. * Callback triggered when an error occurs
  24735. */
  24736. onError: Nullable<(effect: Effect, errors: string) => void>;
  24737. /**
  24738. * Callback triggered to get the render target textures
  24739. */
  24740. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24741. /**
  24742. * Gets a boolean indicating that current material needs to register RTT
  24743. */
  24744. get hasRenderTargetTextures(): boolean;
  24745. /**
  24746. * Specifies if the material should be serialized
  24747. */
  24748. doNotSerialize: boolean;
  24749. /**
  24750. * @hidden
  24751. */
  24752. _storeEffectOnSubMeshes: boolean;
  24753. /**
  24754. * Stores the animations for the material
  24755. */
  24756. animations: Nullable<Array<Animation>>;
  24757. /**
  24758. * An event triggered when the material is disposed
  24759. */
  24760. onDisposeObservable: Observable<Material>;
  24761. /**
  24762. * An observer which watches for dispose events
  24763. */
  24764. private _onDisposeObserver;
  24765. private _onUnBindObservable;
  24766. /**
  24767. * Called during a dispose event
  24768. */
  24769. set onDispose(callback: () => void);
  24770. private _onBindObservable;
  24771. /**
  24772. * An event triggered when the material is bound
  24773. */
  24774. get onBindObservable(): Observable<AbstractMesh>;
  24775. /**
  24776. * An observer which watches for bind events
  24777. */
  24778. private _onBindObserver;
  24779. /**
  24780. * Called during a bind event
  24781. */
  24782. set onBind(callback: (Mesh: AbstractMesh) => void);
  24783. /**
  24784. * An event triggered when the material is unbound
  24785. */
  24786. get onUnBindObservable(): Observable<Material>;
  24787. protected _onEffectCreatedObservable: Nullable<Observable<{
  24788. effect: Effect;
  24789. subMesh: Nullable<SubMesh>;
  24790. }>>;
  24791. /**
  24792. * An event triggered when the effect is (re)created
  24793. */
  24794. get onEffectCreatedObservable(): Observable<{
  24795. effect: Effect;
  24796. subMesh: Nullable<SubMesh>;
  24797. }>;
  24798. /**
  24799. * Stores the value of the alpha mode
  24800. */
  24801. private _alphaMode;
  24802. /**
  24803. * Sets the value of the alpha mode.
  24804. *
  24805. * | Value | Type | Description |
  24806. * | --- | --- | --- |
  24807. * | 0 | ALPHA_DISABLE | |
  24808. * | 1 | ALPHA_ADD | |
  24809. * | 2 | ALPHA_COMBINE | |
  24810. * | 3 | ALPHA_SUBTRACT | |
  24811. * | 4 | ALPHA_MULTIPLY | |
  24812. * | 5 | ALPHA_MAXIMIZED | |
  24813. * | 6 | ALPHA_ONEONE | |
  24814. * | 7 | ALPHA_PREMULTIPLIED | |
  24815. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24816. * | 9 | ALPHA_INTERPOLATE | |
  24817. * | 10 | ALPHA_SCREENMODE | |
  24818. *
  24819. */
  24820. set alphaMode(value: number);
  24821. /**
  24822. * Gets the value of the alpha mode
  24823. */
  24824. get alphaMode(): number;
  24825. /**
  24826. * Stores the state of the need depth pre-pass value
  24827. */
  24828. private _needDepthPrePass;
  24829. /**
  24830. * Sets the need depth pre-pass value
  24831. */
  24832. set needDepthPrePass(value: boolean);
  24833. /**
  24834. * Gets the depth pre-pass value
  24835. */
  24836. get needDepthPrePass(): boolean;
  24837. /**
  24838. * Specifies if depth writing should be disabled
  24839. */
  24840. disableDepthWrite: boolean;
  24841. /**
  24842. * Specifies if color writing should be disabled
  24843. */
  24844. disableColorWrite: boolean;
  24845. /**
  24846. * Specifies if depth writing should be forced
  24847. */
  24848. forceDepthWrite: boolean;
  24849. /**
  24850. * Specifies the depth function that should be used. 0 means the default engine function
  24851. */
  24852. depthFunction: number;
  24853. /**
  24854. * Specifies if there should be a separate pass for culling
  24855. */
  24856. separateCullingPass: boolean;
  24857. /**
  24858. * Stores the state specifing if fog should be enabled
  24859. */
  24860. private _fogEnabled;
  24861. /**
  24862. * Sets the state for enabling fog
  24863. */
  24864. set fogEnabled(value: boolean);
  24865. /**
  24866. * Gets the value of the fog enabled state
  24867. */
  24868. get fogEnabled(): boolean;
  24869. /**
  24870. * Stores the size of points
  24871. */
  24872. pointSize: number;
  24873. /**
  24874. * Stores the z offset value
  24875. */
  24876. zOffset: number;
  24877. get wireframe(): boolean;
  24878. /**
  24879. * Sets the state of wireframe mode
  24880. */
  24881. set wireframe(value: boolean);
  24882. /**
  24883. * Gets the value specifying if point clouds are enabled
  24884. */
  24885. get pointsCloud(): boolean;
  24886. /**
  24887. * Sets the state of point cloud mode
  24888. */
  24889. set pointsCloud(value: boolean);
  24890. /**
  24891. * Gets the material fill mode
  24892. */
  24893. get fillMode(): number;
  24894. /**
  24895. * Sets the material fill mode
  24896. */
  24897. set fillMode(value: number);
  24898. /**
  24899. * @hidden
  24900. * Stores the effects for the material
  24901. */
  24902. _effect: Nullable<Effect>;
  24903. /**
  24904. * Specifies if uniform buffers should be used
  24905. */
  24906. private _useUBO;
  24907. /**
  24908. * Stores a reference to the scene
  24909. */
  24910. private _scene;
  24911. /**
  24912. * Stores the fill mode state
  24913. */
  24914. private _fillMode;
  24915. /**
  24916. * Specifies if the depth write state should be cached
  24917. */
  24918. private _cachedDepthWriteState;
  24919. /**
  24920. * Specifies if the color write state should be cached
  24921. */
  24922. private _cachedColorWriteState;
  24923. /**
  24924. * Specifies if the depth function state should be cached
  24925. */
  24926. private _cachedDepthFunctionState;
  24927. /**
  24928. * Stores the uniform buffer
  24929. */
  24930. protected _uniformBuffer: UniformBuffer;
  24931. /** @hidden */
  24932. _indexInSceneMaterialArray: number;
  24933. /** @hidden */
  24934. meshMap: Nullable<{
  24935. [id: string]: AbstractMesh | undefined;
  24936. }>;
  24937. /**
  24938. * Creates a material instance
  24939. * @param name defines the name of the material
  24940. * @param scene defines the scene to reference
  24941. * @param doNotAdd specifies if the material should be added to the scene
  24942. */
  24943. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24944. /**
  24945. * Returns a string representation of the current material
  24946. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24947. * @returns a string with material information
  24948. */
  24949. toString(fullDetails?: boolean): string;
  24950. /**
  24951. * Gets the class name of the material
  24952. * @returns a string with the class name of the material
  24953. */
  24954. getClassName(): string;
  24955. /**
  24956. * Specifies if updates for the material been locked
  24957. */
  24958. get isFrozen(): boolean;
  24959. /**
  24960. * Locks updates for the material
  24961. */
  24962. freeze(): void;
  24963. /**
  24964. * Unlocks updates for the material
  24965. */
  24966. unfreeze(): void;
  24967. /**
  24968. * Specifies if the material is ready to be used
  24969. * @param mesh defines the mesh to check
  24970. * @param useInstances specifies if instances should be used
  24971. * @returns a boolean indicating if the material is ready to be used
  24972. */
  24973. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24974. /**
  24975. * Specifies that the submesh is ready to be used
  24976. * @param mesh defines the mesh to check
  24977. * @param subMesh defines which submesh to check
  24978. * @param useInstances specifies that instances should be used
  24979. * @returns a boolean indicating that the submesh is ready or not
  24980. */
  24981. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24982. /**
  24983. * Returns the material effect
  24984. * @returns the effect associated with the material
  24985. */
  24986. getEffect(): Nullable<Effect>;
  24987. /**
  24988. * Returns the current scene
  24989. * @returns a Scene
  24990. */
  24991. getScene(): Scene;
  24992. /**
  24993. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24994. */
  24995. protected _forceAlphaTest: boolean;
  24996. /**
  24997. * The transparency mode of the material.
  24998. */
  24999. protected _transparencyMode: Nullable<number>;
  25000. /**
  25001. * Gets the current transparency mode.
  25002. */
  25003. get transparencyMode(): Nullable<number>;
  25004. /**
  25005. * Sets the transparency mode of the material.
  25006. *
  25007. * | Value | Type | Description |
  25008. * | ----- | ----------------------------------- | ----------- |
  25009. * | 0 | OPAQUE | |
  25010. * | 1 | ALPHATEST | |
  25011. * | 2 | ALPHABLEND | |
  25012. * | 3 | ALPHATESTANDBLEND | |
  25013. *
  25014. */
  25015. set transparencyMode(value: Nullable<number>);
  25016. /**
  25017. * Returns true if alpha blending should be disabled.
  25018. */
  25019. protected get _disableAlphaBlending(): boolean;
  25020. /**
  25021. * Specifies whether or not this material should be rendered in alpha blend mode.
  25022. * @returns a boolean specifying if alpha blending is needed
  25023. */
  25024. needAlphaBlending(): boolean;
  25025. /**
  25026. * Specifies if the mesh will require alpha blending
  25027. * @param mesh defines the mesh to check
  25028. * @returns a boolean specifying if alpha blending is needed for the mesh
  25029. */
  25030. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25031. /**
  25032. * Specifies whether or not this material should be rendered in alpha test mode.
  25033. * @returns a boolean specifying if an alpha test is needed.
  25034. */
  25035. needAlphaTesting(): boolean;
  25036. /**
  25037. * Specifies if material alpha testing should be turned on for the mesh
  25038. * @param mesh defines the mesh to check
  25039. */
  25040. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25041. /**
  25042. * Gets the texture used for the alpha test
  25043. * @returns the texture to use for alpha testing
  25044. */
  25045. getAlphaTestTexture(): Nullable<BaseTexture>;
  25046. /**
  25047. * Marks the material to indicate that it needs to be re-calculated
  25048. */
  25049. markDirty(): void;
  25050. /** @hidden */
  25051. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25052. /**
  25053. * Binds the material to the mesh
  25054. * @param world defines the world transformation matrix
  25055. * @param mesh defines the mesh to bind the material to
  25056. */
  25057. bind(world: Matrix, mesh?: Mesh): void;
  25058. /**
  25059. * Binds the submesh to the material
  25060. * @param world defines the world transformation matrix
  25061. * @param mesh defines the mesh containing the submesh
  25062. * @param subMesh defines the submesh to bind the material to
  25063. */
  25064. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25065. /**
  25066. * Binds the world matrix to the material
  25067. * @param world defines the world transformation matrix
  25068. */
  25069. bindOnlyWorldMatrix(world: Matrix): void;
  25070. /**
  25071. * Binds the scene's uniform buffer to the effect.
  25072. * @param effect defines the effect to bind to the scene uniform buffer
  25073. * @param sceneUbo defines the uniform buffer storing scene data
  25074. */
  25075. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25076. /**
  25077. * Binds the view matrix to the effect
  25078. * @param effect defines the effect to bind the view matrix to
  25079. */
  25080. bindView(effect: Effect): void;
  25081. /**
  25082. * Binds the view projection matrix to the effect
  25083. * @param effect defines the effect to bind the view projection matrix to
  25084. */
  25085. bindViewProjection(effect: Effect): void;
  25086. /**
  25087. * Processes to execute after binding the material to a mesh
  25088. * @param mesh defines the rendered mesh
  25089. */
  25090. protected _afterBind(mesh?: Mesh): void;
  25091. /**
  25092. * Unbinds the material from the mesh
  25093. */
  25094. unbind(): void;
  25095. /**
  25096. * Gets the active textures from the material
  25097. * @returns an array of textures
  25098. */
  25099. getActiveTextures(): BaseTexture[];
  25100. /**
  25101. * Specifies if the material uses a texture
  25102. * @param texture defines the texture to check against the material
  25103. * @returns a boolean specifying if the material uses the texture
  25104. */
  25105. hasTexture(texture: BaseTexture): boolean;
  25106. /**
  25107. * Makes a duplicate of the material, and gives it a new name
  25108. * @param name defines the new name for the duplicated material
  25109. * @returns the cloned material
  25110. */
  25111. clone(name: string): Nullable<Material>;
  25112. /**
  25113. * Gets the meshes bound to the material
  25114. * @returns an array of meshes bound to the material
  25115. */
  25116. getBindedMeshes(): AbstractMesh[];
  25117. /**
  25118. * Force shader compilation
  25119. * @param mesh defines the mesh associated with this material
  25120. * @param onCompiled defines a function to execute once the material is compiled
  25121. * @param options defines the options to configure the compilation
  25122. * @param onError defines a function to execute if the material fails compiling
  25123. */
  25124. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25125. /**
  25126. * Force shader compilation
  25127. * @param mesh defines the mesh that will use this material
  25128. * @param options defines additional options for compiling the shaders
  25129. * @returns a promise that resolves when the compilation completes
  25130. */
  25131. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25132. private static readonly _AllDirtyCallBack;
  25133. private static readonly _ImageProcessingDirtyCallBack;
  25134. private static readonly _TextureDirtyCallBack;
  25135. private static readonly _FresnelDirtyCallBack;
  25136. private static readonly _MiscDirtyCallBack;
  25137. private static readonly _LightsDirtyCallBack;
  25138. private static readonly _AttributeDirtyCallBack;
  25139. private static _FresnelAndMiscDirtyCallBack;
  25140. private static _TextureAndMiscDirtyCallBack;
  25141. private static readonly _DirtyCallbackArray;
  25142. private static readonly _RunDirtyCallBacks;
  25143. /**
  25144. * Marks a define in the material to indicate that it needs to be re-computed
  25145. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25146. */
  25147. markAsDirty(flag: number): void;
  25148. /**
  25149. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25150. * @param func defines a function which checks material defines against the submeshes
  25151. */
  25152. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25153. /**
  25154. * Indicates that we need to re-calculated for all submeshes
  25155. */
  25156. protected _markAllSubMeshesAsAllDirty(): void;
  25157. /**
  25158. * Indicates that image processing needs to be re-calculated for all submeshes
  25159. */
  25160. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25161. /**
  25162. * Indicates that textures need to be re-calculated for all submeshes
  25163. */
  25164. protected _markAllSubMeshesAsTexturesDirty(): void;
  25165. /**
  25166. * Indicates that fresnel needs to be re-calculated for all submeshes
  25167. */
  25168. protected _markAllSubMeshesAsFresnelDirty(): void;
  25169. /**
  25170. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25171. */
  25172. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25173. /**
  25174. * Indicates that lights need to be re-calculated for all submeshes
  25175. */
  25176. protected _markAllSubMeshesAsLightsDirty(): void;
  25177. /**
  25178. * Indicates that attributes need to be re-calculated for all submeshes
  25179. */
  25180. protected _markAllSubMeshesAsAttributesDirty(): void;
  25181. /**
  25182. * Indicates that misc needs to be re-calculated for all submeshes
  25183. */
  25184. protected _markAllSubMeshesAsMiscDirty(): void;
  25185. /**
  25186. * Indicates that textures and misc need to be re-calculated for all submeshes
  25187. */
  25188. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25189. /**
  25190. * Disposes the material
  25191. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25192. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25193. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25194. */
  25195. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25196. /** @hidden */
  25197. private releaseVertexArrayObject;
  25198. /**
  25199. * Serializes this material
  25200. * @returns the serialized material object
  25201. */
  25202. serialize(): any;
  25203. /**
  25204. * Creates a material from parsed material data
  25205. * @param parsedMaterial defines parsed material data
  25206. * @param scene defines the hosting scene
  25207. * @param rootUrl defines the root URL to use to load textures
  25208. * @returns a new material
  25209. */
  25210. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25211. }
  25212. }
  25213. declare module "babylonjs/Materials/multiMaterial" {
  25214. import { Nullable } from "babylonjs/types";
  25215. import { Scene } from "babylonjs/scene";
  25216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25217. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25218. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25219. import { Material } from "babylonjs/Materials/material";
  25220. /**
  25221. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25222. * separate meshes. This can be use to improve performances.
  25223. * @see http://doc.babylonjs.com/how_to/multi_materials
  25224. */
  25225. export class MultiMaterial extends Material {
  25226. private _subMaterials;
  25227. /**
  25228. * Gets or Sets the list of Materials used within the multi material.
  25229. * They need to be ordered according to the submeshes order in the associated mesh
  25230. */
  25231. get subMaterials(): Nullable<Material>[];
  25232. set subMaterials(value: Nullable<Material>[]);
  25233. /**
  25234. * Function used to align with Node.getChildren()
  25235. * @returns the list of Materials used within the multi material
  25236. */
  25237. getChildren(): Nullable<Material>[];
  25238. /**
  25239. * Instantiates a new Multi Material
  25240. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25241. * separate meshes. This can be use to improve performances.
  25242. * @see http://doc.babylonjs.com/how_to/multi_materials
  25243. * @param name Define the name in the scene
  25244. * @param scene Define the scene the material belongs to
  25245. */
  25246. constructor(name: string, scene: Scene);
  25247. private _hookArray;
  25248. /**
  25249. * Get one of the submaterial by its index in the submaterials array
  25250. * @param index The index to look the sub material at
  25251. * @returns The Material if the index has been defined
  25252. */
  25253. getSubMaterial(index: number): Nullable<Material>;
  25254. /**
  25255. * Get the list of active textures for the whole sub materials list.
  25256. * @returns All the textures that will be used during the rendering
  25257. */
  25258. getActiveTextures(): BaseTexture[];
  25259. /**
  25260. * Gets the current class name of the material e.g. "MultiMaterial"
  25261. * Mainly use in serialization.
  25262. * @returns the class name
  25263. */
  25264. getClassName(): string;
  25265. /**
  25266. * Checks if the material is ready to render the requested sub mesh
  25267. * @param mesh Define the mesh the submesh belongs to
  25268. * @param subMesh Define the sub mesh to look readyness for
  25269. * @param useInstances Define whether or not the material is used with instances
  25270. * @returns true if ready, otherwise false
  25271. */
  25272. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25273. /**
  25274. * Clones the current material and its related sub materials
  25275. * @param name Define the name of the newly cloned material
  25276. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25277. * @returns the cloned material
  25278. */
  25279. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25280. /**
  25281. * Serializes the materials into a JSON representation.
  25282. * @returns the JSON representation
  25283. */
  25284. serialize(): any;
  25285. /**
  25286. * Dispose the material and release its associated resources
  25287. * @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)
  25288. * @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)
  25289. * @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)
  25290. */
  25291. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25292. /**
  25293. * Creates a MultiMaterial from parsed MultiMaterial data.
  25294. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25295. * @param scene defines the hosting scene
  25296. * @returns a new MultiMaterial
  25297. */
  25298. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25299. }
  25300. }
  25301. declare module "babylonjs/Meshes/subMesh" {
  25302. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  25303. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25304. import { Engine } from "babylonjs/Engines/engine";
  25305. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  25306. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25307. import { Effect } from "babylonjs/Materials/effect";
  25308. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25309. import { Plane } from "babylonjs/Maths/math.plane";
  25310. import { Collider } from "babylonjs/Collisions/collider";
  25311. import { Material } from "babylonjs/Materials/material";
  25312. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25314. import { Mesh } from "babylonjs/Meshes/mesh";
  25315. import { Ray } from "babylonjs/Culling/ray";
  25316. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25317. /**
  25318. * Defines a subdivision inside a mesh
  25319. */
  25320. export class SubMesh implements ICullable {
  25321. /** the material index to use */
  25322. materialIndex: number;
  25323. /** vertex index start */
  25324. verticesStart: number;
  25325. /** vertices count */
  25326. verticesCount: number;
  25327. /** index start */
  25328. indexStart: number;
  25329. /** indices count */
  25330. indexCount: number;
  25331. /** @hidden */
  25332. _materialDefines: Nullable<MaterialDefines>;
  25333. /** @hidden */
  25334. _materialEffect: Nullable<Effect>;
  25335. /** @hidden */
  25336. _effectOverride: Nullable<Effect>;
  25337. /**
  25338. * Gets material defines used by the effect associated to the sub mesh
  25339. */
  25340. get materialDefines(): Nullable<MaterialDefines>;
  25341. /**
  25342. * Sets material defines used by the effect associated to the sub mesh
  25343. */
  25344. set materialDefines(defines: Nullable<MaterialDefines>);
  25345. /**
  25346. * Gets associated effect
  25347. */
  25348. get effect(): Nullable<Effect>;
  25349. /**
  25350. * Sets associated effect (effect used to render this submesh)
  25351. * @param effect defines the effect to associate with
  25352. * @param defines defines the set of defines used to compile this effect
  25353. */
  25354. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25355. /** @hidden */
  25356. _linesIndexCount: number;
  25357. private _mesh;
  25358. private _renderingMesh;
  25359. private _boundingInfo;
  25360. private _linesIndexBuffer;
  25361. /** @hidden */
  25362. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25363. /** @hidden */
  25364. _trianglePlanes: Plane[];
  25365. /** @hidden */
  25366. _lastColliderTransformMatrix: Nullable<Matrix>;
  25367. /** @hidden */
  25368. _renderId: number;
  25369. /** @hidden */
  25370. _alphaIndex: number;
  25371. /** @hidden */
  25372. _distanceToCamera: number;
  25373. /** @hidden */
  25374. _id: number;
  25375. private _currentMaterial;
  25376. /**
  25377. * Add a new submesh to a mesh
  25378. * @param materialIndex defines the material index to use
  25379. * @param verticesStart defines vertex index start
  25380. * @param verticesCount defines vertices count
  25381. * @param indexStart defines index start
  25382. * @param indexCount defines indices count
  25383. * @param mesh defines the parent mesh
  25384. * @param renderingMesh defines an optional rendering mesh
  25385. * @param createBoundingBox defines if bounding box should be created for this submesh
  25386. * @returns the new submesh
  25387. */
  25388. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25389. /**
  25390. * Creates a new submesh
  25391. * @param materialIndex defines the material index to use
  25392. * @param verticesStart defines vertex index start
  25393. * @param verticesCount defines vertices count
  25394. * @param indexStart defines index start
  25395. * @param indexCount defines indices count
  25396. * @param mesh defines the parent mesh
  25397. * @param renderingMesh defines an optional rendering mesh
  25398. * @param createBoundingBox defines if bounding box should be created for this submesh
  25399. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25400. */
  25401. constructor(
  25402. /** the material index to use */
  25403. materialIndex: number,
  25404. /** vertex index start */
  25405. verticesStart: number,
  25406. /** vertices count */
  25407. verticesCount: number,
  25408. /** index start */
  25409. indexStart: number,
  25410. /** indices count */
  25411. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25412. /**
  25413. * Returns true if this submesh covers the entire parent mesh
  25414. * @ignorenaming
  25415. */
  25416. get IsGlobal(): boolean;
  25417. /**
  25418. * Returns the submesh BoudingInfo object
  25419. * @returns current bounding info (or mesh's one if the submesh is global)
  25420. */
  25421. getBoundingInfo(): BoundingInfo;
  25422. /**
  25423. * Sets the submesh BoundingInfo
  25424. * @param boundingInfo defines the new bounding info to use
  25425. * @returns the SubMesh
  25426. */
  25427. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25428. /**
  25429. * Returns the mesh of the current submesh
  25430. * @return the parent mesh
  25431. */
  25432. getMesh(): AbstractMesh;
  25433. /**
  25434. * Returns the rendering mesh of the submesh
  25435. * @returns the rendering mesh (could be different from parent mesh)
  25436. */
  25437. getRenderingMesh(): Mesh;
  25438. /**
  25439. * Returns the replacement mesh of the submesh
  25440. * @returns the replacement mesh (could be different from parent mesh)
  25441. */
  25442. getReplacementMesh(): Nullable<AbstractMesh>;
  25443. /**
  25444. * Returns the effective mesh of the submesh
  25445. * @returns the effective mesh (could be different from parent mesh)
  25446. */
  25447. getEffectiveMesh(): AbstractMesh;
  25448. /**
  25449. * Returns the submesh material
  25450. * @returns null or the current material
  25451. */
  25452. getMaterial(): Nullable<Material>;
  25453. /**
  25454. * Sets a new updated BoundingInfo object to the submesh
  25455. * @param data defines an optional position array to use to determine the bounding info
  25456. * @returns the SubMesh
  25457. */
  25458. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25459. /** @hidden */
  25460. _checkCollision(collider: Collider): boolean;
  25461. /**
  25462. * Updates the submesh BoundingInfo
  25463. * @param world defines the world matrix to use to update the bounding info
  25464. * @returns the submesh
  25465. */
  25466. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25467. /**
  25468. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25469. * @param frustumPlanes defines the frustum planes
  25470. * @returns true if the submesh is intersecting with the frustum
  25471. */
  25472. isInFrustum(frustumPlanes: Plane[]): boolean;
  25473. /**
  25474. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25475. * @param frustumPlanes defines the frustum planes
  25476. * @returns true if the submesh is inside the frustum
  25477. */
  25478. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25479. /**
  25480. * Renders the submesh
  25481. * @param enableAlphaMode defines if alpha needs to be used
  25482. * @returns the submesh
  25483. */
  25484. render(enableAlphaMode: boolean): SubMesh;
  25485. /**
  25486. * @hidden
  25487. */
  25488. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25489. /**
  25490. * Checks if the submesh intersects with a ray
  25491. * @param ray defines the ray to test
  25492. * @returns true is the passed ray intersects the submesh bounding box
  25493. */
  25494. canIntersects(ray: Ray): boolean;
  25495. /**
  25496. * Intersects current submesh with a ray
  25497. * @param ray defines the ray to test
  25498. * @param positions defines mesh's positions array
  25499. * @param indices defines mesh's indices array
  25500. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25501. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25502. * @returns intersection info or null if no intersection
  25503. */
  25504. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25505. /** @hidden */
  25506. private _intersectLines;
  25507. /** @hidden */
  25508. private _intersectUnIndexedLines;
  25509. /** @hidden */
  25510. private _intersectTriangles;
  25511. /** @hidden */
  25512. private _intersectUnIndexedTriangles;
  25513. /** @hidden */
  25514. _rebuild(): void;
  25515. /**
  25516. * Creates a new submesh from the passed mesh
  25517. * @param newMesh defines the new hosting mesh
  25518. * @param newRenderingMesh defines an optional rendering mesh
  25519. * @returns the new submesh
  25520. */
  25521. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25522. /**
  25523. * Release associated resources
  25524. */
  25525. dispose(): void;
  25526. /**
  25527. * Gets the class name
  25528. * @returns the string "SubMesh".
  25529. */
  25530. getClassName(): string;
  25531. /**
  25532. * Creates a new submesh from indices data
  25533. * @param materialIndex the index of the main mesh material
  25534. * @param startIndex the index where to start the copy in the mesh indices array
  25535. * @param indexCount the number of indices to copy then from the startIndex
  25536. * @param mesh the main mesh to create the submesh from
  25537. * @param renderingMesh the optional rendering mesh
  25538. * @returns a new submesh
  25539. */
  25540. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25541. }
  25542. }
  25543. declare module "babylonjs/Loading/sceneLoaderFlags" {
  25544. /**
  25545. * Class used to represent data loading progression
  25546. */
  25547. export class SceneLoaderFlags {
  25548. private static _ForceFullSceneLoadingForIncremental;
  25549. private static _ShowLoadingScreen;
  25550. private static _CleanBoneMatrixWeights;
  25551. private static _loggingLevel;
  25552. /**
  25553. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25554. */
  25555. static get ForceFullSceneLoadingForIncremental(): boolean;
  25556. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25557. /**
  25558. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25559. */
  25560. static get ShowLoadingScreen(): boolean;
  25561. static set ShowLoadingScreen(value: boolean);
  25562. /**
  25563. * Defines the current logging level (while loading the scene)
  25564. * @ignorenaming
  25565. */
  25566. static get loggingLevel(): number;
  25567. static set loggingLevel(value: number);
  25568. /**
  25569. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25570. */
  25571. static get CleanBoneMatrixWeights(): boolean;
  25572. static set CleanBoneMatrixWeights(value: boolean);
  25573. }
  25574. }
  25575. declare module "babylonjs/Meshes/geometry" {
  25576. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  25577. import { Scene } from "babylonjs/scene";
  25578. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  25579. import { Engine } from "babylonjs/Engines/engine";
  25580. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  25581. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25582. import { Effect } from "babylonjs/Materials/effect";
  25583. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25584. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25585. import { Mesh } from "babylonjs/Meshes/mesh";
  25586. /**
  25587. * Class used to store geometry data (vertex buffers + index buffer)
  25588. */
  25589. export class Geometry implements IGetSetVerticesData {
  25590. /**
  25591. * Gets or sets the ID of the geometry
  25592. */
  25593. id: string;
  25594. /**
  25595. * Gets or sets the unique ID of the geometry
  25596. */
  25597. uniqueId: number;
  25598. /**
  25599. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25600. */
  25601. delayLoadState: number;
  25602. /**
  25603. * Gets the file containing the data to load when running in delay load state
  25604. */
  25605. delayLoadingFile: Nullable<string>;
  25606. /**
  25607. * Callback called when the geometry is updated
  25608. */
  25609. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25610. private _scene;
  25611. private _engine;
  25612. private _meshes;
  25613. private _totalVertices;
  25614. /** @hidden */
  25615. _indices: IndicesArray;
  25616. /** @hidden */
  25617. _vertexBuffers: {
  25618. [key: string]: VertexBuffer;
  25619. };
  25620. private _isDisposed;
  25621. private _extend;
  25622. private _boundingBias;
  25623. /** @hidden */
  25624. _delayInfo: Array<string>;
  25625. private _indexBuffer;
  25626. private _indexBufferIsUpdatable;
  25627. /** @hidden */
  25628. _boundingInfo: Nullable<BoundingInfo>;
  25629. /** @hidden */
  25630. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25631. /** @hidden */
  25632. _softwareSkinningFrameId: number;
  25633. private _vertexArrayObjects;
  25634. private _updatable;
  25635. /** @hidden */
  25636. _positions: Nullable<Vector3[]>;
  25637. /**
  25638. * 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
  25639. */
  25640. get boundingBias(): Vector2;
  25641. /**
  25642. * 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
  25643. */
  25644. set boundingBias(value: Vector2);
  25645. /**
  25646. * Static function used to attach a new empty geometry to a mesh
  25647. * @param mesh defines the mesh to attach the geometry to
  25648. * @returns the new Geometry
  25649. */
  25650. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25651. /** Get the list of meshes using this geometry */
  25652. get meshes(): Mesh[];
  25653. /**
  25654. * Creates a new geometry
  25655. * @param id defines the unique ID
  25656. * @param scene defines the hosting scene
  25657. * @param vertexData defines the VertexData used to get geometry data
  25658. * @param updatable defines if geometry must be updatable (false by default)
  25659. * @param mesh defines the mesh that will be associated with the geometry
  25660. */
  25661. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25662. /**
  25663. * Gets the current extend of the geometry
  25664. */
  25665. get extend(): {
  25666. minimum: Vector3;
  25667. maximum: Vector3;
  25668. };
  25669. /**
  25670. * Gets the hosting scene
  25671. * @returns the hosting Scene
  25672. */
  25673. getScene(): Scene;
  25674. /**
  25675. * Gets the hosting engine
  25676. * @returns the hosting Engine
  25677. */
  25678. getEngine(): Engine;
  25679. /**
  25680. * Defines if the geometry is ready to use
  25681. * @returns true if the geometry is ready to be used
  25682. */
  25683. isReady(): boolean;
  25684. /**
  25685. * Gets a value indicating that the geometry should not be serialized
  25686. */
  25687. get doNotSerialize(): boolean;
  25688. /** @hidden */
  25689. _rebuild(): void;
  25690. /**
  25691. * Affects all geometry data in one call
  25692. * @param vertexData defines the geometry data
  25693. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25694. */
  25695. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25696. /**
  25697. * Set specific vertex data
  25698. * @param kind defines the data kind (Position, normal, etc...)
  25699. * @param data defines the vertex data to use
  25700. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25701. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25702. */
  25703. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25704. /**
  25705. * Removes a specific vertex data
  25706. * @param kind defines the data kind (Position, normal, etc...)
  25707. */
  25708. removeVerticesData(kind: string): void;
  25709. /**
  25710. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25711. * @param buffer defines the vertex buffer to use
  25712. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25713. */
  25714. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25715. /**
  25716. * Update a specific vertex buffer
  25717. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25718. * It will do nothing if the buffer is not updatable
  25719. * @param kind defines the data kind (Position, normal, etc...)
  25720. * @param data defines the data to use
  25721. * @param offset defines the offset in the target buffer where to store the data
  25722. * @param useBytes set to true if the offset is in bytes
  25723. */
  25724. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25725. /**
  25726. * Update a specific vertex buffer
  25727. * This function will create a new buffer if the current one is not updatable
  25728. * @param kind defines the data kind (Position, normal, etc...)
  25729. * @param data defines the data to use
  25730. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25731. */
  25732. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25733. private _updateBoundingInfo;
  25734. /** @hidden */
  25735. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25736. /**
  25737. * Gets total number of vertices
  25738. * @returns the total number of vertices
  25739. */
  25740. getTotalVertices(): number;
  25741. /**
  25742. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25743. * @param kind defines the data kind (Position, normal, etc...)
  25744. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25745. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25746. * @returns a float array containing vertex data
  25747. */
  25748. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25749. /**
  25750. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25751. * @param kind defines the data kind (Position, normal, etc...)
  25752. * @returns true if the vertex buffer with the specified kind is updatable
  25753. */
  25754. isVertexBufferUpdatable(kind: string): boolean;
  25755. /**
  25756. * Gets a specific vertex buffer
  25757. * @param kind defines the data kind (Position, normal, etc...)
  25758. * @returns a VertexBuffer
  25759. */
  25760. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25761. /**
  25762. * Returns all vertex buffers
  25763. * @return an object holding all vertex buffers indexed by kind
  25764. */
  25765. getVertexBuffers(): Nullable<{
  25766. [key: string]: VertexBuffer;
  25767. }>;
  25768. /**
  25769. * Gets a boolean indicating if specific vertex buffer is present
  25770. * @param kind defines the data kind (Position, normal, etc...)
  25771. * @returns true if data is present
  25772. */
  25773. isVerticesDataPresent(kind: string): boolean;
  25774. /**
  25775. * Gets a list of all attached data kinds (Position, normal, etc...)
  25776. * @returns a list of string containing all kinds
  25777. */
  25778. getVerticesDataKinds(): string[];
  25779. /**
  25780. * Update index buffer
  25781. * @param indices defines the indices to store in the index buffer
  25782. * @param offset defines the offset in the target buffer where to store the data
  25783. * @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)
  25784. */
  25785. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25786. /**
  25787. * Creates a new index buffer
  25788. * @param indices defines the indices to store in the index buffer
  25789. * @param totalVertices defines the total number of vertices (could be null)
  25790. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25791. */
  25792. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25793. /**
  25794. * Return the total number of indices
  25795. * @returns the total number of indices
  25796. */
  25797. getTotalIndices(): number;
  25798. /**
  25799. * Gets the index buffer array
  25800. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25801. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25802. * @returns the index buffer array
  25803. */
  25804. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25805. /**
  25806. * Gets the index buffer
  25807. * @return the index buffer
  25808. */
  25809. getIndexBuffer(): Nullable<DataBuffer>;
  25810. /** @hidden */
  25811. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25812. /**
  25813. * Release the associated resources for a specific mesh
  25814. * @param mesh defines the source mesh
  25815. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25816. */
  25817. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25818. /**
  25819. * Apply current geometry to a given mesh
  25820. * @param mesh defines the mesh to apply geometry to
  25821. */
  25822. applyToMesh(mesh: Mesh): void;
  25823. private _updateExtend;
  25824. private _applyToMesh;
  25825. private notifyUpdate;
  25826. /**
  25827. * Load the geometry if it was flagged as delay loaded
  25828. * @param scene defines the hosting scene
  25829. * @param onLoaded defines a callback called when the geometry is loaded
  25830. */
  25831. load(scene: Scene, onLoaded?: () => void): void;
  25832. private _queueLoad;
  25833. /**
  25834. * Invert the geometry to move from a right handed system to a left handed one.
  25835. */
  25836. toLeftHanded(): void;
  25837. /** @hidden */
  25838. _resetPointsArrayCache(): void;
  25839. /** @hidden */
  25840. _generatePointsArray(): boolean;
  25841. /**
  25842. * Gets a value indicating if the geometry is disposed
  25843. * @returns true if the geometry was disposed
  25844. */
  25845. isDisposed(): boolean;
  25846. private _disposeVertexArrayObjects;
  25847. /**
  25848. * Free all associated resources
  25849. */
  25850. dispose(): void;
  25851. /**
  25852. * Clone the current geometry into a new geometry
  25853. * @param id defines the unique ID of the new geometry
  25854. * @returns a new geometry object
  25855. */
  25856. copy(id: string): Geometry;
  25857. /**
  25858. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25859. * @return a JSON representation of the current geometry data (without the vertices data)
  25860. */
  25861. serialize(): any;
  25862. private toNumberArray;
  25863. /**
  25864. * Serialize all vertices data into a JSON oject
  25865. * @returns a JSON representation of the current geometry data
  25866. */
  25867. serializeVerticeData(): any;
  25868. /**
  25869. * Extracts a clone of a mesh geometry
  25870. * @param mesh defines the source mesh
  25871. * @param id defines the unique ID of the new geometry object
  25872. * @returns the new geometry object
  25873. */
  25874. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25875. /**
  25876. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25877. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25878. * Be aware Math.random() could cause collisions, but:
  25879. * "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"
  25880. * @returns a string containing a new GUID
  25881. */
  25882. static RandomId(): string;
  25883. /** @hidden */
  25884. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25885. private static _CleanMatricesWeights;
  25886. /**
  25887. * Create a new geometry from persisted data (Using .babylon file format)
  25888. * @param parsedVertexData defines the persisted data
  25889. * @param scene defines the hosting scene
  25890. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25891. * @returns the new geometry object
  25892. */
  25893. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25894. }
  25895. }
  25896. declare module "babylonjs/Meshes/mesh.vertexData" {
  25897. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25898. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25899. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  25900. import { Geometry } from "babylonjs/Meshes/geometry";
  25901. import { Mesh } from "babylonjs/Meshes/mesh";
  25902. /**
  25903. * Define an interface for all classes that will get and set the data on vertices
  25904. */
  25905. export interface IGetSetVerticesData {
  25906. /**
  25907. * Gets a boolean indicating if specific vertex data is present
  25908. * @param kind defines the vertex data kind to use
  25909. * @returns true is data kind is present
  25910. */
  25911. isVerticesDataPresent(kind: string): boolean;
  25912. /**
  25913. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25914. * @param kind defines the data kind (Position, normal, etc...)
  25915. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25916. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25917. * @returns a float array containing vertex data
  25918. */
  25919. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25920. /**
  25921. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25922. * @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.
  25923. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25924. * @returns the indices array or an empty array if the mesh has no geometry
  25925. */
  25926. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25927. /**
  25928. * Set specific vertex data
  25929. * @param kind defines the data kind (Position, normal, etc...)
  25930. * @param data defines the vertex data to use
  25931. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25932. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25933. */
  25934. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25935. /**
  25936. * Update a specific associated vertex buffer
  25937. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25938. * - VertexBuffer.PositionKind
  25939. * - VertexBuffer.UVKind
  25940. * - VertexBuffer.UV2Kind
  25941. * - VertexBuffer.UV3Kind
  25942. * - VertexBuffer.UV4Kind
  25943. * - VertexBuffer.UV5Kind
  25944. * - VertexBuffer.UV6Kind
  25945. * - VertexBuffer.ColorKind
  25946. * - VertexBuffer.MatricesIndicesKind
  25947. * - VertexBuffer.MatricesIndicesExtraKind
  25948. * - VertexBuffer.MatricesWeightsKind
  25949. * - VertexBuffer.MatricesWeightsExtraKind
  25950. * @param data defines the data source
  25951. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25952. * @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)
  25953. */
  25954. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25955. /**
  25956. * Creates a new index buffer
  25957. * @param indices defines the indices to store in the index buffer
  25958. * @param totalVertices defines the total number of vertices (could be null)
  25959. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25960. */
  25961. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25962. }
  25963. /**
  25964. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25965. */
  25966. export class VertexData {
  25967. /**
  25968. * Mesh side orientation : usually the external or front surface
  25969. */
  25970. static readonly FRONTSIDE: number;
  25971. /**
  25972. * Mesh side orientation : usually the internal or back surface
  25973. */
  25974. static readonly BACKSIDE: number;
  25975. /**
  25976. * Mesh side orientation : both internal and external or front and back surfaces
  25977. */
  25978. static readonly DOUBLESIDE: number;
  25979. /**
  25980. * Mesh side orientation : by default, `FRONTSIDE`
  25981. */
  25982. static readonly DEFAULTSIDE: number;
  25983. /**
  25984. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25985. */
  25986. positions: Nullable<FloatArray>;
  25987. /**
  25988. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25989. */
  25990. normals: Nullable<FloatArray>;
  25991. /**
  25992. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25993. */
  25994. tangents: Nullable<FloatArray>;
  25995. /**
  25996. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25997. */
  25998. uvs: Nullable<FloatArray>;
  25999. /**
  26000. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26001. */
  26002. uvs2: Nullable<FloatArray>;
  26003. /**
  26004. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26005. */
  26006. uvs3: Nullable<FloatArray>;
  26007. /**
  26008. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26009. */
  26010. uvs4: Nullable<FloatArray>;
  26011. /**
  26012. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26013. */
  26014. uvs5: Nullable<FloatArray>;
  26015. /**
  26016. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26017. */
  26018. uvs6: Nullable<FloatArray>;
  26019. /**
  26020. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26021. */
  26022. colors: Nullable<FloatArray>;
  26023. /**
  26024. * 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).
  26025. */
  26026. matricesIndices: Nullable<FloatArray>;
  26027. /**
  26028. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26029. */
  26030. matricesWeights: Nullable<FloatArray>;
  26031. /**
  26032. * An array extending the number of possible indices
  26033. */
  26034. matricesIndicesExtra: Nullable<FloatArray>;
  26035. /**
  26036. * An array extending the number of possible weights when the number of indices is extended
  26037. */
  26038. matricesWeightsExtra: Nullable<FloatArray>;
  26039. /**
  26040. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26041. */
  26042. indices: Nullable<IndicesArray>;
  26043. /**
  26044. * Uses the passed data array to set the set the values for the specified kind of data
  26045. * @param data a linear array of floating numbers
  26046. * @param kind the type of data that is being set, eg positions, colors etc
  26047. */
  26048. set(data: FloatArray, kind: string): void;
  26049. /**
  26050. * Associates the vertexData to the passed Mesh.
  26051. * Sets it as updatable or not (default `false`)
  26052. * @param mesh the mesh the vertexData is applied to
  26053. * @param updatable when used and having the value true allows new data to update the vertexData
  26054. * @returns the VertexData
  26055. */
  26056. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26057. /**
  26058. * Associates the vertexData to the passed Geometry.
  26059. * Sets it as updatable or not (default `false`)
  26060. * @param geometry the geometry the vertexData is applied to
  26061. * @param updatable when used and having the value true allows new data to update the vertexData
  26062. * @returns VertexData
  26063. */
  26064. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26065. /**
  26066. * Updates the associated mesh
  26067. * @param mesh the mesh to be updated
  26068. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26069. * @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
  26070. * @returns VertexData
  26071. */
  26072. updateMesh(mesh: Mesh): VertexData;
  26073. /**
  26074. * Updates the associated geometry
  26075. * @param geometry the geometry to be updated
  26076. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26077. * @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
  26078. * @returns VertexData.
  26079. */
  26080. updateGeometry(geometry: Geometry): VertexData;
  26081. private _applyTo;
  26082. private _update;
  26083. /**
  26084. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26085. * @param matrix the transforming matrix
  26086. * @returns the VertexData
  26087. */
  26088. transform(matrix: Matrix): VertexData;
  26089. /**
  26090. * Merges the passed VertexData into the current one
  26091. * @param other the VertexData to be merged into the current one
  26092. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26093. * @returns the modified VertexData
  26094. */
  26095. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26096. private _mergeElement;
  26097. private _validate;
  26098. /**
  26099. * Serializes the VertexData
  26100. * @returns a serialized object
  26101. */
  26102. serialize(): any;
  26103. /**
  26104. * Extracts the vertexData from a mesh
  26105. * @param mesh the mesh from which to extract the VertexData
  26106. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26107. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26108. * @returns the object VertexData associated to the passed mesh
  26109. */
  26110. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26111. /**
  26112. * Extracts the vertexData from the geometry
  26113. * @param geometry the geometry from which to extract the VertexData
  26114. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26115. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26116. * @returns the object VertexData associated to the passed mesh
  26117. */
  26118. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26119. private static _ExtractFrom;
  26120. /**
  26121. * Creates the VertexData for a Ribbon
  26122. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26123. * * pathArray array of paths, each of which an array of successive Vector3
  26124. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26125. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26126. * * 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
  26127. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26128. * * 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)
  26129. * * 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)
  26130. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26131. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26132. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26133. * @returns the VertexData of the ribbon
  26134. */
  26135. static CreateRibbon(options: {
  26136. pathArray: Vector3[][];
  26137. closeArray?: boolean;
  26138. closePath?: boolean;
  26139. offset?: number;
  26140. sideOrientation?: number;
  26141. frontUVs?: Vector4;
  26142. backUVs?: Vector4;
  26143. invertUV?: boolean;
  26144. uvs?: Vector2[];
  26145. colors?: Color4[];
  26146. }): VertexData;
  26147. /**
  26148. * Creates the VertexData for a box
  26149. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26150. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26151. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26152. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26153. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26154. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26155. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26156. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26157. * * 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)
  26158. * * 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)
  26159. * @returns the VertexData of the box
  26160. */
  26161. static CreateBox(options: {
  26162. size?: number;
  26163. width?: number;
  26164. height?: number;
  26165. depth?: number;
  26166. faceUV?: Vector4[];
  26167. faceColors?: Color4[];
  26168. sideOrientation?: number;
  26169. frontUVs?: Vector4;
  26170. backUVs?: Vector4;
  26171. }): VertexData;
  26172. /**
  26173. * Creates the VertexData for a tiled box
  26174. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26175. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26176. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26177. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26178. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26179. * @returns the VertexData of the box
  26180. */
  26181. static CreateTiledBox(options: {
  26182. pattern?: number;
  26183. width?: number;
  26184. height?: number;
  26185. depth?: number;
  26186. tileSize?: number;
  26187. tileWidth?: number;
  26188. tileHeight?: number;
  26189. alignHorizontal?: number;
  26190. alignVertical?: number;
  26191. faceUV?: Vector4[];
  26192. faceColors?: Color4[];
  26193. sideOrientation?: number;
  26194. }): VertexData;
  26195. /**
  26196. * Creates the VertexData for a tiled plane
  26197. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26198. * * pattern a limited pattern arrangement depending on the number
  26199. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26200. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26201. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26202. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26203. * * 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)
  26204. * * 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)
  26205. * @returns the VertexData of the tiled plane
  26206. */
  26207. static CreateTiledPlane(options: {
  26208. pattern?: number;
  26209. tileSize?: number;
  26210. tileWidth?: number;
  26211. tileHeight?: number;
  26212. size?: number;
  26213. width?: number;
  26214. height?: number;
  26215. alignHorizontal?: number;
  26216. alignVertical?: number;
  26217. sideOrientation?: number;
  26218. frontUVs?: Vector4;
  26219. backUVs?: Vector4;
  26220. }): VertexData;
  26221. /**
  26222. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26223. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26224. * * segments sets the number of horizontal strips optional, default 32
  26225. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26226. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26227. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26228. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26229. * * 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
  26230. * * 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
  26231. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26232. * * 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)
  26233. * * 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)
  26234. * @returns the VertexData of the ellipsoid
  26235. */
  26236. static CreateSphere(options: {
  26237. segments?: number;
  26238. diameter?: number;
  26239. diameterX?: number;
  26240. diameterY?: number;
  26241. diameterZ?: number;
  26242. arc?: number;
  26243. slice?: number;
  26244. sideOrientation?: number;
  26245. frontUVs?: Vector4;
  26246. backUVs?: Vector4;
  26247. }): VertexData;
  26248. /**
  26249. * Creates the VertexData for a cylinder, cone or prism
  26250. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26251. * * height sets the height (y direction) of the cylinder, optional, default 2
  26252. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26253. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26254. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26255. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26256. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26257. * * 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
  26258. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26259. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26260. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26261. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26262. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26263. * * 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)
  26264. * * 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)
  26265. * @returns the VertexData of the cylinder, cone or prism
  26266. */
  26267. static CreateCylinder(options: {
  26268. height?: number;
  26269. diameterTop?: number;
  26270. diameterBottom?: number;
  26271. diameter?: number;
  26272. tessellation?: number;
  26273. subdivisions?: number;
  26274. arc?: number;
  26275. faceColors?: Color4[];
  26276. faceUV?: Vector4[];
  26277. hasRings?: boolean;
  26278. enclose?: boolean;
  26279. sideOrientation?: number;
  26280. frontUVs?: Vector4;
  26281. backUVs?: Vector4;
  26282. }): VertexData;
  26283. /**
  26284. * Creates the VertexData for a torus
  26285. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26286. * * diameter the diameter of the torus, optional default 1
  26287. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26288. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26289. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26290. * * 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)
  26291. * * 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)
  26292. * @returns the VertexData of the torus
  26293. */
  26294. static CreateTorus(options: {
  26295. diameter?: number;
  26296. thickness?: number;
  26297. tessellation?: number;
  26298. sideOrientation?: number;
  26299. frontUVs?: Vector4;
  26300. backUVs?: Vector4;
  26301. }): VertexData;
  26302. /**
  26303. * Creates the VertexData of the LineSystem
  26304. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26305. * - lines an array of lines, each line being an array of successive Vector3
  26306. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26307. * @returns the VertexData of the LineSystem
  26308. */
  26309. static CreateLineSystem(options: {
  26310. lines: Vector3[][];
  26311. colors?: Nullable<Color4[][]>;
  26312. }): VertexData;
  26313. /**
  26314. * Create the VertexData for a DashedLines
  26315. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26316. * - points an array successive Vector3
  26317. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26318. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26319. * - dashNb the intended total number of dashes, optional, default 200
  26320. * @returns the VertexData for the DashedLines
  26321. */
  26322. static CreateDashedLines(options: {
  26323. points: Vector3[];
  26324. dashSize?: number;
  26325. gapSize?: number;
  26326. dashNb?: number;
  26327. }): VertexData;
  26328. /**
  26329. * Creates the VertexData for a Ground
  26330. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26331. * - width the width (x direction) of the ground, optional, default 1
  26332. * - height the height (z direction) of the ground, optional, default 1
  26333. * - subdivisions the number of subdivisions per side, optional, default 1
  26334. * @returns the VertexData of the Ground
  26335. */
  26336. static CreateGround(options: {
  26337. width?: number;
  26338. height?: number;
  26339. subdivisions?: number;
  26340. subdivisionsX?: number;
  26341. subdivisionsY?: number;
  26342. }): VertexData;
  26343. /**
  26344. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26345. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26346. * * xmin the ground minimum X coordinate, optional, default -1
  26347. * * zmin the ground minimum Z coordinate, optional, default -1
  26348. * * xmax the ground maximum X coordinate, optional, default 1
  26349. * * zmax the ground maximum Z coordinate, optional, default 1
  26350. * * 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}
  26351. * * 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}
  26352. * @returns the VertexData of the TiledGround
  26353. */
  26354. static CreateTiledGround(options: {
  26355. xmin: number;
  26356. zmin: number;
  26357. xmax: number;
  26358. zmax: number;
  26359. subdivisions?: {
  26360. w: number;
  26361. h: number;
  26362. };
  26363. precision?: {
  26364. w: number;
  26365. h: number;
  26366. };
  26367. }): VertexData;
  26368. /**
  26369. * Creates the VertexData of the Ground designed from a heightmap
  26370. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26371. * * width the width (x direction) of the ground
  26372. * * height the height (z direction) of the ground
  26373. * * subdivisions the number of subdivisions per side
  26374. * * minHeight the minimum altitude on the ground, optional, default 0
  26375. * * maxHeight the maximum altitude on the ground, optional default 1
  26376. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26377. * * buffer the array holding the image color data
  26378. * * bufferWidth the width of image
  26379. * * bufferHeight the height of image
  26380. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26381. * @returns the VertexData of the Ground designed from a heightmap
  26382. */
  26383. static CreateGroundFromHeightMap(options: {
  26384. width: number;
  26385. height: number;
  26386. subdivisions: number;
  26387. minHeight: number;
  26388. maxHeight: number;
  26389. colorFilter: Color3;
  26390. buffer: Uint8Array;
  26391. bufferWidth: number;
  26392. bufferHeight: number;
  26393. alphaFilter: number;
  26394. }): VertexData;
  26395. /**
  26396. * Creates the VertexData for a Plane
  26397. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26398. * * size sets the width and height of the plane to the value of size, optional default 1
  26399. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26400. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26401. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26402. * * 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)
  26403. * * 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)
  26404. * @returns the VertexData of the box
  26405. */
  26406. static CreatePlane(options: {
  26407. size?: number;
  26408. width?: number;
  26409. height?: number;
  26410. sideOrientation?: number;
  26411. frontUVs?: Vector4;
  26412. backUVs?: Vector4;
  26413. }): VertexData;
  26414. /**
  26415. * Creates the VertexData of the Disc or regular Polygon
  26416. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26417. * * radius the radius of the disc, optional default 0.5
  26418. * * tessellation the number of polygon sides, optional, default 64
  26419. * * 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
  26420. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26421. * * 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)
  26422. * * 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)
  26423. * @returns the VertexData of the box
  26424. */
  26425. static CreateDisc(options: {
  26426. radius?: number;
  26427. tessellation?: number;
  26428. arc?: number;
  26429. sideOrientation?: number;
  26430. frontUVs?: Vector4;
  26431. backUVs?: Vector4;
  26432. }): VertexData;
  26433. /**
  26434. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26435. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26436. * @param polygon a mesh built from polygonTriangulation.build()
  26437. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26438. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26439. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26440. * @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)
  26441. * @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)
  26442. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26443. * @returns the VertexData of the Polygon
  26444. */
  26445. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26446. /**
  26447. * Creates the VertexData of the IcoSphere
  26448. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26449. * * radius the radius of the IcoSphere, optional default 1
  26450. * * radiusX allows stretching in the x direction, optional, default radius
  26451. * * radiusY allows stretching in the y direction, optional, default radius
  26452. * * radiusZ allows stretching in the z direction, optional, default radius
  26453. * * flat when true creates a flat shaded mesh, optional, default true
  26454. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26455. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26456. * * 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)
  26457. * * 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)
  26458. * @returns the VertexData of the IcoSphere
  26459. */
  26460. static CreateIcoSphere(options: {
  26461. radius?: number;
  26462. radiusX?: number;
  26463. radiusY?: number;
  26464. radiusZ?: number;
  26465. flat?: boolean;
  26466. subdivisions?: number;
  26467. sideOrientation?: number;
  26468. frontUVs?: Vector4;
  26469. backUVs?: Vector4;
  26470. }): VertexData;
  26471. /**
  26472. * Creates the VertexData for a Polyhedron
  26473. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26474. * * type provided types are:
  26475. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26476. * * 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)
  26477. * * size the size of the IcoSphere, optional default 1
  26478. * * sizeX allows stretching in the x direction, optional, default size
  26479. * * sizeY allows stretching in the y direction, optional, default size
  26480. * * sizeZ allows stretching in the z direction, optional, default size
  26481. * * 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
  26482. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26483. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26484. * * flat when true creates a flat shaded mesh, optional, default true
  26485. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26486. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26487. * * 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)
  26488. * * 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)
  26489. * @returns the VertexData of the Polyhedron
  26490. */
  26491. static CreatePolyhedron(options: {
  26492. type?: number;
  26493. size?: number;
  26494. sizeX?: number;
  26495. sizeY?: number;
  26496. sizeZ?: number;
  26497. custom?: any;
  26498. faceUV?: Vector4[];
  26499. faceColors?: Color4[];
  26500. flat?: boolean;
  26501. sideOrientation?: number;
  26502. frontUVs?: Vector4;
  26503. backUVs?: Vector4;
  26504. }): VertexData;
  26505. /**
  26506. * Creates the VertexData for a TorusKnot
  26507. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26508. * * radius the radius of the torus knot, optional, default 2
  26509. * * tube the thickness of the tube, optional, default 0.5
  26510. * * radialSegments the number of sides on each tube segments, optional, default 32
  26511. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26512. * * p the number of windings around the z axis, optional, default 2
  26513. * * q the number of windings around the x axis, optional, default 3
  26514. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26515. * * 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)
  26516. * * 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)
  26517. * @returns the VertexData of the Torus Knot
  26518. */
  26519. static CreateTorusKnot(options: {
  26520. radius?: number;
  26521. tube?: number;
  26522. radialSegments?: number;
  26523. tubularSegments?: number;
  26524. p?: number;
  26525. q?: number;
  26526. sideOrientation?: number;
  26527. frontUVs?: Vector4;
  26528. backUVs?: Vector4;
  26529. }): VertexData;
  26530. /**
  26531. * Compute normals for given positions and indices
  26532. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26533. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26534. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26535. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26536. * * facetNormals : optional array of facet normals (vector3)
  26537. * * facetPositions : optional array of facet positions (vector3)
  26538. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26539. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26540. * * bInfo : optional bounding info, required for facetPartitioning computation
  26541. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26542. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26543. * * useRightHandedSystem: optional boolean to for right handed system computation
  26544. * * depthSort : optional boolean to enable the facet depth sort computation
  26545. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26546. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26547. */
  26548. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26549. facetNormals?: any;
  26550. facetPositions?: any;
  26551. facetPartitioning?: any;
  26552. ratio?: number;
  26553. bInfo?: any;
  26554. bbSize?: Vector3;
  26555. subDiv?: any;
  26556. useRightHandedSystem?: boolean;
  26557. depthSort?: boolean;
  26558. distanceTo?: Vector3;
  26559. depthSortedFacets?: any;
  26560. }): void;
  26561. /** @hidden */
  26562. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26563. /**
  26564. * Applies VertexData created from the imported parameters to the geometry
  26565. * @param parsedVertexData the parsed data from an imported file
  26566. * @param geometry the geometry to apply the VertexData to
  26567. */
  26568. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26569. }
  26570. }
  26571. declare module "babylonjs/Morph/morphTarget" {
  26572. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26573. import { Observable } from "babylonjs/Misc/observable";
  26574. import { Nullable, FloatArray } from "babylonjs/types";
  26575. import { Scene } from "babylonjs/scene";
  26576. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26577. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26578. /**
  26579. * Defines a target to use with MorphTargetManager
  26580. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26581. */
  26582. export class MorphTarget implements IAnimatable {
  26583. /** defines the name of the target */
  26584. name: string;
  26585. /**
  26586. * Gets or sets the list of animations
  26587. */
  26588. animations: import("babylonjs/Animations/animation").Animation[];
  26589. private _scene;
  26590. private _positions;
  26591. private _normals;
  26592. private _tangents;
  26593. private _uvs;
  26594. private _influence;
  26595. private _uniqueId;
  26596. /**
  26597. * Observable raised when the influence changes
  26598. */
  26599. onInfluenceChanged: Observable<boolean>;
  26600. /** @hidden */
  26601. _onDataLayoutChanged: Observable<void>;
  26602. /**
  26603. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26604. */
  26605. get influence(): number;
  26606. set influence(influence: number);
  26607. /**
  26608. * Gets or sets the id of the morph Target
  26609. */
  26610. id: string;
  26611. private _animationPropertiesOverride;
  26612. /**
  26613. * Gets or sets the animation properties override
  26614. */
  26615. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26616. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26617. /**
  26618. * Creates a new MorphTarget
  26619. * @param name defines the name of the target
  26620. * @param influence defines the influence to use
  26621. * @param scene defines the scene the morphtarget belongs to
  26622. */
  26623. constructor(
  26624. /** defines the name of the target */
  26625. name: string, influence?: number, scene?: Nullable<Scene>);
  26626. /**
  26627. * Gets the unique ID of this manager
  26628. */
  26629. get uniqueId(): number;
  26630. /**
  26631. * Gets a boolean defining if the target contains position data
  26632. */
  26633. get hasPositions(): boolean;
  26634. /**
  26635. * Gets a boolean defining if the target contains normal data
  26636. */
  26637. get hasNormals(): boolean;
  26638. /**
  26639. * Gets a boolean defining if the target contains tangent data
  26640. */
  26641. get hasTangents(): boolean;
  26642. /**
  26643. * Gets a boolean defining if the target contains texture coordinates data
  26644. */
  26645. get hasUVs(): boolean;
  26646. /**
  26647. * Affects position data to this target
  26648. * @param data defines the position data to use
  26649. */
  26650. setPositions(data: Nullable<FloatArray>): void;
  26651. /**
  26652. * Gets the position data stored in this target
  26653. * @returns a FloatArray containing the position data (or null if not present)
  26654. */
  26655. getPositions(): Nullable<FloatArray>;
  26656. /**
  26657. * Affects normal data to this target
  26658. * @param data defines the normal data to use
  26659. */
  26660. setNormals(data: Nullable<FloatArray>): void;
  26661. /**
  26662. * Gets the normal data stored in this target
  26663. * @returns a FloatArray containing the normal data (or null if not present)
  26664. */
  26665. getNormals(): Nullable<FloatArray>;
  26666. /**
  26667. * Affects tangent data to this target
  26668. * @param data defines the tangent data to use
  26669. */
  26670. setTangents(data: Nullable<FloatArray>): void;
  26671. /**
  26672. * Gets the tangent data stored in this target
  26673. * @returns a FloatArray containing the tangent data (or null if not present)
  26674. */
  26675. getTangents(): Nullable<FloatArray>;
  26676. /**
  26677. * Affects texture coordinates data to this target
  26678. * @param data defines the texture coordinates data to use
  26679. */
  26680. setUVs(data: Nullable<FloatArray>): void;
  26681. /**
  26682. * Gets the texture coordinates data stored in this target
  26683. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26684. */
  26685. getUVs(): Nullable<FloatArray>;
  26686. /**
  26687. * Clone the current target
  26688. * @returns a new MorphTarget
  26689. */
  26690. clone(): MorphTarget;
  26691. /**
  26692. * Serializes the current target into a Serialization object
  26693. * @returns the serialized object
  26694. */
  26695. serialize(): any;
  26696. /**
  26697. * Returns the string "MorphTarget"
  26698. * @returns "MorphTarget"
  26699. */
  26700. getClassName(): string;
  26701. /**
  26702. * Creates a new target from serialized data
  26703. * @param serializationObject defines the serialized data to use
  26704. * @returns a new MorphTarget
  26705. */
  26706. static Parse(serializationObject: any): MorphTarget;
  26707. /**
  26708. * Creates a MorphTarget from mesh data
  26709. * @param mesh defines the source mesh
  26710. * @param name defines the name to use for the new target
  26711. * @param influence defines the influence to attach to the target
  26712. * @returns a new MorphTarget
  26713. */
  26714. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26715. }
  26716. }
  26717. declare module "babylonjs/Morph/morphTargetManager" {
  26718. import { Nullable } from "babylonjs/types";
  26719. import { Scene } from "babylonjs/scene";
  26720. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  26721. /**
  26722. * This class is used to deform meshes using morphing between different targets
  26723. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26724. */
  26725. export class MorphTargetManager {
  26726. private _targets;
  26727. private _targetInfluenceChangedObservers;
  26728. private _targetDataLayoutChangedObservers;
  26729. private _activeTargets;
  26730. private _scene;
  26731. private _influences;
  26732. private _supportsNormals;
  26733. private _supportsTangents;
  26734. private _supportsUVs;
  26735. private _vertexCount;
  26736. private _uniqueId;
  26737. private _tempInfluences;
  26738. /**
  26739. * Gets or sets a boolean indicating if normals must be morphed
  26740. */
  26741. enableNormalMorphing: boolean;
  26742. /**
  26743. * Gets or sets a boolean indicating if tangents must be morphed
  26744. */
  26745. enableTangentMorphing: boolean;
  26746. /**
  26747. * Gets or sets a boolean indicating if UV must be morphed
  26748. */
  26749. enableUVMorphing: boolean;
  26750. /**
  26751. * Creates a new MorphTargetManager
  26752. * @param scene defines the current scene
  26753. */
  26754. constructor(scene?: Nullable<Scene>);
  26755. /**
  26756. * Gets the unique ID of this manager
  26757. */
  26758. get uniqueId(): number;
  26759. /**
  26760. * Gets the number of vertices handled by this manager
  26761. */
  26762. get vertexCount(): number;
  26763. /**
  26764. * Gets a boolean indicating if this manager supports morphing of normals
  26765. */
  26766. get supportsNormals(): boolean;
  26767. /**
  26768. * Gets a boolean indicating if this manager supports morphing of tangents
  26769. */
  26770. get supportsTangents(): boolean;
  26771. /**
  26772. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26773. */
  26774. get supportsUVs(): boolean;
  26775. /**
  26776. * Gets the number of targets stored in this manager
  26777. */
  26778. get numTargets(): number;
  26779. /**
  26780. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26781. */
  26782. get numInfluencers(): number;
  26783. /**
  26784. * Gets the list of influences (one per target)
  26785. */
  26786. get influences(): Float32Array;
  26787. /**
  26788. * Gets the active target at specified index. An active target is a target with an influence > 0
  26789. * @param index defines the index to check
  26790. * @returns the requested target
  26791. */
  26792. getActiveTarget(index: number): MorphTarget;
  26793. /**
  26794. * Gets the target at specified index
  26795. * @param index defines the index to check
  26796. * @returns the requested target
  26797. */
  26798. getTarget(index: number): MorphTarget;
  26799. /**
  26800. * Add a new target to this manager
  26801. * @param target defines the target to add
  26802. */
  26803. addTarget(target: MorphTarget): void;
  26804. /**
  26805. * Removes a target from the manager
  26806. * @param target defines the target to remove
  26807. */
  26808. removeTarget(target: MorphTarget): void;
  26809. /**
  26810. * Clone the current manager
  26811. * @returns a new MorphTargetManager
  26812. */
  26813. clone(): MorphTargetManager;
  26814. /**
  26815. * Serializes the current manager into a Serialization object
  26816. * @returns the serialized object
  26817. */
  26818. serialize(): any;
  26819. private _syncActiveTargets;
  26820. /**
  26821. * Syncrhonize the targets with all the meshes using this morph target manager
  26822. */
  26823. synchronize(): void;
  26824. /**
  26825. * Creates a new MorphTargetManager from serialized data
  26826. * @param serializationObject defines the serialized data
  26827. * @param scene defines the hosting scene
  26828. * @returns the new MorphTargetManager
  26829. */
  26830. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26831. }
  26832. }
  26833. declare module "babylonjs/Meshes/meshLODLevel" {
  26834. import { Mesh } from "babylonjs/Meshes/mesh";
  26835. import { Nullable } from "babylonjs/types";
  26836. /**
  26837. * Class used to represent a specific level of detail of a mesh
  26838. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26839. */
  26840. export class MeshLODLevel {
  26841. /** Defines the distance where this level should start being displayed */
  26842. distance: number;
  26843. /** Defines the mesh to use to render this level */
  26844. mesh: Nullable<Mesh>;
  26845. /**
  26846. * Creates a new LOD level
  26847. * @param distance defines the distance where this level should star being displayed
  26848. * @param mesh defines the mesh to use to render this level
  26849. */
  26850. constructor(
  26851. /** Defines the distance where this level should start being displayed */
  26852. distance: number,
  26853. /** Defines the mesh to use to render this level */
  26854. mesh: Nullable<Mesh>);
  26855. }
  26856. }
  26857. declare module "babylonjs/Meshes/groundMesh" {
  26858. import { Scene } from "babylonjs/scene";
  26859. import { Vector3 } from "babylonjs/Maths/math.vector";
  26860. import { Mesh } from "babylonjs/Meshes/mesh";
  26861. /**
  26862. * Mesh representing the gorund
  26863. */
  26864. export class GroundMesh extends Mesh {
  26865. /** If octree should be generated */
  26866. generateOctree: boolean;
  26867. private _heightQuads;
  26868. /** @hidden */
  26869. _subdivisionsX: number;
  26870. /** @hidden */
  26871. _subdivisionsY: number;
  26872. /** @hidden */
  26873. _width: number;
  26874. /** @hidden */
  26875. _height: number;
  26876. /** @hidden */
  26877. _minX: number;
  26878. /** @hidden */
  26879. _maxX: number;
  26880. /** @hidden */
  26881. _minZ: number;
  26882. /** @hidden */
  26883. _maxZ: number;
  26884. constructor(name: string, scene: Scene);
  26885. /**
  26886. * "GroundMesh"
  26887. * @returns "GroundMesh"
  26888. */
  26889. getClassName(): string;
  26890. /**
  26891. * The minimum of x and y subdivisions
  26892. */
  26893. get subdivisions(): number;
  26894. /**
  26895. * X subdivisions
  26896. */
  26897. get subdivisionsX(): number;
  26898. /**
  26899. * Y subdivisions
  26900. */
  26901. get subdivisionsY(): number;
  26902. /**
  26903. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26904. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26905. * @param chunksCount the number of subdivisions for x and y
  26906. * @param octreeBlocksSize (Default: 32)
  26907. */
  26908. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26909. /**
  26910. * Returns a height (y) value in the Worl system :
  26911. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26912. * @param x x coordinate
  26913. * @param z z coordinate
  26914. * @returns the ground y position if (x, z) are outside the ground surface.
  26915. */
  26916. getHeightAtCoordinates(x: number, z: number): number;
  26917. /**
  26918. * Returns a normalized vector (Vector3) orthogonal to the ground
  26919. * at the ground coordinates (x, z) expressed in the World system.
  26920. * @param x x coordinate
  26921. * @param z z coordinate
  26922. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26923. */
  26924. getNormalAtCoordinates(x: number, z: number): Vector3;
  26925. /**
  26926. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26927. * at the ground coordinates (x, z) expressed in the World system.
  26928. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26929. * @param x x coordinate
  26930. * @param z z coordinate
  26931. * @param ref vector to store the result
  26932. * @returns the GroundMesh.
  26933. */
  26934. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26935. /**
  26936. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26937. * if the ground has been updated.
  26938. * This can be used in the render loop.
  26939. * @returns the GroundMesh.
  26940. */
  26941. updateCoordinateHeights(): GroundMesh;
  26942. private _getFacetAt;
  26943. private _initHeightQuads;
  26944. private _computeHeightQuads;
  26945. /**
  26946. * Serializes this ground mesh
  26947. * @param serializationObject object to write serialization to
  26948. */
  26949. serialize(serializationObject: any): void;
  26950. /**
  26951. * Parses a serialized ground mesh
  26952. * @param parsedMesh the serialized mesh
  26953. * @param scene the scene to create the ground mesh in
  26954. * @returns the created ground mesh
  26955. */
  26956. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26957. }
  26958. }
  26959. declare module "babylonjs/Physics/physicsJoint" {
  26960. import { Vector3 } from "babylonjs/Maths/math.vector";
  26961. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  26962. /**
  26963. * Interface for Physics-Joint data
  26964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26965. */
  26966. export interface PhysicsJointData {
  26967. /**
  26968. * The main pivot of the joint
  26969. */
  26970. mainPivot?: Vector3;
  26971. /**
  26972. * The connected pivot of the joint
  26973. */
  26974. connectedPivot?: Vector3;
  26975. /**
  26976. * The main axis of the joint
  26977. */
  26978. mainAxis?: Vector3;
  26979. /**
  26980. * The connected axis of the joint
  26981. */
  26982. connectedAxis?: Vector3;
  26983. /**
  26984. * The collision of the joint
  26985. */
  26986. collision?: boolean;
  26987. /**
  26988. * Native Oimo/Cannon/Energy data
  26989. */
  26990. nativeParams?: any;
  26991. }
  26992. /**
  26993. * This is a holder class for the physics joint created by the physics plugin
  26994. * It holds a set of functions to control the underlying joint
  26995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26996. */
  26997. export class PhysicsJoint {
  26998. /**
  26999. * The type of the physics joint
  27000. */
  27001. type: number;
  27002. /**
  27003. * The data for the physics joint
  27004. */
  27005. jointData: PhysicsJointData;
  27006. private _physicsJoint;
  27007. protected _physicsPlugin: IPhysicsEnginePlugin;
  27008. /**
  27009. * Initializes the physics joint
  27010. * @param type The type of the physics joint
  27011. * @param jointData The data for the physics joint
  27012. */
  27013. constructor(
  27014. /**
  27015. * The type of the physics joint
  27016. */
  27017. type: number,
  27018. /**
  27019. * The data for the physics joint
  27020. */
  27021. jointData: PhysicsJointData);
  27022. /**
  27023. * Gets the physics joint
  27024. */
  27025. get physicsJoint(): any;
  27026. /**
  27027. * Sets the physics joint
  27028. */
  27029. set physicsJoint(newJoint: any);
  27030. /**
  27031. * Sets the physics plugin
  27032. */
  27033. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27034. /**
  27035. * Execute a function that is physics-plugin specific.
  27036. * @param {Function} func the function that will be executed.
  27037. * It accepts two parameters: the physics world and the physics joint
  27038. */
  27039. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27040. /**
  27041. * Distance-Joint type
  27042. */
  27043. static DistanceJoint: number;
  27044. /**
  27045. * Hinge-Joint type
  27046. */
  27047. static HingeJoint: number;
  27048. /**
  27049. * Ball-and-Socket joint type
  27050. */
  27051. static BallAndSocketJoint: number;
  27052. /**
  27053. * Wheel-Joint type
  27054. */
  27055. static WheelJoint: number;
  27056. /**
  27057. * Slider-Joint type
  27058. */
  27059. static SliderJoint: number;
  27060. /**
  27061. * Prismatic-Joint type
  27062. */
  27063. static PrismaticJoint: number;
  27064. /**
  27065. * Universal-Joint type
  27066. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27067. */
  27068. static UniversalJoint: number;
  27069. /**
  27070. * Hinge-Joint 2 type
  27071. */
  27072. static Hinge2Joint: number;
  27073. /**
  27074. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27075. */
  27076. static PointToPointJoint: number;
  27077. /**
  27078. * Spring-Joint type
  27079. */
  27080. static SpringJoint: number;
  27081. /**
  27082. * Lock-Joint type
  27083. */
  27084. static LockJoint: number;
  27085. }
  27086. /**
  27087. * A class representing a physics distance joint
  27088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27089. */
  27090. export class DistanceJoint extends PhysicsJoint {
  27091. /**
  27092. *
  27093. * @param jointData The data for the Distance-Joint
  27094. */
  27095. constructor(jointData: DistanceJointData);
  27096. /**
  27097. * Update the predefined distance.
  27098. * @param maxDistance The maximum preferred distance
  27099. * @param minDistance The minimum preferred distance
  27100. */
  27101. updateDistance(maxDistance: number, minDistance?: number): void;
  27102. }
  27103. /**
  27104. * Represents a Motor-Enabled Joint
  27105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27106. */
  27107. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27108. /**
  27109. * Initializes the Motor-Enabled Joint
  27110. * @param type The type of the joint
  27111. * @param jointData The physica joint data for the joint
  27112. */
  27113. constructor(type: number, jointData: PhysicsJointData);
  27114. /**
  27115. * Set the motor values.
  27116. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27117. * @param force the force to apply
  27118. * @param maxForce max force for this motor.
  27119. */
  27120. setMotor(force?: number, maxForce?: number): void;
  27121. /**
  27122. * Set the motor's limits.
  27123. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27124. * @param upperLimit The upper limit of the motor
  27125. * @param lowerLimit The lower limit of the motor
  27126. */
  27127. setLimit(upperLimit: number, lowerLimit?: number): void;
  27128. }
  27129. /**
  27130. * This class represents a single physics Hinge-Joint
  27131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27132. */
  27133. export class HingeJoint extends MotorEnabledJoint {
  27134. /**
  27135. * Initializes the Hinge-Joint
  27136. * @param jointData The joint data for the Hinge-Joint
  27137. */
  27138. constructor(jointData: PhysicsJointData);
  27139. /**
  27140. * Set the motor values.
  27141. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27142. * @param {number} force the force to apply
  27143. * @param {number} maxForce max force for this motor.
  27144. */
  27145. setMotor(force?: number, maxForce?: number): void;
  27146. /**
  27147. * Set the motor's limits.
  27148. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27149. * @param upperLimit The upper limit of the motor
  27150. * @param lowerLimit The lower limit of the motor
  27151. */
  27152. setLimit(upperLimit: number, lowerLimit?: number): void;
  27153. }
  27154. /**
  27155. * This class represents a dual hinge physics joint (same as wheel joint)
  27156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27157. */
  27158. export class Hinge2Joint extends MotorEnabledJoint {
  27159. /**
  27160. * Initializes the Hinge2-Joint
  27161. * @param jointData The joint data for the Hinge2-Joint
  27162. */
  27163. constructor(jointData: PhysicsJointData);
  27164. /**
  27165. * Set the motor values.
  27166. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27167. * @param {number} targetSpeed the speed the motor is to reach
  27168. * @param {number} maxForce max force for this motor.
  27169. * @param {motorIndex} the motor's index, 0 or 1.
  27170. */
  27171. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27172. /**
  27173. * Set the motor limits.
  27174. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27175. * @param {number} upperLimit the upper limit
  27176. * @param {number} lowerLimit lower limit
  27177. * @param {motorIndex} the motor's index, 0 or 1.
  27178. */
  27179. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27180. }
  27181. /**
  27182. * Interface for a motor enabled joint
  27183. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27184. */
  27185. export interface IMotorEnabledJoint {
  27186. /**
  27187. * Physics joint
  27188. */
  27189. physicsJoint: any;
  27190. /**
  27191. * Sets the motor of the motor-enabled joint
  27192. * @param force The force of the motor
  27193. * @param maxForce The maximum force of the motor
  27194. * @param motorIndex The index of the motor
  27195. */
  27196. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27197. /**
  27198. * Sets the limit of the motor
  27199. * @param upperLimit The upper limit of the motor
  27200. * @param lowerLimit The lower limit of the motor
  27201. * @param motorIndex The index of the motor
  27202. */
  27203. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27204. }
  27205. /**
  27206. * Joint data for a Distance-Joint
  27207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27208. */
  27209. export interface DistanceJointData extends PhysicsJointData {
  27210. /**
  27211. * Max distance the 2 joint objects can be apart
  27212. */
  27213. maxDistance: number;
  27214. }
  27215. /**
  27216. * Joint data from a spring joint
  27217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27218. */
  27219. export interface SpringJointData extends PhysicsJointData {
  27220. /**
  27221. * Length of the spring
  27222. */
  27223. length: number;
  27224. /**
  27225. * Stiffness of the spring
  27226. */
  27227. stiffness: number;
  27228. /**
  27229. * Damping of the spring
  27230. */
  27231. damping: number;
  27232. /** this callback will be called when applying the force to the impostors. */
  27233. forceApplicationCallback: () => void;
  27234. }
  27235. }
  27236. declare module "babylonjs/Physics/physicsRaycastResult" {
  27237. import { Vector3 } from "babylonjs/Maths/math.vector";
  27238. /**
  27239. * Holds the data for the raycast result
  27240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27241. */
  27242. export class PhysicsRaycastResult {
  27243. private _hasHit;
  27244. private _hitDistance;
  27245. private _hitNormalWorld;
  27246. private _hitPointWorld;
  27247. private _rayFromWorld;
  27248. private _rayToWorld;
  27249. /**
  27250. * Gets if there was a hit
  27251. */
  27252. get hasHit(): boolean;
  27253. /**
  27254. * Gets the distance from the hit
  27255. */
  27256. get hitDistance(): number;
  27257. /**
  27258. * Gets the hit normal/direction in the world
  27259. */
  27260. get hitNormalWorld(): Vector3;
  27261. /**
  27262. * Gets the hit point in the world
  27263. */
  27264. get hitPointWorld(): Vector3;
  27265. /**
  27266. * Gets the ray "start point" of the ray in the world
  27267. */
  27268. get rayFromWorld(): Vector3;
  27269. /**
  27270. * Gets the ray "end point" of the ray in the world
  27271. */
  27272. get rayToWorld(): Vector3;
  27273. /**
  27274. * Sets the hit data (normal & point in world space)
  27275. * @param hitNormalWorld defines the normal in world space
  27276. * @param hitPointWorld defines the point in world space
  27277. */
  27278. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27279. /**
  27280. * Sets the distance from the start point to the hit point
  27281. * @param distance
  27282. */
  27283. setHitDistance(distance: number): void;
  27284. /**
  27285. * Calculates the distance manually
  27286. */
  27287. calculateHitDistance(): void;
  27288. /**
  27289. * Resets all the values to default
  27290. * @param from The from point on world space
  27291. * @param to The to point on world space
  27292. */
  27293. reset(from?: Vector3, to?: Vector3): void;
  27294. }
  27295. /**
  27296. * Interface for the size containing width and height
  27297. */
  27298. interface IXYZ {
  27299. /**
  27300. * X
  27301. */
  27302. x: number;
  27303. /**
  27304. * Y
  27305. */
  27306. y: number;
  27307. /**
  27308. * Z
  27309. */
  27310. z: number;
  27311. }
  27312. }
  27313. declare module "babylonjs/Physics/IPhysicsEngine" {
  27314. import { Nullable } from "babylonjs/types";
  27315. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  27316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27317. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  27318. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  27319. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  27320. /**
  27321. * Interface used to describe a physics joint
  27322. */
  27323. export interface PhysicsImpostorJoint {
  27324. /** Defines the main impostor to which the joint is linked */
  27325. mainImpostor: PhysicsImpostor;
  27326. /** Defines the impostor that is connected to the main impostor using this joint */
  27327. connectedImpostor: PhysicsImpostor;
  27328. /** Defines the joint itself */
  27329. joint: PhysicsJoint;
  27330. }
  27331. /** @hidden */
  27332. export interface IPhysicsEnginePlugin {
  27333. world: any;
  27334. name: string;
  27335. setGravity(gravity: Vector3): void;
  27336. setTimeStep(timeStep: number): void;
  27337. getTimeStep(): number;
  27338. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27339. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27340. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27341. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27342. removePhysicsBody(impostor: PhysicsImpostor): void;
  27343. generateJoint(joint: PhysicsImpostorJoint): void;
  27344. removeJoint(joint: PhysicsImpostorJoint): void;
  27345. isSupported(): boolean;
  27346. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27347. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27348. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27349. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27350. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27351. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27352. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27353. getBodyMass(impostor: PhysicsImpostor): number;
  27354. getBodyFriction(impostor: PhysicsImpostor): number;
  27355. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27356. getBodyRestitution(impostor: PhysicsImpostor): number;
  27357. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27358. getBodyPressure?(impostor: PhysicsImpostor): number;
  27359. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27360. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27361. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27362. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27363. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27364. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27365. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27366. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27367. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27368. sleepBody(impostor: PhysicsImpostor): void;
  27369. wakeUpBody(impostor: PhysicsImpostor): void;
  27370. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27371. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27372. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27373. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27374. getRadius(impostor: PhysicsImpostor): number;
  27375. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27376. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27377. dispose(): void;
  27378. }
  27379. /**
  27380. * Interface used to define a physics engine
  27381. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  27382. */
  27383. export interface IPhysicsEngine {
  27384. /**
  27385. * Gets the gravity vector used by the simulation
  27386. */
  27387. gravity: Vector3;
  27388. /**
  27389. * Sets the gravity vector used by the simulation
  27390. * @param gravity defines the gravity vector to use
  27391. */
  27392. setGravity(gravity: Vector3): void;
  27393. /**
  27394. * Set the time step of the physics engine.
  27395. * Default is 1/60.
  27396. * To slow it down, enter 1/600 for example.
  27397. * To speed it up, 1/30
  27398. * @param newTimeStep the new timestep to apply to this world.
  27399. */
  27400. setTimeStep(newTimeStep: number): void;
  27401. /**
  27402. * Get the time step of the physics engine.
  27403. * @returns the current time step
  27404. */
  27405. getTimeStep(): number;
  27406. /**
  27407. * Set the sub time step of the physics engine.
  27408. * Default is 0 meaning there is no sub steps
  27409. * To increase physics resolution precision, set a small value (like 1 ms)
  27410. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27411. */
  27412. setSubTimeStep(subTimeStep: number): void;
  27413. /**
  27414. * Get the sub time step of the physics engine.
  27415. * @returns the current sub time step
  27416. */
  27417. getSubTimeStep(): number;
  27418. /**
  27419. * Release all resources
  27420. */
  27421. dispose(): void;
  27422. /**
  27423. * Gets the name of the current physics plugin
  27424. * @returns the name of the plugin
  27425. */
  27426. getPhysicsPluginName(): string;
  27427. /**
  27428. * Adding a new impostor for the impostor tracking.
  27429. * This will be done by the impostor itself.
  27430. * @param impostor the impostor to add
  27431. */
  27432. addImpostor(impostor: PhysicsImpostor): void;
  27433. /**
  27434. * Remove an impostor from the engine.
  27435. * This impostor and its mesh will not longer be updated by the physics engine.
  27436. * @param impostor the impostor to remove
  27437. */
  27438. removeImpostor(impostor: PhysicsImpostor): void;
  27439. /**
  27440. * Add a joint to the physics engine
  27441. * @param mainImpostor defines the main impostor to which the joint is added.
  27442. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27443. * @param joint defines the joint that will connect both impostors.
  27444. */
  27445. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27446. /**
  27447. * Removes a joint from the simulation
  27448. * @param mainImpostor defines the impostor used with the joint
  27449. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27450. * @param joint defines the joint to remove
  27451. */
  27452. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27453. /**
  27454. * Gets the current plugin used to run the simulation
  27455. * @returns current plugin
  27456. */
  27457. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27458. /**
  27459. * Gets the list of physic impostors
  27460. * @returns an array of PhysicsImpostor
  27461. */
  27462. getImpostors(): Array<PhysicsImpostor>;
  27463. /**
  27464. * Gets the impostor for a physics enabled object
  27465. * @param object defines the object impersonated by the impostor
  27466. * @returns the PhysicsImpostor or null if not found
  27467. */
  27468. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27469. /**
  27470. * Gets the impostor for a physics body object
  27471. * @param body defines physics body used by the impostor
  27472. * @returns the PhysicsImpostor or null if not found
  27473. */
  27474. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27475. /**
  27476. * Does a raycast in the physics world
  27477. * @param from when should the ray start?
  27478. * @param to when should the ray end?
  27479. * @returns PhysicsRaycastResult
  27480. */
  27481. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27482. /**
  27483. * Called by the scene. No need to call it.
  27484. * @param delta defines the timespam between frames
  27485. */
  27486. _step(delta: number): void;
  27487. }
  27488. }
  27489. declare module "babylonjs/Physics/physicsImpostor" {
  27490. import { Nullable, IndicesArray } from "babylonjs/types";
  27491. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  27492. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27494. import { Scene } from "babylonjs/scene";
  27495. import { Bone } from "babylonjs/Bones/bone";
  27496. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27497. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  27498. import { Space } from "babylonjs/Maths/math.axis";
  27499. /**
  27500. * The interface for the physics imposter parameters
  27501. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27502. */
  27503. export interface PhysicsImpostorParameters {
  27504. /**
  27505. * The mass of the physics imposter
  27506. */
  27507. mass: number;
  27508. /**
  27509. * The friction of the physics imposter
  27510. */
  27511. friction?: number;
  27512. /**
  27513. * The coefficient of restitution of the physics imposter
  27514. */
  27515. restitution?: number;
  27516. /**
  27517. * The native options of the physics imposter
  27518. */
  27519. nativeOptions?: any;
  27520. /**
  27521. * Specifies if the parent should be ignored
  27522. */
  27523. ignoreParent?: boolean;
  27524. /**
  27525. * Specifies if bi-directional transformations should be disabled
  27526. */
  27527. disableBidirectionalTransformation?: boolean;
  27528. /**
  27529. * The pressure inside the physics imposter, soft object only
  27530. */
  27531. pressure?: number;
  27532. /**
  27533. * The stiffness the physics imposter, soft object only
  27534. */
  27535. stiffness?: number;
  27536. /**
  27537. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27538. */
  27539. velocityIterations?: number;
  27540. /**
  27541. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27542. */
  27543. positionIterations?: number;
  27544. /**
  27545. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27546. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27547. * Add to fix multiple points
  27548. */
  27549. fixedPoints?: number;
  27550. /**
  27551. * The collision margin around a soft object
  27552. */
  27553. margin?: number;
  27554. /**
  27555. * The collision margin around a soft object
  27556. */
  27557. damping?: number;
  27558. /**
  27559. * The path for a rope based on an extrusion
  27560. */
  27561. path?: any;
  27562. /**
  27563. * The shape of an extrusion used for a rope based on an extrusion
  27564. */
  27565. shape?: any;
  27566. }
  27567. /**
  27568. * Interface for a physics-enabled object
  27569. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27570. */
  27571. export interface IPhysicsEnabledObject {
  27572. /**
  27573. * The position of the physics-enabled object
  27574. */
  27575. position: Vector3;
  27576. /**
  27577. * The rotation of the physics-enabled object
  27578. */
  27579. rotationQuaternion: Nullable<Quaternion>;
  27580. /**
  27581. * The scale of the physics-enabled object
  27582. */
  27583. scaling: Vector3;
  27584. /**
  27585. * The rotation of the physics-enabled object
  27586. */
  27587. rotation?: Vector3;
  27588. /**
  27589. * The parent of the physics-enabled object
  27590. */
  27591. parent?: any;
  27592. /**
  27593. * The bounding info of the physics-enabled object
  27594. * @returns The bounding info of the physics-enabled object
  27595. */
  27596. getBoundingInfo(): BoundingInfo;
  27597. /**
  27598. * Computes the world matrix
  27599. * @param force Specifies if the world matrix should be computed by force
  27600. * @returns A world matrix
  27601. */
  27602. computeWorldMatrix(force: boolean): Matrix;
  27603. /**
  27604. * Gets the world matrix
  27605. * @returns A world matrix
  27606. */
  27607. getWorldMatrix?(): Matrix;
  27608. /**
  27609. * Gets the child meshes
  27610. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27611. * @returns An array of abstract meshes
  27612. */
  27613. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27614. /**
  27615. * Gets the vertex data
  27616. * @param kind The type of vertex data
  27617. * @returns A nullable array of numbers, or a float32 array
  27618. */
  27619. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27620. /**
  27621. * Gets the indices from the mesh
  27622. * @returns A nullable array of index arrays
  27623. */
  27624. getIndices?(): Nullable<IndicesArray>;
  27625. /**
  27626. * Gets the scene from the mesh
  27627. * @returns the indices array or null
  27628. */
  27629. getScene?(): Scene;
  27630. /**
  27631. * Gets the absolute position from the mesh
  27632. * @returns the absolute position
  27633. */
  27634. getAbsolutePosition(): Vector3;
  27635. /**
  27636. * Gets the absolute pivot point from the mesh
  27637. * @returns the absolute pivot point
  27638. */
  27639. getAbsolutePivotPoint(): Vector3;
  27640. /**
  27641. * Rotates the mesh
  27642. * @param axis The axis of rotation
  27643. * @param amount The amount of rotation
  27644. * @param space The space of the rotation
  27645. * @returns The rotation transform node
  27646. */
  27647. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27648. /**
  27649. * Translates the mesh
  27650. * @param axis The axis of translation
  27651. * @param distance The distance of translation
  27652. * @param space The space of the translation
  27653. * @returns The transform node
  27654. */
  27655. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27656. /**
  27657. * Sets the absolute position of the mesh
  27658. * @param absolutePosition The absolute position of the mesh
  27659. * @returns The transform node
  27660. */
  27661. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27662. /**
  27663. * Gets the class name of the mesh
  27664. * @returns The class name
  27665. */
  27666. getClassName(): string;
  27667. }
  27668. /**
  27669. * Represents a physics imposter
  27670. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27671. */
  27672. export class PhysicsImpostor {
  27673. /**
  27674. * The physics-enabled object used as the physics imposter
  27675. */
  27676. object: IPhysicsEnabledObject;
  27677. /**
  27678. * The type of the physics imposter
  27679. */
  27680. type: number;
  27681. private _options;
  27682. private _scene?;
  27683. /**
  27684. * The default object size of the imposter
  27685. */
  27686. static DEFAULT_OBJECT_SIZE: Vector3;
  27687. /**
  27688. * The identity quaternion of the imposter
  27689. */
  27690. static IDENTITY_QUATERNION: Quaternion;
  27691. /** @hidden */
  27692. _pluginData: any;
  27693. private _physicsEngine;
  27694. private _physicsBody;
  27695. private _bodyUpdateRequired;
  27696. private _onBeforePhysicsStepCallbacks;
  27697. private _onAfterPhysicsStepCallbacks;
  27698. /** @hidden */
  27699. _onPhysicsCollideCallbacks: Array<{
  27700. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27701. otherImpostors: Array<PhysicsImpostor>;
  27702. }>;
  27703. private _deltaPosition;
  27704. private _deltaRotation;
  27705. private _deltaRotationConjugated;
  27706. /** @hidden */
  27707. _isFromLine: boolean;
  27708. private _parent;
  27709. private _isDisposed;
  27710. private static _tmpVecs;
  27711. private static _tmpQuat;
  27712. /**
  27713. * Specifies if the physics imposter is disposed
  27714. */
  27715. get isDisposed(): boolean;
  27716. /**
  27717. * Gets the mass of the physics imposter
  27718. */
  27719. get mass(): number;
  27720. set mass(value: number);
  27721. /**
  27722. * Gets the coefficient of friction
  27723. */
  27724. get friction(): number;
  27725. /**
  27726. * Sets the coefficient of friction
  27727. */
  27728. set friction(value: number);
  27729. /**
  27730. * Gets the coefficient of restitution
  27731. */
  27732. get restitution(): number;
  27733. /**
  27734. * Sets the coefficient of restitution
  27735. */
  27736. set restitution(value: number);
  27737. /**
  27738. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27739. */
  27740. get pressure(): number;
  27741. /**
  27742. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27743. */
  27744. set pressure(value: number);
  27745. /**
  27746. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27747. */
  27748. get stiffness(): number;
  27749. /**
  27750. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27751. */
  27752. set stiffness(value: number);
  27753. /**
  27754. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27755. */
  27756. get velocityIterations(): number;
  27757. /**
  27758. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27759. */
  27760. set velocityIterations(value: number);
  27761. /**
  27762. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27763. */
  27764. get positionIterations(): number;
  27765. /**
  27766. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27767. */
  27768. set positionIterations(value: number);
  27769. /**
  27770. * The unique id of the physics imposter
  27771. * set by the physics engine when adding this impostor to the array
  27772. */
  27773. uniqueId: number;
  27774. /**
  27775. * @hidden
  27776. */
  27777. soft: boolean;
  27778. /**
  27779. * @hidden
  27780. */
  27781. segments: number;
  27782. private _joints;
  27783. /**
  27784. * Initializes the physics imposter
  27785. * @param object The physics-enabled object used as the physics imposter
  27786. * @param type The type of the physics imposter
  27787. * @param _options The options for the physics imposter
  27788. * @param _scene The Babylon scene
  27789. */
  27790. constructor(
  27791. /**
  27792. * The physics-enabled object used as the physics imposter
  27793. */
  27794. object: IPhysicsEnabledObject,
  27795. /**
  27796. * The type of the physics imposter
  27797. */
  27798. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27799. /**
  27800. * This function will completly initialize this impostor.
  27801. * It will create a new body - but only if this mesh has no parent.
  27802. * If it has, this impostor will not be used other than to define the impostor
  27803. * of the child mesh.
  27804. * @hidden
  27805. */
  27806. _init(): void;
  27807. private _getPhysicsParent;
  27808. /**
  27809. * Should a new body be generated.
  27810. * @returns boolean specifying if body initialization is required
  27811. */
  27812. isBodyInitRequired(): boolean;
  27813. /**
  27814. * Sets the updated scaling
  27815. * @param updated Specifies if the scaling is updated
  27816. */
  27817. setScalingUpdated(): void;
  27818. /**
  27819. * Force a regeneration of this or the parent's impostor's body.
  27820. * Use under cautious - This will remove all joints already implemented.
  27821. */
  27822. forceUpdate(): void;
  27823. /**
  27824. * Gets the body that holds this impostor. Either its own, or its parent.
  27825. */
  27826. get physicsBody(): any;
  27827. /**
  27828. * Get the parent of the physics imposter
  27829. * @returns Physics imposter or null
  27830. */
  27831. get parent(): Nullable<PhysicsImpostor>;
  27832. /**
  27833. * Sets the parent of the physics imposter
  27834. */
  27835. set parent(value: Nullable<PhysicsImpostor>);
  27836. /**
  27837. * Set the physics body. Used mainly by the physics engine/plugin
  27838. */
  27839. set physicsBody(physicsBody: any);
  27840. /**
  27841. * Resets the update flags
  27842. */
  27843. resetUpdateFlags(): void;
  27844. /**
  27845. * Gets the object extend size
  27846. * @returns the object extend size
  27847. */
  27848. getObjectExtendSize(): Vector3;
  27849. /**
  27850. * Gets the object center
  27851. * @returns The object center
  27852. */
  27853. getObjectCenter(): Vector3;
  27854. /**
  27855. * Get a specific parameter from the options parameters
  27856. * @param paramName The object parameter name
  27857. * @returns The object parameter
  27858. */
  27859. getParam(paramName: string): any;
  27860. /**
  27861. * Sets a specific parameter in the options given to the physics plugin
  27862. * @param paramName The parameter name
  27863. * @param value The value of the parameter
  27864. */
  27865. setParam(paramName: string, value: number): void;
  27866. /**
  27867. * Specifically change the body's mass option. Won't recreate the physics body object
  27868. * @param mass The mass of the physics imposter
  27869. */
  27870. setMass(mass: number): void;
  27871. /**
  27872. * Gets the linear velocity
  27873. * @returns linear velocity or null
  27874. */
  27875. getLinearVelocity(): Nullable<Vector3>;
  27876. /**
  27877. * Sets the linear velocity
  27878. * @param velocity linear velocity or null
  27879. */
  27880. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27881. /**
  27882. * Gets the angular velocity
  27883. * @returns angular velocity or null
  27884. */
  27885. getAngularVelocity(): Nullable<Vector3>;
  27886. /**
  27887. * Sets the angular velocity
  27888. * @param velocity The velocity or null
  27889. */
  27890. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27891. /**
  27892. * Execute a function with the physics plugin native code
  27893. * Provide a function the will have two variables - the world object and the physics body object
  27894. * @param func The function to execute with the physics plugin native code
  27895. */
  27896. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27897. /**
  27898. * Register a function that will be executed before the physics world is stepping forward
  27899. * @param func The function to execute before the physics world is stepped forward
  27900. */
  27901. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27902. /**
  27903. * Unregister a function that will be executed before the physics world is stepping forward
  27904. * @param func The function to execute before the physics world is stepped forward
  27905. */
  27906. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27907. /**
  27908. * Register a function that will be executed after the physics step
  27909. * @param func The function to execute after physics step
  27910. */
  27911. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27912. /**
  27913. * Unregisters a function that will be executed after the physics step
  27914. * @param func The function to execute after physics step
  27915. */
  27916. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27917. /**
  27918. * register a function that will be executed when this impostor collides against a different body
  27919. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27920. * @param func Callback that is executed on collision
  27921. */
  27922. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27923. /**
  27924. * Unregisters the physics imposter on contact
  27925. * @param collideAgainst The physics object to collide against
  27926. * @param func Callback to execute on collision
  27927. */
  27928. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27929. private _tmpQuat;
  27930. private _tmpQuat2;
  27931. /**
  27932. * Get the parent rotation
  27933. * @returns The parent rotation
  27934. */
  27935. getParentsRotation(): Quaternion;
  27936. /**
  27937. * this function is executed by the physics engine.
  27938. */
  27939. beforeStep: () => void;
  27940. /**
  27941. * this function is executed by the physics engine
  27942. */
  27943. afterStep: () => void;
  27944. /**
  27945. * Legacy collision detection event support
  27946. */
  27947. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27948. /**
  27949. * event and body object due to cannon's event-based architecture.
  27950. */
  27951. onCollide: (e: {
  27952. body: any;
  27953. }) => void;
  27954. /**
  27955. * Apply a force
  27956. * @param force The force to apply
  27957. * @param contactPoint The contact point for the force
  27958. * @returns The physics imposter
  27959. */
  27960. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27961. /**
  27962. * Apply an impulse
  27963. * @param force The impulse force
  27964. * @param contactPoint The contact point for the impulse force
  27965. * @returns The physics imposter
  27966. */
  27967. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27968. /**
  27969. * A help function to create a joint
  27970. * @param otherImpostor A physics imposter used to create a joint
  27971. * @param jointType The type of joint
  27972. * @param jointData The data for the joint
  27973. * @returns The physics imposter
  27974. */
  27975. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27976. /**
  27977. * Add a joint to this impostor with a different impostor
  27978. * @param otherImpostor A physics imposter used to add a joint
  27979. * @param joint The joint to add
  27980. * @returns The physics imposter
  27981. */
  27982. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27983. /**
  27984. * Add an anchor to a cloth impostor
  27985. * @param otherImpostor rigid impostor to anchor to
  27986. * @param width ratio across width from 0 to 1
  27987. * @param height ratio up height from 0 to 1
  27988. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27989. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27990. * @returns impostor the soft imposter
  27991. */
  27992. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27993. /**
  27994. * Add a hook to a rope impostor
  27995. * @param otherImpostor rigid impostor to anchor to
  27996. * @param length ratio across rope from 0 to 1
  27997. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27998. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27999. * @returns impostor the rope imposter
  28000. */
  28001. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28002. /**
  28003. * Will keep this body still, in a sleep mode.
  28004. * @returns the physics imposter
  28005. */
  28006. sleep(): PhysicsImpostor;
  28007. /**
  28008. * Wake the body up.
  28009. * @returns The physics imposter
  28010. */
  28011. wakeUp(): PhysicsImpostor;
  28012. /**
  28013. * Clones the physics imposter
  28014. * @param newObject The physics imposter clones to this physics-enabled object
  28015. * @returns A nullable physics imposter
  28016. */
  28017. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28018. /**
  28019. * Disposes the physics imposter
  28020. */
  28021. dispose(): void;
  28022. /**
  28023. * Sets the delta position
  28024. * @param position The delta position amount
  28025. */
  28026. setDeltaPosition(position: Vector3): void;
  28027. /**
  28028. * Sets the delta rotation
  28029. * @param rotation The delta rotation amount
  28030. */
  28031. setDeltaRotation(rotation: Quaternion): void;
  28032. /**
  28033. * Gets the box size of the physics imposter and stores the result in the input parameter
  28034. * @param result Stores the box size
  28035. * @returns The physics imposter
  28036. */
  28037. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28038. /**
  28039. * Gets the radius of the physics imposter
  28040. * @returns Radius of the physics imposter
  28041. */
  28042. getRadius(): number;
  28043. /**
  28044. * Sync a bone with this impostor
  28045. * @param bone The bone to sync to the impostor.
  28046. * @param boneMesh The mesh that the bone is influencing.
  28047. * @param jointPivot The pivot of the joint / bone in local space.
  28048. * @param distToJoint Optional distance from the impostor to the joint.
  28049. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28050. */
  28051. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28052. /**
  28053. * Sync impostor to a bone
  28054. * @param bone The bone that the impostor will be synced to.
  28055. * @param boneMesh The mesh that the bone is influencing.
  28056. * @param jointPivot The pivot of the joint / bone in local space.
  28057. * @param distToJoint Optional distance from the impostor to the joint.
  28058. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28059. * @param boneAxis Optional vector3 axis the bone is aligned with
  28060. */
  28061. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28062. /**
  28063. * No-Imposter type
  28064. */
  28065. static NoImpostor: number;
  28066. /**
  28067. * Sphere-Imposter type
  28068. */
  28069. static SphereImpostor: number;
  28070. /**
  28071. * Box-Imposter type
  28072. */
  28073. static BoxImpostor: number;
  28074. /**
  28075. * Plane-Imposter type
  28076. */
  28077. static PlaneImpostor: number;
  28078. /**
  28079. * Mesh-imposter type
  28080. */
  28081. static MeshImpostor: number;
  28082. /**
  28083. * Capsule-Impostor type (Ammo.js plugin only)
  28084. */
  28085. static CapsuleImpostor: number;
  28086. /**
  28087. * Cylinder-Imposter type
  28088. */
  28089. static CylinderImpostor: number;
  28090. /**
  28091. * Particle-Imposter type
  28092. */
  28093. static ParticleImpostor: number;
  28094. /**
  28095. * Heightmap-Imposter type
  28096. */
  28097. static HeightmapImpostor: number;
  28098. /**
  28099. * ConvexHull-Impostor type (Ammo.js plugin only)
  28100. */
  28101. static ConvexHullImpostor: number;
  28102. /**
  28103. * Custom-Imposter type (Ammo.js plugin only)
  28104. */
  28105. static CustomImpostor: number;
  28106. /**
  28107. * Rope-Imposter type
  28108. */
  28109. static RopeImpostor: number;
  28110. /**
  28111. * Cloth-Imposter type
  28112. */
  28113. static ClothImpostor: number;
  28114. /**
  28115. * Softbody-Imposter type
  28116. */
  28117. static SoftbodyImpostor: number;
  28118. }
  28119. }
  28120. declare module "babylonjs/Meshes/mesh" {
  28121. import { Observable } from "babylonjs/Misc/observable";
  28122. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28123. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28124. import { Camera } from "babylonjs/Cameras/camera";
  28125. import { Scene } from "babylonjs/scene";
  28126. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28127. import { Color4 } from "babylonjs/Maths/math.color";
  28128. import { Engine } from "babylonjs/Engines/engine";
  28129. import { Node } from "babylonjs/node";
  28130. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28131. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28132. import { Buffer } from "babylonjs/Meshes/buffer";
  28133. import { Geometry } from "babylonjs/Meshes/geometry";
  28134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28135. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28136. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  28137. import { Effect } from "babylonjs/Materials/effect";
  28138. import { Material } from "babylonjs/Materials/material";
  28139. import { Skeleton } from "babylonjs/Bones/skeleton";
  28140. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  28141. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  28142. import { Path3D } from "babylonjs/Maths/math.path";
  28143. import { Plane } from "babylonjs/Maths/math.plane";
  28144. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28145. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28146. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28147. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28148. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28149. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28150. /**
  28151. * @hidden
  28152. **/
  28153. export class _CreationDataStorage {
  28154. closePath?: boolean;
  28155. closeArray?: boolean;
  28156. idx: number[];
  28157. dashSize: number;
  28158. gapSize: number;
  28159. path3D: Path3D;
  28160. pathArray: Vector3[][];
  28161. arc: number;
  28162. radius: number;
  28163. cap: number;
  28164. tessellation: number;
  28165. }
  28166. /**
  28167. * @hidden
  28168. **/
  28169. class _InstanceDataStorage {
  28170. visibleInstances: any;
  28171. batchCache: _InstancesBatch;
  28172. instancesBufferSize: number;
  28173. instancesBuffer: Nullable<Buffer>;
  28174. instancesData: Float32Array;
  28175. overridenInstanceCount: number;
  28176. isFrozen: boolean;
  28177. previousBatch: Nullable<_InstancesBatch>;
  28178. hardwareInstancedRendering: boolean;
  28179. sideOrientation: number;
  28180. manualUpdate: boolean;
  28181. }
  28182. /**
  28183. * @hidden
  28184. **/
  28185. export class _InstancesBatch {
  28186. mustReturn: boolean;
  28187. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  28188. renderSelf: boolean[];
  28189. hardwareInstancedRendering: boolean[];
  28190. }
  28191. /**
  28192. * @hidden
  28193. **/
  28194. class _ThinInstanceDataStorage {
  28195. instancesCount: number;
  28196. matrixBuffer: Nullable<Buffer>;
  28197. matrixBufferSize: number;
  28198. matrixData: Nullable<Float32Array>;
  28199. boundingVectors: Array<Vector3>;
  28200. }
  28201. /**
  28202. * Class used to represent renderable models
  28203. */
  28204. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28205. /**
  28206. * Mesh side orientation : usually the external or front surface
  28207. */
  28208. static readonly FRONTSIDE: number;
  28209. /**
  28210. * Mesh side orientation : usually the internal or back surface
  28211. */
  28212. static readonly BACKSIDE: number;
  28213. /**
  28214. * Mesh side orientation : both internal and external or front and back surfaces
  28215. */
  28216. static readonly DOUBLESIDE: number;
  28217. /**
  28218. * Mesh side orientation : by default, `FRONTSIDE`
  28219. */
  28220. static readonly DEFAULTSIDE: number;
  28221. /**
  28222. * Mesh cap setting : no cap
  28223. */
  28224. static readonly NO_CAP: number;
  28225. /**
  28226. * Mesh cap setting : one cap at the beginning of the mesh
  28227. */
  28228. static readonly CAP_START: number;
  28229. /**
  28230. * Mesh cap setting : one cap at the end of the mesh
  28231. */
  28232. static readonly CAP_END: number;
  28233. /**
  28234. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28235. */
  28236. static readonly CAP_ALL: number;
  28237. /**
  28238. * Mesh pattern setting : no flip or rotate
  28239. */
  28240. static readonly NO_FLIP: number;
  28241. /**
  28242. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28243. */
  28244. static readonly FLIP_TILE: number;
  28245. /**
  28246. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28247. */
  28248. static readonly ROTATE_TILE: number;
  28249. /**
  28250. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28251. */
  28252. static readonly FLIP_ROW: number;
  28253. /**
  28254. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28255. */
  28256. static readonly ROTATE_ROW: number;
  28257. /**
  28258. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28259. */
  28260. static readonly FLIP_N_ROTATE_TILE: number;
  28261. /**
  28262. * Mesh pattern setting : rotate pattern and rotate
  28263. */
  28264. static readonly FLIP_N_ROTATE_ROW: number;
  28265. /**
  28266. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28267. */
  28268. static readonly CENTER: number;
  28269. /**
  28270. * Mesh tile positioning : part tiles on left
  28271. */
  28272. static readonly LEFT: number;
  28273. /**
  28274. * Mesh tile positioning : part tiles on right
  28275. */
  28276. static readonly RIGHT: number;
  28277. /**
  28278. * Mesh tile positioning : part tiles on top
  28279. */
  28280. static readonly TOP: number;
  28281. /**
  28282. * Mesh tile positioning : part tiles on bottom
  28283. */
  28284. static readonly BOTTOM: number;
  28285. /**
  28286. * Gets the default side orientation.
  28287. * @param orientation the orientation to value to attempt to get
  28288. * @returns the default orientation
  28289. * @hidden
  28290. */
  28291. static _GetDefaultSideOrientation(orientation?: number): number;
  28292. private _internalMeshDataInfo;
  28293. /**
  28294. * An event triggered before rendering the mesh
  28295. */
  28296. get onBeforeRenderObservable(): Observable<Mesh>;
  28297. /**
  28298. * An event triggered before binding the mesh
  28299. */
  28300. get onBeforeBindObservable(): Observable<Mesh>;
  28301. /**
  28302. * An event triggered after rendering the mesh
  28303. */
  28304. get onAfterRenderObservable(): Observable<Mesh>;
  28305. /**
  28306. * An event triggered before drawing the mesh
  28307. */
  28308. get onBeforeDrawObservable(): Observable<Mesh>;
  28309. private _onBeforeDrawObserver;
  28310. /**
  28311. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28312. */
  28313. set onBeforeDraw(callback: () => void);
  28314. get hasInstances(): boolean;
  28315. get hasThinInstances(): boolean;
  28316. /**
  28317. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28318. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28319. */
  28320. delayLoadState: number;
  28321. /**
  28322. * Gets the list of instances created from this mesh
  28323. * it is not supposed to be modified manually.
  28324. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28325. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  28326. */
  28327. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  28328. /**
  28329. * Gets the file containing delay loading data for this mesh
  28330. */
  28331. delayLoadingFile: string;
  28332. /** @hidden */
  28333. _binaryInfo: any;
  28334. /**
  28335. * User defined function used to change how LOD level selection is done
  28336. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28337. */
  28338. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28339. /**
  28340. * Gets or sets the morph target manager
  28341. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28342. */
  28343. get morphTargetManager(): Nullable<MorphTargetManager>;
  28344. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28345. /** @hidden */
  28346. _creationDataStorage: Nullable<_CreationDataStorage>;
  28347. /** @hidden */
  28348. _geometry: Nullable<Geometry>;
  28349. /** @hidden */
  28350. _delayInfo: Array<string>;
  28351. /** @hidden */
  28352. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28353. /** @hidden */
  28354. _instanceDataStorage: _InstanceDataStorage;
  28355. /** @hidden */
  28356. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28357. private _effectiveMaterial;
  28358. /** @hidden */
  28359. _shouldGenerateFlatShading: boolean;
  28360. /** @hidden */
  28361. _originalBuilderSideOrientation: number;
  28362. /**
  28363. * Use this property to change the original side orientation defined at construction time
  28364. */
  28365. overrideMaterialSideOrientation: Nullable<number>;
  28366. /**
  28367. * Gets the source mesh (the one used to clone this one from)
  28368. */
  28369. get source(): Nullable<Mesh>;
  28370. /**
  28371. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28372. */
  28373. get isUnIndexed(): boolean;
  28374. set isUnIndexed(value: boolean);
  28375. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28376. get worldMatrixInstancedBuffer(): Float32Array;
  28377. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28378. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28379. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28380. /**
  28381. * @constructor
  28382. * @param name The value used by scene.getMeshByName() to do a lookup.
  28383. * @param scene The scene to add this mesh to.
  28384. * @param parent The parent of this mesh, if it has one
  28385. * @param source An optional Mesh from which geometry is shared, cloned.
  28386. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28387. * When false, achieved by calling a clone(), also passing False.
  28388. * This will make creation of children, recursive.
  28389. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28390. */
  28391. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28392. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28393. doNotInstantiate: boolean;
  28394. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28395. /**
  28396. * Gets the class name
  28397. * @returns the string "Mesh".
  28398. */
  28399. getClassName(): string;
  28400. /** @hidden */
  28401. get _isMesh(): boolean;
  28402. /**
  28403. * Returns a description of this mesh
  28404. * @param fullDetails define if full details about this mesh must be used
  28405. * @returns a descriptive string representing this mesh
  28406. */
  28407. toString(fullDetails?: boolean): string;
  28408. /** @hidden */
  28409. _unBindEffect(): void;
  28410. /**
  28411. * Gets a boolean indicating if this mesh has LOD
  28412. */
  28413. get hasLODLevels(): boolean;
  28414. /**
  28415. * Gets the list of MeshLODLevel associated with the current mesh
  28416. * @returns an array of MeshLODLevel
  28417. */
  28418. getLODLevels(): MeshLODLevel[];
  28419. private _sortLODLevels;
  28420. /**
  28421. * Add a mesh as LOD level triggered at the given distance.
  28422. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28423. * @param distance The distance from the center of the object to show this level
  28424. * @param mesh The mesh to be added as LOD level (can be null)
  28425. * @return This mesh (for chaining)
  28426. */
  28427. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28428. /**
  28429. * Returns the LOD level mesh at the passed distance or null if not found.
  28430. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28431. * @param distance The distance from the center of the object to show this level
  28432. * @returns a Mesh or `null`
  28433. */
  28434. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28435. /**
  28436. * Remove a mesh from the LOD array
  28437. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28438. * @param mesh defines the mesh to be removed
  28439. * @return This mesh (for chaining)
  28440. */
  28441. removeLODLevel(mesh: Mesh): Mesh;
  28442. /**
  28443. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28444. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28445. * @param camera defines the camera to use to compute distance
  28446. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28447. * @return This mesh (for chaining)
  28448. */
  28449. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28450. /**
  28451. * Gets the mesh internal Geometry object
  28452. */
  28453. get geometry(): Nullable<Geometry>;
  28454. /**
  28455. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28456. * @returns the total number of vertices
  28457. */
  28458. getTotalVertices(): number;
  28459. /**
  28460. * Returns the content of an associated vertex buffer
  28461. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28462. * - VertexBuffer.PositionKind
  28463. * - VertexBuffer.UVKind
  28464. * - VertexBuffer.UV2Kind
  28465. * - VertexBuffer.UV3Kind
  28466. * - VertexBuffer.UV4Kind
  28467. * - VertexBuffer.UV5Kind
  28468. * - VertexBuffer.UV6Kind
  28469. * - VertexBuffer.ColorKind
  28470. * - VertexBuffer.MatricesIndicesKind
  28471. * - VertexBuffer.MatricesIndicesExtraKind
  28472. * - VertexBuffer.MatricesWeightsKind
  28473. * - VertexBuffer.MatricesWeightsExtraKind
  28474. * @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
  28475. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28476. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28477. */
  28478. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28479. /**
  28480. * Returns the mesh VertexBuffer object from the requested `kind`
  28481. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28482. * - VertexBuffer.PositionKind
  28483. * - VertexBuffer.NormalKind
  28484. * - VertexBuffer.UVKind
  28485. * - VertexBuffer.UV2Kind
  28486. * - VertexBuffer.UV3Kind
  28487. * - VertexBuffer.UV4Kind
  28488. * - VertexBuffer.UV5Kind
  28489. * - VertexBuffer.UV6Kind
  28490. * - VertexBuffer.ColorKind
  28491. * - VertexBuffer.MatricesIndicesKind
  28492. * - VertexBuffer.MatricesIndicesExtraKind
  28493. * - VertexBuffer.MatricesWeightsKind
  28494. * - VertexBuffer.MatricesWeightsExtraKind
  28495. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28496. */
  28497. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28498. /**
  28499. * Tests if a specific vertex buffer is associated with this mesh
  28500. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28501. * - VertexBuffer.PositionKind
  28502. * - VertexBuffer.NormalKind
  28503. * - VertexBuffer.UVKind
  28504. * - VertexBuffer.UV2Kind
  28505. * - VertexBuffer.UV3Kind
  28506. * - VertexBuffer.UV4Kind
  28507. * - VertexBuffer.UV5Kind
  28508. * - VertexBuffer.UV6Kind
  28509. * - VertexBuffer.ColorKind
  28510. * - VertexBuffer.MatricesIndicesKind
  28511. * - VertexBuffer.MatricesIndicesExtraKind
  28512. * - VertexBuffer.MatricesWeightsKind
  28513. * - VertexBuffer.MatricesWeightsExtraKind
  28514. * @returns a boolean
  28515. */
  28516. isVerticesDataPresent(kind: string): boolean;
  28517. /**
  28518. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28519. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28520. * - VertexBuffer.PositionKind
  28521. * - VertexBuffer.UVKind
  28522. * - VertexBuffer.UV2Kind
  28523. * - VertexBuffer.UV3Kind
  28524. * - VertexBuffer.UV4Kind
  28525. * - VertexBuffer.UV5Kind
  28526. * - VertexBuffer.UV6Kind
  28527. * - VertexBuffer.ColorKind
  28528. * - VertexBuffer.MatricesIndicesKind
  28529. * - VertexBuffer.MatricesIndicesExtraKind
  28530. * - VertexBuffer.MatricesWeightsKind
  28531. * - VertexBuffer.MatricesWeightsExtraKind
  28532. * @returns a boolean
  28533. */
  28534. isVertexBufferUpdatable(kind: string): boolean;
  28535. /**
  28536. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28537. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28538. * - VertexBuffer.PositionKind
  28539. * - VertexBuffer.NormalKind
  28540. * - VertexBuffer.UVKind
  28541. * - VertexBuffer.UV2Kind
  28542. * - VertexBuffer.UV3Kind
  28543. * - VertexBuffer.UV4Kind
  28544. * - VertexBuffer.UV5Kind
  28545. * - VertexBuffer.UV6Kind
  28546. * - VertexBuffer.ColorKind
  28547. * - VertexBuffer.MatricesIndicesKind
  28548. * - VertexBuffer.MatricesIndicesExtraKind
  28549. * - VertexBuffer.MatricesWeightsKind
  28550. * - VertexBuffer.MatricesWeightsExtraKind
  28551. * @returns an array of strings
  28552. */
  28553. getVerticesDataKinds(): string[];
  28554. /**
  28555. * Returns a positive integer : the total number of indices in this mesh geometry.
  28556. * @returns the numner of indices or zero if the mesh has no geometry.
  28557. */
  28558. getTotalIndices(): number;
  28559. /**
  28560. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28561. * @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.
  28562. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28563. * @returns the indices array or an empty array if the mesh has no geometry
  28564. */
  28565. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28566. get isBlocked(): boolean;
  28567. /**
  28568. * Determine if the current mesh is ready to be rendered
  28569. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28570. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28571. * @returns true if all associated assets are ready (material, textures, shaders)
  28572. */
  28573. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28574. /**
  28575. * 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.
  28576. */
  28577. get areNormalsFrozen(): boolean;
  28578. /**
  28579. * 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.
  28580. * @returns the current mesh
  28581. */
  28582. freezeNormals(): Mesh;
  28583. /**
  28584. * 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
  28585. * @returns the current mesh
  28586. */
  28587. unfreezeNormals(): Mesh;
  28588. /**
  28589. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28590. */
  28591. set overridenInstanceCount(count: number);
  28592. /** @hidden */
  28593. _preActivate(): Mesh;
  28594. /** @hidden */
  28595. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28596. /** @hidden */
  28597. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28598. protected _afterComputeWorldMatrix(): void;
  28599. /** @hidden */
  28600. _postActivate(): void;
  28601. /**
  28602. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28603. * This means the mesh underlying bounding box and sphere are recomputed.
  28604. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28605. * @returns the current mesh
  28606. */
  28607. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28608. /** @hidden */
  28609. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28610. /**
  28611. * This function will subdivide the mesh into multiple submeshes
  28612. * @param count defines the expected number of submeshes
  28613. */
  28614. subdivide(count: number): void;
  28615. /**
  28616. * Copy a FloatArray into a specific associated vertex buffer
  28617. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28618. * - VertexBuffer.PositionKind
  28619. * - VertexBuffer.UVKind
  28620. * - VertexBuffer.UV2Kind
  28621. * - VertexBuffer.UV3Kind
  28622. * - VertexBuffer.UV4Kind
  28623. * - VertexBuffer.UV5Kind
  28624. * - VertexBuffer.UV6Kind
  28625. * - VertexBuffer.ColorKind
  28626. * - VertexBuffer.MatricesIndicesKind
  28627. * - VertexBuffer.MatricesIndicesExtraKind
  28628. * - VertexBuffer.MatricesWeightsKind
  28629. * - VertexBuffer.MatricesWeightsExtraKind
  28630. * @param data defines the data source
  28631. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28632. * @param stride defines the data stride size (can be null)
  28633. * @returns the current mesh
  28634. */
  28635. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28636. /**
  28637. * Delete a vertex buffer associated with this mesh
  28638. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28639. * - VertexBuffer.PositionKind
  28640. * - VertexBuffer.UVKind
  28641. * - VertexBuffer.UV2Kind
  28642. * - VertexBuffer.UV3Kind
  28643. * - VertexBuffer.UV4Kind
  28644. * - VertexBuffer.UV5Kind
  28645. * - VertexBuffer.UV6Kind
  28646. * - VertexBuffer.ColorKind
  28647. * - VertexBuffer.MatricesIndicesKind
  28648. * - VertexBuffer.MatricesIndicesExtraKind
  28649. * - VertexBuffer.MatricesWeightsKind
  28650. * - VertexBuffer.MatricesWeightsExtraKind
  28651. */
  28652. removeVerticesData(kind: string): void;
  28653. /**
  28654. * Flags an associated vertex buffer as updatable
  28655. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28656. * - VertexBuffer.PositionKind
  28657. * - VertexBuffer.UVKind
  28658. * - VertexBuffer.UV2Kind
  28659. * - VertexBuffer.UV3Kind
  28660. * - VertexBuffer.UV4Kind
  28661. * - VertexBuffer.UV5Kind
  28662. * - VertexBuffer.UV6Kind
  28663. * - VertexBuffer.ColorKind
  28664. * - VertexBuffer.MatricesIndicesKind
  28665. * - VertexBuffer.MatricesIndicesExtraKind
  28666. * - VertexBuffer.MatricesWeightsKind
  28667. * - VertexBuffer.MatricesWeightsExtraKind
  28668. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28669. */
  28670. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28671. /**
  28672. * Sets the mesh global Vertex Buffer
  28673. * @param buffer defines the buffer to use
  28674. * @returns the current mesh
  28675. */
  28676. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28677. /**
  28678. * Update a specific associated vertex buffer
  28679. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28680. * - VertexBuffer.PositionKind
  28681. * - VertexBuffer.UVKind
  28682. * - VertexBuffer.UV2Kind
  28683. * - VertexBuffer.UV3Kind
  28684. * - VertexBuffer.UV4Kind
  28685. * - VertexBuffer.UV5Kind
  28686. * - VertexBuffer.UV6Kind
  28687. * - VertexBuffer.ColorKind
  28688. * - VertexBuffer.MatricesIndicesKind
  28689. * - VertexBuffer.MatricesIndicesExtraKind
  28690. * - VertexBuffer.MatricesWeightsKind
  28691. * - VertexBuffer.MatricesWeightsExtraKind
  28692. * @param data defines the data source
  28693. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28694. * @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)
  28695. * @returns the current mesh
  28696. */
  28697. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28698. /**
  28699. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28700. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28701. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28702. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28703. * @returns the current mesh
  28704. */
  28705. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28706. /**
  28707. * Creates a un-shared specific occurence of the geometry for the mesh.
  28708. * @returns the current mesh
  28709. */
  28710. makeGeometryUnique(): Mesh;
  28711. /**
  28712. * Set the index buffer of this mesh
  28713. * @param indices defines the source data
  28714. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28715. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28716. * @returns the current mesh
  28717. */
  28718. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28719. /**
  28720. * Update the current index buffer
  28721. * @param indices defines the source data
  28722. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28723. * @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)
  28724. * @returns the current mesh
  28725. */
  28726. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28727. /**
  28728. * Invert the geometry to move from a right handed system to a left handed one.
  28729. * @returns the current mesh
  28730. */
  28731. toLeftHanded(): Mesh;
  28732. /** @hidden */
  28733. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28734. /** @hidden */
  28735. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28736. /**
  28737. * Registers for this mesh a javascript function called just before the rendering process
  28738. * @param func defines the function to call before rendering this mesh
  28739. * @returns the current mesh
  28740. */
  28741. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28742. /**
  28743. * Disposes a previously registered javascript function called before the rendering
  28744. * @param func defines the function to remove
  28745. * @returns the current mesh
  28746. */
  28747. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28748. /**
  28749. * Registers for this mesh a javascript function called just after the rendering is complete
  28750. * @param func defines the function to call after rendering this mesh
  28751. * @returns the current mesh
  28752. */
  28753. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28754. /**
  28755. * Disposes a previously registered javascript function called after the rendering.
  28756. * @param func defines the function to remove
  28757. * @returns the current mesh
  28758. */
  28759. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28760. /** @hidden */
  28761. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28762. /** @hidden */
  28763. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28764. /** @hidden */
  28765. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28766. /** @hidden */
  28767. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28768. /** @hidden */
  28769. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28770. /** @hidden */
  28771. _rebuild(): void;
  28772. /** @hidden */
  28773. _freeze(): void;
  28774. /** @hidden */
  28775. _unFreeze(): void;
  28776. /**
  28777. * 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
  28778. * @param subMesh defines the subMesh to render
  28779. * @param enableAlphaMode defines if alpha mode can be changed
  28780. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28781. * @returns the current mesh
  28782. */
  28783. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28784. private _onBeforeDraw;
  28785. /**
  28786. * Renormalize the mesh and patch it up if there are no weights
  28787. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28788. * However in the case of zero weights then we set just a single influence to 1.
  28789. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28790. */
  28791. cleanMatrixWeights(): void;
  28792. private normalizeSkinFourWeights;
  28793. private normalizeSkinWeightsAndExtra;
  28794. /**
  28795. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28796. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28797. * the user know there was an issue with importing the mesh
  28798. * @returns a validation object with skinned, valid and report string
  28799. */
  28800. validateSkinning(): {
  28801. skinned: boolean;
  28802. valid: boolean;
  28803. report: string;
  28804. };
  28805. /** @hidden */
  28806. _checkDelayState(): Mesh;
  28807. private _queueLoad;
  28808. /**
  28809. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28810. * A mesh is in the frustum if its bounding box intersects the frustum
  28811. * @param frustumPlanes defines the frustum to test
  28812. * @returns true if the mesh is in the frustum planes
  28813. */
  28814. isInFrustum(frustumPlanes: Plane[]): boolean;
  28815. /**
  28816. * Sets the mesh material by the material or multiMaterial `id` property
  28817. * @param id is a string identifying the material or the multiMaterial
  28818. * @returns the current mesh
  28819. */
  28820. setMaterialByID(id: string): Mesh;
  28821. /**
  28822. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28823. * @returns an array of IAnimatable
  28824. */
  28825. getAnimatables(): IAnimatable[];
  28826. /**
  28827. * Modifies the mesh geometry according to the passed transformation matrix.
  28828. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28829. * The mesh normals are modified using the same transformation.
  28830. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28831. * @param transform defines the transform matrix to use
  28832. * @see http://doc.babylonjs.com/resources/baking_transformations
  28833. * @returns the current mesh
  28834. */
  28835. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28836. /**
  28837. * Modifies the mesh geometry according to its own current World Matrix.
  28838. * The mesh World Matrix is then reset.
  28839. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28840. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28841. * @see http://doc.babylonjs.com/resources/baking_transformations
  28842. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28843. * @returns the current mesh
  28844. */
  28845. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28846. /** @hidden */
  28847. get _positions(): Nullable<Vector3[]>;
  28848. /** @hidden */
  28849. _resetPointsArrayCache(): Mesh;
  28850. /** @hidden */
  28851. _generatePointsArray(): boolean;
  28852. /**
  28853. * Returns a new Mesh object generated from the current mesh properties.
  28854. * This method must not get confused with createInstance()
  28855. * @param name is a string, the name given to the new mesh
  28856. * @param newParent can be any Node object (default `null`)
  28857. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28858. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28859. * @returns a new mesh
  28860. */
  28861. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28862. /**
  28863. * Releases resources associated with this mesh.
  28864. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28865. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28866. */
  28867. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28868. /** @hidden */
  28869. _disposeInstanceSpecificData(): void;
  28870. /** @hidden */
  28871. _disposeThinInstanceSpecificData(): void;
  28872. /**
  28873. * Modifies the mesh geometry according to a displacement map.
  28874. * 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.
  28875. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28876. * @param url is a string, the URL from the image file is to be downloaded.
  28877. * @param minHeight is the lower limit of the displacement.
  28878. * @param maxHeight is the upper limit of the displacement.
  28879. * @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.
  28880. * @param uvOffset is an optional vector2 used to offset UV.
  28881. * @param uvScale is an optional vector2 used to scale UV.
  28882. * @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.
  28883. * @returns the Mesh.
  28884. */
  28885. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28886. /**
  28887. * Modifies the mesh geometry according to a displacementMap buffer.
  28888. * 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.
  28889. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28890. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28891. * @param heightMapWidth is the width of the buffer image.
  28892. * @param heightMapHeight is the height of the buffer image.
  28893. * @param minHeight is the lower limit of the displacement.
  28894. * @param maxHeight is the upper limit of the displacement.
  28895. * @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.
  28896. * @param uvOffset is an optional vector2 used to offset UV.
  28897. * @param uvScale is an optional vector2 used to scale UV.
  28898. * @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.
  28899. * @returns the Mesh.
  28900. */
  28901. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28902. /**
  28903. * Modify the mesh to get a flat shading rendering.
  28904. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28905. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28906. * @returns current mesh
  28907. */
  28908. convertToFlatShadedMesh(): Mesh;
  28909. /**
  28910. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28911. * In other words, more vertices, no more indices and a single bigger VBO.
  28912. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28913. * @returns current mesh
  28914. */
  28915. convertToUnIndexedMesh(): Mesh;
  28916. /**
  28917. * Inverses facet orientations.
  28918. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28919. * @param flipNormals will also inverts the normals
  28920. * @returns current mesh
  28921. */
  28922. flipFaces(flipNormals?: boolean): Mesh;
  28923. /**
  28924. * Increase the number of facets and hence vertices in a mesh
  28925. * Vertex normals are interpolated from existing vertex normals
  28926. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28927. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28928. */
  28929. increaseVertices(numberPerEdge: number): void;
  28930. /**
  28931. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28932. * This will undo any application of covertToFlatShadedMesh
  28933. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28934. */
  28935. forceSharedVertices(): void;
  28936. /** @hidden */
  28937. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28938. /** @hidden */
  28939. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28940. /**
  28941. * Creates a new InstancedMesh object from the mesh model.
  28942. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  28943. * @param name defines the name of the new instance
  28944. * @returns a new InstancedMesh
  28945. */
  28946. createInstance(name: string): InstancedMesh;
  28947. /**
  28948. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28949. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28950. * @returns the current mesh
  28951. */
  28952. synchronizeInstances(): Mesh;
  28953. /**
  28954. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28955. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28956. * This should be used together with the simplification to avoid disappearing triangles.
  28957. * @param successCallback an optional success callback to be called after the optimization finished.
  28958. * @returns the current mesh
  28959. */
  28960. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28961. /**
  28962. * Serialize current mesh
  28963. * @param serializationObject defines the object which will receive the serialization data
  28964. */
  28965. serialize(serializationObject: any): void;
  28966. /** @hidden */
  28967. _syncGeometryWithMorphTargetManager(): void;
  28968. /** @hidden */
  28969. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28970. /**
  28971. * Returns a new Mesh object parsed from the source provided.
  28972. * @param parsedMesh is the source
  28973. * @param scene defines the hosting scene
  28974. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28975. * @returns a new Mesh
  28976. */
  28977. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28978. /**
  28979. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28980. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28981. * @param name defines the name of the mesh to create
  28982. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28983. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28984. * @param closePath creates a seam between the first and the last points of each path of the path array
  28985. * @param offset is taken in account only if the `pathArray` is containing a single path
  28986. * @param scene defines the hosting scene
  28987. * @param updatable defines if the mesh must be flagged as updatable
  28988. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28989. * @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)
  28990. * @returns a new Mesh
  28991. */
  28992. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28993. /**
  28994. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28995. * @param name defines the name of the mesh to create
  28996. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28997. * @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
  28998. * @param scene defines the hosting scene
  28999. * @param updatable defines if the mesh must be flagged as updatable
  29000. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29001. * @returns a new Mesh
  29002. */
  29003. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29004. /**
  29005. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  29006. * @param name defines the name of the mesh to create
  29007. * @param size sets the size (float) of each box side (default 1)
  29008. * @param scene defines the hosting scene
  29009. * @param updatable defines if the mesh must be flagged as updatable
  29010. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29011. * @returns a new Mesh
  29012. */
  29013. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29014. /**
  29015. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29016. * @param name defines the name of the mesh to create
  29017. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29018. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29019. * @param scene defines the hosting scene
  29020. * @param updatable defines if the mesh must be flagged as updatable
  29021. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29022. * @returns a new Mesh
  29023. */
  29024. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29025. /**
  29026. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29027. * @param name defines the name of the mesh to create
  29028. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29029. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29030. * @param scene defines the hosting scene
  29031. * @returns a new Mesh
  29032. */
  29033. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29034. /**
  29035. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29036. * @param name defines the name of the mesh to create
  29037. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29038. * @param diameterTop set the top cap diameter (floats, default 1)
  29039. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29040. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29041. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29042. * @param scene defines the hosting scene
  29043. * @param updatable defines if the mesh must be flagged as updatable
  29044. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29045. * @returns a new Mesh
  29046. */
  29047. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29048. /**
  29049. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29050. * @param name defines the name of the mesh to create
  29051. * @param diameter sets the diameter size (float) of the torus (default 1)
  29052. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29053. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29054. * @param scene defines the hosting scene
  29055. * @param updatable defines if the mesh must be flagged as updatable
  29056. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29057. * @returns a new Mesh
  29058. */
  29059. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29060. /**
  29061. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  29062. * @param name defines the name of the mesh to create
  29063. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29064. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29065. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29066. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29067. * @param p the number of windings on X axis (positive integers, default 2)
  29068. * @param q the number of windings on Y axis (positive integers, default 3)
  29069. * @param scene defines the hosting scene
  29070. * @param updatable defines if the mesh must be flagged as updatable
  29071. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29072. * @returns a new Mesh
  29073. */
  29074. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29075. /**
  29076. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29077. * @param name defines the name of the mesh to create
  29078. * @param points is an array successive Vector3
  29079. * @param scene defines the hosting scene
  29080. * @param updatable defines if the mesh must be flagged as updatable
  29081. * @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).
  29082. * @returns a new Mesh
  29083. */
  29084. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29085. /**
  29086. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29087. * @param name defines the name of the mesh to create
  29088. * @param points is an array successive Vector3
  29089. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29090. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29091. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29092. * @param scene defines the hosting scene
  29093. * @param updatable defines if the mesh must be flagged as updatable
  29094. * @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)
  29095. * @returns a new Mesh
  29096. */
  29097. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29098. /**
  29099. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29100. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29101. * 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.
  29102. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29103. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29104. * Remember you can only change the shape positions, not their number when updating a polygon.
  29105. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29106. * @param name defines the name of the mesh to create
  29107. * @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
  29108. * @param scene defines the hosting scene
  29109. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29110. * @param updatable defines if the mesh must be flagged as updatable
  29111. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29112. * @param earcutInjection can be used to inject your own earcut reference
  29113. * @returns a new Mesh
  29114. */
  29115. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29116. /**
  29117. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29118. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29119. * @param name defines the name of the mesh to create
  29120. * @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
  29121. * @param depth defines the height of extrusion
  29122. * @param scene defines the hosting scene
  29123. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29124. * @param updatable defines if the mesh must be flagged as updatable
  29125. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29126. * @param earcutInjection can be used to inject your own earcut reference
  29127. * @returns a new Mesh
  29128. */
  29129. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29130. /**
  29131. * Creates an extruded shape mesh.
  29132. * 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
  29133. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  29134. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29135. * @param name defines the name of the mesh to create
  29136. * @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
  29137. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29138. * @param scale is the value to scale the shape
  29139. * @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
  29140. * @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
  29141. * @param scene defines the hosting scene
  29142. * @param updatable defines if the mesh must be flagged as updatable
  29143. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29144. * @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)
  29145. * @returns a new Mesh
  29146. */
  29147. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29148. /**
  29149. * Creates an custom extruded shape mesh.
  29150. * The custom extrusion is a parametric shape.
  29151. * It has no predefined shape. Its final shape will depend on the input parameters.
  29152. * Please consider using the same method from the MeshBuilder class instead
  29153. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29154. * @param name defines the name of the mesh to create
  29155. * @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
  29156. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29157. * @param scaleFunction is a custom Javascript function called on each path point
  29158. * @param rotationFunction is a custom Javascript function called on each path point
  29159. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29160. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29161. * @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
  29162. * @param scene defines the hosting scene
  29163. * @param updatable defines if the mesh must be flagged as updatable
  29164. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29165. * @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)
  29166. * @returns a new Mesh
  29167. */
  29168. 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;
  29169. /**
  29170. * Creates lathe mesh.
  29171. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29172. * Please consider using the same method from the MeshBuilder class instead
  29173. * @param name defines the name of the mesh to create
  29174. * @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
  29175. * @param radius is the radius value of the lathe
  29176. * @param tessellation is the side number of the lathe.
  29177. * @param scene defines the hosting scene
  29178. * @param updatable defines if the mesh must be flagged as updatable
  29179. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29180. * @returns a new Mesh
  29181. */
  29182. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29183. /**
  29184. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29185. * @param name defines the name of the mesh to create
  29186. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29187. * @param scene defines the hosting scene
  29188. * @param updatable defines if the mesh must be flagged as updatable
  29189. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29190. * @returns a new Mesh
  29191. */
  29192. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29193. /**
  29194. * Creates a ground mesh.
  29195. * Please consider using the same method from the MeshBuilder class instead
  29196. * @param name defines the name of the mesh to create
  29197. * @param width set the width of the ground
  29198. * @param height set the height of the ground
  29199. * @param subdivisions sets the number of subdivisions per side
  29200. * @param scene defines the hosting scene
  29201. * @param updatable defines if the mesh must be flagged as updatable
  29202. * @returns a new Mesh
  29203. */
  29204. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29205. /**
  29206. * Creates a tiled ground mesh.
  29207. * Please consider using the same method from the MeshBuilder class instead
  29208. * @param name defines the name of the mesh to create
  29209. * @param xmin set the ground minimum X coordinate
  29210. * @param zmin set the ground minimum Y coordinate
  29211. * @param xmax set the ground maximum X coordinate
  29212. * @param zmax set the ground maximum Z coordinate
  29213. * @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
  29214. * @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
  29215. * @param scene defines the hosting scene
  29216. * @param updatable defines if the mesh must be flagged as updatable
  29217. * @returns a new Mesh
  29218. */
  29219. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29220. w: number;
  29221. h: number;
  29222. }, precision: {
  29223. w: number;
  29224. h: number;
  29225. }, scene: Scene, updatable?: boolean): Mesh;
  29226. /**
  29227. * Creates a ground mesh from a height map.
  29228. * Please consider using the same method from the MeshBuilder class instead
  29229. * @see http://doc.babylonjs.com/babylon101/height_map
  29230. * @param name defines the name of the mesh to create
  29231. * @param url sets the URL of the height map image resource
  29232. * @param width set the ground width size
  29233. * @param height set the ground height size
  29234. * @param subdivisions sets the number of subdivision per side
  29235. * @param minHeight is the minimum altitude on the ground
  29236. * @param maxHeight is the maximum altitude on the ground
  29237. * @param scene defines the hosting scene
  29238. * @param updatable defines if the mesh must be flagged as updatable
  29239. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29240. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29241. * @returns a new Mesh
  29242. */
  29243. 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;
  29244. /**
  29245. * Creates a tube mesh.
  29246. * The tube is a parametric shape.
  29247. * It has no predefined shape. Its final shape will depend on the input parameters.
  29248. * Please consider using the same method from the MeshBuilder class instead
  29249. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  29250. * @param name defines the name of the mesh to create
  29251. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29252. * @param radius sets the tube radius size
  29253. * @param tessellation is the number of sides on the tubular surface
  29254. * @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
  29255. * @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
  29256. * @param scene defines the hosting scene
  29257. * @param updatable defines if the mesh must be flagged as updatable
  29258. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29259. * @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)
  29260. * @returns a new Mesh
  29261. */
  29262. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29263. (i: number, distance: number): number;
  29264. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29265. /**
  29266. * Creates a polyhedron mesh.
  29267. * Please consider using the same method from the MeshBuilder class instead.
  29268. * * 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
  29269. * * The parameter `size` (positive float, default 1) sets the polygon size
  29270. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29271. * * 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`
  29272. * * 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
  29273. * * 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)`)
  29274. * * 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
  29275. * * 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
  29276. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29277. * * If you create a double-sided mesh, you can choose what parts of 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
  29278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29279. * @param name defines the name of the mesh to create
  29280. * @param options defines the options used to create the mesh
  29281. * @param scene defines the hosting scene
  29282. * @returns a new Mesh
  29283. */
  29284. static CreatePolyhedron(name: string, options: {
  29285. type?: number;
  29286. size?: number;
  29287. sizeX?: number;
  29288. sizeY?: number;
  29289. sizeZ?: number;
  29290. custom?: any;
  29291. faceUV?: Vector4[];
  29292. faceColors?: Color4[];
  29293. updatable?: boolean;
  29294. sideOrientation?: number;
  29295. }, scene: Scene): Mesh;
  29296. /**
  29297. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29298. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29299. * * 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`)
  29300. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29301. * * 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
  29302. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29303. * * If you create a double-sided mesh, you can choose what parts of 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
  29304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29305. * @param name defines the name of the mesh
  29306. * @param options defines the options used to create the mesh
  29307. * @param scene defines the hosting scene
  29308. * @returns a new Mesh
  29309. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29310. */
  29311. static CreateIcoSphere(name: string, options: {
  29312. radius?: number;
  29313. flat?: boolean;
  29314. subdivisions?: number;
  29315. sideOrientation?: number;
  29316. updatable?: boolean;
  29317. }, scene: Scene): Mesh;
  29318. /**
  29319. * Creates a decal mesh.
  29320. * Please consider using the same method from the MeshBuilder class instead.
  29321. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29322. * @param name defines the name of the mesh
  29323. * @param sourceMesh defines the mesh receiving the decal
  29324. * @param position sets the position of the decal in world coordinates
  29325. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29326. * @param size sets the decal scaling
  29327. * @param angle sets the angle to rotate the decal
  29328. * @returns a new Mesh
  29329. */
  29330. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29331. /**
  29332. * Prepare internal position array for software CPU skinning
  29333. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29334. */
  29335. setPositionsForCPUSkinning(): Float32Array;
  29336. /**
  29337. * Prepare internal normal array for software CPU skinning
  29338. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29339. */
  29340. setNormalsForCPUSkinning(): Float32Array;
  29341. /**
  29342. * Updates the vertex buffer by applying transformation from the bones
  29343. * @param skeleton defines the skeleton to apply to current mesh
  29344. * @returns the current mesh
  29345. */
  29346. applySkeleton(skeleton: Skeleton): Mesh;
  29347. /**
  29348. * 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
  29349. * @param meshes defines the list of meshes to scan
  29350. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29351. */
  29352. static MinMax(meshes: AbstractMesh[]): {
  29353. min: Vector3;
  29354. max: Vector3;
  29355. };
  29356. /**
  29357. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29358. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29359. * @returns a vector3
  29360. */
  29361. static Center(meshesOrMinMaxVector: {
  29362. min: Vector3;
  29363. max: Vector3;
  29364. } | AbstractMesh[]): Vector3;
  29365. /**
  29366. * Merge the array of meshes into a single mesh for performance reasons.
  29367. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29368. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29369. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29370. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29371. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29372. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29373. * @returns a new mesh
  29374. */
  29375. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29376. /** @hidden */
  29377. addInstance(instance: InstancedMesh): void;
  29378. /** @hidden */
  29379. removeInstance(instance: InstancedMesh): void;
  29380. }
  29381. }
  29382. declare module "babylonjs/Cameras/camera" {
  29383. import { SmartArray } from "babylonjs/Misc/smartArray";
  29384. import { Observable } from "babylonjs/Misc/observable";
  29385. import { Nullable } from "babylonjs/types";
  29386. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  29387. import { Scene } from "babylonjs/scene";
  29388. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  29389. import { Node } from "babylonjs/node";
  29390. import { Mesh } from "babylonjs/Meshes/mesh";
  29391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29392. import { ICullable } from "babylonjs/Culling/boundingInfo";
  29393. import { Viewport } from "babylonjs/Maths/math.viewport";
  29394. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29395. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29396. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  29397. import { Ray } from "babylonjs/Culling/ray";
  29398. /**
  29399. * This is the base class of all the camera used in the application.
  29400. * @see http://doc.babylonjs.com/features/cameras
  29401. */
  29402. export class Camera extends Node {
  29403. /** @hidden */
  29404. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29405. /**
  29406. * This is the default projection mode used by the cameras.
  29407. * It helps recreating a feeling of perspective and better appreciate depth.
  29408. * This is the best way to simulate real life cameras.
  29409. */
  29410. static readonly PERSPECTIVE_CAMERA: number;
  29411. /**
  29412. * This helps creating camera with an orthographic mode.
  29413. * 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.
  29414. */
  29415. static readonly ORTHOGRAPHIC_CAMERA: number;
  29416. /**
  29417. * This is the default FOV mode for perspective cameras.
  29418. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29419. */
  29420. static readonly FOVMODE_VERTICAL_FIXED: number;
  29421. /**
  29422. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29423. */
  29424. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29425. /**
  29426. * This specifies ther is no need for a camera rig.
  29427. * Basically only one eye is rendered corresponding to the camera.
  29428. */
  29429. static readonly RIG_MODE_NONE: number;
  29430. /**
  29431. * Simulates a camera Rig with one blue eye and one red eye.
  29432. * This can be use with 3d blue and red glasses.
  29433. */
  29434. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29435. /**
  29436. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29437. */
  29438. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29439. /**
  29440. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29441. */
  29442. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29443. /**
  29444. * Defines that both eyes of the camera will be rendered over under each other.
  29445. */
  29446. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29447. /**
  29448. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29449. */
  29450. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29451. /**
  29452. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29453. */
  29454. static readonly RIG_MODE_VR: number;
  29455. /**
  29456. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29457. */
  29458. static readonly RIG_MODE_WEBVR: number;
  29459. /**
  29460. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29461. */
  29462. static readonly RIG_MODE_CUSTOM: number;
  29463. /**
  29464. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29465. */
  29466. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29467. /**
  29468. * Define the input manager associated with the camera.
  29469. */
  29470. inputs: CameraInputsManager<Camera>;
  29471. /** @hidden */
  29472. _position: Vector3;
  29473. /**
  29474. * Define the current local position of the camera in the scene
  29475. */
  29476. get position(): Vector3;
  29477. set position(newPosition: Vector3);
  29478. /**
  29479. * The vector the camera should consider as up.
  29480. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29481. */
  29482. upVector: Vector3;
  29483. /**
  29484. * Define the current limit on the left side for an orthographic camera
  29485. * In scene unit
  29486. */
  29487. orthoLeft: Nullable<number>;
  29488. /**
  29489. * Define the current limit on the right side for an orthographic camera
  29490. * In scene unit
  29491. */
  29492. orthoRight: Nullable<number>;
  29493. /**
  29494. * Define the current limit on the bottom side for an orthographic camera
  29495. * In scene unit
  29496. */
  29497. orthoBottom: Nullable<number>;
  29498. /**
  29499. * Define the current limit on the top side for an orthographic camera
  29500. * In scene unit
  29501. */
  29502. orthoTop: Nullable<number>;
  29503. /**
  29504. * Field Of View is set in Radians. (default is 0.8)
  29505. */
  29506. fov: number;
  29507. /**
  29508. * Define the minimum distance the camera can see from.
  29509. * This is important to note that the depth buffer are not infinite and the closer it starts
  29510. * the more your scene might encounter depth fighting issue.
  29511. */
  29512. minZ: number;
  29513. /**
  29514. * Define the maximum distance the camera can see to.
  29515. * This is important to note that the depth buffer are not infinite and the further it end
  29516. * the more your scene might encounter depth fighting issue.
  29517. */
  29518. maxZ: number;
  29519. /**
  29520. * Define the default inertia of the camera.
  29521. * This helps giving a smooth feeling to the camera movement.
  29522. */
  29523. inertia: number;
  29524. /**
  29525. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29526. */
  29527. mode: number;
  29528. /**
  29529. * Define whether the camera is intermediate.
  29530. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29531. */
  29532. isIntermediate: boolean;
  29533. /**
  29534. * Define the viewport of the camera.
  29535. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29536. */
  29537. viewport: Viewport;
  29538. /**
  29539. * Restricts the camera to viewing objects with the same layerMask.
  29540. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29541. */
  29542. layerMask: number;
  29543. /**
  29544. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29545. */
  29546. fovMode: number;
  29547. /**
  29548. * Rig mode of the camera.
  29549. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29550. * This is normally controlled byt the camera themselves as internal use.
  29551. */
  29552. cameraRigMode: number;
  29553. /**
  29554. * Defines the distance between both "eyes" in case of a RIG
  29555. */
  29556. interaxialDistance: number;
  29557. /**
  29558. * Defines if stereoscopic rendering is done side by side or over under.
  29559. */
  29560. isStereoscopicSideBySide: boolean;
  29561. /**
  29562. * 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
  29563. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29564. * else in the scene. (Eg. security camera)
  29565. *
  29566. * 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)
  29567. */
  29568. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  29569. /**
  29570. * When set, the camera will render to this render target instead of the default canvas
  29571. *
  29572. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29573. */
  29574. outputRenderTarget: Nullable<RenderTargetTexture>;
  29575. /**
  29576. * Observable triggered when the camera view matrix has changed.
  29577. */
  29578. onViewMatrixChangedObservable: Observable<Camera>;
  29579. /**
  29580. * Observable triggered when the camera Projection matrix has changed.
  29581. */
  29582. onProjectionMatrixChangedObservable: Observable<Camera>;
  29583. /**
  29584. * Observable triggered when the inputs have been processed.
  29585. */
  29586. onAfterCheckInputsObservable: Observable<Camera>;
  29587. /**
  29588. * Observable triggered when reset has been called and applied to the camera.
  29589. */
  29590. onRestoreStateObservable: Observable<Camera>;
  29591. /**
  29592. * Is this camera a part of a rig system?
  29593. */
  29594. isRigCamera: boolean;
  29595. /**
  29596. * If isRigCamera set to true this will be set with the parent camera.
  29597. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29598. */
  29599. rigParent?: Camera;
  29600. /** @hidden */
  29601. _cameraRigParams: any;
  29602. /** @hidden */
  29603. _rigCameras: Camera[];
  29604. /** @hidden */
  29605. _rigPostProcess: Nullable<PostProcess>;
  29606. protected _webvrViewMatrix: Matrix;
  29607. /** @hidden */
  29608. _skipRendering: boolean;
  29609. /** @hidden */
  29610. _projectionMatrix: Matrix;
  29611. /** @hidden */
  29612. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  29613. /** @hidden */
  29614. _activeMeshes: SmartArray<AbstractMesh>;
  29615. protected _globalPosition: Vector3;
  29616. /** @hidden */
  29617. _computedViewMatrix: Matrix;
  29618. private _doNotComputeProjectionMatrix;
  29619. private _transformMatrix;
  29620. private _frustumPlanes;
  29621. private _refreshFrustumPlanes;
  29622. private _storedFov;
  29623. private _stateStored;
  29624. /**
  29625. * Instantiates a new camera object.
  29626. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29627. * @see http://doc.babylonjs.com/features/cameras
  29628. * @param name Defines the name of the camera in the scene
  29629. * @param position Defines the position of the camera
  29630. * @param scene Defines the scene the camera belongs too
  29631. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29632. */
  29633. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29634. /**
  29635. * Store current camera state (fov, position, etc..)
  29636. * @returns the camera
  29637. */
  29638. storeState(): Camera;
  29639. /**
  29640. * Restores the camera state values if it has been stored. You must call storeState() first
  29641. */
  29642. protected _restoreStateValues(): boolean;
  29643. /**
  29644. * Restored camera state. You must call storeState() first.
  29645. * @returns true if restored and false otherwise
  29646. */
  29647. restoreState(): boolean;
  29648. /**
  29649. * Gets the class name of the camera.
  29650. * @returns the class name
  29651. */
  29652. getClassName(): string;
  29653. /** @hidden */
  29654. readonly _isCamera: boolean;
  29655. /**
  29656. * Gets a string representation of the camera useful for debug purpose.
  29657. * @param fullDetails Defines that a more verboe level of logging is required
  29658. * @returns the string representation
  29659. */
  29660. toString(fullDetails?: boolean): string;
  29661. /**
  29662. * Gets the current world space position of the camera.
  29663. */
  29664. get globalPosition(): Vector3;
  29665. /**
  29666. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29667. * @returns the active meshe list
  29668. */
  29669. getActiveMeshes(): SmartArray<AbstractMesh>;
  29670. /**
  29671. * Check whether a mesh is part of the current active mesh list of the camera
  29672. * @param mesh Defines the mesh to check
  29673. * @returns true if active, false otherwise
  29674. */
  29675. isActiveMesh(mesh: Mesh): boolean;
  29676. /**
  29677. * Is this camera ready to be used/rendered
  29678. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29679. * @return true if the camera is ready
  29680. */
  29681. isReady(completeCheck?: boolean): boolean;
  29682. /** @hidden */
  29683. _initCache(): void;
  29684. /** @hidden */
  29685. _updateCache(ignoreParentClass?: boolean): void;
  29686. /** @hidden */
  29687. _isSynchronized(): boolean;
  29688. /** @hidden */
  29689. _isSynchronizedViewMatrix(): boolean;
  29690. /** @hidden */
  29691. _isSynchronizedProjectionMatrix(): boolean;
  29692. /**
  29693. * Attach the input controls to a specific dom element to get the input from.
  29694. * @param element Defines the element the controls should be listened from
  29695. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29696. */
  29697. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29698. /**
  29699. * Detach the current controls from the specified dom element.
  29700. * @param element Defines the element to stop listening the inputs from
  29701. */
  29702. detachControl(element: HTMLElement): void;
  29703. /**
  29704. * Update the camera state according to the different inputs gathered during the frame.
  29705. */
  29706. update(): void;
  29707. /** @hidden */
  29708. _checkInputs(): void;
  29709. /** @hidden */
  29710. get rigCameras(): Camera[];
  29711. /**
  29712. * Gets the post process used by the rig cameras
  29713. */
  29714. get rigPostProcess(): Nullable<PostProcess>;
  29715. /**
  29716. * Internal, gets the first post proces.
  29717. * @returns the first post process to be run on this camera.
  29718. */
  29719. _getFirstPostProcess(): Nullable<PostProcess>;
  29720. private _cascadePostProcessesToRigCams;
  29721. /**
  29722. * Attach a post process to the camera.
  29723. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29724. * @param postProcess The post process to attach to the camera
  29725. * @param insertAt The position of the post process in case several of them are in use in the scene
  29726. * @returns the position the post process has been inserted at
  29727. */
  29728. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29729. /**
  29730. * Detach a post process to the camera.
  29731. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29732. * @param postProcess The post process to detach from the camera
  29733. */
  29734. detachPostProcess(postProcess: PostProcess): void;
  29735. /**
  29736. * Gets the current world matrix of the camera
  29737. */
  29738. getWorldMatrix(): Matrix;
  29739. /** @hidden */
  29740. _getViewMatrix(): Matrix;
  29741. /**
  29742. * Gets the current view matrix of the camera.
  29743. * @param force forces the camera to recompute the matrix without looking at the cached state
  29744. * @returns the view matrix
  29745. */
  29746. getViewMatrix(force?: boolean): Matrix;
  29747. /**
  29748. * Freeze the projection matrix.
  29749. * It will prevent the cache check of the camera projection compute and can speed up perf
  29750. * if no parameter of the camera are meant to change
  29751. * @param projection Defines manually a projection if necessary
  29752. */
  29753. freezeProjectionMatrix(projection?: Matrix): void;
  29754. /**
  29755. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29756. */
  29757. unfreezeProjectionMatrix(): void;
  29758. /**
  29759. * Gets the current projection matrix of the camera.
  29760. * @param force forces the camera to recompute the matrix without looking at the cached state
  29761. * @returns the projection matrix
  29762. */
  29763. getProjectionMatrix(force?: boolean): Matrix;
  29764. /**
  29765. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29766. * @returns a Matrix
  29767. */
  29768. getTransformationMatrix(): Matrix;
  29769. private _updateFrustumPlanes;
  29770. /**
  29771. * Checks if a cullable object (mesh...) is in the camera frustum
  29772. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29773. * @param target The object to check
  29774. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29775. * @returns true if the object is in frustum otherwise false
  29776. */
  29777. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29778. /**
  29779. * Checks if a cullable object (mesh...) is in the camera frustum
  29780. * Unlike isInFrustum this cheks the full bounding box
  29781. * @param target The object to check
  29782. * @returns true if the object is in frustum otherwise false
  29783. */
  29784. isCompletelyInFrustum(target: ICullable): boolean;
  29785. /**
  29786. * Gets a ray in the forward direction from the camera.
  29787. * @param length Defines the length of the ray to create
  29788. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29789. * @param origin Defines the start point of the ray which defaults to the camera position
  29790. * @returns the forward ray
  29791. */
  29792. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29793. /**
  29794. * Releases resources associated with this node.
  29795. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29796. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29797. */
  29798. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29799. /** @hidden */
  29800. _isLeftCamera: boolean;
  29801. /**
  29802. * Gets the left camera of a rig setup in case of Rigged Camera
  29803. */
  29804. get isLeftCamera(): boolean;
  29805. /** @hidden */
  29806. _isRightCamera: boolean;
  29807. /**
  29808. * Gets the right camera of a rig setup in case of Rigged Camera
  29809. */
  29810. get isRightCamera(): boolean;
  29811. /**
  29812. * Gets the left camera of a rig setup in case of Rigged Camera
  29813. */
  29814. get leftCamera(): Nullable<FreeCamera>;
  29815. /**
  29816. * Gets the right camera of a rig setup in case of Rigged Camera
  29817. */
  29818. get rightCamera(): Nullable<FreeCamera>;
  29819. /**
  29820. * Gets the left camera target of a rig setup in case of Rigged Camera
  29821. * @returns the target position
  29822. */
  29823. getLeftTarget(): Nullable<Vector3>;
  29824. /**
  29825. * Gets the right camera target of a rig setup in case of Rigged Camera
  29826. * @returns the target position
  29827. */
  29828. getRightTarget(): Nullable<Vector3>;
  29829. /**
  29830. * @hidden
  29831. */
  29832. setCameraRigMode(mode: number, rigParams: any): void;
  29833. /** @hidden */
  29834. static _setStereoscopicRigMode(camera: Camera): void;
  29835. /** @hidden */
  29836. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29837. /** @hidden */
  29838. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29839. /** @hidden */
  29840. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29841. /** @hidden */
  29842. _getVRProjectionMatrix(): Matrix;
  29843. protected _updateCameraRotationMatrix(): void;
  29844. protected _updateWebVRCameraRotationMatrix(): void;
  29845. /**
  29846. * This function MUST be overwritten by the different WebVR cameras available.
  29847. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29848. * @hidden
  29849. */
  29850. _getWebVRProjectionMatrix(): Matrix;
  29851. /**
  29852. * This function MUST be overwritten by the different WebVR cameras available.
  29853. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29854. * @hidden
  29855. */
  29856. _getWebVRViewMatrix(): Matrix;
  29857. /** @hidden */
  29858. setCameraRigParameter(name: string, value: any): void;
  29859. /**
  29860. * needs to be overridden by children so sub has required properties to be copied
  29861. * @hidden
  29862. */
  29863. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29864. /**
  29865. * May need to be overridden by children
  29866. * @hidden
  29867. */
  29868. _updateRigCameras(): void;
  29869. /** @hidden */
  29870. _setupInputs(): void;
  29871. /**
  29872. * Serialiaze the camera setup to a json represention
  29873. * @returns the JSON representation
  29874. */
  29875. serialize(): any;
  29876. /**
  29877. * Clones the current camera.
  29878. * @param name The cloned camera name
  29879. * @returns the cloned camera
  29880. */
  29881. clone(name: string): Camera;
  29882. /**
  29883. * Gets the direction of the camera relative to a given local axis.
  29884. * @param localAxis Defines the reference axis to provide a relative direction.
  29885. * @return the direction
  29886. */
  29887. getDirection(localAxis: Vector3): Vector3;
  29888. /**
  29889. * Returns the current camera absolute rotation
  29890. */
  29891. get absoluteRotation(): Quaternion;
  29892. /**
  29893. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29894. * @param localAxis Defines the reference axis to provide a relative direction.
  29895. * @param result Defines the vector to store the result in
  29896. */
  29897. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29898. /**
  29899. * Gets a camera constructor for a given camera type
  29900. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29901. * @param name The name of the camera the result will be able to instantiate
  29902. * @param scene The scene the result will construct the camera in
  29903. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29904. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29905. * @returns a factory method to construc the camera
  29906. */
  29907. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29908. /**
  29909. * Compute the world matrix of the camera.
  29910. * @returns the camera world matrix
  29911. */
  29912. computeWorldMatrix(): Matrix;
  29913. /**
  29914. * Parse a JSON and creates the camera from the parsed information
  29915. * @param parsedCamera The JSON to parse
  29916. * @param scene The scene to instantiate the camera in
  29917. * @returns the newly constructed camera
  29918. */
  29919. static Parse(parsedCamera: any, scene: Scene): Camera;
  29920. }
  29921. }
  29922. declare module "babylonjs/Meshes/Builders/discBuilder" {
  29923. import { Nullable } from "babylonjs/types";
  29924. import { Scene } from "babylonjs/scene";
  29925. import { Vector4 } from "babylonjs/Maths/math.vector";
  29926. import { Mesh } from "babylonjs/Meshes/mesh";
  29927. /**
  29928. * Class containing static functions to help procedurally build meshes
  29929. */
  29930. export class DiscBuilder {
  29931. /**
  29932. * Creates a plane polygonal mesh. By default, this is a disc
  29933. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29934. * * 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
  29935. * * 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
  29936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29937. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29939. * @param name defines the name of the mesh
  29940. * @param options defines the options used to create the mesh
  29941. * @param scene defines the hosting scene
  29942. * @returns the plane polygonal mesh
  29943. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29944. */
  29945. static CreateDisc(name: string, options: {
  29946. radius?: number;
  29947. tessellation?: number;
  29948. arc?: number;
  29949. updatable?: boolean;
  29950. sideOrientation?: number;
  29951. frontUVs?: Vector4;
  29952. backUVs?: Vector4;
  29953. }, scene?: Nullable<Scene>): Mesh;
  29954. }
  29955. }
  29956. declare module "babylonjs/Materials/fresnelParameters" {
  29957. import { DeepImmutable } from "babylonjs/types";
  29958. import { Color3 } from "babylonjs/Maths/math.color";
  29959. /**
  29960. * Options to be used when creating a FresnelParameters.
  29961. */
  29962. export type IFresnelParametersCreationOptions = {
  29963. /**
  29964. * Define the color used on edges (grazing angle)
  29965. */
  29966. leftColor?: Color3;
  29967. /**
  29968. * Define the color used on center
  29969. */
  29970. rightColor?: Color3;
  29971. /**
  29972. * Define bias applied to computed fresnel term
  29973. */
  29974. bias?: number;
  29975. /**
  29976. * Defined the power exponent applied to fresnel term
  29977. */
  29978. power?: number;
  29979. /**
  29980. * Define if the fresnel effect is enable or not.
  29981. */
  29982. isEnabled?: boolean;
  29983. };
  29984. /**
  29985. * Serialized format for FresnelParameters.
  29986. */
  29987. export type IFresnelParametersSerialized = {
  29988. /**
  29989. * Define the color used on edges (grazing angle) [as an array]
  29990. */
  29991. leftColor: number[];
  29992. /**
  29993. * Define the color used on center [as an array]
  29994. */
  29995. rightColor: number[];
  29996. /**
  29997. * Define bias applied to computed fresnel term
  29998. */
  29999. bias: number;
  30000. /**
  30001. * Defined the power exponent applied to fresnel term
  30002. */
  30003. power?: number;
  30004. /**
  30005. * Define if the fresnel effect is enable or not.
  30006. */
  30007. isEnabled: boolean;
  30008. };
  30009. /**
  30010. * This represents all the required information to add a fresnel effect on a material:
  30011. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30012. */
  30013. export class FresnelParameters {
  30014. private _isEnabled;
  30015. /**
  30016. * Define if the fresnel effect is enable or not.
  30017. */
  30018. get isEnabled(): boolean;
  30019. set isEnabled(value: boolean);
  30020. /**
  30021. * Define the color used on edges (grazing angle)
  30022. */
  30023. leftColor: Color3;
  30024. /**
  30025. * Define the color used on center
  30026. */
  30027. rightColor: Color3;
  30028. /**
  30029. * Define bias applied to computed fresnel term
  30030. */
  30031. bias: number;
  30032. /**
  30033. * Defined the power exponent applied to fresnel term
  30034. */
  30035. power: number;
  30036. /**
  30037. * Creates a new FresnelParameters object.
  30038. *
  30039. * @param options provide your own settings to optionally to override defaults
  30040. */
  30041. constructor(options?: IFresnelParametersCreationOptions);
  30042. /**
  30043. * Clones the current fresnel and its valuues
  30044. * @returns a clone fresnel configuration
  30045. */
  30046. clone(): FresnelParameters;
  30047. /**
  30048. * Determines equality between FresnelParameters objects
  30049. * @param otherFresnelParameters defines the second operand
  30050. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  30051. */
  30052. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  30053. /**
  30054. * Serializes the current fresnel parameters to a JSON representation.
  30055. * @return the JSON serialization
  30056. */
  30057. serialize(): IFresnelParametersSerialized;
  30058. /**
  30059. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30060. * @param parsedFresnelParameters Define the JSON representation
  30061. * @returns the parsed parameters
  30062. */
  30063. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30064. }
  30065. }
  30066. declare module "babylonjs/Materials/materialFlags" {
  30067. /**
  30068. * This groups all the flags used to control the materials channel.
  30069. */
  30070. export class MaterialFlags {
  30071. private static _DiffuseTextureEnabled;
  30072. /**
  30073. * Are diffuse textures enabled in the application.
  30074. */
  30075. static get DiffuseTextureEnabled(): boolean;
  30076. static set DiffuseTextureEnabled(value: boolean);
  30077. private static _DetailTextureEnabled;
  30078. /**
  30079. * Are detail textures enabled in the application.
  30080. */
  30081. static get DetailTextureEnabled(): boolean;
  30082. static set DetailTextureEnabled(value: boolean);
  30083. private static _AmbientTextureEnabled;
  30084. /**
  30085. * Are ambient textures enabled in the application.
  30086. */
  30087. static get AmbientTextureEnabled(): boolean;
  30088. static set AmbientTextureEnabled(value: boolean);
  30089. private static _OpacityTextureEnabled;
  30090. /**
  30091. * Are opacity textures enabled in the application.
  30092. */
  30093. static get OpacityTextureEnabled(): boolean;
  30094. static set OpacityTextureEnabled(value: boolean);
  30095. private static _ReflectionTextureEnabled;
  30096. /**
  30097. * Are reflection textures enabled in the application.
  30098. */
  30099. static get ReflectionTextureEnabled(): boolean;
  30100. static set ReflectionTextureEnabled(value: boolean);
  30101. private static _EmissiveTextureEnabled;
  30102. /**
  30103. * Are emissive textures enabled in the application.
  30104. */
  30105. static get EmissiveTextureEnabled(): boolean;
  30106. static set EmissiveTextureEnabled(value: boolean);
  30107. private static _SpecularTextureEnabled;
  30108. /**
  30109. * Are specular textures enabled in the application.
  30110. */
  30111. static get SpecularTextureEnabled(): boolean;
  30112. static set SpecularTextureEnabled(value: boolean);
  30113. private static _BumpTextureEnabled;
  30114. /**
  30115. * Are bump textures enabled in the application.
  30116. */
  30117. static get BumpTextureEnabled(): boolean;
  30118. static set BumpTextureEnabled(value: boolean);
  30119. private static _LightmapTextureEnabled;
  30120. /**
  30121. * Are lightmap textures enabled in the application.
  30122. */
  30123. static get LightmapTextureEnabled(): boolean;
  30124. static set LightmapTextureEnabled(value: boolean);
  30125. private static _RefractionTextureEnabled;
  30126. /**
  30127. * Are refraction textures enabled in the application.
  30128. */
  30129. static get RefractionTextureEnabled(): boolean;
  30130. static set RefractionTextureEnabled(value: boolean);
  30131. private static _ColorGradingTextureEnabled;
  30132. /**
  30133. * Are color grading textures enabled in the application.
  30134. */
  30135. static get ColorGradingTextureEnabled(): boolean;
  30136. static set ColorGradingTextureEnabled(value: boolean);
  30137. private static _FresnelEnabled;
  30138. /**
  30139. * Are fresnels enabled in the application.
  30140. */
  30141. static get FresnelEnabled(): boolean;
  30142. static set FresnelEnabled(value: boolean);
  30143. private static _ClearCoatTextureEnabled;
  30144. /**
  30145. * Are clear coat textures enabled in the application.
  30146. */
  30147. static get ClearCoatTextureEnabled(): boolean;
  30148. static set ClearCoatTextureEnabled(value: boolean);
  30149. private static _ClearCoatBumpTextureEnabled;
  30150. /**
  30151. * Are clear coat bump textures enabled in the application.
  30152. */
  30153. static get ClearCoatBumpTextureEnabled(): boolean;
  30154. static set ClearCoatBumpTextureEnabled(value: boolean);
  30155. private static _ClearCoatTintTextureEnabled;
  30156. /**
  30157. * Are clear coat tint textures enabled in the application.
  30158. */
  30159. static get ClearCoatTintTextureEnabled(): boolean;
  30160. static set ClearCoatTintTextureEnabled(value: boolean);
  30161. private static _SheenTextureEnabled;
  30162. /**
  30163. * Are sheen textures enabled in the application.
  30164. */
  30165. static get SheenTextureEnabled(): boolean;
  30166. static set SheenTextureEnabled(value: boolean);
  30167. private static _AnisotropicTextureEnabled;
  30168. /**
  30169. * Are anisotropic textures enabled in the application.
  30170. */
  30171. static get AnisotropicTextureEnabled(): boolean;
  30172. static set AnisotropicTextureEnabled(value: boolean);
  30173. private static _ThicknessTextureEnabled;
  30174. /**
  30175. * Are thickness textures enabled in the application.
  30176. */
  30177. static get ThicknessTextureEnabled(): boolean;
  30178. static set ThicknessTextureEnabled(value: boolean);
  30179. }
  30180. }
  30181. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  30182. /** @hidden */
  30183. export var defaultFragmentDeclaration: {
  30184. name: string;
  30185. shader: string;
  30186. };
  30187. }
  30188. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  30189. /** @hidden */
  30190. export var defaultUboDeclaration: {
  30191. name: string;
  30192. shader: string;
  30193. };
  30194. }
  30195. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  30196. /** @hidden */
  30197. export var lightFragmentDeclaration: {
  30198. name: string;
  30199. shader: string;
  30200. };
  30201. }
  30202. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  30203. /** @hidden */
  30204. export var lightUboDeclaration: {
  30205. name: string;
  30206. shader: string;
  30207. };
  30208. }
  30209. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  30210. /** @hidden */
  30211. export var lightsFragmentFunctions: {
  30212. name: string;
  30213. shader: string;
  30214. };
  30215. }
  30216. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  30217. /** @hidden */
  30218. export var shadowsFragmentFunctions: {
  30219. name: string;
  30220. shader: string;
  30221. };
  30222. }
  30223. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  30224. /** @hidden */
  30225. export var fresnelFunction: {
  30226. name: string;
  30227. shader: string;
  30228. };
  30229. }
  30230. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  30231. /** @hidden */
  30232. export var bumpFragmentMainFunctions: {
  30233. name: string;
  30234. shader: string;
  30235. };
  30236. }
  30237. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  30238. /** @hidden */
  30239. export var bumpFragmentFunctions: {
  30240. name: string;
  30241. shader: string;
  30242. };
  30243. }
  30244. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  30245. /** @hidden */
  30246. export var logDepthDeclaration: {
  30247. name: string;
  30248. shader: string;
  30249. };
  30250. }
  30251. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  30252. /** @hidden */
  30253. export var bumpFragment: {
  30254. name: string;
  30255. shader: string;
  30256. };
  30257. }
  30258. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  30259. /** @hidden */
  30260. export var depthPrePass: {
  30261. name: string;
  30262. shader: string;
  30263. };
  30264. }
  30265. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  30266. /** @hidden */
  30267. export var lightFragment: {
  30268. name: string;
  30269. shader: string;
  30270. };
  30271. }
  30272. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  30273. /** @hidden */
  30274. export var logDepthFragment: {
  30275. name: string;
  30276. shader: string;
  30277. };
  30278. }
  30279. declare module "babylonjs/Shaders/default.fragment" {
  30280. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  30281. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30282. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30283. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30284. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30285. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  30286. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  30287. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  30288. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  30289. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  30290. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  30291. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  30292. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  30293. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  30294. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30295. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  30296. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  30297. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  30298. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  30299. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  30300. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  30301. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  30302. /** @hidden */
  30303. export var defaultPixelShader: {
  30304. name: string;
  30305. shader: string;
  30306. };
  30307. }
  30308. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  30309. /** @hidden */
  30310. export var defaultVertexDeclaration: {
  30311. name: string;
  30312. shader: string;
  30313. };
  30314. }
  30315. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  30316. /** @hidden */
  30317. export var bumpVertexDeclaration: {
  30318. name: string;
  30319. shader: string;
  30320. };
  30321. }
  30322. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  30323. /** @hidden */
  30324. export var bumpVertex: {
  30325. name: string;
  30326. shader: string;
  30327. };
  30328. }
  30329. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  30330. /** @hidden */
  30331. export var fogVertex: {
  30332. name: string;
  30333. shader: string;
  30334. };
  30335. }
  30336. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  30337. /** @hidden */
  30338. export var shadowsVertex: {
  30339. name: string;
  30340. shader: string;
  30341. };
  30342. }
  30343. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  30344. /** @hidden */
  30345. export var pointCloudVertex: {
  30346. name: string;
  30347. shader: string;
  30348. };
  30349. }
  30350. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  30351. /** @hidden */
  30352. export var logDepthVertex: {
  30353. name: string;
  30354. shader: string;
  30355. };
  30356. }
  30357. declare module "babylonjs/Shaders/default.vertex" {
  30358. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  30359. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30360. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30361. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  30362. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  30363. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  30364. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  30365. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  30366. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30367. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30368. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  30369. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  30370. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30371. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  30372. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  30373. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  30374. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  30375. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  30376. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  30377. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  30378. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  30379. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  30380. /** @hidden */
  30381. export var defaultVertexShader: {
  30382. name: string;
  30383. shader: string;
  30384. };
  30385. }
  30386. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  30387. import { Nullable } from "babylonjs/types";
  30388. import { Scene } from "babylonjs/scene";
  30389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30390. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30391. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30392. /**
  30393. * @hidden
  30394. */
  30395. export interface IMaterialDetailMapDefines {
  30396. DETAIL: boolean;
  30397. DETAILDIRECTUV: number;
  30398. DETAIL_NORMALBLENDMETHOD: number;
  30399. /** @hidden */
  30400. _areTexturesDirty: boolean;
  30401. }
  30402. /**
  30403. * Define the code related to the detail map parameters of a material
  30404. *
  30405. * Inspired from:
  30406. * 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
  30407. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30408. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30409. */
  30410. export class DetailMapConfiguration {
  30411. private _texture;
  30412. /**
  30413. * The detail texture of the material.
  30414. */
  30415. texture: Nullable<BaseTexture>;
  30416. /**
  30417. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30418. * Bigger values mean stronger blending
  30419. */
  30420. diffuseBlendLevel: number;
  30421. /**
  30422. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30423. * Bigger values mean stronger blending. Only used with PBR materials
  30424. */
  30425. roughnessBlendLevel: number;
  30426. /**
  30427. * Defines how strong the bump effect from the detail map is
  30428. * Bigger values mean stronger effect
  30429. */
  30430. bumpLevel: number;
  30431. private _normalBlendMethod;
  30432. /**
  30433. * The method used to blend the bump and detail normals together
  30434. */
  30435. normalBlendMethod: number;
  30436. private _isEnabled;
  30437. /**
  30438. * Enable or disable the detail map on this material
  30439. */
  30440. isEnabled: boolean;
  30441. /** @hidden */
  30442. private _internalMarkAllSubMeshesAsTexturesDirty;
  30443. /** @hidden */
  30444. _markAllSubMeshesAsTexturesDirty(): void;
  30445. /**
  30446. * Instantiate a new detail map
  30447. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30448. */
  30449. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30450. /**
  30451. * Gets whether the submesh is ready to be used or not.
  30452. * @param defines the list of "defines" to update.
  30453. * @param scene defines the scene the material belongs to.
  30454. * @returns - boolean indicating that the submesh is ready or not.
  30455. */
  30456. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30457. /**
  30458. * Update the defines for detail map usage
  30459. * @param defines the list of "defines" to update.
  30460. * @param scene defines the scene the material belongs to.
  30461. */
  30462. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30463. /**
  30464. * Binds the material data.
  30465. * @param uniformBuffer defines the Uniform buffer to fill in.
  30466. * @param scene defines the scene the material belongs to.
  30467. * @param isFrozen defines whether the material is frozen or not.
  30468. */
  30469. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30470. /**
  30471. * Checks to see if a texture is used in the material.
  30472. * @param texture - Base texture to use.
  30473. * @returns - Boolean specifying if a texture is used in the material.
  30474. */
  30475. hasTexture(texture: BaseTexture): boolean;
  30476. /**
  30477. * Returns an array of the actively used textures.
  30478. * @param activeTextures Array of BaseTextures
  30479. */
  30480. getActiveTextures(activeTextures: BaseTexture[]): void;
  30481. /**
  30482. * Returns the animatable textures.
  30483. * @param animatables Array of animatable textures.
  30484. */
  30485. getAnimatables(animatables: IAnimatable[]): void;
  30486. /**
  30487. * Disposes the resources of the material.
  30488. * @param forceDisposeTextures - Forces the disposal of all textures.
  30489. */
  30490. dispose(forceDisposeTextures?: boolean): void;
  30491. /**
  30492. * Get the current class name useful for serialization or dynamic coding.
  30493. * @returns "DetailMap"
  30494. */
  30495. getClassName(): string;
  30496. /**
  30497. * Add the required uniforms to the current list.
  30498. * @param uniforms defines the current uniform list.
  30499. */
  30500. static AddUniforms(uniforms: string[]): void;
  30501. /**
  30502. * Add the required samplers to the current list.
  30503. * @param samplers defines the current sampler list.
  30504. */
  30505. static AddSamplers(samplers: string[]): void;
  30506. /**
  30507. * Add the required uniforms to the current buffer.
  30508. * @param uniformBuffer defines the current uniform buffer.
  30509. */
  30510. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30511. /**
  30512. * Makes a duplicate of the current instance into another one.
  30513. * @param detailMap define the instance where to copy the info
  30514. */
  30515. copyTo(detailMap: DetailMapConfiguration): void;
  30516. /**
  30517. * Serializes this detail map instance
  30518. * @returns - An object with the serialized instance.
  30519. */
  30520. serialize(): any;
  30521. /**
  30522. * Parses a detail map setting from a serialized object.
  30523. * @param source - Serialized object.
  30524. * @param scene Defines the scene we are parsing for
  30525. * @param rootUrl Defines the rootUrl to load from
  30526. */
  30527. parse(source: any, scene: Scene, rootUrl: string): void;
  30528. }
  30529. }
  30530. declare module "babylonjs/Materials/standardMaterial" {
  30531. import { SmartArray } from "babylonjs/Misc/smartArray";
  30532. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30533. import { Nullable } from "babylonjs/types";
  30534. import { Scene } from "babylonjs/scene";
  30535. import { Matrix } from "babylonjs/Maths/math.vector";
  30536. import { Color3 } from "babylonjs/Maths/math.color";
  30537. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30538. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30539. import { Mesh } from "babylonjs/Meshes/mesh";
  30540. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  30541. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30542. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  30543. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30544. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  30545. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30546. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30547. import "babylonjs/Shaders/default.fragment";
  30548. import "babylonjs/Shaders/default.vertex";
  30549. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  30550. /** @hidden */
  30551. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30552. MAINUV1: boolean;
  30553. MAINUV2: boolean;
  30554. DIFFUSE: boolean;
  30555. DIFFUSEDIRECTUV: number;
  30556. DETAIL: boolean;
  30557. DETAILDIRECTUV: number;
  30558. DETAIL_NORMALBLENDMETHOD: number;
  30559. AMBIENT: boolean;
  30560. AMBIENTDIRECTUV: number;
  30561. OPACITY: boolean;
  30562. OPACITYDIRECTUV: number;
  30563. OPACITYRGB: boolean;
  30564. REFLECTION: boolean;
  30565. EMISSIVE: boolean;
  30566. EMISSIVEDIRECTUV: number;
  30567. SPECULAR: boolean;
  30568. SPECULARDIRECTUV: number;
  30569. BUMP: boolean;
  30570. BUMPDIRECTUV: number;
  30571. PARALLAX: boolean;
  30572. PARALLAXOCCLUSION: boolean;
  30573. SPECULAROVERALPHA: boolean;
  30574. CLIPPLANE: boolean;
  30575. CLIPPLANE2: boolean;
  30576. CLIPPLANE3: boolean;
  30577. CLIPPLANE4: boolean;
  30578. CLIPPLANE5: boolean;
  30579. CLIPPLANE6: boolean;
  30580. ALPHATEST: boolean;
  30581. DEPTHPREPASS: boolean;
  30582. ALPHAFROMDIFFUSE: boolean;
  30583. POINTSIZE: boolean;
  30584. FOG: boolean;
  30585. SPECULARTERM: boolean;
  30586. DIFFUSEFRESNEL: boolean;
  30587. OPACITYFRESNEL: boolean;
  30588. REFLECTIONFRESNEL: boolean;
  30589. REFRACTIONFRESNEL: boolean;
  30590. EMISSIVEFRESNEL: boolean;
  30591. FRESNEL: boolean;
  30592. NORMAL: boolean;
  30593. UV1: boolean;
  30594. UV2: boolean;
  30595. VERTEXCOLOR: boolean;
  30596. VERTEXALPHA: boolean;
  30597. NUM_BONE_INFLUENCERS: number;
  30598. BonesPerMesh: number;
  30599. BONETEXTURE: boolean;
  30600. INSTANCES: boolean;
  30601. THIN_INSTANCES: boolean;
  30602. GLOSSINESS: boolean;
  30603. ROUGHNESS: boolean;
  30604. EMISSIVEASILLUMINATION: boolean;
  30605. LINKEMISSIVEWITHDIFFUSE: boolean;
  30606. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30607. LIGHTMAP: boolean;
  30608. LIGHTMAPDIRECTUV: number;
  30609. OBJECTSPACE_NORMALMAP: boolean;
  30610. USELIGHTMAPASSHADOWMAP: boolean;
  30611. REFLECTIONMAP_3D: boolean;
  30612. REFLECTIONMAP_SPHERICAL: boolean;
  30613. REFLECTIONMAP_PLANAR: boolean;
  30614. REFLECTIONMAP_CUBIC: boolean;
  30615. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30616. REFLECTIONMAP_PROJECTION: boolean;
  30617. REFLECTIONMAP_SKYBOX: boolean;
  30618. REFLECTIONMAP_EXPLICIT: boolean;
  30619. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30620. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30621. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30622. INVERTCUBICMAP: boolean;
  30623. LOGARITHMICDEPTH: boolean;
  30624. REFRACTION: boolean;
  30625. REFRACTIONMAP_3D: boolean;
  30626. REFLECTIONOVERALPHA: boolean;
  30627. TWOSIDEDLIGHTING: boolean;
  30628. SHADOWFLOAT: boolean;
  30629. MORPHTARGETS: boolean;
  30630. MORPHTARGETS_NORMAL: boolean;
  30631. MORPHTARGETS_TANGENT: boolean;
  30632. MORPHTARGETS_UV: boolean;
  30633. NUM_MORPH_INFLUENCERS: number;
  30634. NONUNIFORMSCALING: boolean;
  30635. PREMULTIPLYALPHA: boolean;
  30636. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30637. ALPHABLEND: boolean;
  30638. RGBDLIGHTMAP: boolean;
  30639. RGBDREFLECTION: boolean;
  30640. RGBDREFRACTION: boolean;
  30641. IMAGEPROCESSING: boolean;
  30642. VIGNETTE: boolean;
  30643. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30644. VIGNETTEBLENDMODEOPAQUE: boolean;
  30645. TONEMAPPING: boolean;
  30646. TONEMAPPING_ACES: boolean;
  30647. CONTRAST: boolean;
  30648. COLORCURVES: boolean;
  30649. COLORGRADING: boolean;
  30650. COLORGRADING3D: boolean;
  30651. SAMPLER3DGREENDEPTH: boolean;
  30652. SAMPLER3DBGRMAP: boolean;
  30653. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30654. MULTIVIEW: boolean;
  30655. /**
  30656. * If the reflection texture on this material is in linear color space
  30657. * @hidden
  30658. */
  30659. IS_REFLECTION_LINEAR: boolean;
  30660. /**
  30661. * If the refraction texture on this material is in linear color space
  30662. * @hidden
  30663. */
  30664. IS_REFRACTION_LINEAR: boolean;
  30665. EXPOSURE: boolean;
  30666. constructor();
  30667. setReflectionMode(modeToEnable: string): void;
  30668. }
  30669. /**
  30670. * This is the default material used in Babylon. It is the best trade off between quality
  30671. * and performances.
  30672. * @see http://doc.babylonjs.com/babylon101/materials
  30673. */
  30674. export class StandardMaterial extends PushMaterial {
  30675. private _diffuseTexture;
  30676. /**
  30677. * The basic texture of the material as viewed under a light.
  30678. */
  30679. diffuseTexture: Nullable<BaseTexture>;
  30680. private _ambientTexture;
  30681. /**
  30682. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30683. */
  30684. ambientTexture: Nullable<BaseTexture>;
  30685. private _opacityTexture;
  30686. /**
  30687. * Define the transparency of the material from a texture.
  30688. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30689. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30690. */
  30691. opacityTexture: Nullable<BaseTexture>;
  30692. private _reflectionTexture;
  30693. /**
  30694. * Define the texture used to display the reflection.
  30695. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30696. */
  30697. reflectionTexture: Nullable<BaseTexture>;
  30698. private _emissiveTexture;
  30699. /**
  30700. * Define texture of the material as if self lit.
  30701. * This will be mixed in the final result even in the absence of light.
  30702. */
  30703. emissiveTexture: Nullable<BaseTexture>;
  30704. private _specularTexture;
  30705. /**
  30706. * Define how the color and intensity of the highlight given by the light in the material.
  30707. */
  30708. specularTexture: Nullable<BaseTexture>;
  30709. private _bumpTexture;
  30710. /**
  30711. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30712. * 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.
  30713. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  30714. */
  30715. bumpTexture: Nullable<BaseTexture>;
  30716. private _lightmapTexture;
  30717. /**
  30718. * Complex lighting can be computationally expensive to compute at runtime.
  30719. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30720. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  30721. */
  30722. lightmapTexture: Nullable<BaseTexture>;
  30723. private _refractionTexture;
  30724. /**
  30725. * Define the texture used to display the refraction.
  30726. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30727. */
  30728. refractionTexture: Nullable<BaseTexture>;
  30729. /**
  30730. * The color of the material lit by the environmental background lighting.
  30731. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30732. */
  30733. ambientColor: Color3;
  30734. /**
  30735. * The basic color of the material as viewed under a light.
  30736. */
  30737. diffuseColor: Color3;
  30738. /**
  30739. * Define how the color and intensity of the highlight given by the light in the material.
  30740. */
  30741. specularColor: Color3;
  30742. /**
  30743. * Define the color of the material as if self lit.
  30744. * This will be mixed in the final result even in the absence of light.
  30745. */
  30746. emissiveColor: Color3;
  30747. /**
  30748. * Defines how sharp are the highlights in the material.
  30749. * The bigger the value the sharper giving a more glossy feeling to the result.
  30750. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30751. */
  30752. specularPower: number;
  30753. private _useAlphaFromDiffuseTexture;
  30754. /**
  30755. * Does the transparency come from the diffuse texture alpha channel.
  30756. */
  30757. useAlphaFromDiffuseTexture: boolean;
  30758. private _useEmissiveAsIllumination;
  30759. /**
  30760. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30761. */
  30762. useEmissiveAsIllumination: boolean;
  30763. private _linkEmissiveWithDiffuse;
  30764. /**
  30765. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30766. * the emissive level when the final color is close to one.
  30767. */
  30768. linkEmissiveWithDiffuse: boolean;
  30769. private _useSpecularOverAlpha;
  30770. /**
  30771. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30772. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30773. */
  30774. useSpecularOverAlpha: boolean;
  30775. private _useReflectionOverAlpha;
  30776. /**
  30777. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30778. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30779. */
  30780. useReflectionOverAlpha: boolean;
  30781. private _disableLighting;
  30782. /**
  30783. * Does lights from the scene impacts this material.
  30784. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30785. */
  30786. disableLighting: boolean;
  30787. private _useObjectSpaceNormalMap;
  30788. /**
  30789. * Allows using an object space normal map (instead of tangent space).
  30790. */
  30791. useObjectSpaceNormalMap: boolean;
  30792. private _useParallax;
  30793. /**
  30794. * Is parallax enabled or not.
  30795. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  30796. */
  30797. useParallax: boolean;
  30798. private _useParallaxOcclusion;
  30799. /**
  30800. * Is parallax occlusion enabled or not.
  30801. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30802. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  30803. */
  30804. useParallaxOcclusion: boolean;
  30805. /**
  30806. * 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.
  30807. */
  30808. parallaxScaleBias: number;
  30809. private _roughness;
  30810. /**
  30811. * Helps to define how blurry the reflections should appears in the material.
  30812. */
  30813. roughness: number;
  30814. /**
  30815. * In case of refraction, define the value of the index of refraction.
  30816. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30817. */
  30818. indexOfRefraction: number;
  30819. /**
  30820. * Invert the refraction texture alongside the y axis.
  30821. * It can be useful with procedural textures or probe for instance.
  30822. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30823. */
  30824. invertRefractionY: boolean;
  30825. /**
  30826. * Defines the alpha limits in alpha test mode.
  30827. */
  30828. alphaCutOff: number;
  30829. private _useLightmapAsShadowmap;
  30830. /**
  30831. * In case of light mapping, define whether the map contains light or shadow informations.
  30832. */
  30833. useLightmapAsShadowmap: boolean;
  30834. private _diffuseFresnelParameters;
  30835. /**
  30836. * Define the diffuse fresnel parameters of the material.
  30837. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30838. */
  30839. diffuseFresnelParameters: FresnelParameters;
  30840. private _opacityFresnelParameters;
  30841. /**
  30842. * Define the opacity fresnel parameters of the material.
  30843. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30844. */
  30845. opacityFresnelParameters: FresnelParameters;
  30846. private _reflectionFresnelParameters;
  30847. /**
  30848. * Define the reflection fresnel parameters of the material.
  30849. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30850. */
  30851. reflectionFresnelParameters: FresnelParameters;
  30852. private _refractionFresnelParameters;
  30853. /**
  30854. * Define the refraction fresnel parameters of the material.
  30855. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30856. */
  30857. refractionFresnelParameters: FresnelParameters;
  30858. private _emissiveFresnelParameters;
  30859. /**
  30860. * Define the emissive fresnel parameters of the material.
  30861. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30862. */
  30863. emissiveFresnelParameters: FresnelParameters;
  30864. private _useReflectionFresnelFromSpecular;
  30865. /**
  30866. * If true automatically deducts the fresnels values from the material specularity.
  30867. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30868. */
  30869. useReflectionFresnelFromSpecular: boolean;
  30870. private _useGlossinessFromSpecularMapAlpha;
  30871. /**
  30872. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30873. */
  30874. useGlossinessFromSpecularMapAlpha: boolean;
  30875. private _maxSimultaneousLights;
  30876. /**
  30877. * Defines the maximum number of lights that can be used in the material
  30878. */
  30879. maxSimultaneousLights: number;
  30880. private _invertNormalMapX;
  30881. /**
  30882. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30883. */
  30884. invertNormalMapX: boolean;
  30885. private _invertNormalMapY;
  30886. /**
  30887. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30888. */
  30889. invertNormalMapY: boolean;
  30890. private _twoSidedLighting;
  30891. /**
  30892. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30893. */
  30894. twoSidedLighting: boolean;
  30895. /**
  30896. * Default configuration related to image processing available in the standard Material.
  30897. */
  30898. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30899. /**
  30900. * Gets the image processing configuration used either in this material.
  30901. */
  30902. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30903. /**
  30904. * Sets the Default image processing configuration used either in the this material.
  30905. *
  30906. * If sets to null, the scene one is in use.
  30907. */
  30908. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30909. /**
  30910. * Keep track of the image processing observer to allow dispose and replace.
  30911. */
  30912. private _imageProcessingObserver;
  30913. /**
  30914. * Attaches a new image processing configuration to the Standard Material.
  30915. * @param configuration
  30916. */
  30917. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30918. /**
  30919. * Gets wether the color curves effect is enabled.
  30920. */
  30921. get cameraColorCurvesEnabled(): boolean;
  30922. /**
  30923. * Sets wether the color curves effect is enabled.
  30924. */
  30925. set cameraColorCurvesEnabled(value: boolean);
  30926. /**
  30927. * Gets wether the color grading effect is enabled.
  30928. */
  30929. get cameraColorGradingEnabled(): boolean;
  30930. /**
  30931. * Gets wether the color grading effect is enabled.
  30932. */
  30933. set cameraColorGradingEnabled(value: boolean);
  30934. /**
  30935. * Gets wether tonemapping is enabled or not.
  30936. */
  30937. get cameraToneMappingEnabled(): boolean;
  30938. /**
  30939. * Sets wether tonemapping is enabled or not
  30940. */
  30941. set cameraToneMappingEnabled(value: boolean);
  30942. /**
  30943. * The camera exposure used on this material.
  30944. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30945. * This corresponds to a photographic exposure.
  30946. */
  30947. get cameraExposure(): number;
  30948. /**
  30949. * The camera exposure used on this material.
  30950. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30951. * This corresponds to a photographic exposure.
  30952. */
  30953. set cameraExposure(value: number);
  30954. /**
  30955. * Gets The camera contrast used on this material.
  30956. */
  30957. get cameraContrast(): number;
  30958. /**
  30959. * Sets The camera contrast used on this material.
  30960. */
  30961. set cameraContrast(value: number);
  30962. /**
  30963. * Gets the Color Grading 2D Lookup Texture.
  30964. */
  30965. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30966. /**
  30967. * Sets the Color Grading 2D Lookup Texture.
  30968. */
  30969. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30970. /**
  30971. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30972. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30973. * 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;
  30974. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30975. */
  30976. get cameraColorCurves(): Nullable<ColorCurves>;
  30977. /**
  30978. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30979. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30980. * 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;
  30981. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30982. */
  30983. set cameraColorCurves(value: Nullable<ColorCurves>);
  30984. /**
  30985. * Defines the detail map parameters for the material.
  30986. */
  30987. readonly detailMap: DetailMapConfiguration;
  30988. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30989. protected _worldViewProjectionMatrix: Matrix;
  30990. protected _globalAmbientColor: Color3;
  30991. protected _useLogarithmicDepth: boolean;
  30992. protected _rebuildInParallel: boolean;
  30993. /**
  30994. * Instantiates a new standard material.
  30995. * This is the default material used in Babylon. It is the best trade off between quality
  30996. * and performances.
  30997. * @see http://doc.babylonjs.com/babylon101/materials
  30998. * @param name Define the name of the material in the scene
  30999. * @param scene Define the scene the material belong to
  31000. */
  31001. constructor(name: string, scene: Scene);
  31002. /**
  31003. * Gets a boolean indicating that current material needs to register RTT
  31004. */
  31005. get hasRenderTargetTextures(): boolean;
  31006. /**
  31007. * Gets the current class name of the material e.g. "StandardMaterial"
  31008. * Mainly use in serialization.
  31009. * @returns the class name
  31010. */
  31011. getClassName(): string;
  31012. /**
  31013. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  31014. * You can try switching to logarithmic depth.
  31015. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  31016. */
  31017. get useLogarithmicDepth(): boolean;
  31018. set useLogarithmicDepth(value: boolean);
  31019. /**
  31020. * Specifies if the material will require alpha blending
  31021. * @returns a boolean specifying if alpha blending is needed
  31022. */
  31023. needAlphaBlending(): boolean;
  31024. /**
  31025. * Specifies if this material should be rendered in alpha test mode
  31026. * @returns a boolean specifying if an alpha test is needed.
  31027. */
  31028. needAlphaTesting(): boolean;
  31029. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  31030. /**
  31031. * Get the texture used for alpha test purpose.
  31032. * @returns the diffuse texture in case of the standard material.
  31033. */
  31034. getAlphaTestTexture(): Nullable<BaseTexture>;
  31035. /**
  31036. * Get if the submesh is ready to be used and all its information available.
  31037. * Child classes can use it to update shaders
  31038. * @param mesh defines the mesh to check
  31039. * @param subMesh defines which submesh to check
  31040. * @param useInstances specifies that instances should be used
  31041. * @returns a boolean indicating that the submesh is ready or not
  31042. */
  31043. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31044. /**
  31045. * Builds the material UBO layouts.
  31046. * Used internally during the effect preparation.
  31047. */
  31048. buildUniformLayout(): void;
  31049. /**
  31050. * Unbinds the material from the mesh
  31051. */
  31052. unbind(): void;
  31053. /**
  31054. * Binds the submesh to this material by preparing the effect and shader to draw
  31055. * @param world defines the world transformation matrix
  31056. * @param mesh defines the mesh containing the submesh
  31057. * @param subMesh defines the submesh to bind the material to
  31058. */
  31059. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31060. /**
  31061. * Get the list of animatables in the material.
  31062. * @returns the list of animatables object used in the material
  31063. */
  31064. getAnimatables(): IAnimatable[];
  31065. /**
  31066. * Gets the active textures from the material
  31067. * @returns an array of textures
  31068. */
  31069. getActiveTextures(): BaseTexture[];
  31070. /**
  31071. * Specifies if the material uses a texture
  31072. * @param texture defines the texture to check against the material
  31073. * @returns a boolean specifying if the material uses the texture
  31074. */
  31075. hasTexture(texture: BaseTexture): boolean;
  31076. /**
  31077. * Disposes the material
  31078. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31079. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31080. */
  31081. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31082. /**
  31083. * Makes a duplicate of the material, and gives it a new name
  31084. * @param name defines the new name for the duplicated material
  31085. * @returns the cloned material
  31086. */
  31087. clone(name: string): StandardMaterial;
  31088. /**
  31089. * Serializes this material in a JSON representation
  31090. * @returns the serialized material object
  31091. */
  31092. serialize(): any;
  31093. /**
  31094. * Creates a standard material from parsed material data
  31095. * @param source defines the JSON representation of the material
  31096. * @param scene defines the hosting scene
  31097. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31098. * @returns a new standard material
  31099. */
  31100. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31101. /**
  31102. * Are diffuse textures enabled in the application.
  31103. */
  31104. static get DiffuseTextureEnabled(): boolean;
  31105. static set DiffuseTextureEnabled(value: boolean);
  31106. /**
  31107. * Are detail textures enabled in the application.
  31108. */
  31109. static get DetailTextureEnabled(): boolean;
  31110. static set DetailTextureEnabled(value: boolean);
  31111. /**
  31112. * Are ambient textures enabled in the application.
  31113. */
  31114. static get AmbientTextureEnabled(): boolean;
  31115. static set AmbientTextureEnabled(value: boolean);
  31116. /**
  31117. * Are opacity textures enabled in the application.
  31118. */
  31119. static get OpacityTextureEnabled(): boolean;
  31120. static set OpacityTextureEnabled(value: boolean);
  31121. /**
  31122. * Are reflection textures enabled in the application.
  31123. */
  31124. static get ReflectionTextureEnabled(): boolean;
  31125. static set ReflectionTextureEnabled(value: boolean);
  31126. /**
  31127. * Are emissive textures enabled in the application.
  31128. */
  31129. static get EmissiveTextureEnabled(): boolean;
  31130. static set EmissiveTextureEnabled(value: boolean);
  31131. /**
  31132. * Are specular textures enabled in the application.
  31133. */
  31134. static get SpecularTextureEnabled(): boolean;
  31135. static set SpecularTextureEnabled(value: boolean);
  31136. /**
  31137. * Are bump textures enabled in the application.
  31138. */
  31139. static get BumpTextureEnabled(): boolean;
  31140. static set BumpTextureEnabled(value: boolean);
  31141. /**
  31142. * Are lightmap textures enabled in the application.
  31143. */
  31144. static get LightmapTextureEnabled(): boolean;
  31145. static set LightmapTextureEnabled(value: boolean);
  31146. /**
  31147. * Are refraction textures enabled in the application.
  31148. */
  31149. static get RefractionTextureEnabled(): boolean;
  31150. static set RefractionTextureEnabled(value: boolean);
  31151. /**
  31152. * Are color grading textures enabled in the application.
  31153. */
  31154. static get ColorGradingTextureEnabled(): boolean;
  31155. static set ColorGradingTextureEnabled(value: boolean);
  31156. /**
  31157. * Are fresnels enabled in the application.
  31158. */
  31159. static get FresnelEnabled(): boolean;
  31160. static set FresnelEnabled(value: boolean);
  31161. }
  31162. }
  31163. declare module "babylonjs/Particles/solidParticleSystem" {
  31164. import { Nullable } from "babylonjs/types";
  31165. import { Mesh } from "babylonjs/Meshes/mesh";
  31166. import { Scene, IDisposable } from "babylonjs/scene";
  31167. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  31168. import { Material } from "babylonjs/Materials/material";
  31169. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31170. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31171. /**
  31172. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31173. *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.
  31174. * The SPS is also a particle system. It provides some methods to manage the particles.
  31175. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31176. *
  31177. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  31178. */
  31179. export class SolidParticleSystem implements IDisposable {
  31180. /**
  31181. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31182. * Example : var p = SPS.particles[i];
  31183. */
  31184. particles: SolidParticle[];
  31185. /**
  31186. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31187. */
  31188. nbParticles: number;
  31189. /**
  31190. * If the particles must ever face the camera (default false). Useful for planar particles.
  31191. */
  31192. billboard: boolean;
  31193. /**
  31194. * Recompute normals when adding a shape
  31195. */
  31196. recomputeNormals: boolean;
  31197. /**
  31198. * This a counter ofr your own usage. It's not set by any SPS functions.
  31199. */
  31200. counter: number;
  31201. /**
  31202. * The SPS name. This name is also given to the underlying mesh.
  31203. */
  31204. name: string;
  31205. /**
  31206. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31207. */
  31208. mesh: Mesh;
  31209. /**
  31210. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31211. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31212. */
  31213. vars: any;
  31214. /**
  31215. * This array is populated when the SPS is set as 'pickable'.
  31216. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31217. * Each element of this array is an object `{idx: int, faceId: int}`.
  31218. * `idx` is the picked particle index in the `SPS.particles` array
  31219. * `faceId` is the picked face index counted within this particle.
  31220. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31221. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31222. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31223. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31224. */
  31225. pickedParticles: {
  31226. idx: number;
  31227. faceId: number;
  31228. }[];
  31229. /**
  31230. * This array is populated when the SPS is set as 'pickable'
  31231. * Each key of this array is a submesh index.
  31232. * Each element of this array is a second array defined like this :
  31233. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31234. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31235. * `idx` is the picked particle index in the `SPS.particles` array
  31236. * `faceId` is the picked face index counted within this particle.
  31237. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31238. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31239. */
  31240. pickedBySubMesh: {
  31241. idx: number;
  31242. faceId: number;
  31243. }[][];
  31244. /**
  31245. * This array is populated when `enableDepthSort` is set to true.
  31246. * Each element of this array is an instance of the class DepthSortedParticle.
  31247. */
  31248. depthSortedParticles: DepthSortedParticle[];
  31249. /**
  31250. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31251. * @hidden
  31252. */
  31253. _bSphereOnly: boolean;
  31254. /**
  31255. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31256. * @hidden
  31257. */
  31258. _bSphereRadiusFactor: number;
  31259. private _scene;
  31260. private _positions;
  31261. private _indices;
  31262. private _normals;
  31263. private _colors;
  31264. private _uvs;
  31265. private _indices32;
  31266. private _positions32;
  31267. private _normals32;
  31268. private _fixedNormal32;
  31269. private _colors32;
  31270. private _uvs32;
  31271. private _index;
  31272. private _updatable;
  31273. private _pickable;
  31274. private _isVisibilityBoxLocked;
  31275. private _alwaysVisible;
  31276. private _depthSort;
  31277. private _expandable;
  31278. private _shapeCounter;
  31279. private _copy;
  31280. private _color;
  31281. private _computeParticleColor;
  31282. private _computeParticleTexture;
  31283. private _computeParticleRotation;
  31284. private _computeParticleVertex;
  31285. private _computeBoundingBox;
  31286. private _depthSortParticles;
  31287. private _camera;
  31288. private _mustUnrotateFixedNormals;
  31289. private _particlesIntersect;
  31290. private _needs32Bits;
  31291. private _isNotBuilt;
  31292. private _lastParticleId;
  31293. private _idxOfId;
  31294. private _multimaterialEnabled;
  31295. private _useModelMaterial;
  31296. private _indicesByMaterial;
  31297. private _materialIndexes;
  31298. private _depthSortFunction;
  31299. private _materialSortFunction;
  31300. private _materials;
  31301. private _multimaterial;
  31302. private _materialIndexesById;
  31303. private _defaultMaterial;
  31304. private _autoUpdateSubMeshes;
  31305. private _tmpVertex;
  31306. /**
  31307. * Creates a SPS (Solid Particle System) object.
  31308. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31309. * @param scene (Scene) is the scene in which the SPS is added.
  31310. * @param options defines the options of the sps e.g.
  31311. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31312. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31313. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31314. * * 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.
  31315. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31316. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31317. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31318. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31319. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31320. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31321. */
  31322. constructor(name: string, scene: Scene, options?: {
  31323. updatable?: boolean;
  31324. isPickable?: boolean;
  31325. enableDepthSort?: boolean;
  31326. particleIntersection?: boolean;
  31327. boundingSphereOnly?: boolean;
  31328. bSphereRadiusFactor?: number;
  31329. expandable?: boolean;
  31330. useModelMaterial?: boolean;
  31331. enableMultiMaterial?: boolean;
  31332. });
  31333. /**
  31334. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31335. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31336. * @returns the created mesh
  31337. */
  31338. buildMesh(): Mesh;
  31339. /**
  31340. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31341. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31342. * Thus the particles generated from `digest()` have their property `position` set yet.
  31343. * @param mesh ( Mesh ) is the mesh to be digested
  31344. * @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
  31345. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31346. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31347. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31348. * @returns the current SPS
  31349. */
  31350. digest(mesh: Mesh, options?: {
  31351. facetNb?: number;
  31352. number?: number;
  31353. delta?: number;
  31354. storage?: [];
  31355. }): SolidParticleSystem;
  31356. /**
  31357. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31358. * @hidden
  31359. */
  31360. private _unrotateFixedNormals;
  31361. /**
  31362. * Resets the temporary working copy particle
  31363. * @hidden
  31364. */
  31365. private _resetCopy;
  31366. /**
  31367. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31368. * @param p the current index in the positions array to be updated
  31369. * @param ind the current index in the indices array
  31370. * @param shape a Vector3 array, the shape geometry
  31371. * @param positions the positions array to be updated
  31372. * @param meshInd the shape indices array
  31373. * @param indices the indices array to be updated
  31374. * @param meshUV the shape uv array
  31375. * @param uvs the uv array to be updated
  31376. * @param meshCol the shape color array
  31377. * @param colors the color array to be updated
  31378. * @param meshNor the shape normals array
  31379. * @param normals the normals array to be updated
  31380. * @param idx the particle index
  31381. * @param idxInShape the particle index in its shape
  31382. * @param options the addShape() method passed options
  31383. * @model the particle model
  31384. * @hidden
  31385. */
  31386. private _meshBuilder;
  31387. /**
  31388. * Returns a shape Vector3 array from positions float array
  31389. * @param positions float array
  31390. * @returns a vector3 array
  31391. * @hidden
  31392. */
  31393. private _posToShape;
  31394. /**
  31395. * Returns a shapeUV array from a float uvs (array deep copy)
  31396. * @param uvs as a float array
  31397. * @returns a shapeUV array
  31398. * @hidden
  31399. */
  31400. private _uvsToShapeUV;
  31401. /**
  31402. * Adds a new particle object in the particles array
  31403. * @param idx particle index in particles array
  31404. * @param id particle id
  31405. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31406. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31407. * @param model particle ModelShape object
  31408. * @param shapeId model shape identifier
  31409. * @param idxInShape index of the particle in the current model
  31410. * @param bInfo model bounding info object
  31411. * @param storage target storage array, if any
  31412. * @hidden
  31413. */
  31414. private _addParticle;
  31415. /**
  31416. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31417. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31418. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31419. * @param nb (positive integer) the number of particles to be created from this model
  31420. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31421. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31422. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31423. * @returns the number of shapes in the system
  31424. */
  31425. addShape(mesh: Mesh, nb: number, options?: {
  31426. positionFunction?: any;
  31427. vertexFunction?: any;
  31428. storage?: [];
  31429. }): number;
  31430. /**
  31431. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31432. * @hidden
  31433. */
  31434. private _rebuildParticle;
  31435. /**
  31436. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31437. * @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.
  31438. * @returns the SPS.
  31439. */
  31440. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31441. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31442. * Returns an array with the removed particles.
  31443. * 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.
  31444. * The SPS can't be empty so at least one particle needs to remain in place.
  31445. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31446. * @param start index of the first particle to remove
  31447. * @param end index of the last particle to remove (included)
  31448. * @returns an array populated with the removed particles
  31449. */
  31450. removeParticles(start: number, end: number): SolidParticle[];
  31451. /**
  31452. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31453. * @param solidParticleArray an array populated with Solid Particles objects
  31454. * @returns the SPS
  31455. */
  31456. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31457. /**
  31458. * Creates a new particle and modifies the SPS mesh geometry :
  31459. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31460. * - calls _addParticle() to populate the particle array
  31461. * factorized code from addShape() and insertParticlesFromArray()
  31462. * @param idx particle index in the particles array
  31463. * @param i particle index in its shape
  31464. * @param modelShape particle ModelShape object
  31465. * @param shape shape vertex array
  31466. * @param meshInd shape indices array
  31467. * @param meshUV shape uv array
  31468. * @param meshCol shape color array
  31469. * @param meshNor shape normals array
  31470. * @param bbInfo shape bounding info
  31471. * @param storage target particle storage
  31472. * @options addShape() passed options
  31473. * @hidden
  31474. */
  31475. private _insertNewParticle;
  31476. /**
  31477. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31478. * This method calls `updateParticle()` for each particle of the SPS.
  31479. * For an animated SPS, it is usually called within the render loop.
  31480. * 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.
  31481. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31482. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31483. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31484. * @returns the SPS.
  31485. */
  31486. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31487. /**
  31488. * Disposes the SPS.
  31489. */
  31490. dispose(): void;
  31491. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31492. * idx is the particle index in the SPS
  31493. * faceId is the picked face index counted within this particle.
  31494. * Returns null if the pickInfo can't identify a picked particle.
  31495. * @param pickingInfo (PickingInfo object)
  31496. * @returns {idx: number, faceId: number} or null
  31497. */
  31498. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31499. idx: number;
  31500. faceId: number;
  31501. }>;
  31502. /**
  31503. * Returns a SolidParticle object from its identifier : particle.id
  31504. * @param id (integer) the particle Id
  31505. * @returns the searched particle or null if not found in the SPS.
  31506. */
  31507. getParticleById(id: number): Nullable<SolidParticle>;
  31508. /**
  31509. * Returns a new array populated with the particles having the passed shapeId.
  31510. * @param shapeId (integer) the shape identifier
  31511. * @returns a new solid particle array
  31512. */
  31513. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31514. /**
  31515. * Populates the passed array "ref" with the particles having the passed shapeId.
  31516. * @param shapeId the shape identifier
  31517. * @returns the SPS
  31518. * @param ref
  31519. */
  31520. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31521. /**
  31522. * Computes the required SubMeshes according the materials assigned to the particles.
  31523. * @returns the solid particle system.
  31524. * Does nothing if called before the SPS mesh is built.
  31525. */
  31526. computeSubMeshes(): SolidParticleSystem;
  31527. /**
  31528. * Sorts the solid particles by material when MultiMaterial is enabled.
  31529. * Updates the indices32 array.
  31530. * Updates the indicesByMaterial array.
  31531. * Updates the mesh indices array.
  31532. * @returns the SPS
  31533. * @hidden
  31534. */
  31535. private _sortParticlesByMaterial;
  31536. /**
  31537. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31538. * @hidden
  31539. */
  31540. private _setMaterialIndexesById;
  31541. /**
  31542. * Returns an array with unique values of Materials from the passed array
  31543. * @param array the material array to be checked and filtered
  31544. * @hidden
  31545. */
  31546. private _filterUniqueMaterialId;
  31547. /**
  31548. * Sets a new Standard Material as _defaultMaterial if not already set.
  31549. * @hidden
  31550. */
  31551. private _setDefaultMaterial;
  31552. /**
  31553. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31554. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31555. * @returns the SPS.
  31556. */
  31557. refreshVisibleSize(): SolidParticleSystem;
  31558. /**
  31559. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31560. * @param size the size (float) of the visibility box
  31561. * note : this doesn't lock the SPS mesh bounding box.
  31562. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31563. */
  31564. setVisibilityBox(size: number): void;
  31565. /**
  31566. * Gets whether the SPS as always visible or not
  31567. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31568. */
  31569. get isAlwaysVisible(): boolean;
  31570. /**
  31571. * Sets the SPS as always visible or not
  31572. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31573. */
  31574. set isAlwaysVisible(val: boolean);
  31575. /**
  31576. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31577. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31578. */
  31579. set isVisibilityBoxLocked(val: boolean);
  31580. /**
  31581. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31582. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31583. */
  31584. get isVisibilityBoxLocked(): boolean;
  31585. /**
  31586. * Tells to `setParticles()` to compute the particle rotations or not.
  31587. * Default value : true. The SPS is faster when it's set to false.
  31588. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31589. */
  31590. set computeParticleRotation(val: boolean);
  31591. /**
  31592. * Tells to `setParticles()` to compute the particle colors or not.
  31593. * Default value : true. The SPS is faster when it's set to false.
  31594. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31595. */
  31596. set computeParticleColor(val: boolean);
  31597. set computeParticleTexture(val: boolean);
  31598. /**
  31599. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31600. * Default value : false. The SPS is faster when it's set to false.
  31601. * Note : the particle custom vertex positions aren't stored values.
  31602. */
  31603. set computeParticleVertex(val: boolean);
  31604. /**
  31605. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31606. */
  31607. set computeBoundingBox(val: boolean);
  31608. /**
  31609. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31610. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31611. * Default : `true`
  31612. */
  31613. set depthSortParticles(val: boolean);
  31614. /**
  31615. * Gets if `setParticles()` computes the particle rotations or not.
  31616. * Default value : true. The SPS is faster when it's set to false.
  31617. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31618. */
  31619. get computeParticleRotation(): boolean;
  31620. /**
  31621. * Gets if `setParticles()` computes the particle colors or not.
  31622. * Default value : true. The SPS is faster when it's set to false.
  31623. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31624. */
  31625. get computeParticleColor(): boolean;
  31626. /**
  31627. * Gets if `setParticles()` computes the particle textures or not.
  31628. * Default value : true. The SPS is faster when it's set to false.
  31629. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31630. */
  31631. get computeParticleTexture(): boolean;
  31632. /**
  31633. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31634. * Default value : false. The SPS is faster when it's set to false.
  31635. * Note : the particle custom vertex positions aren't stored values.
  31636. */
  31637. get computeParticleVertex(): boolean;
  31638. /**
  31639. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31640. */
  31641. get computeBoundingBox(): boolean;
  31642. /**
  31643. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31644. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31645. * Default : `true`
  31646. */
  31647. get depthSortParticles(): boolean;
  31648. /**
  31649. * Gets if the SPS is created as expandable at construction time.
  31650. * Default : `false`
  31651. */
  31652. get expandable(): boolean;
  31653. /**
  31654. * Gets if the SPS supports the Multi Materials
  31655. */
  31656. get multimaterialEnabled(): boolean;
  31657. /**
  31658. * Gets if the SPS uses the model materials for its own multimaterial.
  31659. */
  31660. get useModelMaterial(): boolean;
  31661. /**
  31662. * The SPS used material array.
  31663. */
  31664. get materials(): Material[];
  31665. /**
  31666. * Sets the SPS MultiMaterial from the passed materials.
  31667. * Note : the passed array is internally copied and not used then by reference.
  31668. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31669. */
  31670. setMultiMaterial(materials: Material[]): void;
  31671. /**
  31672. * The SPS computed multimaterial object
  31673. */
  31674. get multimaterial(): MultiMaterial;
  31675. set multimaterial(mm: MultiMaterial);
  31676. /**
  31677. * If the subMeshes must be updated on the next call to setParticles()
  31678. */
  31679. get autoUpdateSubMeshes(): boolean;
  31680. set autoUpdateSubMeshes(val: boolean);
  31681. /**
  31682. * This function does nothing. It may be overwritten to set all the particle first values.
  31683. * The SPS doesn't call this function, you may have to call it by your own.
  31684. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31685. */
  31686. initParticles(): void;
  31687. /**
  31688. * This function does nothing. It may be overwritten to recycle a particle.
  31689. * The SPS doesn't call this function, you may have to call it by your own.
  31690. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31691. * @param particle The particle to recycle
  31692. * @returns the recycled particle
  31693. */
  31694. recycleParticle(particle: SolidParticle): SolidParticle;
  31695. /**
  31696. * Updates a particle : this function should be overwritten by the user.
  31697. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31698. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31699. * @example : just set a particle position or velocity and recycle conditions
  31700. * @param particle The particle to update
  31701. * @returns the updated particle
  31702. */
  31703. updateParticle(particle: SolidParticle): SolidParticle;
  31704. /**
  31705. * Updates a vertex of a particle : it can be overwritten by the user.
  31706. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31707. * @param particle the current particle
  31708. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31709. * @param pt the index of the current vertex in the particle shape
  31710. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31711. * @example : just set a vertex particle position or color
  31712. * @returns the sps
  31713. */
  31714. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31715. /**
  31716. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31717. * This does nothing and may be overwritten by the user.
  31718. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31719. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31720. * @param update the boolean update value actually passed to setParticles()
  31721. */
  31722. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31723. /**
  31724. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31725. * This will be passed three parameters.
  31726. * This does nothing and may be overwritten by the user.
  31727. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31728. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31729. * @param update the boolean update value actually passed to setParticles()
  31730. */
  31731. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31732. }
  31733. }
  31734. declare module "babylonjs/Particles/solidParticle" {
  31735. import { Nullable } from "babylonjs/types";
  31736. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  31737. import { Color4 } from "babylonjs/Maths/math.color";
  31738. import { Mesh } from "babylonjs/Meshes/mesh";
  31739. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31740. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  31741. import { Plane } from "babylonjs/Maths/math.plane";
  31742. import { Material } from "babylonjs/Materials/material";
  31743. /**
  31744. * Represents one particle of a solid particle system.
  31745. */
  31746. export class SolidParticle {
  31747. /**
  31748. * particle global index
  31749. */
  31750. idx: number;
  31751. /**
  31752. * particle identifier
  31753. */
  31754. id: number;
  31755. /**
  31756. * The color of the particle
  31757. */
  31758. color: Nullable<Color4>;
  31759. /**
  31760. * The world space position of the particle.
  31761. */
  31762. position: Vector3;
  31763. /**
  31764. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31765. */
  31766. rotation: Vector3;
  31767. /**
  31768. * The world space rotation quaternion of the particle.
  31769. */
  31770. rotationQuaternion: Nullable<Quaternion>;
  31771. /**
  31772. * The scaling of the particle.
  31773. */
  31774. scaling: Vector3;
  31775. /**
  31776. * The uvs of the particle.
  31777. */
  31778. uvs: Vector4;
  31779. /**
  31780. * The current speed of the particle.
  31781. */
  31782. velocity: Vector3;
  31783. /**
  31784. * The pivot point in the particle local space.
  31785. */
  31786. pivot: Vector3;
  31787. /**
  31788. * Must the particle be translated from its pivot point in its local space ?
  31789. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31790. * Default : false
  31791. */
  31792. translateFromPivot: boolean;
  31793. /**
  31794. * Is the particle active or not ?
  31795. */
  31796. alive: boolean;
  31797. /**
  31798. * Is the particle visible or not ?
  31799. */
  31800. isVisible: boolean;
  31801. /**
  31802. * Index of this particle in the global "positions" array (Internal use)
  31803. * @hidden
  31804. */
  31805. _pos: number;
  31806. /**
  31807. * @hidden Index of this particle in the global "indices" array (Internal use)
  31808. */
  31809. _ind: number;
  31810. /**
  31811. * @hidden ModelShape of this particle (Internal use)
  31812. */
  31813. _model: ModelShape;
  31814. /**
  31815. * ModelShape id of this particle
  31816. */
  31817. shapeId: number;
  31818. /**
  31819. * Index of the particle in its shape id
  31820. */
  31821. idxInShape: number;
  31822. /**
  31823. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31824. */
  31825. _modelBoundingInfo: BoundingInfo;
  31826. /**
  31827. * @hidden Particle BoundingInfo object (Internal use)
  31828. */
  31829. _boundingInfo: BoundingInfo;
  31830. /**
  31831. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31832. */
  31833. _sps: SolidParticleSystem;
  31834. /**
  31835. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31836. */
  31837. _stillInvisible: boolean;
  31838. /**
  31839. * @hidden Last computed particle rotation matrix
  31840. */
  31841. _rotationMatrix: number[];
  31842. /**
  31843. * Parent particle Id, if any.
  31844. * Default null.
  31845. */
  31846. parentId: Nullable<number>;
  31847. /**
  31848. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31849. */
  31850. materialIndex: Nullable<number>;
  31851. /**
  31852. * Custom object or properties.
  31853. */
  31854. props: Nullable<any>;
  31855. /**
  31856. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31857. * The possible values are :
  31858. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31859. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31860. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31861. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31862. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31863. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31864. * */
  31865. cullingStrategy: number;
  31866. /**
  31867. * @hidden Internal global position in the SPS.
  31868. */
  31869. _globalPosition: Vector3;
  31870. /**
  31871. * Creates a Solid Particle object.
  31872. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31873. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31874. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31875. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31876. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31877. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31878. * @param shapeId (integer) is the model shape identifier in the SPS.
  31879. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31880. * @param sps defines the sps it is associated to
  31881. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31882. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31883. */
  31884. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31885. /**
  31886. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31887. * @param target the particle target
  31888. * @returns the current particle
  31889. */
  31890. copyToRef(target: SolidParticle): SolidParticle;
  31891. /**
  31892. * Legacy support, changed scale to scaling
  31893. */
  31894. get scale(): Vector3;
  31895. /**
  31896. * Legacy support, changed scale to scaling
  31897. */
  31898. set scale(scale: Vector3);
  31899. /**
  31900. * Legacy support, changed quaternion to rotationQuaternion
  31901. */
  31902. get quaternion(): Nullable<Quaternion>;
  31903. /**
  31904. * Legacy support, changed quaternion to rotationQuaternion
  31905. */
  31906. set quaternion(q: Nullable<Quaternion>);
  31907. /**
  31908. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31909. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31910. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31911. * @returns true if it intersects
  31912. */
  31913. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31914. /**
  31915. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31916. * A particle is in the frustum if its bounding box intersects the frustum
  31917. * @param frustumPlanes defines the frustum to test
  31918. * @returns true if the particle is in the frustum planes
  31919. */
  31920. isInFrustum(frustumPlanes: Plane[]): boolean;
  31921. /**
  31922. * get the rotation matrix of the particle
  31923. * @hidden
  31924. */
  31925. getRotationMatrix(m: Matrix): void;
  31926. }
  31927. /**
  31928. * Represents the shape of the model used by one particle of a solid particle system.
  31929. * SPS internal tool, don't use it manually.
  31930. */
  31931. export class ModelShape {
  31932. /**
  31933. * The shape id
  31934. * @hidden
  31935. */
  31936. shapeID: number;
  31937. /**
  31938. * flat array of model positions (internal use)
  31939. * @hidden
  31940. */
  31941. _shape: Vector3[];
  31942. /**
  31943. * flat array of model UVs (internal use)
  31944. * @hidden
  31945. */
  31946. _shapeUV: number[];
  31947. /**
  31948. * color array of the model
  31949. * @hidden
  31950. */
  31951. _shapeColors: number[];
  31952. /**
  31953. * indices array of the model
  31954. * @hidden
  31955. */
  31956. _indices: number[];
  31957. /**
  31958. * normals array of the model
  31959. * @hidden
  31960. */
  31961. _normals: number[];
  31962. /**
  31963. * length of the shape in the model indices array (internal use)
  31964. * @hidden
  31965. */
  31966. _indicesLength: number;
  31967. /**
  31968. * Custom position function (internal use)
  31969. * @hidden
  31970. */
  31971. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31972. /**
  31973. * Custom vertex function (internal use)
  31974. * @hidden
  31975. */
  31976. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31977. /**
  31978. * Model material (internal use)
  31979. * @hidden
  31980. */
  31981. _material: Nullable<Material>;
  31982. /**
  31983. * 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.
  31984. * SPS internal tool, don't use it manually.
  31985. * @hidden
  31986. */
  31987. 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>);
  31988. }
  31989. /**
  31990. * Represents a Depth Sorted Particle in the solid particle system.
  31991. * @hidden
  31992. */
  31993. export class DepthSortedParticle {
  31994. /**
  31995. * Particle index
  31996. */
  31997. idx: number;
  31998. /**
  31999. * Index of the particle in the "indices" array
  32000. */
  32001. ind: number;
  32002. /**
  32003. * Length of the particle shape in the "indices" array
  32004. */
  32005. indicesLength: number;
  32006. /**
  32007. * Squared distance from the particle to the camera
  32008. */
  32009. sqDistance: number;
  32010. /**
  32011. * Material index when used with MultiMaterials
  32012. */
  32013. materialIndex: number;
  32014. /**
  32015. * Creates a new sorted particle
  32016. * @param materialIndex
  32017. */
  32018. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  32019. }
  32020. /**
  32021. * Represents a solid particle vertex
  32022. */
  32023. export class SolidParticleVertex {
  32024. /**
  32025. * Vertex position
  32026. */
  32027. position: Vector3;
  32028. /**
  32029. * Vertex color
  32030. */
  32031. color: Color4;
  32032. /**
  32033. * Vertex UV
  32034. */
  32035. uv: Vector2;
  32036. /**
  32037. * Creates a new solid particle vertex
  32038. */
  32039. constructor();
  32040. /** Vertex x coordinate */
  32041. get x(): number;
  32042. set x(val: number);
  32043. /** Vertex y coordinate */
  32044. get y(): number;
  32045. set y(val: number);
  32046. /** Vertex z coordinate */
  32047. get z(): number;
  32048. set z(val: number);
  32049. }
  32050. }
  32051. declare module "babylonjs/Collisions/meshCollisionData" {
  32052. import { Collider } from "babylonjs/Collisions/collider";
  32053. import { Vector3 } from "babylonjs/Maths/math.vector";
  32054. import { Nullable } from "babylonjs/types";
  32055. import { Observer } from "babylonjs/Misc/observable";
  32056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32057. /**
  32058. * @hidden
  32059. */
  32060. export class _MeshCollisionData {
  32061. _checkCollisions: boolean;
  32062. _collisionMask: number;
  32063. _collisionGroup: number;
  32064. _surroundingMeshes: Nullable<AbstractMesh[]>;
  32065. _collider: Nullable<Collider>;
  32066. _oldPositionForCollisions: Vector3;
  32067. _diffPositionForCollisions: Vector3;
  32068. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  32069. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  32070. }
  32071. }
  32072. declare module "babylonjs/Meshes/abstractMesh" {
  32073. import { Observable } from "babylonjs/Misc/observable";
  32074. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  32075. import { Camera } from "babylonjs/Cameras/camera";
  32076. import { Scene, IDisposable } from "babylonjs/scene";
  32077. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  32078. import { Node } from "babylonjs/node";
  32079. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  32080. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32081. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32082. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32083. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32084. import { Material } from "babylonjs/Materials/material";
  32085. import { Light } from "babylonjs/Lights/light";
  32086. import { Skeleton } from "babylonjs/Bones/skeleton";
  32087. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  32088. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  32089. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32090. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  32091. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  32092. import { Plane } from "babylonjs/Maths/math.plane";
  32093. import { Ray } from "babylonjs/Culling/ray";
  32094. import { Collider } from "babylonjs/Collisions/collider";
  32095. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32096. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  32097. /** @hidden */
  32098. class _FacetDataStorage {
  32099. facetPositions: Vector3[];
  32100. facetNormals: Vector3[];
  32101. facetPartitioning: number[][];
  32102. facetNb: number;
  32103. partitioningSubdivisions: number;
  32104. partitioningBBoxRatio: number;
  32105. facetDataEnabled: boolean;
  32106. facetParameters: any;
  32107. bbSize: Vector3;
  32108. subDiv: {
  32109. max: number;
  32110. X: number;
  32111. Y: number;
  32112. Z: number;
  32113. };
  32114. facetDepthSort: boolean;
  32115. facetDepthSortEnabled: boolean;
  32116. depthSortedIndices: IndicesArray;
  32117. depthSortedFacets: {
  32118. ind: number;
  32119. sqDistance: number;
  32120. }[];
  32121. facetDepthSortFunction: (f1: {
  32122. ind: number;
  32123. sqDistance: number;
  32124. }, f2: {
  32125. ind: number;
  32126. sqDistance: number;
  32127. }) => number;
  32128. facetDepthSortFrom: Vector3;
  32129. facetDepthSortOrigin: Vector3;
  32130. invertedMatrix: Matrix;
  32131. }
  32132. /**
  32133. * @hidden
  32134. **/
  32135. class _InternalAbstractMeshDataInfo {
  32136. _hasVertexAlpha: boolean;
  32137. _useVertexColors: boolean;
  32138. _numBoneInfluencers: number;
  32139. _applyFog: boolean;
  32140. _receiveShadows: boolean;
  32141. _facetData: _FacetDataStorage;
  32142. _visibility: number;
  32143. _skeleton: Nullable<Skeleton>;
  32144. _layerMask: number;
  32145. _computeBonesUsingShaders: boolean;
  32146. _isActive: boolean;
  32147. _onlyForInstances: boolean;
  32148. _isActiveIntermediate: boolean;
  32149. _onlyForInstancesIntermediate: boolean;
  32150. _actAsRegularMesh: boolean;
  32151. }
  32152. /**
  32153. * Class used to store all common mesh properties
  32154. */
  32155. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32156. /** No occlusion */
  32157. static OCCLUSION_TYPE_NONE: number;
  32158. /** Occlusion set to optimisitic */
  32159. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32160. /** Occlusion set to strict */
  32161. static OCCLUSION_TYPE_STRICT: number;
  32162. /** Use an accurante occlusion algorithm */
  32163. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32164. /** Use a conservative occlusion algorithm */
  32165. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32166. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32167. * Test order :
  32168. * Is the bounding sphere outside the frustum ?
  32169. * If not, are the bounding box vertices outside the frustum ?
  32170. * It not, then the cullable object is in the frustum.
  32171. */
  32172. static readonly CULLINGSTRATEGY_STANDARD: number;
  32173. /** Culling strategy : Bounding Sphere Only.
  32174. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32175. * It's also less accurate than the standard because some not visible objects can still be selected.
  32176. * Test : is the bounding sphere outside the frustum ?
  32177. * If not, then the cullable object is in the frustum.
  32178. */
  32179. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32180. /** Culling strategy : Optimistic Inclusion.
  32181. * This in an inclusion test first, then the standard exclusion test.
  32182. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32183. * 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.
  32184. * Anyway, it's as accurate as the standard strategy.
  32185. * Test :
  32186. * Is the cullable object bounding sphere center in the frustum ?
  32187. * If not, apply the default culling strategy.
  32188. */
  32189. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32190. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32191. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32192. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32193. * 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.
  32194. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32195. * Test :
  32196. * Is the cullable object bounding sphere center in the frustum ?
  32197. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32198. */
  32199. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32200. /**
  32201. * No billboard
  32202. */
  32203. static get BILLBOARDMODE_NONE(): number;
  32204. /** Billboard on X axis */
  32205. static get BILLBOARDMODE_X(): number;
  32206. /** Billboard on Y axis */
  32207. static get BILLBOARDMODE_Y(): number;
  32208. /** Billboard on Z axis */
  32209. static get BILLBOARDMODE_Z(): number;
  32210. /** Billboard on all axes */
  32211. static get BILLBOARDMODE_ALL(): number;
  32212. /** Billboard on using position instead of orientation */
  32213. static get BILLBOARDMODE_USE_POSITION(): number;
  32214. /** @hidden */
  32215. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32216. /**
  32217. * The culling strategy to use to check whether the mesh must be rendered or not.
  32218. * This value can be changed at any time and will be used on the next render mesh selection.
  32219. * The possible values are :
  32220. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32221. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32222. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32223. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32224. * Please read each static variable documentation to get details about the culling process.
  32225. * */
  32226. cullingStrategy: number;
  32227. /**
  32228. * Gets the number of facets in the mesh
  32229. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32230. */
  32231. get facetNb(): number;
  32232. /**
  32233. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32234. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32235. */
  32236. get partitioningSubdivisions(): number;
  32237. set partitioningSubdivisions(nb: number);
  32238. /**
  32239. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32240. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32242. */
  32243. get partitioningBBoxRatio(): number;
  32244. set partitioningBBoxRatio(ratio: number);
  32245. /**
  32246. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32247. * Works only for updatable meshes.
  32248. * Doesn't work with multi-materials
  32249. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32250. */
  32251. get mustDepthSortFacets(): boolean;
  32252. set mustDepthSortFacets(sort: boolean);
  32253. /**
  32254. * The location (Vector3) where the facet depth sort must be computed from.
  32255. * By default, the active camera position.
  32256. * Used only when facet depth sort is enabled
  32257. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32258. */
  32259. get facetDepthSortFrom(): Vector3;
  32260. set facetDepthSortFrom(location: Vector3);
  32261. /**
  32262. * gets a boolean indicating if facetData is enabled
  32263. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32264. */
  32265. get isFacetDataEnabled(): boolean;
  32266. /** @hidden */
  32267. _updateNonUniformScalingState(value: boolean): boolean;
  32268. /**
  32269. * An event triggered when this mesh collides with another one
  32270. */
  32271. onCollideObservable: Observable<AbstractMesh>;
  32272. /** Set a function to call when this mesh collides with another one */
  32273. set onCollide(callback: () => void);
  32274. /**
  32275. * An event triggered when the collision's position changes
  32276. */
  32277. onCollisionPositionChangeObservable: Observable<Vector3>;
  32278. /** Set a function to call when the collision's position changes */
  32279. set onCollisionPositionChange(callback: () => void);
  32280. /**
  32281. * An event triggered when material is changed
  32282. */
  32283. onMaterialChangedObservable: Observable<AbstractMesh>;
  32284. /**
  32285. * Gets or sets the orientation for POV movement & rotation
  32286. */
  32287. definedFacingForward: boolean;
  32288. /** @hidden */
  32289. _occlusionQuery: Nullable<WebGLQuery>;
  32290. /** @hidden */
  32291. _renderingGroup: Nullable<RenderingGroup>;
  32292. /**
  32293. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32294. */
  32295. get visibility(): number;
  32296. /**
  32297. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32298. */
  32299. set visibility(value: number);
  32300. /** Gets or sets the alpha index used to sort transparent meshes
  32301. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32302. */
  32303. alphaIndex: number;
  32304. /**
  32305. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32306. */
  32307. isVisible: boolean;
  32308. /**
  32309. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32310. */
  32311. isPickable: boolean;
  32312. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32313. showSubMeshesBoundingBox: boolean;
  32314. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32315. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32316. */
  32317. isBlocker: boolean;
  32318. /**
  32319. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32320. */
  32321. enablePointerMoveEvents: boolean;
  32322. /**
  32323. * Specifies the rendering group id for this mesh (0 by default)
  32324. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32325. */
  32326. renderingGroupId: number;
  32327. private _material;
  32328. /** Gets or sets current material */
  32329. get material(): Nullable<Material>;
  32330. set material(value: Nullable<Material>);
  32331. /**
  32332. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32333. * @see http://doc.babylonjs.com/babylon101/shadows
  32334. */
  32335. get receiveShadows(): boolean;
  32336. set receiveShadows(value: boolean);
  32337. /** Defines color to use when rendering outline */
  32338. outlineColor: Color3;
  32339. /** Define width to use when rendering outline */
  32340. outlineWidth: number;
  32341. /** Defines color to use when rendering overlay */
  32342. overlayColor: Color3;
  32343. /** Defines alpha to use when rendering overlay */
  32344. overlayAlpha: number;
  32345. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32346. get hasVertexAlpha(): boolean;
  32347. set hasVertexAlpha(value: boolean);
  32348. /** 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) */
  32349. get useVertexColors(): boolean;
  32350. set useVertexColors(value: boolean);
  32351. /**
  32352. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32353. */
  32354. get computeBonesUsingShaders(): boolean;
  32355. set computeBonesUsingShaders(value: boolean);
  32356. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32357. get numBoneInfluencers(): number;
  32358. set numBoneInfluencers(value: number);
  32359. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32360. get applyFog(): boolean;
  32361. set applyFog(value: boolean);
  32362. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32363. useOctreeForRenderingSelection: boolean;
  32364. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32365. useOctreeForPicking: boolean;
  32366. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32367. useOctreeForCollisions: boolean;
  32368. /**
  32369. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32370. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32371. */
  32372. get layerMask(): number;
  32373. set layerMask(value: number);
  32374. /**
  32375. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32376. */
  32377. alwaysSelectAsActiveMesh: boolean;
  32378. /**
  32379. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32380. */
  32381. doNotSyncBoundingInfo: boolean;
  32382. /**
  32383. * Gets or sets the current action manager
  32384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32385. */
  32386. actionManager: Nullable<AbstractActionManager>;
  32387. private _meshCollisionData;
  32388. /**
  32389. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32390. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32391. */
  32392. ellipsoid: Vector3;
  32393. /**
  32394. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32395. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32396. */
  32397. ellipsoidOffset: Vector3;
  32398. /**
  32399. * Gets or sets a collision mask used to mask collisions (default is -1).
  32400. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32401. */
  32402. get collisionMask(): number;
  32403. set collisionMask(mask: number);
  32404. /**
  32405. * Gets or sets the current collision group mask (-1 by default).
  32406. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32407. */
  32408. get collisionGroup(): number;
  32409. set collisionGroup(mask: number);
  32410. /**
  32411. * Gets or sets current surrounding meshes (null by default).
  32412. *
  32413. * By default collision detection is tested against every mesh in the scene.
  32414. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32415. * meshes will be tested for the collision.
  32416. *
  32417. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32418. */
  32419. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32420. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32421. /**
  32422. * Defines edge width used when edgesRenderer is enabled
  32423. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32424. */
  32425. edgesWidth: number;
  32426. /**
  32427. * Defines edge color used when edgesRenderer is enabled
  32428. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32429. */
  32430. edgesColor: Color4;
  32431. /** @hidden */
  32432. _edgesRenderer: Nullable<IEdgesRenderer>;
  32433. /** @hidden */
  32434. _masterMesh: Nullable<AbstractMesh>;
  32435. /** @hidden */
  32436. _boundingInfo: Nullable<BoundingInfo>;
  32437. /** @hidden */
  32438. _renderId: number;
  32439. /**
  32440. * Gets or sets the list of subMeshes
  32441. * @see http://doc.babylonjs.com/how_to/multi_materials
  32442. */
  32443. subMeshes: SubMesh[];
  32444. /** @hidden */
  32445. _intersectionsInProgress: AbstractMesh[];
  32446. /** @hidden */
  32447. _unIndexed: boolean;
  32448. /** @hidden */
  32449. _lightSources: Light[];
  32450. /** Gets the list of lights affecting that mesh */
  32451. get lightSources(): Light[];
  32452. /** @hidden */
  32453. get _positions(): Nullable<Vector3[]>;
  32454. /** @hidden */
  32455. _waitingData: {
  32456. lods: Nullable<any>;
  32457. actions: Nullable<any>;
  32458. freezeWorldMatrix: Nullable<boolean>;
  32459. };
  32460. /** @hidden */
  32461. _bonesTransformMatrices: Nullable<Float32Array>;
  32462. /** @hidden */
  32463. _transformMatrixTexture: Nullable<RawTexture>;
  32464. /**
  32465. * Gets or sets a skeleton to apply skining transformations
  32466. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32467. */
  32468. set skeleton(value: Nullable<Skeleton>);
  32469. get skeleton(): Nullable<Skeleton>;
  32470. /**
  32471. * An event triggered when the mesh is rebuilt.
  32472. */
  32473. onRebuildObservable: Observable<AbstractMesh>;
  32474. /**
  32475. * Creates a new AbstractMesh
  32476. * @param name defines the name of the mesh
  32477. * @param scene defines the hosting scene
  32478. */
  32479. constructor(name: string, scene?: Nullable<Scene>);
  32480. /**
  32481. * Returns the string "AbstractMesh"
  32482. * @returns "AbstractMesh"
  32483. */
  32484. getClassName(): string;
  32485. /**
  32486. * Gets a string representation of the current mesh
  32487. * @param fullDetails defines a boolean indicating if full details must be included
  32488. * @returns a string representation of the current mesh
  32489. */
  32490. toString(fullDetails?: boolean): string;
  32491. /**
  32492. * @hidden
  32493. */
  32494. protected _getEffectiveParent(): Nullable<Node>;
  32495. /** @hidden */
  32496. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32497. /** @hidden */
  32498. _rebuild(): void;
  32499. /** @hidden */
  32500. _resyncLightSources(): void;
  32501. /** @hidden */
  32502. _resyncLightSource(light: Light): void;
  32503. /** @hidden */
  32504. _unBindEffect(): void;
  32505. /** @hidden */
  32506. _removeLightSource(light: Light, dispose: boolean): void;
  32507. private _markSubMeshesAsDirty;
  32508. /** @hidden */
  32509. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32510. /** @hidden */
  32511. _markSubMeshesAsAttributesDirty(): void;
  32512. /** @hidden */
  32513. _markSubMeshesAsMiscDirty(): void;
  32514. /**
  32515. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32516. */
  32517. get scaling(): Vector3;
  32518. set scaling(newScaling: Vector3);
  32519. /**
  32520. * Returns true if the mesh is blocked. Implemented by child classes
  32521. */
  32522. get isBlocked(): boolean;
  32523. /**
  32524. * Returns the mesh itself by default. Implemented by child classes
  32525. * @param camera defines the camera to use to pick the right LOD level
  32526. * @returns the currentAbstractMesh
  32527. */
  32528. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32529. /**
  32530. * Returns 0 by default. Implemented by child classes
  32531. * @returns an integer
  32532. */
  32533. getTotalVertices(): number;
  32534. /**
  32535. * Returns a positive integer : the total number of indices in this mesh geometry.
  32536. * @returns the numner of indices or zero if the mesh has no geometry.
  32537. */
  32538. getTotalIndices(): number;
  32539. /**
  32540. * Returns null by default. Implemented by child classes
  32541. * @returns null
  32542. */
  32543. getIndices(): Nullable<IndicesArray>;
  32544. /**
  32545. * Returns the array of the requested vertex data kind. Implemented by child classes
  32546. * @param kind defines the vertex data kind to use
  32547. * @returns null
  32548. */
  32549. getVerticesData(kind: string): Nullable<FloatArray>;
  32550. /**
  32551. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32552. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32553. * Note that a new underlying VertexBuffer object is created each call.
  32554. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32555. * @param kind defines vertex data kind:
  32556. * * VertexBuffer.PositionKind
  32557. * * VertexBuffer.UVKind
  32558. * * VertexBuffer.UV2Kind
  32559. * * VertexBuffer.UV3Kind
  32560. * * VertexBuffer.UV4Kind
  32561. * * VertexBuffer.UV5Kind
  32562. * * VertexBuffer.UV6Kind
  32563. * * VertexBuffer.ColorKind
  32564. * * VertexBuffer.MatricesIndicesKind
  32565. * * VertexBuffer.MatricesIndicesExtraKind
  32566. * * VertexBuffer.MatricesWeightsKind
  32567. * * VertexBuffer.MatricesWeightsExtraKind
  32568. * @param data defines the data source
  32569. * @param updatable defines if the data must be flagged as updatable (or static)
  32570. * @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
  32571. * @returns the current mesh
  32572. */
  32573. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32574. /**
  32575. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32576. * If the mesh has no geometry, it is simply returned as it is.
  32577. * @param kind defines vertex data kind:
  32578. * * VertexBuffer.PositionKind
  32579. * * VertexBuffer.UVKind
  32580. * * VertexBuffer.UV2Kind
  32581. * * VertexBuffer.UV3Kind
  32582. * * VertexBuffer.UV4Kind
  32583. * * VertexBuffer.UV5Kind
  32584. * * VertexBuffer.UV6Kind
  32585. * * VertexBuffer.ColorKind
  32586. * * VertexBuffer.MatricesIndicesKind
  32587. * * VertexBuffer.MatricesIndicesExtraKind
  32588. * * VertexBuffer.MatricesWeightsKind
  32589. * * VertexBuffer.MatricesWeightsExtraKind
  32590. * @param data defines the data source
  32591. * @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
  32592. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32593. * @returns the current mesh
  32594. */
  32595. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32596. /**
  32597. * Sets the mesh indices,
  32598. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32599. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32600. * @param totalVertices Defines the total number of vertices
  32601. * @returns the current mesh
  32602. */
  32603. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32604. /**
  32605. * Gets a boolean indicating if specific vertex data is present
  32606. * @param kind defines the vertex data kind to use
  32607. * @returns true is data kind is present
  32608. */
  32609. isVerticesDataPresent(kind: string): boolean;
  32610. /**
  32611. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32612. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32613. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32614. * @returns a BoundingInfo
  32615. */
  32616. getBoundingInfo(): BoundingInfo;
  32617. /**
  32618. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32619. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32620. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32621. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32622. * @returns the current mesh
  32623. */
  32624. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32625. /**
  32626. * Overwrite the current bounding info
  32627. * @param boundingInfo defines the new bounding info
  32628. * @returns the current mesh
  32629. */
  32630. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32631. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32632. get useBones(): boolean;
  32633. /** @hidden */
  32634. _preActivate(): void;
  32635. /** @hidden */
  32636. _preActivateForIntermediateRendering(renderId: number): void;
  32637. /** @hidden */
  32638. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32639. /** @hidden */
  32640. _postActivate(): void;
  32641. /** @hidden */
  32642. _freeze(): void;
  32643. /** @hidden */
  32644. _unFreeze(): void;
  32645. /**
  32646. * Gets the current world matrix
  32647. * @returns a Matrix
  32648. */
  32649. getWorldMatrix(): Matrix;
  32650. /** @hidden */
  32651. _getWorldMatrixDeterminant(): number;
  32652. /**
  32653. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32654. */
  32655. get isAnInstance(): boolean;
  32656. /**
  32657. * Gets a boolean indicating if this mesh has instances
  32658. */
  32659. get hasInstances(): boolean;
  32660. /**
  32661. * Gets a boolean indicating if this mesh has thin instances
  32662. */
  32663. get hasThinInstances(): boolean;
  32664. /**
  32665. * Perform relative position change from the point of view of behind the front of the mesh.
  32666. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32667. * Supports definition of mesh facing forward or backward
  32668. * @param amountRight defines the distance on the right axis
  32669. * @param amountUp defines the distance on the up axis
  32670. * @param amountForward defines the distance on the forward axis
  32671. * @returns the current mesh
  32672. */
  32673. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32674. /**
  32675. * Calculate relative position change from the point of view of behind the front of the mesh.
  32676. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32677. * Supports definition of mesh facing forward or backward
  32678. * @param amountRight defines the distance on the right axis
  32679. * @param amountUp defines the distance on the up axis
  32680. * @param amountForward defines the distance on the forward axis
  32681. * @returns the new displacement vector
  32682. */
  32683. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32684. /**
  32685. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32686. * Supports definition of mesh facing forward or backward
  32687. * @param flipBack defines the flip
  32688. * @param twirlClockwise defines the twirl
  32689. * @param tiltRight defines the tilt
  32690. * @returns the current mesh
  32691. */
  32692. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32693. /**
  32694. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32695. * Supports definition of mesh facing forward or backward.
  32696. * @param flipBack defines the flip
  32697. * @param twirlClockwise defines the twirl
  32698. * @param tiltRight defines the tilt
  32699. * @returns the new rotation vector
  32700. */
  32701. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32702. /**
  32703. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32704. * This means the mesh underlying bounding box and sphere are recomputed.
  32705. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32706. * @returns the current mesh
  32707. */
  32708. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32709. /** @hidden */
  32710. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32711. /** @hidden */
  32712. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32713. /** @hidden */
  32714. _updateBoundingInfo(): AbstractMesh;
  32715. /** @hidden */
  32716. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32717. /** @hidden */
  32718. protected _afterComputeWorldMatrix(): void;
  32719. /** @hidden */
  32720. get _effectiveMesh(): AbstractMesh;
  32721. /**
  32722. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32723. * A mesh is in the frustum if its bounding box intersects the frustum
  32724. * @param frustumPlanes defines the frustum to test
  32725. * @returns true if the mesh is in the frustum planes
  32726. */
  32727. isInFrustum(frustumPlanes: Plane[]): boolean;
  32728. /**
  32729. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32730. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32731. * @param frustumPlanes defines the frustum to test
  32732. * @returns true if the mesh is completely in the frustum planes
  32733. */
  32734. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32735. /**
  32736. * True if the mesh intersects another mesh or a SolidParticle object
  32737. * @param mesh defines a target mesh or SolidParticle to test
  32738. * @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)
  32739. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32740. * @returns true if there is an intersection
  32741. */
  32742. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32743. /**
  32744. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32745. * @param point defines the point to test
  32746. * @returns true if there is an intersection
  32747. */
  32748. intersectsPoint(point: Vector3): boolean;
  32749. /**
  32750. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32751. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32752. */
  32753. get checkCollisions(): boolean;
  32754. set checkCollisions(collisionEnabled: boolean);
  32755. /**
  32756. * Gets Collider object used to compute collisions (not physics)
  32757. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32758. */
  32759. get collider(): Nullable<Collider>;
  32760. /**
  32761. * Move the mesh using collision engine
  32762. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32763. * @param displacement defines the requested displacement vector
  32764. * @returns the current mesh
  32765. */
  32766. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32767. private _onCollisionPositionChange;
  32768. /** @hidden */
  32769. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32770. /** @hidden */
  32771. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32772. /** @hidden */
  32773. _checkCollision(collider: Collider): AbstractMesh;
  32774. /** @hidden */
  32775. _generatePointsArray(): boolean;
  32776. /**
  32777. * Checks if the passed Ray intersects with the mesh
  32778. * @param ray defines the ray to use
  32779. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32780. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32781. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32782. * @returns the picking info
  32783. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32784. */
  32785. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  32786. /**
  32787. * Clones the current mesh
  32788. * @param name defines the mesh name
  32789. * @param newParent defines the new mesh parent
  32790. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32791. * @returns the new mesh
  32792. */
  32793. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32794. /**
  32795. * Disposes all the submeshes of the current meshnp
  32796. * @returns the current mesh
  32797. */
  32798. releaseSubMeshes(): AbstractMesh;
  32799. /**
  32800. * Releases resources associated with this abstract mesh.
  32801. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32802. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32803. */
  32804. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32805. /**
  32806. * Adds the passed mesh as a child to the current mesh
  32807. * @param mesh defines the child mesh
  32808. * @returns the current mesh
  32809. */
  32810. addChild(mesh: AbstractMesh): AbstractMesh;
  32811. /**
  32812. * Removes the passed mesh from the current mesh children list
  32813. * @param mesh defines the child mesh
  32814. * @returns the current mesh
  32815. */
  32816. removeChild(mesh: AbstractMesh): AbstractMesh;
  32817. /** @hidden */
  32818. private _initFacetData;
  32819. /**
  32820. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32821. * This method can be called within the render loop.
  32822. * 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
  32823. * @returns the current mesh
  32824. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32825. */
  32826. updateFacetData(): AbstractMesh;
  32827. /**
  32828. * Returns the facetLocalNormals array.
  32829. * The normals are expressed in the mesh local spac
  32830. * @returns an array of Vector3
  32831. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32832. */
  32833. getFacetLocalNormals(): Vector3[];
  32834. /**
  32835. * Returns the facetLocalPositions array.
  32836. * The facet positions are expressed in the mesh local space
  32837. * @returns an array of Vector3
  32838. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32839. */
  32840. getFacetLocalPositions(): Vector3[];
  32841. /**
  32842. * Returns the facetLocalPartioning array
  32843. * @returns an array of array of numbers
  32844. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32845. */
  32846. getFacetLocalPartitioning(): number[][];
  32847. /**
  32848. * Returns the i-th facet position in the world system.
  32849. * This method allocates a new Vector3 per call
  32850. * @param i defines the facet index
  32851. * @returns a new Vector3
  32852. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32853. */
  32854. getFacetPosition(i: number): Vector3;
  32855. /**
  32856. * Sets the reference Vector3 with the i-th facet position in the world system
  32857. * @param i defines the facet index
  32858. * @param ref defines the target vector
  32859. * @returns the current mesh
  32860. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32861. */
  32862. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32863. /**
  32864. * Returns the i-th facet normal in the world system.
  32865. * This method allocates a new Vector3 per call
  32866. * @param i defines the facet index
  32867. * @returns a new Vector3
  32868. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32869. */
  32870. getFacetNormal(i: number): Vector3;
  32871. /**
  32872. * Sets the reference Vector3 with the i-th facet normal in the world system
  32873. * @param i defines the facet index
  32874. * @param ref defines the target vector
  32875. * @returns the current mesh
  32876. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32877. */
  32878. getFacetNormalToRef(i: number, ref: Vector3): this;
  32879. /**
  32880. * 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)
  32881. * @param x defines x coordinate
  32882. * @param y defines y coordinate
  32883. * @param z defines z coordinate
  32884. * @returns the array of facet indexes
  32885. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32886. */
  32887. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32888. /**
  32889. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32890. * @param projected sets as the (x,y,z) world projection on the facet
  32891. * @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
  32892. * @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
  32893. * @param x defines x coordinate
  32894. * @param y defines y coordinate
  32895. * @param z defines z coordinate
  32896. * @returns the face index if found (or null instead)
  32897. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32898. */
  32899. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32900. /**
  32901. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32902. * @param projected sets as the (x,y,z) local projection on the facet
  32903. * @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
  32904. * @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
  32905. * @param x defines x coordinate
  32906. * @param y defines y coordinate
  32907. * @param z defines z coordinate
  32908. * @returns the face index if found (or null instead)
  32909. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32910. */
  32911. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32912. /**
  32913. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32914. * @returns the parameters
  32915. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32916. */
  32917. getFacetDataParameters(): any;
  32918. /**
  32919. * Disables the feature FacetData and frees the related memory
  32920. * @returns the current mesh
  32921. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32922. */
  32923. disableFacetData(): AbstractMesh;
  32924. /**
  32925. * Updates the AbstractMesh indices array
  32926. * @param indices defines the data source
  32927. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32928. * @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)
  32929. * @returns the current mesh
  32930. */
  32931. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32932. /**
  32933. * Creates new normals data for the mesh
  32934. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32935. * @returns the current mesh
  32936. */
  32937. createNormals(updatable: boolean): AbstractMesh;
  32938. /**
  32939. * Align the mesh with a normal
  32940. * @param normal defines the normal to use
  32941. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32942. * @returns the current mesh
  32943. */
  32944. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32945. /** @hidden */
  32946. _checkOcclusionQuery(): boolean;
  32947. /**
  32948. * Disables the mesh edge rendering mode
  32949. * @returns the currentAbstractMesh
  32950. */
  32951. disableEdgesRendering(): AbstractMesh;
  32952. /**
  32953. * Enables the edge rendering mode on the mesh.
  32954. * This mode makes the mesh edges visible
  32955. * @param epsilon defines the maximal distance between two angles to detect a face
  32956. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32957. * @returns the currentAbstractMesh
  32958. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32959. */
  32960. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32961. }
  32962. }
  32963. declare module "babylonjs/Actions/actionEvent" {
  32964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32965. import { Nullable } from "babylonjs/types";
  32966. import { Sprite } from "babylonjs/Sprites/sprite";
  32967. import { Scene } from "babylonjs/scene";
  32968. import { Vector2 } from "babylonjs/Maths/math.vector";
  32969. /**
  32970. * Interface used to define ActionEvent
  32971. */
  32972. export interface IActionEvent {
  32973. /** The mesh or sprite that triggered the action */
  32974. source: any;
  32975. /** The X mouse cursor position at the time of the event */
  32976. pointerX: number;
  32977. /** The Y mouse cursor position at the time of the event */
  32978. pointerY: number;
  32979. /** The mesh that is currently pointed at (can be null) */
  32980. meshUnderPointer: Nullable<AbstractMesh>;
  32981. /** the original (browser) event that triggered the ActionEvent */
  32982. sourceEvent?: any;
  32983. /** additional data for the event */
  32984. additionalData?: any;
  32985. }
  32986. /**
  32987. * ActionEvent is the event being sent when an action is triggered.
  32988. */
  32989. export class ActionEvent implements IActionEvent {
  32990. /** The mesh or sprite that triggered the action */
  32991. source: any;
  32992. /** The X mouse cursor position at the time of the event */
  32993. pointerX: number;
  32994. /** The Y mouse cursor position at the time of the event */
  32995. pointerY: number;
  32996. /** The mesh that is currently pointed at (can be null) */
  32997. meshUnderPointer: Nullable<AbstractMesh>;
  32998. /** the original (browser) event that triggered the ActionEvent */
  32999. sourceEvent?: any;
  33000. /** additional data for the event */
  33001. additionalData?: any;
  33002. /**
  33003. * Creates a new ActionEvent
  33004. * @param source The mesh or sprite that triggered the action
  33005. * @param pointerX The X mouse cursor position at the time of the event
  33006. * @param pointerY The Y mouse cursor position at the time of the event
  33007. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  33008. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  33009. * @param additionalData additional data for the event
  33010. */
  33011. constructor(
  33012. /** The mesh or sprite that triggered the action */
  33013. source: any,
  33014. /** The X mouse cursor position at the time of the event */
  33015. pointerX: number,
  33016. /** The Y mouse cursor position at the time of the event */
  33017. pointerY: number,
  33018. /** The mesh that is currently pointed at (can be null) */
  33019. meshUnderPointer: Nullable<AbstractMesh>,
  33020. /** the original (browser) event that triggered the ActionEvent */
  33021. sourceEvent?: any,
  33022. /** additional data for the event */
  33023. additionalData?: any);
  33024. /**
  33025. * Helper function to auto-create an ActionEvent from a source mesh.
  33026. * @param source The source mesh that triggered the event
  33027. * @param evt The original (browser) event
  33028. * @param additionalData additional data for the event
  33029. * @returns the new ActionEvent
  33030. */
  33031. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  33032. /**
  33033. * Helper function to auto-create an ActionEvent from a source sprite
  33034. * @param source The source sprite that triggered the event
  33035. * @param scene Scene associated with the sprite
  33036. * @param evt The original (browser) event
  33037. * @param additionalData additional data for the event
  33038. * @returns the new ActionEvent
  33039. */
  33040. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  33041. /**
  33042. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  33043. * @param scene the scene where the event occurred
  33044. * @param evt The original (browser) event
  33045. * @returns the new ActionEvent
  33046. */
  33047. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  33048. /**
  33049. * Helper function to auto-create an ActionEvent from a primitive
  33050. * @param prim defines the target primitive
  33051. * @param pointerPos defines the pointer position
  33052. * @param evt The original (browser) event
  33053. * @param additionalData additional data for the event
  33054. * @returns the new ActionEvent
  33055. */
  33056. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  33057. }
  33058. }
  33059. declare module "babylonjs/Actions/abstractActionManager" {
  33060. import { IDisposable } from "babylonjs/scene";
  33061. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  33062. import { IAction } from "babylonjs/Actions/action";
  33063. import { Nullable } from "babylonjs/types";
  33064. /**
  33065. * Abstract class used to decouple action Manager from scene and meshes.
  33066. * Do not instantiate.
  33067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33068. */
  33069. export abstract class AbstractActionManager implements IDisposable {
  33070. /** Gets the list of active triggers */
  33071. static Triggers: {
  33072. [key: string]: number;
  33073. };
  33074. /** Gets the cursor to use when hovering items */
  33075. hoverCursor: string;
  33076. /** Gets the list of actions */
  33077. actions: IAction[];
  33078. /**
  33079. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  33080. */
  33081. isRecursive: boolean;
  33082. /**
  33083. * Releases all associated resources
  33084. */
  33085. abstract dispose(): void;
  33086. /**
  33087. * Does this action manager has pointer triggers
  33088. */
  33089. abstract get hasPointerTriggers(): boolean;
  33090. /**
  33091. * Does this action manager has pick triggers
  33092. */
  33093. abstract get hasPickTriggers(): boolean;
  33094. /**
  33095. * Process a specific trigger
  33096. * @param trigger defines the trigger to process
  33097. * @param evt defines the event details to be processed
  33098. */
  33099. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  33100. /**
  33101. * Does this action manager handles actions of any of the given triggers
  33102. * @param triggers defines the triggers to be tested
  33103. * @return a boolean indicating whether one (or more) of the triggers is handled
  33104. */
  33105. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33106. /**
  33107. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33108. * speed.
  33109. * @param triggerA defines the trigger to be tested
  33110. * @param triggerB defines the trigger to be tested
  33111. * @return a boolean indicating whether one (or more) of the triggers is handled
  33112. */
  33113. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33114. /**
  33115. * Does this action manager handles actions of a given trigger
  33116. * @param trigger defines the trigger to be tested
  33117. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33118. * @return whether the trigger is handled
  33119. */
  33120. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33121. /**
  33122. * Serialize this manager to a JSON object
  33123. * @param name defines the property name to store this manager
  33124. * @returns a JSON representation of this manager
  33125. */
  33126. abstract serialize(name: string): any;
  33127. /**
  33128. * Registers an action to this action manager
  33129. * @param action defines the action to be registered
  33130. * @return the action amended (prepared) after registration
  33131. */
  33132. abstract registerAction(action: IAction): Nullable<IAction>;
  33133. /**
  33134. * Unregisters an action to this action manager
  33135. * @param action defines the action to be unregistered
  33136. * @return a boolean indicating whether the action has been unregistered
  33137. */
  33138. abstract unregisterAction(action: IAction): Boolean;
  33139. /**
  33140. * Does exist one action manager with at least one trigger
  33141. **/
  33142. static get HasTriggers(): boolean;
  33143. /**
  33144. * Does exist one action manager with at least one pick trigger
  33145. **/
  33146. static get HasPickTriggers(): boolean;
  33147. /**
  33148. * Does exist one action manager that handles actions of a given trigger
  33149. * @param trigger defines the trigger to be tested
  33150. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33151. **/
  33152. static HasSpecificTrigger(trigger: number): boolean;
  33153. }
  33154. }
  33155. declare module "babylonjs/node" {
  33156. import { Scene } from "babylonjs/scene";
  33157. import { Nullable } from "babylonjs/types";
  33158. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  33159. import { Engine } from "babylonjs/Engines/engine";
  33160. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  33161. import { Observable } from "babylonjs/Misc/observable";
  33162. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33163. import { IInspectable } from "babylonjs/Misc/iInspectable";
  33164. import { Animatable } from "babylonjs/Animations/animatable";
  33165. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33166. import { Animation } from "babylonjs/Animations/animation";
  33167. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33169. /**
  33170. * Defines how a node can be built from a string name.
  33171. */
  33172. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33173. /**
  33174. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33175. */
  33176. export class Node implements IBehaviorAware<Node> {
  33177. /** @hidden */
  33178. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  33179. private static _NodeConstructors;
  33180. /**
  33181. * Add a new node constructor
  33182. * @param type defines the type name of the node to construct
  33183. * @param constructorFunc defines the constructor function
  33184. */
  33185. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33186. /**
  33187. * Returns a node constructor based on type name
  33188. * @param type defines the type name
  33189. * @param name defines the new node name
  33190. * @param scene defines the hosting scene
  33191. * @param options defines optional options to transmit to constructors
  33192. * @returns the new constructor or null
  33193. */
  33194. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33195. /**
  33196. * Gets or sets the name of the node
  33197. */
  33198. name: string;
  33199. /**
  33200. * Gets or sets the id of the node
  33201. */
  33202. id: string;
  33203. /**
  33204. * Gets or sets the unique id of the node
  33205. */
  33206. uniqueId: number;
  33207. /**
  33208. * Gets or sets a string used to store user defined state for the node
  33209. */
  33210. state: string;
  33211. /**
  33212. * Gets or sets an object used to store user defined information for the node
  33213. */
  33214. metadata: any;
  33215. /**
  33216. * For internal use only. Please do not use.
  33217. */
  33218. reservedDataStore: any;
  33219. /**
  33220. * List of inspectable custom properties (used by the Inspector)
  33221. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33222. */
  33223. inspectableCustomProperties: IInspectable[];
  33224. private _doNotSerialize;
  33225. /**
  33226. * Gets or sets a boolean used to define if the node must be serialized
  33227. */
  33228. get doNotSerialize(): boolean;
  33229. set doNotSerialize(value: boolean);
  33230. /** @hidden */
  33231. _isDisposed: boolean;
  33232. /**
  33233. * Gets a list of Animations associated with the node
  33234. */
  33235. animations: import("babylonjs/Animations/animation").Animation[];
  33236. protected _ranges: {
  33237. [name: string]: Nullable<AnimationRange>;
  33238. };
  33239. /**
  33240. * Callback raised when the node is ready to be used
  33241. */
  33242. onReady: Nullable<(node: Node) => void>;
  33243. private _isEnabled;
  33244. private _isParentEnabled;
  33245. private _isReady;
  33246. /** @hidden */
  33247. _currentRenderId: number;
  33248. private _parentUpdateId;
  33249. /** @hidden */
  33250. _childUpdateId: number;
  33251. /** @hidden */
  33252. _waitingParentId: Nullable<string>;
  33253. /** @hidden */
  33254. _scene: Scene;
  33255. /** @hidden */
  33256. _cache: any;
  33257. private _parentNode;
  33258. private _children;
  33259. /** @hidden */
  33260. _worldMatrix: Matrix;
  33261. /** @hidden */
  33262. _worldMatrixDeterminant: number;
  33263. /** @hidden */
  33264. _worldMatrixDeterminantIsDirty: boolean;
  33265. /** @hidden */
  33266. private _sceneRootNodesIndex;
  33267. /**
  33268. * Gets a boolean indicating if the node has been disposed
  33269. * @returns true if the node was disposed
  33270. */
  33271. isDisposed(): boolean;
  33272. /**
  33273. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33274. * @see https://doc.babylonjs.com/how_to/parenting
  33275. */
  33276. set parent(parent: Nullable<Node>);
  33277. get parent(): Nullable<Node>;
  33278. /** @hidden */
  33279. _addToSceneRootNodes(): void;
  33280. /** @hidden */
  33281. _removeFromSceneRootNodes(): void;
  33282. private _animationPropertiesOverride;
  33283. /**
  33284. * Gets or sets the animation properties override
  33285. */
  33286. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33287. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33288. /**
  33289. * Gets a string idenfifying the name of the class
  33290. * @returns "Node" string
  33291. */
  33292. getClassName(): string;
  33293. /** @hidden */
  33294. readonly _isNode: boolean;
  33295. /**
  33296. * An event triggered when the mesh is disposed
  33297. */
  33298. onDisposeObservable: Observable<Node>;
  33299. private _onDisposeObserver;
  33300. /**
  33301. * Sets a callback that will be raised when the node will be disposed
  33302. */
  33303. set onDispose(callback: () => void);
  33304. /**
  33305. * Creates a new Node
  33306. * @param name the name and id to be given to this node
  33307. * @param scene the scene this node will be added to
  33308. */
  33309. constructor(name: string, scene?: Nullable<Scene>);
  33310. /**
  33311. * Gets the scene of the node
  33312. * @returns a scene
  33313. */
  33314. getScene(): Scene;
  33315. /**
  33316. * Gets the engine of the node
  33317. * @returns a Engine
  33318. */
  33319. getEngine(): Engine;
  33320. private _behaviors;
  33321. /**
  33322. * Attach a behavior to the node
  33323. * @see http://doc.babylonjs.com/features/behaviour
  33324. * @param behavior defines the behavior to attach
  33325. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33326. * @returns the current Node
  33327. */
  33328. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33329. /**
  33330. * Remove an attached behavior
  33331. * @see http://doc.babylonjs.com/features/behaviour
  33332. * @param behavior defines the behavior to attach
  33333. * @returns the current Node
  33334. */
  33335. removeBehavior(behavior: Behavior<Node>): Node;
  33336. /**
  33337. * Gets the list of attached behaviors
  33338. * @see http://doc.babylonjs.com/features/behaviour
  33339. */
  33340. get behaviors(): Behavior<Node>[];
  33341. /**
  33342. * Gets an attached behavior by name
  33343. * @param name defines the name of the behavior to look for
  33344. * @see http://doc.babylonjs.com/features/behaviour
  33345. * @returns null if behavior was not found else the requested behavior
  33346. */
  33347. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33348. /**
  33349. * Returns the latest update of the World matrix
  33350. * @returns a Matrix
  33351. */
  33352. getWorldMatrix(): Matrix;
  33353. /** @hidden */
  33354. _getWorldMatrixDeterminant(): number;
  33355. /**
  33356. * Returns directly the latest state of the mesh World matrix.
  33357. * A Matrix is returned.
  33358. */
  33359. get worldMatrixFromCache(): Matrix;
  33360. /** @hidden */
  33361. _initCache(): void;
  33362. /** @hidden */
  33363. updateCache(force?: boolean): void;
  33364. /** @hidden */
  33365. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33366. /** @hidden */
  33367. _updateCache(ignoreParentClass?: boolean): void;
  33368. /** @hidden */
  33369. _isSynchronized(): boolean;
  33370. /** @hidden */
  33371. _markSyncedWithParent(): void;
  33372. /** @hidden */
  33373. isSynchronizedWithParent(): boolean;
  33374. /** @hidden */
  33375. isSynchronized(): boolean;
  33376. /**
  33377. * Is this node ready to be used/rendered
  33378. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33379. * @return true if the node is ready
  33380. */
  33381. isReady(completeCheck?: boolean): boolean;
  33382. /**
  33383. * Is this node enabled?
  33384. * 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
  33385. * @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
  33386. * @return whether this node (and its parent) is enabled
  33387. */
  33388. isEnabled(checkAncestors?: boolean): boolean;
  33389. /** @hidden */
  33390. protected _syncParentEnabledState(): void;
  33391. /**
  33392. * Set the enabled state of this node
  33393. * @param value defines the new enabled state
  33394. */
  33395. setEnabled(value: boolean): void;
  33396. /**
  33397. * Is this node a descendant of the given node?
  33398. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33399. * @param ancestor defines the parent node to inspect
  33400. * @returns a boolean indicating if this node is a descendant of the given node
  33401. */
  33402. isDescendantOf(ancestor: Node): boolean;
  33403. /** @hidden */
  33404. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33405. /**
  33406. * Will return all nodes that have this node as ascendant
  33407. * @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
  33408. * @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
  33409. * @return all children nodes of all types
  33410. */
  33411. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33412. /**
  33413. * Get all child-meshes of this node
  33414. * @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)
  33415. * @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
  33416. * @returns an array of AbstractMesh
  33417. */
  33418. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33419. /**
  33420. * Get all direct children of this node
  33421. * @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
  33422. * @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)
  33423. * @returns an array of Node
  33424. */
  33425. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33426. /** @hidden */
  33427. _setReady(state: boolean): void;
  33428. /**
  33429. * Get an animation by name
  33430. * @param name defines the name of the animation to look for
  33431. * @returns null if not found else the requested animation
  33432. */
  33433. getAnimationByName(name: string): Nullable<Animation>;
  33434. /**
  33435. * Creates an animation range for this node
  33436. * @param name defines the name of the range
  33437. * @param from defines the starting key
  33438. * @param to defines the end key
  33439. */
  33440. createAnimationRange(name: string, from: number, to: number): void;
  33441. /**
  33442. * Delete a specific animation range
  33443. * @param name defines the name of the range to delete
  33444. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33445. */
  33446. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33447. /**
  33448. * Get an animation range by name
  33449. * @param name defines the name of the animation range to look for
  33450. * @returns null if not found else the requested animation range
  33451. */
  33452. getAnimationRange(name: string): Nullable<AnimationRange>;
  33453. /**
  33454. * Gets the list of all animation ranges defined on this node
  33455. * @returns an array
  33456. */
  33457. getAnimationRanges(): Nullable<AnimationRange>[];
  33458. /**
  33459. * Will start the animation sequence
  33460. * @param name defines the range frames for animation sequence
  33461. * @param loop defines if the animation should loop (false by default)
  33462. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33463. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33464. * @returns the object created for this animation. If range does not exist, it will return null
  33465. */
  33466. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33467. /**
  33468. * Serialize animation ranges into a JSON compatible object
  33469. * @returns serialization object
  33470. */
  33471. serializeAnimationRanges(): any;
  33472. /**
  33473. * Computes the world matrix of the node
  33474. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33475. * @returns the world matrix
  33476. */
  33477. computeWorldMatrix(force?: boolean): Matrix;
  33478. /**
  33479. * Releases resources associated with this node.
  33480. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33481. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33482. */
  33483. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33484. /**
  33485. * Parse animation range data from a serialization object and store them into a given node
  33486. * @param node defines where to store the animation ranges
  33487. * @param parsedNode defines the serialization object to read data from
  33488. * @param scene defines the hosting scene
  33489. */
  33490. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33491. /**
  33492. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33493. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33494. * @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
  33495. * @returns the new bounding vectors
  33496. */
  33497. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33498. min: Vector3;
  33499. max: Vector3;
  33500. };
  33501. }
  33502. }
  33503. declare module "babylonjs/Animations/animation" {
  33504. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  33505. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  33506. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33507. import { Nullable } from "babylonjs/types";
  33508. import { Scene } from "babylonjs/scene";
  33509. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  33510. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33511. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  33512. import { Node } from "babylonjs/node";
  33513. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33514. import { Size } from "babylonjs/Maths/math.size";
  33515. import { Animatable } from "babylonjs/Animations/animatable";
  33516. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  33517. /**
  33518. * @hidden
  33519. */
  33520. export class _IAnimationState {
  33521. key: number;
  33522. repeatCount: number;
  33523. workValue?: any;
  33524. loopMode?: number;
  33525. offsetValue?: any;
  33526. highLimitValue?: any;
  33527. }
  33528. /**
  33529. * Class used to store any kind of animation
  33530. */
  33531. export class Animation {
  33532. /**Name of the animation */
  33533. name: string;
  33534. /**Property to animate */
  33535. targetProperty: string;
  33536. /**The frames per second of the animation */
  33537. framePerSecond: number;
  33538. /**The data type of the animation */
  33539. dataType: number;
  33540. /**The loop mode of the animation */
  33541. loopMode?: number | undefined;
  33542. /**Specifies if blending should be enabled */
  33543. enableBlending?: boolean | undefined;
  33544. /**
  33545. * Use matrix interpolation instead of using direct key value when animating matrices
  33546. */
  33547. static AllowMatricesInterpolation: boolean;
  33548. /**
  33549. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33550. */
  33551. static AllowMatrixDecomposeForInterpolation: boolean;
  33552. /** Define the Url to load snippets */
  33553. static SnippetUrl: string;
  33554. /** Snippet ID if the animation was created from the snippet server */
  33555. snippetId: string;
  33556. /**
  33557. * Stores the key frames of the animation
  33558. */
  33559. private _keys;
  33560. /**
  33561. * Stores the easing function of the animation
  33562. */
  33563. private _easingFunction;
  33564. /**
  33565. * @hidden Internal use only
  33566. */
  33567. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  33568. /**
  33569. * The set of event that will be linked to this animation
  33570. */
  33571. private _events;
  33572. /**
  33573. * Stores an array of target property paths
  33574. */
  33575. targetPropertyPath: string[];
  33576. /**
  33577. * Stores the blending speed of the animation
  33578. */
  33579. blendingSpeed: number;
  33580. /**
  33581. * Stores the animation ranges for the animation
  33582. */
  33583. private _ranges;
  33584. /**
  33585. * @hidden Internal use
  33586. */
  33587. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33588. /**
  33589. * Sets up an animation
  33590. * @param property The property to animate
  33591. * @param animationType The animation type to apply
  33592. * @param framePerSecond The frames per second of the animation
  33593. * @param easingFunction The easing function used in the animation
  33594. * @returns The created animation
  33595. */
  33596. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33597. /**
  33598. * Create and start an animation on a node
  33599. * @param name defines the name of the global animation that will be run on all nodes
  33600. * @param node defines the root node where the animation will take place
  33601. * @param targetProperty defines property to animate
  33602. * @param framePerSecond defines the number of frame per second yo use
  33603. * @param totalFrame defines the number of frames in total
  33604. * @param from defines the initial value
  33605. * @param to defines the final value
  33606. * @param loopMode defines which loop mode you want to use (off by default)
  33607. * @param easingFunction defines the easing function to use (linear by default)
  33608. * @param onAnimationEnd defines the callback to call when animation end
  33609. * @returns the animatable created for this animation
  33610. */
  33611. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33612. /**
  33613. * Create and start an animation on a node and its descendants
  33614. * @param name defines the name of the global animation that will be run on all nodes
  33615. * @param node defines the root node where the animation will take place
  33616. * @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
  33617. * @param targetProperty defines property to animate
  33618. * @param framePerSecond defines the number of frame per second to use
  33619. * @param totalFrame defines the number of frames in total
  33620. * @param from defines the initial value
  33621. * @param to defines the final value
  33622. * @param loopMode defines which loop mode you want to use (off by default)
  33623. * @param easingFunction defines the easing function to use (linear by default)
  33624. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33625. * @returns the list of animatables created for all nodes
  33626. * @example https://www.babylonjs-playground.com/#MH0VLI
  33627. */
  33628. 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[]>;
  33629. /**
  33630. * Creates a new animation, merges it with the existing animations and starts it
  33631. * @param name Name of the animation
  33632. * @param node Node which contains the scene that begins the animations
  33633. * @param targetProperty Specifies which property to animate
  33634. * @param framePerSecond The frames per second of the animation
  33635. * @param totalFrame The total number of frames
  33636. * @param from The frame at the beginning of the animation
  33637. * @param to The frame at the end of the animation
  33638. * @param loopMode Specifies the loop mode of the animation
  33639. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33640. * @param onAnimationEnd Callback to run once the animation is complete
  33641. * @returns Nullable animation
  33642. */
  33643. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33644. /**
  33645. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33646. * @param sourceAnimation defines the Animation containing keyframes to convert
  33647. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33648. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33649. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33650. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33651. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33652. */
  33653. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33654. /**
  33655. * Transition property of an host to the target Value
  33656. * @param property The property to transition
  33657. * @param targetValue The target Value of the property
  33658. * @param host The object where the property to animate belongs
  33659. * @param scene Scene used to run the animation
  33660. * @param frameRate Framerate (in frame/s) to use
  33661. * @param transition The transition type we want to use
  33662. * @param duration The duration of the animation, in milliseconds
  33663. * @param onAnimationEnd Callback trigger at the end of the animation
  33664. * @returns Nullable animation
  33665. */
  33666. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33667. /**
  33668. * Return the array of runtime animations currently using this animation
  33669. */
  33670. get runtimeAnimations(): RuntimeAnimation[];
  33671. /**
  33672. * Specifies if any of the runtime animations are currently running
  33673. */
  33674. get hasRunningRuntimeAnimations(): boolean;
  33675. /**
  33676. * Initializes the animation
  33677. * @param name Name of the animation
  33678. * @param targetProperty Property to animate
  33679. * @param framePerSecond The frames per second of the animation
  33680. * @param dataType The data type of the animation
  33681. * @param loopMode The loop mode of the animation
  33682. * @param enableBlending Specifies if blending should be enabled
  33683. */
  33684. constructor(
  33685. /**Name of the animation */
  33686. name: string,
  33687. /**Property to animate */
  33688. targetProperty: string,
  33689. /**The frames per second of the animation */
  33690. framePerSecond: number,
  33691. /**The data type of the animation */
  33692. dataType: number,
  33693. /**The loop mode of the animation */
  33694. loopMode?: number | undefined,
  33695. /**Specifies if blending should be enabled */
  33696. enableBlending?: boolean | undefined);
  33697. /**
  33698. * Converts the animation to a string
  33699. * @param fullDetails support for multiple levels of logging within scene loading
  33700. * @returns String form of the animation
  33701. */
  33702. toString(fullDetails?: boolean): string;
  33703. /**
  33704. * Add an event to this animation
  33705. * @param event Event to add
  33706. */
  33707. addEvent(event: AnimationEvent): void;
  33708. /**
  33709. * Remove all events found at the given frame
  33710. * @param frame The frame to remove events from
  33711. */
  33712. removeEvents(frame: number): void;
  33713. /**
  33714. * Retrieves all the events from the animation
  33715. * @returns Events from the animation
  33716. */
  33717. getEvents(): AnimationEvent[];
  33718. /**
  33719. * Creates an animation range
  33720. * @param name Name of the animation range
  33721. * @param from Starting frame of the animation range
  33722. * @param to Ending frame of the animation
  33723. */
  33724. createRange(name: string, from: number, to: number): void;
  33725. /**
  33726. * Deletes an animation range by name
  33727. * @param name Name of the animation range to delete
  33728. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33729. */
  33730. deleteRange(name: string, deleteFrames?: boolean): void;
  33731. /**
  33732. * Gets the animation range by name, or null if not defined
  33733. * @param name Name of the animation range
  33734. * @returns Nullable animation range
  33735. */
  33736. getRange(name: string): Nullable<AnimationRange>;
  33737. /**
  33738. * Gets the key frames from the animation
  33739. * @returns The key frames of the animation
  33740. */
  33741. getKeys(): Array<IAnimationKey>;
  33742. /**
  33743. * Gets the highest frame rate of the animation
  33744. * @returns Highest frame rate of the animation
  33745. */
  33746. getHighestFrame(): number;
  33747. /**
  33748. * Gets the easing function of the animation
  33749. * @returns Easing function of the animation
  33750. */
  33751. getEasingFunction(): IEasingFunction;
  33752. /**
  33753. * Sets the easing function of the animation
  33754. * @param easingFunction A custom mathematical formula for animation
  33755. */
  33756. setEasingFunction(easingFunction: EasingFunction): void;
  33757. /**
  33758. * Interpolates a scalar linearly
  33759. * @param startValue Start value of the animation curve
  33760. * @param endValue End value of the animation curve
  33761. * @param gradient Scalar amount to interpolate
  33762. * @returns Interpolated scalar value
  33763. */
  33764. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33765. /**
  33766. * Interpolates a scalar cubically
  33767. * @param startValue Start value of the animation curve
  33768. * @param outTangent End tangent of the animation
  33769. * @param endValue End value of the animation curve
  33770. * @param inTangent Start tangent of the animation curve
  33771. * @param gradient Scalar amount to interpolate
  33772. * @returns Interpolated scalar value
  33773. */
  33774. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33775. /**
  33776. * Interpolates a quaternion using a spherical linear interpolation
  33777. * @param startValue Start value of the animation curve
  33778. * @param endValue End value of the animation curve
  33779. * @param gradient Scalar amount to interpolate
  33780. * @returns Interpolated quaternion value
  33781. */
  33782. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33783. /**
  33784. * Interpolates a quaternion cubically
  33785. * @param startValue Start value of the animation curve
  33786. * @param outTangent End tangent of the animation curve
  33787. * @param endValue End value of the animation curve
  33788. * @param inTangent Start tangent of the animation curve
  33789. * @param gradient Scalar amount to interpolate
  33790. * @returns Interpolated quaternion value
  33791. */
  33792. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33793. /**
  33794. * Interpolates a Vector3 linearl
  33795. * @param startValue Start value of the animation curve
  33796. * @param endValue End value of the animation curve
  33797. * @param gradient Scalar amount to interpolate
  33798. * @returns Interpolated scalar value
  33799. */
  33800. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33801. /**
  33802. * Interpolates a Vector3 cubically
  33803. * @param startValue Start value of the animation curve
  33804. * @param outTangent End tangent of the animation
  33805. * @param endValue End value of the animation curve
  33806. * @param inTangent Start tangent of the animation curve
  33807. * @param gradient Scalar amount to interpolate
  33808. * @returns InterpolatedVector3 value
  33809. */
  33810. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33811. /**
  33812. * Interpolates a Vector2 linearly
  33813. * @param startValue Start value of the animation curve
  33814. * @param endValue End value of the animation curve
  33815. * @param gradient Scalar amount to interpolate
  33816. * @returns Interpolated Vector2 value
  33817. */
  33818. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33819. /**
  33820. * Interpolates a Vector2 cubically
  33821. * @param startValue Start value of the animation curve
  33822. * @param outTangent End tangent of the animation
  33823. * @param endValue End value of the animation curve
  33824. * @param inTangent Start tangent of the animation curve
  33825. * @param gradient Scalar amount to interpolate
  33826. * @returns Interpolated Vector2 value
  33827. */
  33828. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33829. /**
  33830. * Interpolates a size linearly
  33831. * @param startValue Start value of the animation curve
  33832. * @param endValue End value of the animation curve
  33833. * @param gradient Scalar amount to interpolate
  33834. * @returns Interpolated Size value
  33835. */
  33836. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33837. /**
  33838. * Interpolates a Color3 linearly
  33839. * @param startValue Start value of the animation curve
  33840. * @param endValue End value of the animation curve
  33841. * @param gradient Scalar amount to interpolate
  33842. * @returns Interpolated Color3 value
  33843. */
  33844. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33845. /**
  33846. * Interpolates a Color4 linearly
  33847. * @param startValue Start value of the animation curve
  33848. * @param endValue End value of the animation curve
  33849. * @param gradient Scalar amount to interpolate
  33850. * @returns Interpolated Color3 value
  33851. */
  33852. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33853. /**
  33854. * @hidden Internal use only
  33855. */
  33856. _getKeyValue(value: any): any;
  33857. /**
  33858. * @hidden Internal use only
  33859. */
  33860. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33861. /**
  33862. * Defines the function to use to interpolate matrices
  33863. * @param startValue defines the start matrix
  33864. * @param endValue defines the end matrix
  33865. * @param gradient defines the gradient between both matrices
  33866. * @param result defines an optional target matrix where to store the interpolation
  33867. * @returns the interpolated matrix
  33868. */
  33869. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33870. /**
  33871. * Makes a copy of the animation
  33872. * @returns Cloned animation
  33873. */
  33874. clone(): Animation;
  33875. /**
  33876. * Sets the key frames of the animation
  33877. * @param values The animation key frames to set
  33878. */
  33879. setKeys(values: Array<IAnimationKey>): void;
  33880. /**
  33881. * Serializes the animation to an object
  33882. * @returns Serialized object
  33883. */
  33884. serialize(): any;
  33885. /**
  33886. * Float animation type
  33887. */
  33888. static readonly ANIMATIONTYPE_FLOAT: number;
  33889. /**
  33890. * Vector3 animation type
  33891. */
  33892. static readonly ANIMATIONTYPE_VECTOR3: number;
  33893. /**
  33894. * Quaternion animation type
  33895. */
  33896. static readonly ANIMATIONTYPE_QUATERNION: number;
  33897. /**
  33898. * Matrix animation type
  33899. */
  33900. static readonly ANIMATIONTYPE_MATRIX: number;
  33901. /**
  33902. * Color3 animation type
  33903. */
  33904. static readonly ANIMATIONTYPE_COLOR3: number;
  33905. /**
  33906. * Color3 animation type
  33907. */
  33908. static readonly ANIMATIONTYPE_COLOR4: number;
  33909. /**
  33910. * Vector2 animation type
  33911. */
  33912. static readonly ANIMATIONTYPE_VECTOR2: number;
  33913. /**
  33914. * Size animation type
  33915. */
  33916. static readonly ANIMATIONTYPE_SIZE: number;
  33917. /**
  33918. * Relative Loop Mode
  33919. */
  33920. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33921. /**
  33922. * Cycle Loop Mode
  33923. */
  33924. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33925. /**
  33926. * Constant Loop Mode
  33927. */
  33928. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33929. /** @hidden */
  33930. static _UniversalLerp(left: any, right: any, amount: number): any;
  33931. /**
  33932. * Parses an animation object and creates an animation
  33933. * @param parsedAnimation Parsed animation object
  33934. * @returns Animation object
  33935. */
  33936. static Parse(parsedAnimation: any): Animation;
  33937. /**
  33938. * Appends the serialized animations from the source animations
  33939. * @param source Source containing the animations
  33940. * @param destination Target to store the animations
  33941. */
  33942. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33943. /**
  33944. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33945. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33946. * @param url defines the url to load from
  33947. * @returns a promise that will resolve to the new animation or an array of animations
  33948. */
  33949. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33950. /**
  33951. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33952. * @param snippetId defines the snippet to load
  33953. * @returns a promise that will resolve to the new animation or a new array of animations
  33954. */
  33955. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33956. }
  33957. }
  33958. declare module "babylonjs/Animations/animatable.interface" {
  33959. import { Nullable } from "babylonjs/types";
  33960. import { Animation } from "babylonjs/Animations/animation";
  33961. /**
  33962. * Interface containing an array of animations
  33963. */
  33964. export interface IAnimatable {
  33965. /**
  33966. * Array of animations
  33967. */
  33968. animations: Nullable<Array<Animation>>;
  33969. }
  33970. }
  33971. declare module "babylonjs/Misc/decorators" {
  33972. import { Nullable } from "babylonjs/types";
  33973. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33974. import { Scene } from "babylonjs/scene";
  33975. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33976. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33977. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33978. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33979. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33980. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33981. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33982. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33983. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33984. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33985. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33986. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33987. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33988. /**
  33989. * Decorator used to define property that can be serialized as reference to a camera
  33990. * @param sourceName defines the name of the property to decorate
  33991. */
  33992. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33993. /**
  33994. * Class used to help serialization objects
  33995. */
  33996. export class SerializationHelper {
  33997. /** @hidden */
  33998. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  33999. /** @hidden */
  34000. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  34001. /** @hidden */
  34002. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  34003. /** @hidden */
  34004. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  34005. /**
  34006. * Appends the serialized animations from the source animations
  34007. * @param source Source containing the animations
  34008. * @param destination Target to store the animations
  34009. */
  34010. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34011. /**
  34012. * Static function used to serialized a specific entity
  34013. * @param entity defines the entity to serialize
  34014. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  34015. * @returns a JSON compatible object representing the serialization of the entity
  34016. */
  34017. static Serialize<T>(entity: T, serializationObject?: any): any;
  34018. /**
  34019. * Creates a new entity from a serialization data object
  34020. * @param creationFunction defines a function used to instanciated the new entity
  34021. * @param source defines the source serialization data
  34022. * @param scene defines the hosting scene
  34023. * @param rootUrl defines the root url for resources
  34024. * @returns a new entity
  34025. */
  34026. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  34027. /**
  34028. * Clones an object
  34029. * @param creationFunction defines the function used to instanciate the new object
  34030. * @param source defines the source object
  34031. * @returns the cloned object
  34032. */
  34033. static Clone<T>(creationFunction: () => T, source: T): T;
  34034. /**
  34035. * Instanciates a new object based on a source one (some data will be shared between both object)
  34036. * @param creationFunction defines the function used to instanciate the new object
  34037. * @param source defines the source object
  34038. * @returns the new object
  34039. */
  34040. static Instanciate<T>(creationFunction: () => T, source: T): T;
  34041. }
  34042. }
  34043. declare module "babylonjs/Materials/Textures/baseTexture" {
  34044. import { Observable } from "babylonjs/Misc/observable";
  34045. import { Nullable } from "babylonjs/types";
  34046. import { Scene } from "babylonjs/scene";
  34047. import { Matrix } from "babylonjs/Maths/math.vector";
  34048. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34049. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34050. import { ISize } from "babylonjs/Maths/math.size";
  34051. import "babylonjs/Misc/fileTools";
  34052. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34053. /**
  34054. * Base class of all the textures in babylon.
  34055. * It groups all the common properties the materials, post process, lights... might need
  34056. * in order to make a correct use of the texture.
  34057. */
  34058. export class BaseTexture implements IAnimatable {
  34059. /**
  34060. * Default anisotropic filtering level for the application.
  34061. * It is set to 4 as a good tradeoff between perf and quality.
  34062. */
  34063. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  34064. /**
  34065. * Gets or sets the unique id of the texture
  34066. */
  34067. uniqueId: number;
  34068. /**
  34069. * Define the name of the texture.
  34070. */
  34071. name: string;
  34072. /**
  34073. * Gets or sets an object used to store user defined information.
  34074. */
  34075. metadata: any;
  34076. /**
  34077. * For internal use only. Please do not use.
  34078. */
  34079. reservedDataStore: any;
  34080. private _hasAlpha;
  34081. /**
  34082. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  34083. */
  34084. set hasAlpha(value: boolean);
  34085. get hasAlpha(): boolean;
  34086. /**
  34087. * Defines if the alpha value should be determined via the rgb values.
  34088. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  34089. */
  34090. getAlphaFromRGB: boolean;
  34091. /**
  34092. * Intensity or strength of the texture.
  34093. * It is commonly used by materials to fine tune the intensity of the texture
  34094. */
  34095. level: number;
  34096. /**
  34097. * Define the UV chanel to use starting from 0 and defaulting to 0.
  34098. * This is part of the texture as textures usually maps to one uv set.
  34099. */
  34100. coordinatesIndex: number;
  34101. private _coordinatesMode;
  34102. /**
  34103. * How a texture is mapped.
  34104. *
  34105. * | Value | Type | Description |
  34106. * | ----- | ----------------------------------- | ----------- |
  34107. * | 0 | EXPLICIT_MODE | |
  34108. * | 1 | SPHERICAL_MODE | |
  34109. * | 2 | PLANAR_MODE | |
  34110. * | 3 | CUBIC_MODE | |
  34111. * | 4 | PROJECTION_MODE | |
  34112. * | 5 | SKYBOX_MODE | |
  34113. * | 6 | INVCUBIC_MODE | |
  34114. * | 7 | EQUIRECTANGULAR_MODE | |
  34115. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34116. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34117. */
  34118. set coordinatesMode(value: number);
  34119. get coordinatesMode(): number;
  34120. /**
  34121. * | Value | Type | Description |
  34122. * | ----- | ------------------ | ----------- |
  34123. * | 0 | CLAMP_ADDRESSMODE | |
  34124. * | 1 | WRAP_ADDRESSMODE | |
  34125. * | 2 | MIRROR_ADDRESSMODE | |
  34126. */
  34127. wrapU: number;
  34128. /**
  34129. * | Value | Type | Description |
  34130. * | ----- | ------------------ | ----------- |
  34131. * | 0 | CLAMP_ADDRESSMODE | |
  34132. * | 1 | WRAP_ADDRESSMODE | |
  34133. * | 2 | MIRROR_ADDRESSMODE | |
  34134. */
  34135. wrapV: number;
  34136. /**
  34137. * | Value | Type | Description |
  34138. * | ----- | ------------------ | ----------- |
  34139. * | 0 | CLAMP_ADDRESSMODE | |
  34140. * | 1 | WRAP_ADDRESSMODE | |
  34141. * | 2 | MIRROR_ADDRESSMODE | |
  34142. */
  34143. wrapR: number;
  34144. /**
  34145. * With compliant hardware and browser (supporting anisotropic filtering)
  34146. * this defines the level of anisotropic filtering in the texture.
  34147. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  34148. */
  34149. anisotropicFilteringLevel: number;
  34150. /**
  34151. * Define if the texture is a cube texture or if false a 2d texture.
  34152. */
  34153. get isCube(): boolean;
  34154. set isCube(value: boolean);
  34155. /**
  34156. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  34157. */
  34158. get is3D(): boolean;
  34159. set is3D(value: boolean);
  34160. /**
  34161. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34162. */
  34163. get is2DArray(): boolean;
  34164. set is2DArray(value: boolean);
  34165. /**
  34166. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34167. * HDR texture are usually stored in linear space.
  34168. * This only impacts the PBR and Background materials
  34169. */
  34170. gammaSpace: boolean;
  34171. /**
  34172. * Gets or sets whether or not the texture contains RGBD data.
  34173. */
  34174. get isRGBD(): boolean;
  34175. set isRGBD(value: boolean);
  34176. /**
  34177. * Is Z inverted in the texture (useful in a cube texture).
  34178. */
  34179. invertZ: boolean;
  34180. /**
  34181. * Are mip maps generated for this texture or not.
  34182. */
  34183. get noMipmap(): boolean;
  34184. /**
  34185. * @hidden
  34186. */
  34187. lodLevelInAlpha: boolean;
  34188. /**
  34189. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34190. */
  34191. get lodGenerationOffset(): number;
  34192. set lodGenerationOffset(value: number);
  34193. /**
  34194. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34195. */
  34196. get lodGenerationScale(): number;
  34197. set lodGenerationScale(value: number);
  34198. /**
  34199. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34200. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34201. * average roughness values.
  34202. */
  34203. get linearSpecularLOD(): boolean;
  34204. set linearSpecularLOD(value: boolean);
  34205. /**
  34206. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34207. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34208. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34209. */
  34210. get irradianceTexture(): Nullable<BaseTexture>;
  34211. set irradianceTexture(value: Nullable<BaseTexture>);
  34212. /**
  34213. * Define if the texture is a render target.
  34214. */
  34215. isRenderTarget: boolean;
  34216. /**
  34217. * Define the unique id of the texture in the scene.
  34218. */
  34219. get uid(): string;
  34220. /** @hidden */
  34221. _prefiltered: boolean;
  34222. /**
  34223. * Return a string representation of the texture.
  34224. * @returns the texture as a string
  34225. */
  34226. toString(): string;
  34227. /**
  34228. * Get the class name of the texture.
  34229. * @returns "BaseTexture"
  34230. */
  34231. getClassName(): string;
  34232. /**
  34233. * Define the list of animation attached to the texture.
  34234. */
  34235. animations: import("babylonjs/Animations/animation").Animation[];
  34236. /**
  34237. * An event triggered when the texture is disposed.
  34238. */
  34239. onDisposeObservable: Observable<BaseTexture>;
  34240. private _onDisposeObserver;
  34241. /**
  34242. * Callback triggered when the texture has been disposed.
  34243. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34244. */
  34245. set onDispose(callback: () => void);
  34246. /**
  34247. * Define the current state of the loading sequence when in delayed load mode.
  34248. */
  34249. delayLoadState: number;
  34250. private _scene;
  34251. private _engine;
  34252. /** @hidden */
  34253. _texture: Nullable<InternalTexture>;
  34254. private _uid;
  34255. /**
  34256. * Define if the texture is preventinga material to render or not.
  34257. * If not and the texture is not ready, the engine will use a default black texture instead.
  34258. */
  34259. get isBlocking(): boolean;
  34260. /**
  34261. * Instantiates a new BaseTexture.
  34262. * Base class of all the textures in babylon.
  34263. * It groups all the common properties the materials, post process, lights... might need
  34264. * in order to make a correct use of the texture.
  34265. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34266. */
  34267. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34268. /**
  34269. * Get the scene the texture belongs to.
  34270. * @returns the scene or null if undefined
  34271. */
  34272. getScene(): Nullable<Scene>;
  34273. /** @hidden */
  34274. protected _getEngine(): Nullable<ThinEngine>;
  34275. /**
  34276. * Get the texture transform matrix used to offset tile the texture for istance.
  34277. * @returns the transformation matrix
  34278. */
  34279. getTextureMatrix(): Matrix;
  34280. /**
  34281. * Get the texture reflection matrix used to rotate/transform the reflection.
  34282. * @returns the reflection matrix
  34283. */
  34284. getReflectionTextureMatrix(): Matrix;
  34285. /**
  34286. * Get the underlying lower level texture from Babylon.
  34287. * @returns the insternal texture
  34288. */
  34289. getInternalTexture(): Nullable<InternalTexture>;
  34290. /**
  34291. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34292. * @returns true if ready or not blocking
  34293. */
  34294. isReadyOrNotBlocking(): boolean;
  34295. /**
  34296. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34297. * @returns true if fully ready
  34298. */
  34299. isReady(): boolean;
  34300. private _cachedSize;
  34301. /**
  34302. * Get the size of the texture.
  34303. * @returns the texture size.
  34304. */
  34305. getSize(): ISize;
  34306. /**
  34307. * Get the base size of the texture.
  34308. * It can be different from the size if the texture has been resized for POT for instance
  34309. * @returns the base size
  34310. */
  34311. getBaseSize(): ISize;
  34312. /**
  34313. * Update the sampling mode of the texture.
  34314. * Default is Trilinear mode.
  34315. *
  34316. * | Value | Type | Description |
  34317. * | ----- | ------------------ | ----------- |
  34318. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34319. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34320. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34321. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34322. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34323. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34324. * | 7 | NEAREST_LINEAR | |
  34325. * | 8 | NEAREST_NEAREST | |
  34326. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34327. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34328. * | 11 | LINEAR_LINEAR | |
  34329. * | 12 | LINEAR_NEAREST | |
  34330. *
  34331. * > _mag_: magnification filter (close to the viewer)
  34332. * > _min_: minification filter (far from the viewer)
  34333. * > _mip_: filter used between mip map levels
  34334. *@param samplingMode Define the new sampling mode of the texture
  34335. */
  34336. updateSamplingMode(samplingMode: number): void;
  34337. /**
  34338. * Scales the texture if is `canRescale()`
  34339. * @param ratio the resize factor we want to use to rescale
  34340. */
  34341. scale(ratio: number): void;
  34342. /**
  34343. * Get if the texture can rescale.
  34344. */
  34345. get canRescale(): boolean;
  34346. /** @hidden */
  34347. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34348. /** @hidden */
  34349. _rebuild(): void;
  34350. /**
  34351. * Triggers the load sequence in delayed load mode.
  34352. */
  34353. delayLoad(): void;
  34354. /**
  34355. * Clones the texture.
  34356. * @returns the cloned texture
  34357. */
  34358. clone(): Nullable<BaseTexture>;
  34359. /**
  34360. * Get the texture underlying type (INT, FLOAT...)
  34361. */
  34362. get textureType(): number;
  34363. /**
  34364. * Get the texture underlying format (RGB, RGBA...)
  34365. */
  34366. get textureFormat(): number;
  34367. /**
  34368. * Indicates that textures need to be re-calculated for all materials
  34369. */
  34370. protected _markAllSubMeshesAsTexturesDirty(): void;
  34371. /**
  34372. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34373. * This will returns an RGBA array buffer containing either in values (0-255) or
  34374. * float values (0-1) depending of the underlying buffer type.
  34375. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34376. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34377. * @param buffer defines a user defined buffer to fill with data (can be null)
  34378. * @returns The Array buffer containing the pixels data.
  34379. */
  34380. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34381. /**
  34382. * Release and destroy the underlying lower level texture aka internalTexture.
  34383. */
  34384. releaseInternalTexture(): void;
  34385. /** @hidden */
  34386. get _lodTextureHigh(): Nullable<BaseTexture>;
  34387. /** @hidden */
  34388. get _lodTextureMid(): Nullable<BaseTexture>;
  34389. /** @hidden */
  34390. get _lodTextureLow(): Nullable<BaseTexture>;
  34391. /**
  34392. * Dispose the texture and release its associated resources.
  34393. */
  34394. dispose(): void;
  34395. /**
  34396. * Serialize the texture into a JSON representation that can be parsed later on.
  34397. * @returns the JSON representation of the texture
  34398. */
  34399. serialize(): any;
  34400. /**
  34401. * Helper function to be called back once a list of texture contains only ready textures.
  34402. * @param textures Define the list of textures to wait for
  34403. * @param callback Define the callback triggered once the entire list will be ready
  34404. */
  34405. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34406. private static _isScene;
  34407. }
  34408. }
  34409. declare module "babylonjs/Materials/effect" {
  34410. import { Observable } from "babylonjs/Misc/observable";
  34411. import { Nullable } from "babylonjs/types";
  34412. import { IDisposable } from "babylonjs/scene";
  34413. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34414. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34415. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  34416. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34417. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  34418. import { Engine } from "babylonjs/Engines/engine";
  34419. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34420. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34421. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34422. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34423. /**
  34424. * Options to be used when creating an effect.
  34425. */
  34426. export interface IEffectCreationOptions {
  34427. /**
  34428. * Atrributes that will be used in the shader.
  34429. */
  34430. attributes: string[];
  34431. /**
  34432. * Uniform varible names that will be set in the shader.
  34433. */
  34434. uniformsNames: string[];
  34435. /**
  34436. * Uniform buffer variable names that will be set in the shader.
  34437. */
  34438. uniformBuffersNames: string[];
  34439. /**
  34440. * Sampler texture variable names that will be set in the shader.
  34441. */
  34442. samplers: string[];
  34443. /**
  34444. * Define statements that will be set in the shader.
  34445. */
  34446. defines: any;
  34447. /**
  34448. * Possible fallbacks for this effect to improve performance when needed.
  34449. */
  34450. fallbacks: Nullable<IEffectFallbacks>;
  34451. /**
  34452. * Callback that will be called when the shader is compiled.
  34453. */
  34454. onCompiled: Nullable<(effect: Effect) => void>;
  34455. /**
  34456. * Callback that will be called if an error occurs during shader compilation.
  34457. */
  34458. onError: Nullable<(effect: Effect, errors: string) => void>;
  34459. /**
  34460. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34461. */
  34462. indexParameters?: any;
  34463. /**
  34464. * Max number of lights that can be used in the shader.
  34465. */
  34466. maxSimultaneousLights?: number;
  34467. /**
  34468. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34469. */
  34470. transformFeedbackVaryings?: Nullable<string[]>;
  34471. /**
  34472. * 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
  34473. */
  34474. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34475. }
  34476. /**
  34477. * Effect containing vertex and fragment shader that can be executed on an object.
  34478. */
  34479. export class Effect implements IDisposable {
  34480. /**
  34481. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34482. */
  34483. static ShadersRepository: string;
  34484. /**
  34485. * Enable logging of the shader code when a compilation error occurs
  34486. */
  34487. static LogShaderCodeOnCompilationError: boolean;
  34488. /**
  34489. * Name of the effect.
  34490. */
  34491. name: any;
  34492. /**
  34493. * String container all the define statements that should be set on the shader.
  34494. */
  34495. defines: string;
  34496. /**
  34497. * Callback that will be called when the shader is compiled.
  34498. */
  34499. onCompiled: Nullable<(effect: Effect) => void>;
  34500. /**
  34501. * Callback that will be called if an error occurs during shader compilation.
  34502. */
  34503. onError: Nullable<(effect: Effect, errors: string) => void>;
  34504. /**
  34505. * Callback that will be called when effect is bound.
  34506. */
  34507. onBind: Nullable<(effect: Effect) => void>;
  34508. /**
  34509. * Unique ID of the effect.
  34510. */
  34511. uniqueId: number;
  34512. /**
  34513. * Observable that will be called when the shader is compiled.
  34514. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34515. */
  34516. onCompileObservable: Observable<Effect>;
  34517. /**
  34518. * Observable that will be called if an error occurs during shader compilation.
  34519. */
  34520. onErrorObservable: Observable<Effect>;
  34521. /** @hidden */
  34522. _onBindObservable: Nullable<Observable<Effect>>;
  34523. /**
  34524. * @hidden
  34525. * Specifies if the effect was previously ready
  34526. */
  34527. _wasPreviouslyReady: boolean;
  34528. /**
  34529. * Observable that will be called when effect is bound.
  34530. */
  34531. get onBindObservable(): Observable<Effect>;
  34532. /** @hidden */
  34533. _bonesComputationForcedToCPU: boolean;
  34534. private static _uniqueIdSeed;
  34535. private _engine;
  34536. private _uniformBuffersNames;
  34537. private _uniformBuffersNamesList;
  34538. private _uniformsNames;
  34539. private _samplerList;
  34540. private _samplers;
  34541. private _isReady;
  34542. private _compilationError;
  34543. private _allFallbacksProcessed;
  34544. private _attributesNames;
  34545. private _attributes;
  34546. private _attributeLocationByName;
  34547. private _uniforms;
  34548. /**
  34549. * Key for the effect.
  34550. * @hidden
  34551. */
  34552. _key: string;
  34553. private _indexParameters;
  34554. private _fallbacks;
  34555. private _vertexSourceCode;
  34556. private _fragmentSourceCode;
  34557. private _vertexSourceCodeOverride;
  34558. private _fragmentSourceCodeOverride;
  34559. private _transformFeedbackVaryings;
  34560. /**
  34561. * Compiled shader to webGL program.
  34562. * @hidden
  34563. */
  34564. _pipelineContext: Nullable<IPipelineContext>;
  34565. private _valueCache;
  34566. private static _baseCache;
  34567. /**
  34568. * Instantiates an effect.
  34569. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34570. * @param baseName Name of the effect.
  34571. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34572. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34573. * @param samplers List of sampler variables that will be passed to the shader.
  34574. * @param engine Engine to be used to render the effect
  34575. * @param defines Define statements to be added to the shader.
  34576. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34577. * @param onCompiled Callback that will be called when the shader is compiled.
  34578. * @param onError Callback that will be called if an error occurs during shader compilation.
  34579. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34580. */
  34581. 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);
  34582. private _useFinalCode;
  34583. /**
  34584. * Unique key for this effect
  34585. */
  34586. get key(): string;
  34587. /**
  34588. * If the effect has been compiled and prepared.
  34589. * @returns if the effect is compiled and prepared.
  34590. */
  34591. isReady(): boolean;
  34592. private _isReadyInternal;
  34593. /**
  34594. * The engine the effect was initialized with.
  34595. * @returns the engine.
  34596. */
  34597. getEngine(): Engine;
  34598. /**
  34599. * The pipeline context for this effect
  34600. * @returns the associated pipeline context
  34601. */
  34602. getPipelineContext(): Nullable<IPipelineContext>;
  34603. /**
  34604. * The set of names of attribute variables for the shader.
  34605. * @returns An array of attribute names.
  34606. */
  34607. getAttributesNames(): string[];
  34608. /**
  34609. * Returns the attribute at the given index.
  34610. * @param index The index of the attribute.
  34611. * @returns The location of the attribute.
  34612. */
  34613. getAttributeLocation(index: number): number;
  34614. /**
  34615. * Returns the attribute based on the name of the variable.
  34616. * @param name of the attribute to look up.
  34617. * @returns the attribute location.
  34618. */
  34619. getAttributeLocationByName(name: string): number;
  34620. /**
  34621. * The number of attributes.
  34622. * @returns the numnber of attributes.
  34623. */
  34624. getAttributesCount(): number;
  34625. /**
  34626. * Gets the index of a uniform variable.
  34627. * @param uniformName of the uniform to look up.
  34628. * @returns the index.
  34629. */
  34630. getUniformIndex(uniformName: string): number;
  34631. /**
  34632. * Returns the attribute based on the name of the variable.
  34633. * @param uniformName of the uniform to look up.
  34634. * @returns the location of the uniform.
  34635. */
  34636. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34637. /**
  34638. * Returns an array of sampler variable names
  34639. * @returns The array of sampler variable names.
  34640. */
  34641. getSamplers(): string[];
  34642. /**
  34643. * Returns an array of uniform variable names
  34644. * @returns The array of uniform variable names.
  34645. */
  34646. getUniformNames(): string[];
  34647. /**
  34648. * Returns an array of uniform buffer variable names
  34649. * @returns The array of uniform buffer variable names.
  34650. */
  34651. getUniformBuffersNames(): string[];
  34652. /**
  34653. * Returns the index parameters used to create the effect
  34654. * @returns The index parameters object
  34655. */
  34656. getIndexParameters(): any;
  34657. /**
  34658. * The error from the last compilation.
  34659. * @returns the error string.
  34660. */
  34661. getCompilationError(): string;
  34662. /**
  34663. * Gets a boolean indicating that all fallbacks were used during compilation
  34664. * @returns true if all fallbacks were used
  34665. */
  34666. allFallbacksProcessed(): boolean;
  34667. /**
  34668. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34669. * @param func The callback to be used.
  34670. */
  34671. executeWhenCompiled(func: (effect: Effect) => void): void;
  34672. private _checkIsReady;
  34673. private _loadShader;
  34674. /**
  34675. * Gets the vertex shader source code of this effect
  34676. */
  34677. get vertexSourceCode(): string;
  34678. /**
  34679. * Gets the fragment shader source code of this effect
  34680. */
  34681. get fragmentSourceCode(): string;
  34682. /**
  34683. * Recompiles the webGL program
  34684. * @param vertexSourceCode The source code for the vertex shader.
  34685. * @param fragmentSourceCode The source code for the fragment shader.
  34686. * @param onCompiled Callback called when completed.
  34687. * @param onError Callback called on error.
  34688. * @hidden
  34689. */
  34690. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34691. /**
  34692. * Prepares the effect
  34693. * @hidden
  34694. */
  34695. _prepareEffect(): void;
  34696. private _getShaderCodeAndErrorLine;
  34697. private _processCompilationErrors;
  34698. /**
  34699. * Checks if the effect is supported. (Must be called after compilation)
  34700. */
  34701. get isSupported(): boolean;
  34702. /**
  34703. * Binds a texture to the engine to be used as output of the shader.
  34704. * @param channel Name of the output variable.
  34705. * @param texture Texture to bind.
  34706. * @hidden
  34707. */
  34708. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34709. /**
  34710. * Sets a texture on the engine to be used in the shader.
  34711. * @param channel Name of the sampler variable.
  34712. * @param texture Texture to set.
  34713. */
  34714. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34715. /**
  34716. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34717. * @param channel Name of the sampler variable.
  34718. * @param texture Texture to set.
  34719. */
  34720. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34721. /**
  34722. * Sets an array of textures on the engine to be used in the shader.
  34723. * @param channel Name of the variable.
  34724. * @param textures Textures to set.
  34725. */
  34726. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34727. /**
  34728. * 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)
  34729. * @param channel Name of the sampler variable.
  34730. * @param postProcess Post process to get the input texture from.
  34731. */
  34732. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34733. /**
  34734. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34735. * 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)
  34736. * @param channel Name of the sampler variable.
  34737. * @param postProcess Post process to get the output texture from.
  34738. */
  34739. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34740. /** @hidden */
  34741. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34742. /** @hidden */
  34743. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34744. /** @hidden */
  34745. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34746. /** @hidden */
  34747. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34748. /**
  34749. * Binds a buffer to a uniform.
  34750. * @param buffer Buffer to bind.
  34751. * @param name Name of the uniform variable to bind to.
  34752. */
  34753. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34754. /**
  34755. * Binds block to a uniform.
  34756. * @param blockName Name of the block to bind.
  34757. * @param index Index to bind.
  34758. */
  34759. bindUniformBlock(blockName: string, index: number): void;
  34760. /**
  34761. * Sets an interger value on a uniform variable.
  34762. * @param uniformName Name of the variable.
  34763. * @param value Value to be set.
  34764. * @returns this effect.
  34765. */
  34766. setInt(uniformName: string, value: number): Effect;
  34767. /**
  34768. * Sets an int array on a uniform variable.
  34769. * @param uniformName Name of the variable.
  34770. * @param array array to be set.
  34771. * @returns this effect.
  34772. */
  34773. setIntArray(uniformName: string, array: Int32Array): Effect;
  34774. /**
  34775. * 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)
  34776. * @param uniformName Name of the variable.
  34777. * @param array array to be set.
  34778. * @returns this effect.
  34779. */
  34780. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34781. /**
  34782. * 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)
  34783. * @param uniformName Name of the variable.
  34784. * @param array array to be set.
  34785. * @returns this effect.
  34786. */
  34787. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34788. /**
  34789. * 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)
  34790. * @param uniformName Name of the variable.
  34791. * @param array array to be set.
  34792. * @returns this effect.
  34793. */
  34794. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34795. /**
  34796. * Sets an float array on a uniform variable.
  34797. * @param uniformName Name of the variable.
  34798. * @param array array to be set.
  34799. * @returns this effect.
  34800. */
  34801. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34802. /**
  34803. * 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)
  34804. * @param uniformName Name of the variable.
  34805. * @param array array to be set.
  34806. * @returns this effect.
  34807. */
  34808. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34809. /**
  34810. * 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)
  34811. * @param uniformName Name of the variable.
  34812. * @param array array to be set.
  34813. * @returns this effect.
  34814. */
  34815. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34816. /**
  34817. * 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)
  34818. * @param uniformName Name of the variable.
  34819. * @param array array to be set.
  34820. * @returns this effect.
  34821. */
  34822. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34823. /**
  34824. * Sets an array on a uniform variable.
  34825. * @param uniformName Name of the variable.
  34826. * @param array array to be set.
  34827. * @returns this effect.
  34828. */
  34829. setArray(uniformName: string, array: number[]): Effect;
  34830. /**
  34831. * 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)
  34832. * @param uniformName Name of the variable.
  34833. * @param array array to be set.
  34834. * @returns this effect.
  34835. */
  34836. setArray2(uniformName: string, array: number[]): Effect;
  34837. /**
  34838. * 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)
  34839. * @param uniformName Name of the variable.
  34840. * @param array array to be set.
  34841. * @returns this effect.
  34842. */
  34843. setArray3(uniformName: string, array: number[]): Effect;
  34844. /**
  34845. * 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)
  34846. * @param uniformName Name of the variable.
  34847. * @param array array to be set.
  34848. * @returns this effect.
  34849. */
  34850. setArray4(uniformName: string, array: number[]): Effect;
  34851. /**
  34852. * Sets matrices on a uniform variable.
  34853. * @param uniformName Name of the variable.
  34854. * @param matrices matrices to be set.
  34855. * @returns this effect.
  34856. */
  34857. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  34858. /**
  34859. * Sets matrix on a uniform variable.
  34860. * @param uniformName Name of the variable.
  34861. * @param matrix matrix to be set.
  34862. * @returns this effect.
  34863. */
  34864. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34865. /**
  34866. * 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)
  34867. * @param uniformName Name of the variable.
  34868. * @param matrix matrix to be set.
  34869. * @returns this effect.
  34870. */
  34871. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  34872. /**
  34873. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34874. * @param uniformName Name of the variable.
  34875. * @param matrix matrix to be set.
  34876. * @returns this effect.
  34877. */
  34878. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  34879. /**
  34880. * Sets a float on a uniform variable.
  34881. * @param uniformName Name of the variable.
  34882. * @param value value to be set.
  34883. * @returns this effect.
  34884. */
  34885. setFloat(uniformName: string, value: number): Effect;
  34886. /**
  34887. * Sets a boolean on a uniform variable.
  34888. * @param uniformName Name of the variable.
  34889. * @param bool value to be set.
  34890. * @returns this effect.
  34891. */
  34892. setBool(uniformName: string, bool: boolean): Effect;
  34893. /**
  34894. * Sets a Vector2 on a uniform variable.
  34895. * @param uniformName Name of the variable.
  34896. * @param vector2 vector2 to be set.
  34897. * @returns this effect.
  34898. */
  34899. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34900. /**
  34901. * Sets a float2 on a uniform variable.
  34902. * @param uniformName Name of the variable.
  34903. * @param x First float in float2.
  34904. * @param y Second float in float2.
  34905. * @returns this effect.
  34906. */
  34907. setFloat2(uniformName: string, x: number, y: number): Effect;
  34908. /**
  34909. * Sets a Vector3 on a uniform variable.
  34910. * @param uniformName Name of the variable.
  34911. * @param vector3 Value to be set.
  34912. * @returns this effect.
  34913. */
  34914. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34915. /**
  34916. * Sets a float3 on a uniform variable.
  34917. * @param uniformName Name of the variable.
  34918. * @param x First float in float3.
  34919. * @param y Second float in float3.
  34920. * @param z Third float in float3.
  34921. * @returns this effect.
  34922. */
  34923. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34924. /**
  34925. * Sets a Vector4 on a uniform variable.
  34926. * @param uniformName Name of the variable.
  34927. * @param vector4 Value to be set.
  34928. * @returns this effect.
  34929. */
  34930. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34931. /**
  34932. * Sets a float4 on a uniform variable.
  34933. * @param uniformName Name of the variable.
  34934. * @param x First float in float4.
  34935. * @param y Second float in float4.
  34936. * @param z Third float in float4.
  34937. * @param w Fourth float in float4.
  34938. * @returns this effect.
  34939. */
  34940. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34941. /**
  34942. * Sets a Color3 on a uniform variable.
  34943. * @param uniformName Name of the variable.
  34944. * @param color3 Value to be set.
  34945. * @returns this effect.
  34946. */
  34947. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34948. /**
  34949. * Sets a Color4 on a uniform variable.
  34950. * @param uniformName Name of the variable.
  34951. * @param color3 Value to be set.
  34952. * @param alpha Alpha value to be set.
  34953. * @returns this effect.
  34954. */
  34955. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34956. /**
  34957. * Sets a Color4 on a uniform variable
  34958. * @param uniformName defines the name of the variable
  34959. * @param color4 defines the value to be set
  34960. * @returns this effect.
  34961. */
  34962. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34963. /** Release all associated resources */
  34964. dispose(): void;
  34965. /**
  34966. * This function will add a new shader to the shader store
  34967. * @param name the name of the shader
  34968. * @param pixelShader optional pixel shader content
  34969. * @param vertexShader optional vertex shader content
  34970. */
  34971. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34972. /**
  34973. * Store of each shader (The can be looked up using effect.key)
  34974. */
  34975. static ShadersStore: {
  34976. [key: string]: string;
  34977. };
  34978. /**
  34979. * Store of each included file for a shader (The can be looked up using effect.key)
  34980. */
  34981. static IncludesShadersStore: {
  34982. [key: string]: string;
  34983. };
  34984. /**
  34985. * Resets the cache of effects.
  34986. */
  34987. static ResetCache(): void;
  34988. }
  34989. }
  34990. declare module "babylonjs/Engines/engineCapabilities" {
  34991. /**
  34992. * Interface used to describe the capabilities of the engine relatively to the current browser
  34993. */
  34994. export interface EngineCapabilities {
  34995. /** Maximum textures units per fragment shader */
  34996. maxTexturesImageUnits: number;
  34997. /** Maximum texture units per vertex shader */
  34998. maxVertexTextureImageUnits: number;
  34999. /** Maximum textures units in the entire pipeline */
  35000. maxCombinedTexturesImageUnits: number;
  35001. /** Maximum texture size */
  35002. maxTextureSize: number;
  35003. /** Maximum texture samples */
  35004. maxSamples?: number;
  35005. /** Maximum cube texture size */
  35006. maxCubemapTextureSize: number;
  35007. /** Maximum render texture size */
  35008. maxRenderTextureSize: number;
  35009. /** Maximum number of vertex attributes */
  35010. maxVertexAttribs: number;
  35011. /** Maximum number of varyings */
  35012. maxVaryingVectors: number;
  35013. /** Maximum number of uniforms per vertex shader */
  35014. maxVertexUniformVectors: number;
  35015. /** Maximum number of uniforms per fragment shader */
  35016. maxFragmentUniformVectors: number;
  35017. /** Defines if standard derivates (dx/dy) are supported */
  35018. standardDerivatives: boolean;
  35019. /** Defines if s3tc texture compression is supported */
  35020. s3tc?: WEBGL_compressed_texture_s3tc;
  35021. /** Defines if pvrtc texture compression is supported */
  35022. pvrtc: any;
  35023. /** Defines if etc1 texture compression is supported */
  35024. etc1: any;
  35025. /** Defines if etc2 texture compression is supported */
  35026. etc2: any;
  35027. /** Defines if astc texture compression is supported */
  35028. astc: any;
  35029. /** Defines if float textures are supported */
  35030. textureFloat: boolean;
  35031. /** Defines if vertex array objects are supported */
  35032. vertexArrayObject: boolean;
  35033. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  35034. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  35035. /** Gets the maximum level of anisotropy supported */
  35036. maxAnisotropy: number;
  35037. /** Defines if instancing is supported */
  35038. instancedArrays: boolean;
  35039. /** Defines if 32 bits indices are supported */
  35040. uintIndices: boolean;
  35041. /** Defines if high precision shaders are supported */
  35042. highPrecisionShaderSupported: boolean;
  35043. /** Defines if depth reading in the fragment shader is supported */
  35044. fragmentDepthSupported: boolean;
  35045. /** Defines if float texture linear filtering is supported*/
  35046. textureFloatLinearFiltering: boolean;
  35047. /** Defines if rendering to float textures is supported */
  35048. textureFloatRender: boolean;
  35049. /** Defines if half float textures are supported*/
  35050. textureHalfFloat: boolean;
  35051. /** Defines if half float texture linear filtering is supported*/
  35052. textureHalfFloatLinearFiltering: boolean;
  35053. /** Defines if rendering to half float textures is supported */
  35054. textureHalfFloatRender: boolean;
  35055. /** Defines if textureLOD shader command is supported */
  35056. textureLOD: boolean;
  35057. /** Defines if draw buffers extension is supported */
  35058. drawBuffersExtension: boolean;
  35059. /** Defines if depth textures are supported */
  35060. depthTextureExtension: boolean;
  35061. /** Defines if float color buffer are supported */
  35062. colorBufferFloat: boolean;
  35063. /** Gets disjoint timer query extension (null if not supported) */
  35064. timerQuery?: EXT_disjoint_timer_query;
  35065. /** Defines if timestamp can be used with timer query */
  35066. canUseTimestampForTimerQuery: boolean;
  35067. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  35068. multiview?: any;
  35069. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  35070. oculusMultiview?: any;
  35071. /** Function used to let the system compiles shaders in background */
  35072. parallelShaderCompile?: {
  35073. COMPLETION_STATUS_KHR: number;
  35074. };
  35075. /** Max number of texture samples for MSAA */
  35076. maxMSAASamples: number;
  35077. /** Defines if the blend min max extension is supported */
  35078. blendMinMax: boolean;
  35079. }
  35080. }
  35081. declare module "babylonjs/States/depthCullingState" {
  35082. import { Nullable } from "babylonjs/types";
  35083. /**
  35084. * @hidden
  35085. **/
  35086. export class DepthCullingState {
  35087. private _isDepthTestDirty;
  35088. private _isDepthMaskDirty;
  35089. private _isDepthFuncDirty;
  35090. private _isCullFaceDirty;
  35091. private _isCullDirty;
  35092. private _isZOffsetDirty;
  35093. private _isFrontFaceDirty;
  35094. private _depthTest;
  35095. private _depthMask;
  35096. private _depthFunc;
  35097. private _cull;
  35098. private _cullFace;
  35099. private _zOffset;
  35100. private _frontFace;
  35101. /**
  35102. * Initializes the state.
  35103. */
  35104. constructor();
  35105. get isDirty(): boolean;
  35106. get zOffset(): number;
  35107. set zOffset(value: number);
  35108. get cullFace(): Nullable<number>;
  35109. set cullFace(value: Nullable<number>);
  35110. get cull(): Nullable<boolean>;
  35111. set cull(value: Nullable<boolean>);
  35112. get depthFunc(): Nullable<number>;
  35113. set depthFunc(value: Nullable<number>);
  35114. get depthMask(): boolean;
  35115. set depthMask(value: boolean);
  35116. get depthTest(): boolean;
  35117. set depthTest(value: boolean);
  35118. get frontFace(): Nullable<number>;
  35119. set frontFace(value: Nullable<number>);
  35120. reset(): void;
  35121. apply(gl: WebGLRenderingContext): void;
  35122. }
  35123. }
  35124. declare module "babylonjs/States/stencilState" {
  35125. /**
  35126. * @hidden
  35127. **/
  35128. export class StencilState {
  35129. /** 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 */
  35130. static readonly ALWAYS: number;
  35131. /** Passed to stencilOperation to specify that stencil value must be kept */
  35132. static readonly KEEP: number;
  35133. /** Passed to stencilOperation to specify that stencil value must be replaced */
  35134. static readonly REPLACE: number;
  35135. private _isStencilTestDirty;
  35136. private _isStencilMaskDirty;
  35137. private _isStencilFuncDirty;
  35138. private _isStencilOpDirty;
  35139. private _stencilTest;
  35140. private _stencilMask;
  35141. private _stencilFunc;
  35142. private _stencilFuncRef;
  35143. private _stencilFuncMask;
  35144. private _stencilOpStencilFail;
  35145. private _stencilOpDepthFail;
  35146. private _stencilOpStencilDepthPass;
  35147. get isDirty(): boolean;
  35148. get stencilFunc(): number;
  35149. set stencilFunc(value: number);
  35150. get stencilFuncRef(): number;
  35151. set stencilFuncRef(value: number);
  35152. get stencilFuncMask(): number;
  35153. set stencilFuncMask(value: number);
  35154. get stencilOpStencilFail(): number;
  35155. set stencilOpStencilFail(value: number);
  35156. get stencilOpDepthFail(): number;
  35157. set stencilOpDepthFail(value: number);
  35158. get stencilOpStencilDepthPass(): number;
  35159. set stencilOpStencilDepthPass(value: number);
  35160. get stencilMask(): number;
  35161. set stencilMask(value: number);
  35162. get stencilTest(): boolean;
  35163. set stencilTest(value: boolean);
  35164. constructor();
  35165. reset(): void;
  35166. apply(gl: WebGLRenderingContext): void;
  35167. }
  35168. }
  35169. declare module "babylonjs/States/alphaCullingState" {
  35170. /**
  35171. * @hidden
  35172. **/
  35173. export class AlphaState {
  35174. private _isAlphaBlendDirty;
  35175. private _isBlendFunctionParametersDirty;
  35176. private _isBlendEquationParametersDirty;
  35177. private _isBlendConstantsDirty;
  35178. private _alphaBlend;
  35179. private _blendFunctionParameters;
  35180. private _blendEquationParameters;
  35181. private _blendConstants;
  35182. /**
  35183. * Initializes the state.
  35184. */
  35185. constructor();
  35186. get isDirty(): boolean;
  35187. get alphaBlend(): boolean;
  35188. set alphaBlend(value: boolean);
  35189. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35190. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35191. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35192. reset(): void;
  35193. apply(gl: WebGLRenderingContext): void;
  35194. }
  35195. }
  35196. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  35197. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35198. /** @hidden */
  35199. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35200. attributeProcessor(attribute: string): string;
  35201. varyingProcessor(varying: string, isFragment: boolean): string;
  35202. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35203. }
  35204. }
  35205. declare module "babylonjs/Engines/instancingAttributeInfo" {
  35206. /**
  35207. * Interface for attribute information associated with buffer instanciation
  35208. */
  35209. export interface InstancingAttributeInfo {
  35210. /**
  35211. * Name of the GLSL attribute
  35212. * if attribute index is not specified, this is used to retrieve the index from the effect
  35213. */
  35214. attributeName: string;
  35215. /**
  35216. * Index/offset of the attribute in the vertex shader
  35217. * if not specified, this will be computes from the name.
  35218. */
  35219. index?: number;
  35220. /**
  35221. * size of the attribute, 1, 2, 3 or 4
  35222. */
  35223. attributeSize: number;
  35224. /**
  35225. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  35226. */
  35227. offset: number;
  35228. /**
  35229. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  35230. * default to 1
  35231. */
  35232. divisor?: number;
  35233. /**
  35234. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35235. * default is FLOAT
  35236. */
  35237. attributeType?: number;
  35238. /**
  35239. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35240. */
  35241. normalized?: boolean;
  35242. }
  35243. }
  35244. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  35245. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35246. import { Nullable } from "babylonjs/types";
  35247. module "babylonjs/Engines/thinEngine" {
  35248. interface ThinEngine {
  35249. /**
  35250. * Update a video texture
  35251. * @param texture defines the texture to update
  35252. * @param video defines the video element to use
  35253. * @param invertY defines if data must be stored with Y axis inverted
  35254. */
  35255. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35256. }
  35257. }
  35258. }
  35259. declare module "babylonjs/Materials/Textures/videoTexture" {
  35260. import { Observable } from "babylonjs/Misc/observable";
  35261. import { Nullable } from "babylonjs/types";
  35262. import { Scene } from "babylonjs/scene";
  35263. import { Texture } from "babylonjs/Materials/Textures/texture";
  35264. import "babylonjs/Engines/Extensions/engine.videoTexture";
  35265. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  35266. /**
  35267. * Settings for finer control over video usage
  35268. */
  35269. export interface VideoTextureSettings {
  35270. /**
  35271. * Applies `autoplay` to video, if specified
  35272. */
  35273. autoPlay?: boolean;
  35274. /**
  35275. * Applies `loop` to video, if specified
  35276. */
  35277. loop?: boolean;
  35278. /**
  35279. * Automatically updates internal texture from video at every frame in the render loop
  35280. */
  35281. autoUpdateTexture: boolean;
  35282. /**
  35283. * Image src displayed during the video loading or until the user interacts with the video.
  35284. */
  35285. poster?: string;
  35286. }
  35287. /**
  35288. * If you want to display a video in your scene, this is the special texture for that.
  35289. * This special texture works similar to other textures, with the exception of a few parameters.
  35290. * @see https://doc.babylonjs.com/how_to/video_texture
  35291. */
  35292. export class VideoTexture extends Texture {
  35293. /**
  35294. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35295. */
  35296. readonly autoUpdateTexture: boolean;
  35297. /**
  35298. * The video instance used by the texture internally
  35299. */
  35300. readonly video: HTMLVideoElement;
  35301. private _onUserActionRequestedObservable;
  35302. /**
  35303. * Event triggerd when a dom action is required by the user to play the video.
  35304. * This happens due to recent changes in browser policies preventing video to auto start.
  35305. */
  35306. get onUserActionRequestedObservable(): Observable<Texture>;
  35307. private _generateMipMaps;
  35308. private _stillImageCaptured;
  35309. private _displayingPosterTexture;
  35310. private _settings;
  35311. private _createInternalTextureOnEvent;
  35312. private _frameId;
  35313. private _currentSrc;
  35314. /**
  35315. * Creates a video texture.
  35316. * If you want to display a video in your scene, this is the special texture for that.
  35317. * This special texture works similar to other textures, with the exception of a few parameters.
  35318. * @see https://doc.babylonjs.com/how_to/video_texture
  35319. * @param name optional name, will detect from video source, if not defined
  35320. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35321. * @param scene is obviously the current scene.
  35322. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35323. * @param invertY is false by default but can be used to invert video on Y axis
  35324. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35325. * @param settings allows finer control over video usage
  35326. */
  35327. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35328. private _getName;
  35329. private _getVideo;
  35330. private _createInternalTexture;
  35331. private reset;
  35332. /**
  35333. * @hidden Internal method to initiate `update`.
  35334. */
  35335. _rebuild(): void;
  35336. /**
  35337. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35338. */
  35339. update(): void;
  35340. /**
  35341. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35342. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35343. */
  35344. updateTexture(isVisible: boolean): void;
  35345. protected _updateInternalTexture: () => void;
  35346. /**
  35347. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35348. * @param url New url.
  35349. */
  35350. updateURL(url: string): void;
  35351. /**
  35352. * Clones the texture.
  35353. * @returns the cloned texture
  35354. */
  35355. clone(): VideoTexture;
  35356. /**
  35357. * Dispose the texture and release its associated resources.
  35358. */
  35359. dispose(): void;
  35360. /**
  35361. * Creates a video texture straight from a stream.
  35362. * @param scene Define the scene the texture should be created in
  35363. * @param stream Define the stream the texture should be created from
  35364. * @returns The created video texture as a promise
  35365. */
  35366. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35367. /**
  35368. * Creates a video texture straight from your WebCam video feed.
  35369. * @param scene Define the scene the texture should be created in
  35370. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35371. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35372. * @returns The created video texture as a promise
  35373. */
  35374. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35375. minWidth: number;
  35376. maxWidth: number;
  35377. minHeight: number;
  35378. maxHeight: number;
  35379. deviceId: string;
  35380. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35381. /**
  35382. * Creates a video texture straight from your WebCam video feed.
  35383. * @param scene Define the scene the texture should be created in
  35384. * @param onReady Define a callback to triggered once the texture will be ready
  35385. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35386. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35387. */
  35388. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35389. minWidth: number;
  35390. maxWidth: number;
  35391. minHeight: number;
  35392. maxHeight: number;
  35393. deviceId: string;
  35394. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35395. }
  35396. }
  35397. declare module "babylonjs/Engines/thinEngine" {
  35398. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  35399. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  35400. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35401. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35402. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  35403. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  35404. import { Observable } from "babylonjs/Misc/observable";
  35405. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  35406. import { StencilState } from "babylonjs/States/stencilState";
  35407. import { AlphaState } from "babylonjs/States/alphaCullingState";
  35408. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35409. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  35410. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35411. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35412. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35413. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  35414. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  35415. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  35416. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35417. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35418. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35419. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  35420. import { WebRequest } from "babylonjs/Misc/webRequest";
  35421. import { LoadFileError } from "babylonjs/Misc/fileTools";
  35422. /**
  35423. * Defines the interface used by objects working like Scene
  35424. * @hidden
  35425. */
  35426. export interface ISceneLike {
  35427. _addPendingData(data: any): void;
  35428. _removePendingData(data: any): void;
  35429. offlineProvider: IOfflineProvider;
  35430. }
  35431. /** Interface defining initialization parameters for Engine class */
  35432. export interface EngineOptions extends WebGLContextAttributes {
  35433. /**
  35434. * Defines if the engine should no exceed a specified device ratio
  35435. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35436. */
  35437. limitDeviceRatio?: number;
  35438. /**
  35439. * Defines if webvr should be enabled automatically
  35440. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35441. */
  35442. autoEnableWebVR?: boolean;
  35443. /**
  35444. * Defines if webgl2 should be turned off even if supported
  35445. * @see http://doc.babylonjs.com/features/webgl2
  35446. */
  35447. disableWebGL2Support?: boolean;
  35448. /**
  35449. * Defines if webaudio should be initialized as well
  35450. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35451. */
  35452. audioEngine?: boolean;
  35453. /**
  35454. * Defines if animations should run using a deterministic lock step
  35455. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35456. */
  35457. deterministicLockstep?: boolean;
  35458. /** Defines the maximum steps to use with deterministic lock step mode */
  35459. lockstepMaxSteps?: number;
  35460. /** Defines the seconds between each deterministic lock step */
  35461. timeStep?: number;
  35462. /**
  35463. * Defines that engine should ignore context lost events
  35464. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35465. */
  35466. doNotHandleContextLost?: boolean;
  35467. /**
  35468. * Defines that engine should ignore modifying touch action attribute and style
  35469. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35470. */
  35471. doNotHandleTouchAction?: boolean;
  35472. /**
  35473. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35474. */
  35475. useHighPrecisionFloats?: boolean;
  35476. /**
  35477. * Make the canvas XR Compatible for XR sessions
  35478. */
  35479. xrCompatible?: boolean;
  35480. }
  35481. /**
  35482. * The base engine class (root of all engines)
  35483. */
  35484. export class ThinEngine {
  35485. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35486. static ExceptionList: ({
  35487. key: string;
  35488. capture: string;
  35489. captureConstraint: number;
  35490. targets: string[];
  35491. } | {
  35492. key: string;
  35493. capture: null;
  35494. captureConstraint: null;
  35495. targets: string[];
  35496. })[];
  35497. /** @hidden */
  35498. static _TextureLoaders: IInternalTextureLoader[];
  35499. /**
  35500. * Returns the current npm package of the sdk
  35501. */
  35502. static get NpmPackage(): string;
  35503. /**
  35504. * Returns the current version of the framework
  35505. */
  35506. static get Version(): string;
  35507. /**
  35508. * Returns a string describing the current engine
  35509. */
  35510. get description(): string;
  35511. /**
  35512. * Gets or sets the epsilon value used by collision engine
  35513. */
  35514. static CollisionsEpsilon: number;
  35515. /**
  35516. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35517. */
  35518. static get ShadersRepository(): string;
  35519. static set ShadersRepository(value: string);
  35520. /** @hidden */
  35521. _shaderProcessor: IShaderProcessor;
  35522. /**
  35523. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35524. */
  35525. forcePOTTextures: boolean;
  35526. /**
  35527. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35528. */
  35529. isFullscreen: boolean;
  35530. /**
  35531. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35532. */
  35533. cullBackFaces: boolean;
  35534. /**
  35535. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35536. */
  35537. renderEvenInBackground: boolean;
  35538. /**
  35539. * Gets or sets a boolean indicating that cache can be kept between frames
  35540. */
  35541. preventCacheWipeBetweenFrames: boolean;
  35542. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35543. validateShaderPrograms: boolean;
  35544. /**
  35545. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35546. * This can provide greater z depth for distant objects.
  35547. */
  35548. useReverseDepthBuffer: boolean;
  35549. /**
  35550. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35551. */
  35552. disableUniformBuffers: boolean;
  35553. /** @hidden */
  35554. _uniformBuffers: UniformBuffer[];
  35555. /**
  35556. * Gets a boolean indicating that the engine supports uniform buffers
  35557. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35558. */
  35559. get supportsUniformBuffers(): boolean;
  35560. /** @hidden */
  35561. _gl: WebGLRenderingContext;
  35562. /** @hidden */
  35563. _webGLVersion: number;
  35564. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35565. protected _windowIsBackground: boolean;
  35566. protected _creationOptions: EngineOptions;
  35567. protected _highPrecisionShadersAllowed: boolean;
  35568. /** @hidden */
  35569. get _shouldUseHighPrecisionShader(): boolean;
  35570. /**
  35571. * Gets a boolean indicating that only power of 2 textures are supported
  35572. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35573. */
  35574. get needPOTTextures(): boolean;
  35575. /** @hidden */
  35576. _badOS: boolean;
  35577. /** @hidden */
  35578. _badDesktopOS: boolean;
  35579. private _hardwareScalingLevel;
  35580. /** @hidden */
  35581. _caps: EngineCapabilities;
  35582. private _isStencilEnable;
  35583. private _glVersion;
  35584. private _glRenderer;
  35585. private _glVendor;
  35586. /** @hidden */
  35587. _videoTextureSupported: boolean;
  35588. protected _renderingQueueLaunched: boolean;
  35589. protected _activeRenderLoops: (() => void)[];
  35590. /**
  35591. * Observable signaled when a context lost event is raised
  35592. */
  35593. onContextLostObservable: Observable<ThinEngine>;
  35594. /**
  35595. * Observable signaled when a context restored event is raised
  35596. */
  35597. onContextRestoredObservable: Observable<ThinEngine>;
  35598. private _onContextLost;
  35599. private _onContextRestored;
  35600. protected _contextWasLost: boolean;
  35601. /** @hidden */
  35602. _doNotHandleContextLost: boolean;
  35603. /**
  35604. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35605. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35606. */
  35607. get doNotHandleContextLost(): boolean;
  35608. set doNotHandleContextLost(value: boolean);
  35609. /**
  35610. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35611. */
  35612. disableVertexArrayObjects: boolean;
  35613. /** @hidden */
  35614. protected _colorWrite: boolean;
  35615. /** @hidden */
  35616. protected _colorWriteChanged: boolean;
  35617. /** @hidden */
  35618. protected _depthCullingState: DepthCullingState;
  35619. /** @hidden */
  35620. protected _stencilState: StencilState;
  35621. /** @hidden */
  35622. _alphaState: AlphaState;
  35623. /** @hidden */
  35624. _alphaMode: number;
  35625. /** @hidden */
  35626. _alphaEquation: number;
  35627. /** @hidden */
  35628. _internalTexturesCache: InternalTexture[];
  35629. /** @hidden */
  35630. protected _activeChannel: number;
  35631. private _currentTextureChannel;
  35632. /** @hidden */
  35633. protected _boundTexturesCache: {
  35634. [key: string]: Nullable<InternalTexture>;
  35635. };
  35636. /** @hidden */
  35637. protected _currentEffect: Nullable<Effect>;
  35638. /** @hidden */
  35639. protected _currentProgram: Nullable<WebGLProgram>;
  35640. private _compiledEffects;
  35641. private _vertexAttribArraysEnabled;
  35642. /** @hidden */
  35643. protected _cachedViewport: Nullable<IViewportLike>;
  35644. private _cachedVertexArrayObject;
  35645. /** @hidden */
  35646. protected _cachedVertexBuffers: any;
  35647. /** @hidden */
  35648. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35649. /** @hidden */
  35650. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35651. /** @hidden */
  35652. _currentRenderTarget: Nullable<InternalTexture>;
  35653. private _uintIndicesCurrentlySet;
  35654. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35655. /** @hidden */
  35656. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35657. /** @hidden */
  35658. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35659. private _currentBufferPointers;
  35660. private _currentInstanceLocations;
  35661. private _currentInstanceBuffers;
  35662. private _textureUnits;
  35663. /** @hidden */
  35664. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35665. /** @hidden */
  35666. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35667. /** @hidden */
  35668. _boundRenderFunction: any;
  35669. private _vaoRecordInProgress;
  35670. private _mustWipeVertexAttributes;
  35671. private _emptyTexture;
  35672. private _emptyCubeTexture;
  35673. private _emptyTexture3D;
  35674. private _emptyTexture2DArray;
  35675. /** @hidden */
  35676. _frameHandler: number;
  35677. private _nextFreeTextureSlots;
  35678. private _maxSimultaneousTextures;
  35679. private _activeRequests;
  35680. /** @hidden */
  35681. _transformTextureUrl: Nullable<(url: string) => string>;
  35682. protected get _supportsHardwareTextureRescaling(): boolean;
  35683. private _framebufferDimensionsObject;
  35684. /**
  35685. * sets the object from which width and height will be taken from when getting render width and height
  35686. * Will fallback to the gl object
  35687. * @param dimensions the framebuffer width and height that will be used.
  35688. */
  35689. set framebufferDimensionsObject(dimensions: Nullable<{
  35690. framebufferWidth: number;
  35691. framebufferHeight: number;
  35692. }>);
  35693. /**
  35694. * Gets the current viewport
  35695. */
  35696. get currentViewport(): Nullable<IViewportLike>;
  35697. /**
  35698. * Gets the default empty texture
  35699. */
  35700. get emptyTexture(): InternalTexture;
  35701. /**
  35702. * Gets the default empty 3D texture
  35703. */
  35704. get emptyTexture3D(): InternalTexture;
  35705. /**
  35706. * Gets the default empty 2D array texture
  35707. */
  35708. get emptyTexture2DArray(): InternalTexture;
  35709. /**
  35710. * Gets the default empty cube texture
  35711. */
  35712. get emptyCubeTexture(): InternalTexture;
  35713. /**
  35714. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35715. */
  35716. readonly premultipliedAlpha: boolean;
  35717. /**
  35718. * Observable event triggered before each texture is initialized
  35719. */
  35720. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  35721. /**
  35722. * Creates a new engine
  35723. * @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
  35724. * @param antialias defines enable antialiasing (default: false)
  35725. * @param options defines further options to be sent to the getContext() function
  35726. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35727. */
  35728. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35729. private _rebuildInternalTextures;
  35730. private _rebuildEffects;
  35731. /**
  35732. * Gets a boolean indicating if all created effects are ready
  35733. * @returns true if all effects are ready
  35734. */
  35735. areAllEffectsReady(): boolean;
  35736. protected _rebuildBuffers(): void;
  35737. protected _initGLContext(): void;
  35738. /**
  35739. * Gets version of the current webGL context
  35740. */
  35741. get webGLVersion(): number;
  35742. /**
  35743. * Gets a string idenfifying the name of the class
  35744. * @returns "Engine" string
  35745. */
  35746. getClassName(): string;
  35747. /**
  35748. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35749. */
  35750. get isStencilEnable(): boolean;
  35751. /** @hidden */
  35752. _prepareWorkingCanvas(): void;
  35753. /**
  35754. * Reset the texture cache to empty state
  35755. */
  35756. resetTextureCache(): void;
  35757. /**
  35758. * Gets an object containing information about the current webGL context
  35759. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35760. */
  35761. getGlInfo(): {
  35762. vendor: string;
  35763. renderer: string;
  35764. version: string;
  35765. };
  35766. /**
  35767. * Defines the hardware scaling level.
  35768. * By default the hardware scaling level is computed from the window device ratio.
  35769. * 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.
  35770. * @param level defines the level to use
  35771. */
  35772. setHardwareScalingLevel(level: number): void;
  35773. /**
  35774. * Gets the current hardware scaling level.
  35775. * By default the hardware scaling level is computed from the window device ratio.
  35776. * 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.
  35777. * @returns a number indicating the current hardware scaling level
  35778. */
  35779. getHardwareScalingLevel(): number;
  35780. /**
  35781. * Gets the list of loaded textures
  35782. * @returns an array containing all loaded textures
  35783. */
  35784. getLoadedTexturesCache(): InternalTexture[];
  35785. /**
  35786. * Gets the object containing all engine capabilities
  35787. * @returns the EngineCapabilities object
  35788. */
  35789. getCaps(): EngineCapabilities;
  35790. /**
  35791. * stop executing a render loop function and remove it from the execution array
  35792. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35793. */
  35794. stopRenderLoop(renderFunction?: () => void): void;
  35795. /** @hidden */
  35796. _renderLoop(): void;
  35797. /**
  35798. * Gets the HTML canvas attached with the current webGL context
  35799. * @returns a HTML canvas
  35800. */
  35801. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35802. /**
  35803. * Gets host window
  35804. * @returns the host window object
  35805. */
  35806. getHostWindow(): Nullable<Window>;
  35807. /**
  35808. * Gets the current render width
  35809. * @param useScreen defines if screen size must be used (or the current render target if any)
  35810. * @returns a number defining the current render width
  35811. */
  35812. getRenderWidth(useScreen?: boolean): number;
  35813. /**
  35814. * Gets the current render height
  35815. * @param useScreen defines if screen size must be used (or the current render target if any)
  35816. * @returns a number defining the current render height
  35817. */
  35818. getRenderHeight(useScreen?: boolean): number;
  35819. /**
  35820. * Can be used to override the current requestAnimationFrame requester.
  35821. * @hidden
  35822. */
  35823. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35824. /**
  35825. * Register and execute a render loop. The engine can have more than one render function
  35826. * @param renderFunction defines the function to continuously execute
  35827. */
  35828. runRenderLoop(renderFunction: () => void): void;
  35829. /**
  35830. * Clear the current render buffer or the current render target (if any is set up)
  35831. * @param color defines the color to use
  35832. * @param backBuffer defines if the back buffer must be cleared
  35833. * @param depth defines if the depth buffer must be cleared
  35834. * @param stencil defines if the stencil buffer must be cleared
  35835. */
  35836. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35837. private _viewportCached;
  35838. /** @hidden */
  35839. _viewport(x: number, y: number, width: number, height: number): void;
  35840. /**
  35841. * Set the WebGL's viewport
  35842. * @param viewport defines the viewport element to be used
  35843. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35844. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35845. */
  35846. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35847. /**
  35848. * Begin a new frame
  35849. */
  35850. beginFrame(): void;
  35851. /**
  35852. * Enf the current frame
  35853. */
  35854. endFrame(): void;
  35855. /**
  35856. * Resize the view according to the canvas' size
  35857. */
  35858. resize(): void;
  35859. /**
  35860. * Force a specific size of the canvas
  35861. * @param width defines the new canvas' width
  35862. * @param height defines the new canvas' height
  35863. */
  35864. setSize(width: number, height: number): void;
  35865. /**
  35866. * Binds the frame buffer to the specified texture.
  35867. * @param texture The texture to render to or null for the default canvas
  35868. * @param faceIndex The face of the texture to render to in case of cube texture
  35869. * @param requiredWidth The width of the target to render to
  35870. * @param requiredHeight The height of the target to render to
  35871. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35872. * @param lodLevel defines the lod level to bind to the frame buffer
  35873. * @param layer defines the 2d array index to bind to frame buffer to
  35874. */
  35875. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35876. /** @hidden */
  35877. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35878. /**
  35879. * Unbind the current render target texture from the webGL context
  35880. * @param texture defines the render target texture to unbind
  35881. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35882. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35883. */
  35884. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35885. /**
  35886. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35887. */
  35888. flushFramebuffer(): void;
  35889. /**
  35890. * Unbind the current render target and bind the default framebuffer
  35891. */
  35892. restoreDefaultFramebuffer(): void;
  35893. /** @hidden */
  35894. protected _resetVertexBufferBinding(): void;
  35895. /**
  35896. * Creates a vertex buffer
  35897. * @param data the data for the vertex buffer
  35898. * @returns the new WebGL static buffer
  35899. */
  35900. createVertexBuffer(data: DataArray): DataBuffer;
  35901. private _createVertexBuffer;
  35902. /**
  35903. * Creates a dynamic vertex buffer
  35904. * @param data the data for the dynamic vertex buffer
  35905. * @returns the new WebGL dynamic buffer
  35906. */
  35907. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35908. protected _resetIndexBufferBinding(): void;
  35909. /**
  35910. * Creates a new index buffer
  35911. * @param indices defines the content of the index buffer
  35912. * @param updatable defines if the index buffer must be updatable
  35913. * @returns a new webGL buffer
  35914. */
  35915. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35916. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35917. /**
  35918. * Bind a webGL buffer to the webGL context
  35919. * @param buffer defines the buffer to bind
  35920. */
  35921. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35922. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35923. private bindBuffer;
  35924. /**
  35925. * update the bound buffer with the given data
  35926. * @param data defines the data to update
  35927. */
  35928. updateArrayBuffer(data: Float32Array): void;
  35929. private _vertexAttribPointer;
  35930. /** @hidden */
  35931. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35932. private _bindVertexBuffersAttributes;
  35933. /**
  35934. * Records a vertex array object
  35935. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35936. * @param vertexBuffers defines the list of vertex buffers to store
  35937. * @param indexBuffer defines the index buffer to store
  35938. * @param effect defines the effect to store
  35939. * @returns the new vertex array object
  35940. */
  35941. recordVertexArrayObject(vertexBuffers: {
  35942. [key: string]: VertexBuffer;
  35943. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35944. /**
  35945. * Bind a specific vertex array object
  35946. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35947. * @param vertexArrayObject defines the vertex array object to bind
  35948. * @param indexBuffer defines the index buffer to bind
  35949. */
  35950. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35951. /**
  35952. * Bind webGl buffers directly to the webGL context
  35953. * @param vertexBuffer defines the vertex buffer to bind
  35954. * @param indexBuffer defines the index buffer to bind
  35955. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35956. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35957. * @param effect defines the effect associated with the vertex buffer
  35958. */
  35959. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35960. private _unbindVertexArrayObject;
  35961. /**
  35962. * Bind a list of vertex buffers to the webGL context
  35963. * @param vertexBuffers defines the list of vertex buffers to bind
  35964. * @param indexBuffer defines the index buffer to bind
  35965. * @param effect defines the effect associated with the vertex buffers
  35966. */
  35967. bindBuffers(vertexBuffers: {
  35968. [key: string]: Nullable<VertexBuffer>;
  35969. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35970. /**
  35971. * Unbind all instance attributes
  35972. */
  35973. unbindInstanceAttributes(): void;
  35974. /**
  35975. * Release and free the memory of a vertex array object
  35976. * @param vao defines the vertex array object to delete
  35977. */
  35978. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35979. /** @hidden */
  35980. _releaseBuffer(buffer: DataBuffer): boolean;
  35981. protected _deleteBuffer(buffer: DataBuffer): void;
  35982. /**
  35983. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35984. * @param instancesBuffer defines the webGL buffer to update and bind
  35985. * @param data defines the data to store in the buffer
  35986. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35987. */
  35988. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35989. /**
  35990. * Bind the content of a webGL buffer used with instantiation
  35991. * @param instancesBuffer defines the webGL buffer to bind
  35992. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35993. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35994. */
  35995. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35996. /**
  35997. * Disable the instance attribute corresponding to the name in parameter
  35998. * @param name defines the name of the attribute to disable
  35999. */
  36000. disableInstanceAttributeByName(name: string): void;
  36001. /**
  36002. * Disable the instance attribute corresponding to the location in parameter
  36003. * @param attributeLocation defines the attribute location of the attribute to disable
  36004. */
  36005. disableInstanceAttribute(attributeLocation: number): void;
  36006. /**
  36007. * Disable the attribute corresponding to the location in parameter
  36008. * @param attributeLocation defines the attribute location of the attribute to disable
  36009. */
  36010. disableAttributeByIndex(attributeLocation: number): void;
  36011. /**
  36012. * Send a draw order
  36013. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36014. * @param indexStart defines the starting index
  36015. * @param indexCount defines the number of index to draw
  36016. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36017. */
  36018. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  36019. /**
  36020. * Draw a list of points
  36021. * @param verticesStart defines the index of first vertex to draw
  36022. * @param verticesCount defines the count of vertices to draw
  36023. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36024. */
  36025. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36026. /**
  36027. * Draw a list of unindexed primitives
  36028. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36029. * @param verticesStart defines the index of first vertex to draw
  36030. * @param verticesCount defines the count of vertices to draw
  36031. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36032. */
  36033. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36034. /**
  36035. * Draw a list of indexed primitives
  36036. * @param fillMode defines the primitive to use
  36037. * @param indexStart defines the starting index
  36038. * @param indexCount defines the number of index to draw
  36039. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36040. */
  36041. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  36042. /**
  36043. * Draw a list of unindexed primitives
  36044. * @param fillMode defines the primitive to use
  36045. * @param verticesStart defines the index of first vertex to draw
  36046. * @param verticesCount defines the count of vertices to draw
  36047. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36048. */
  36049. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36050. private _drawMode;
  36051. /** @hidden */
  36052. protected _reportDrawCall(): void;
  36053. /** @hidden */
  36054. _releaseEffect(effect: Effect): void;
  36055. /** @hidden */
  36056. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36057. /**
  36058. * Create a new effect (used to store vertex/fragment shaders)
  36059. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  36060. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  36061. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  36062. * @param samplers defines an array of string used to represent textures
  36063. * @param defines defines the string containing the defines to use to compile the shaders
  36064. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  36065. * @param onCompiled defines a function to call when the effect creation is successful
  36066. * @param onError defines a function to call when the effect creation has failed
  36067. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  36068. * @returns the new Effect
  36069. */
  36070. 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;
  36071. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  36072. private _compileShader;
  36073. private _compileRawShader;
  36074. /** @hidden */
  36075. _getShaderSource(shader: WebGLShader): Nullable<string>;
  36076. /**
  36077. * Directly creates a webGL program
  36078. * @param pipelineContext defines the pipeline context to attach to
  36079. * @param vertexCode defines the vertex shader code to use
  36080. * @param fragmentCode defines the fragment shader code to use
  36081. * @param context defines the webGL context to use (if not set, the current one will be used)
  36082. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36083. * @returns the new webGL program
  36084. */
  36085. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36086. /**
  36087. * Creates a webGL program
  36088. * @param pipelineContext defines the pipeline context to attach to
  36089. * @param vertexCode defines the vertex shader code to use
  36090. * @param fragmentCode defines the fragment shader code to use
  36091. * @param defines defines the string containing the defines to use to compile the shaders
  36092. * @param context defines the webGL context to use (if not set, the current one will be used)
  36093. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36094. * @returns the new webGL program
  36095. */
  36096. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36097. /**
  36098. * Creates a new pipeline context
  36099. * @returns the new pipeline
  36100. */
  36101. createPipelineContext(): IPipelineContext;
  36102. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36103. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  36104. /** @hidden */
  36105. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  36106. /** @hidden */
  36107. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  36108. /** @hidden */
  36109. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  36110. /**
  36111. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  36112. * @param pipelineContext defines the pipeline context to use
  36113. * @param uniformsNames defines the list of uniform names
  36114. * @returns an array of webGL uniform locations
  36115. */
  36116. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  36117. /**
  36118. * Gets the lsit of active attributes for a given webGL program
  36119. * @param pipelineContext defines the pipeline context to use
  36120. * @param attributesNames defines the list of attribute names to get
  36121. * @returns an array of indices indicating the offset of each attribute
  36122. */
  36123. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  36124. /**
  36125. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  36126. * @param effect defines the effect to activate
  36127. */
  36128. enableEffect(effect: Nullable<Effect>): void;
  36129. /**
  36130. * Set the value of an uniform to a number (int)
  36131. * @param uniform defines the webGL uniform location where to store the value
  36132. * @param value defines the int number to store
  36133. */
  36134. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36135. /**
  36136. * Set the value of an uniform to an array of int32
  36137. * @param uniform defines the webGL uniform location where to store the value
  36138. * @param array defines the array of int32 to store
  36139. */
  36140. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36141. /**
  36142. * Set the value of an uniform to an array of int32 (stored as vec2)
  36143. * @param uniform defines the webGL uniform location where to store the value
  36144. * @param array defines the array of int32 to store
  36145. */
  36146. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36147. /**
  36148. * Set the value of an uniform to an array of int32 (stored as vec3)
  36149. * @param uniform defines the webGL uniform location where to store the value
  36150. * @param array defines the array of int32 to store
  36151. */
  36152. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36153. /**
  36154. * Set the value of an uniform to an array of int32 (stored as vec4)
  36155. * @param uniform defines the webGL uniform location where to store the value
  36156. * @param array defines the array of int32 to store
  36157. */
  36158. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36159. /**
  36160. * Set the value of an uniform to an array of number
  36161. * @param uniform defines the webGL uniform location where to store the value
  36162. * @param array defines the array of number to store
  36163. */
  36164. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36165. /**
  36166. * Set the value of an uniform to an array of number (stored as vec2)
  36167. * @param uniform defines the webGL uniform location where to store the value
  36168. * @param array defines the array of number to store
  36169. */
  36170. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36171. /**
  36172. * Set the value of an uniform to an array of number (stored as vec3)
  36173. * @param uniform defines the webGL uniform location where to store the value
  36174. * @param array defines the array of number to store
  36175. */
  36176. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36177. /**
  36178. * Set the value of an uniform to an array of number (stored as vec4)
  36179. * @param uniform defines the webGL uniform location where to store the value
  36180. * @param array defines the array of number to store
  36181. */
  36182. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36183. /**
  36184. * Set the value of an uniform to an array of float32 (stored as matrices)
  36185. * @param uniform defines the webGL uniform location where to store the value
  36186. * @param matrices defines the array of float32 to store
  36187. */
  36188. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  36189. /**
  36190. * Set the value of an uniform to a matrix (3x3)
  36191. * @param uniform defines the webGL uniform location where to store the value
  36192. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  36193. */
  36194. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36195. /**
  36196. * Set the value of an uniform to a matrix (2x2)
  36197. * @param uniform defines the webGL uniform location where to store the value
  36198. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  36199. */
  36200. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36201. /**
  36202. * Set the value of an uniform to a number (float)
  36203. * @param uniform defines the webGL uniform location where to store the value
  36204. * @param value defines the float number to store
  36205. */
  36206. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36207. /**
  36208. * Set the value of an uniform to a vec2
  36209. * @param uniform defines the webGL uniform location where to store the value
  36210. * @param x defines the 1st component of the value
  36211. * @param y defines the 2nd component of the value
  36212. */
  36213. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  36214. /**
  36215. * Set the value of an uniform to a vec3
  36216. * @param uniform defines the webGL uniform location where to store the value
  36217. * @param x defines the 1st component of the value
  36218. * @param y defines the 2nd component of the value
  36219. * @param z defines the 3rd component of the value
  36220. */
  36221. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  36222. /**
  36223. * Set the value of an uniform to a vec4
  36224. * @param uniform defines the webGL uniform location where to store the value
  36225. * @param x defines the 1st component of the value
  36226. * @param y defines the 2nd component of the value
  36227. * @param z defines the 3rd component of the value
  36228. * @param w defines the 4th component of the value
  36229. */
  36230. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  36231. /**
  36232. * Apply all cached states (depth, culling, stencil and alpha)
  36233. */
  36234. applyStates(): void;
  36235. /**
  36236. * Enable or disable color writing
  36237. * @param enable defines the state to set
  36238. */
  36239. setColorWrite(enable: boolean): void;
  36240. /**
  36241. * Gets a boolean indicating if color writing is enabled
  36242. * @returns the current color writing state
  36243. */
  36244. getColorWrite(): boolean;
  36245. /**
  36246. * Gets the depth culling state manager
  36247. */
  36248. get depthCullingState(): DepthCullingState;
  36249. /**
  36250. * Gets the alpha state manager
  36251. */
  36252. get alphaState(): AlphaState;
  36253. /**
  36254. * Gets the stencil state manager
  36255. */
  36256. get stencilState(): StencilState;
  36257. /**
  36258. * Clears the list of texture accessible through engine.
  36259. * This can help preventing texture load conflict due to name collision.
  36260. */
  36261. clearInternalTexturesCache(): void;
  36262. /**
  36263. * Force the entire cache to be cleared
  36264. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36265. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36266. */
  36267. wipeCaches(bruteForce?: boolean): void;
  36268. /** @hidden */
  36269. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36270. min: number;
  36271. mag: number;
  36272. };
  36273. /** @hidden */
  36274. _createTexture(): WebGLTexture;
  36275. /**
  36276. * Usually called from Texture.ts.
  36277. * Passed information to create a WebGLTexture
  36278. * @param url defines a value which contains one of the following:
  36279. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36280. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36281. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36282. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36283. * @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)
  36284. * @param scene needed for loading to the correct scene
  36285. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36286. * @param onLoad optional callback to be called upon successful completion
  36287. * @param onError optional callback to be called upon failure
  36288. * @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
  36289. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36290. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36291. * @param forcedExtension defines the extension to use to pick the right loader
  36292. * @param mimeType defines an optional mime type
  36293. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36294. */
  36295. 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;
  36296. /**
  36297. * Loads an image as an HTMLImageElement.
  36298. * @param input url string, ArrayBuffer, or Blob to load
  36299. * @param onLoad callback called when the image successfully loads
  36300. * @param onError callback called when the image fails to load
  36301. * @param offlineProvider offline provider for caching
  36302. * @param mimeType optional mime type
  36303. * @returns the HTMLImageElement of the loaded image
  36304. * @hidden
  36305. */
  36306. 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>;
  36307. /**
  36308. * @hidden
  36309. */
  36310. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36311. private _unpackFlipYCached;
  36312. /**
  36313. * In case you are sharing the context with other applications, it might
  36314. * be interested to not cache the unpack flip y state to ensure a consistent
  36315. * value would be set.
  36316. */
  36317. enableUnpackFlipYCached: boolean;
  36318. /** @hidden */
  36319. _unpackFlipY(value: boolean): void;
  36320. /** @hidden */
  36321. _getUnpackAlignement(): number;
  36322. private _getTextureTarget;
  36323. /**
  36324. * Update the sampling mode of a given texture
  36325. * @param samplingMode defines the required sampling mode
  36326. * @param texture defines the texture to update
  36327. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36328. */
  36329. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36330. /**
  36331. * Update the sampling mode of a given texture
  36332. * @param texture defines the texture to update
  36333. * @param wrapU defines the texture wrap mode of the u coordinates
  36334. * @param wrapV defines the texture wrap mode of the v coordinates
  36335. * @param wrapR defines the texture wrap mode of the r coordinates
  36336. */
  36337. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36338. /** @hidden */
  36339. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36340. width: number;
  36341. height: number;
  36342. layers?: number;
  36343. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36344. /** @hidden */
  36345. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36346. /** @hidden */
  36347. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36348. /**
  36349. * Update a portion of an internal texture
  36350. * @param texture defines the texture to update
  36351. * @param imageData defines the data to store into the texture
  36352. * @param xOffset defines the x coordinates of the update rectangle
  36353. * @param yOffset defines the y coordinates of the update rectangle
  36354. * @param width defines the width of the update rectangle
  36355. * @param height defines the height of the update rectangle
  36356. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36357. * @param lod defines the lod level to update (0 by default)
  36358. */
  36359. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36360. /** @hidden */
  36361. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36362. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36363. private _prepareWebGLTexture;
  36364. /** @hidden */
  36365. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36366. private _getDepthStencilBuffer;
  36367. /** @hidden */
  36368. _releaseFramebufferObjects(texture: InternalTexture): void;
  36369. /** @hidden */
  36370. _releaseTexture(texture: InternalTexture): void;
  36371. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36372. protected _setProgram(program: WebGLProgram): void;
  36373. protected _boundUniforms: {
  36374. [key: number]: WebGLUniformLocation;
  36375. };
  36376. /**
  36377. * Binds an effect to the webGL context
  36378. * @param effect defines the effect to bind
  36379. */
  36380. bindSamplers(effect: Effect): void;
  36381. private _activateCurrentTexture;
  36382. /** @hidden */
  36383. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36384. /** @hidden */
  36385. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36386. /**
  36387. * Unbind all textures from the webGL context
  36388. */
  36389. unbindAllTextures(): void;
  36390. /**
  36391. * Sets a texture to the according uniform.
  36392. * @param channel The texture channel
  36393. * @param uniform The uniform to set
  36394. * @param texture The texture to apply
  36395. */
  36396. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36397. private _bindSamplerUniformToChannel;
  36398. private _getTextureWrapMode;
  36399. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36400. /**
  36401. * Sets an array of texture to the webGL context
  36402. * @param channel defines the channel where the texture array must be set
  36403. * @param uniform defines the associated uniform location
  36404. * @param textures defines the array of textures to bind
  36405. */
  36406. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36407. /** @hidden */
  36408. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36409. private _setTextureParameterFloat;
  36410. private _setTextureParameterInteger;
  36411. /**
  36412. * Unbind all vertex attributes from the webGL context
  36413. */
  36414. unbindAllAttributes(): void;
  36415. /**
  36416. * 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
  36417. */
  36418. releaseEffects(): void;
  36419. /**
  36420. * Dispose and release all associated resources
  36421. */
  36422. dispose(): void;
  36423. /**
  36424. * Attach a new callback raised when context lost event is fired
  36425. * @param callback defines the callback to call
  36426. */
  36427. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36428. /**
  36429. * Attach a new callback raised when context restored event is fired
  36430. * @param callback defines the callback to call
  36431. */
  36432. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36433. /**
  36434. * Get the current error code of the webGL context
  36435. * @returns the error code
  36436. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36437. */
  36438. getError(): number;
  36439. private _canRenderToFloatFramebuffer;
  36440. private _canRenderToHalfFloatFramebuffer;
  36441. private _canRenderToFramebuffer;
  36442. /** @hidden */
  36443. _getWebGLTextureType(type: number): number;
  36444. /** @hidden */
  36445. _getInternalFormat(format: number): number;
  36446. /** @hidden */
  36447. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36448. /** @hidden */
  36449. _getRGBAMultiSampleBufferFormat(type: number): number;
  36450. /** @hidden */
  36451. _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;
  36452. /**
  36453. * Loads a file from a url
  36454. * @param url url to load
  36455. * @param onSuccess callback called when the file successfully loads
  36456. * @param onProgress callback called while file is loading (if the server supports this mode)
  36457. * @param offlineProvider defines the offline provider for caching
  36458. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36459. * @param onError callback called when the file fails to load
  36460. * @returns a file request object
  36461. * @hidden
  36462. */
  36463. 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;
  36464. /**
  36465. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36466. * @param x defines the x coordinate of the rectangle where pixels must be read
  36467. * @param y defines the y coordinate of the rectangle where pixels must be read
  36468. * @param width defines the width of the rectangle where pixels must be read
  36469. * @param height defines the height of the rectangle where pixels must be read
  36470. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36471. * @returns a Uint8Array containing RGBA colors
  36472. */
  36473. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36474. private static _isSupported;
  36475. /**
  36476. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36477. * @returns true if the engine can be created
  36478. * @ignorenaming
  36479. */
  36480. static isSupported(): boolean;
  36481. /**
  36482. * Find the next highest power of two.
  36483. * @param x Number to start search from.
  36484. * @return Next highest power of two.
  36485. */
  36486. static CeilingPOT(x: number): number;
  36487. /**
  36488. * Find the next lowest power of two.
  36489. * @param x Number to start search from.
  36490. * @return Next lowest power of two.
  36491. */
  36492. static FloorPOT(x: number): number;
  36493. /**
  36494. * Find the nearest power of two.
  36495. * @param x Number to start search from.
  36496. * @return Next nearest power of two.
  36497. */
  36498. static NearestPOT(x: number): number;
  36499. /**
  36500. * Get the closest exponent of two
  36501. * @param value defines the value to approximate
  36502. * @param max defines the maximum value to return
  36503. * @param mode defines how to define the closest value
  36504. * @returns closest exponent of two of the given value
  36505. */
  36506. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36507. /**
  36508. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36509. * @param func - the function to be called
  36510. * @param requester - the object that will request the next frame. Falls back to window.
  36511. * @returns frame number
  36512. */
  36513. static QueueNewFrame(func: () => void, requester?: any): number;
  36514. /**
  36515. * Gets host document
  36516. * @returns the host document object
  36517. */
  36518. getHostDocument(): Nullable<Document>;
  36519. }
  36520. }
  36521. declare module "babylonjs/Maths/sphericalPolynomial" {
  36522. import { Vector3 } from "babylonjs/Maths/math.vector";
  36523. import { Color3 } from "babylonjs/Maths/math.color";
  36524. /**
  36525. * Class representing spherical harmonics coefficients to the 3rd degree
  36526. */
  36527. export class SphericalHarmonics {
  36528. /**
  36529. * Defines whether or not the harmonics have been prescaled for rendering.
  36530. */
  36531. preScaled: boolean;
  36532. /**
  36533. * The l0,0 coefficients of the spherical harmonics
  36534. */
  36535. l00: Vector3;
  36536. /**
  36537. * The l1,-1 coefficients of the spherical harmonics
  36538. */
  36539. l1_1: Vector3;
  36540. /**
  36541. * The l1,0 coefficients of the spherical harmonics
  36542. */
  36543. l10: Vector3;
  36544. /**
  36545. * The l1,1 coefficients of the spherical harmonics
  36546. */
  36547. l11: Vector3;
  36548. /**
  36549. * The l2,-2 coefficients of the spherical harmonics
  36550. */
  36551. l2_2: Vector3;
  36552. /**
  36553. * The l2,-1 coefficients of the spherical harmonics
  36554. */
  36555. l2_1: Vector3;
  36556. /**
  36557. * The l2,0 coefficients of the spherical harmonics
  36558. */
  36559. l20: Vector3;
  36560. /**
  36561. * The l2,1 coefficients of the spherical harmonics
  36562. */
  36563. l21: Vector3;
  36564. /**
  36565. * The l2,2 coefficients of the spherical harmonics
  36566. */
  36567. l22: Vector3;
  36568. /**
  36569. * Adds a light to the spherical harmonics
  36570. * @param direction the direction of the light
  36571. * @param color the color of the light
  36572. * @param deltaSolidAngle the delta solid angle of the light
  36573. */
  36574. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36575. /**
  36576. * Scales the spherical harmonics by the given amount
  36577. * @param scale the amount to scale
  36578. */
  36579. scaleInPlace(scale: number): void;
  36580. /**
  36581. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36582. *
  36583. * ```
  36584. * E_lm = A_l * L_lm
  36585. * ```
  36586. *
  36587. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36588. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36589. * the scaling factors are given in equation 9.
  36590. */
  36591. convertIncidentRadianceToIrradiance(): void;
  36592. /**
  36593. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36594. *
  36595. * ```
  36596. * L = (1/pi) * E * rho
  36597. * ```
  36598. *
  36599. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36600. */
  36601. convertIrradianceToLambertianRadiance(): void;
  36602. /**
  36603. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36604. * required operations at run time.
  36605. *
  36606. * This is simply done by scaling back the SH with Ylm constants parameter.
  36607. * The trigonometric part being applied by the shader at run time.
  36608. */
  36609. preScaleForRendering(): void;
  36610. /**
  36611. * Constructs a spherical harmonics from an array.
  36612. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36613. * @returns the spherical harmonics
  36614. */
  36615. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36616. /**
  36617. * Gets the spherical harmonics from polynomial
  36618. * @param polynomial the spherical polynomial
  36619. * @returns the spherical harmonics
  36620. */
  36621. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36622. }
  36623. /**
  36624. * Class representing spherical polynomial coefficients to the 3rd degree
  36625. */
  36626. export class SphericalPolynomial {
  36627. private _harmonics;
  36628. /**
  36629. * The spherical harmonics used to create the polynomials.
  36630. */
  36631. get preScaledHarmonics(): SphericalHarmonics;
  36632. /**
  36633. * The x coefficients of the spherical polynomial
  36634. */
  36635. x: Vector3;
  36636. /**
  36637. * The y coefficients of the spherical polynomial
  36638. */
  36639. y: Vector3;
  36640. /**
  36641. * The z coefficients of the spherical polynomial
  36642. */
  36643. z: Vector3;
  36644. /**
  36645. * The xx coefficients of the spherical polynomial
  36646. */
  36647. xx: Vector3;
  36648. /**
  36649. * The yy coefficients of the spherical polynomial
  36650. */
  36651. yy: Vector3;
  36652. /**
  36653. * The zz coefficients of the spherical polynomial
  36654. */
  36655. zz: Vector3;
  36656. /**
  36657. * The xy coefficients of the spherical polynomial
  36658. */
  36659. xy: Vector3;
  36660. /**
  36661. * The yz coefficients of the spherical polynomial
  36662. */
  36663. yz: Vector3;
  36664. /**
  36665. * The zx coefficients of the spherical polynomial
  36666. */
  36667. zx: Vector3;
  36668. /**
  36669. * Adds an ambient color to the spherical polynomial
  36670. * @param color the color to add
  36671. */
  36672. addAmbient(color: Color3): void;
  36673. /**
  36674. * Scales the spherical polynomial by the given amount
  36675. * @param scale the amount to scale
  36676. */
  36677. scaleInPlace(scale: number): void;
  36678. /**
  36679. * Gets the spherical polynomial from harmonics
  36680. * @param harmonics the spherical harmonics
  36681. * @returns the spherical polynomial
  36682. */
  36683. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36684. /**
  36685. * Constructs a spherical polynomial from an array.
  36686. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36687. * @returns the spherical polynomial
  36688. */
  36689. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36690. }
  36691. }
  36692. declare module "babylonjs/Materials/Textures/internalTexture" {
  36693. import { Observable } from "babylonjs/Misc/observable";
  36694. import { Nullable, int } from "babylonjs/types";
  36695. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  36696. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36697. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  36698. /**
  36699. * Defines the source of the internal texture
  36700. */
  36701. export enum InternalTextureSource {
  36702. /**
  36703. * The source of the texture data is unknown
  36704. */
  36705. Unknown = 0,
  36706. /**
  36707. * Texture data comes from an URL
  36708. */
  36709. Url = 1,
  36710. /**
  36711. * Texture data is only used for temporary storage
  36712. */
  36713. Temp = 2,
  36714. /**
  36715. * Texture data comes from raw data (ArrayBuffer)
  36716. */
  36717. Raw = 3,
  36718. /**
  36719. * Texture content is dynamic (video or dynamic texture)
  36720. */
  36721. Dynamic = 4,
  36722. /**
  36723. * Texture content is generated by rendering to it
  36724. */
  36725. RenderTarget = 5,
  36726. /**
  36727. * Texture content is part of a multi render target process
  36728. */
  36729. MultiRenderTarget = 6,
  36730. /**
  36731. * Texture data comes from a cube data file
  36732. */
  36733. Cube = 7,
  36734. /**
  36735. * Texture data comes from a raw cube data
  36736. */
  36737. CubeRaw = 8,
  36738. /**
  36739. * Texture data come from a prefiltered cube data file
  36740. */
  36741. CubePrefiltered = 9,
  36742. /**
  36743. * Texture content is raw 3D data
  36744. */
  36745. Raw3D = 10,
  36746. /**
  36747. * Texture content is raw 2D array data
  36748. */
  36749. Raw2DArray = 11,
  36750. /**
  36751. * Texture content is a depth texture
  36752. */
  36753. Depth = 12,
  36754. /**
  36755. * Texture data comes from a raw cube data encoded with RGBD
  36756. */
  36757. CubeRawRGBD = 13
  36758. }
  36759. /**
  36760. * Class used to store data associated with WebGL texture data for the engine
  36761. * This class should not be used directly
  36762. */
  36763. export class InternalTexture {
  36764. /** @hidden */
  36765. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36766. /**
  36767. * Defines if the texture is ready
  36768. */
  36769. isReady: boolean;
  36770. /**
  36771. * Defines if the texture is a cube texture
  36772. */
  36773. isCube: boolean;
  36774. /**
  36775. * Defines if the texture contains 3D data
  36776. */
  36777. is3D: boolean;
  36778. /**
  36779. * Defines if the texture contains 2D array data
  36780. */
  36781. is2DArray: boolean;
  36782. /**
  36783. * Defines if the texture contains multiview data
  36784. */
  36785. isMultiview: boolean;
  36786. /**
  36787. * Gets the URL used to load this texture
  36788. */
  36789. url: string;
  36790. /**
  36791. * Gets the sampling mode of the texture
  36792. */
  36793. samplingMode: number;
  36794. /**
  36795. * Gets a boolean indicating if the texture needs mipmaps generation
  36796. */
  36797. generateMipMaps: boolean;
  36798. /**
  36799. * Gets the number of samples used by the texture (WebGL2+ only)
  36800. */
  36801. samples: number;
  36802. /**
  36803. * Gets the type of the texture (int, float...)
  36804. */
  36805. type: number;
  36806. /**
  36807. * Gets the format of the texture (RGB, RGBA...)
  36808. */
  36809. format: number;
  36810. /**
  36811. * Observable called when the texture is loaded
  36812. */
  36813. onLoadedObservable: Observable<InternalTexture>;
  36814. /**
  36815. * Gets the width of the texture
  36816. */
  36817. width: number;
  36818. /**
  36819. * Gets the height of the texture
  36820. */
  36821. height: number;
  36822. /**
  36823. * Gets the depth of the texture
  36824. */
  36825. depth: number;
  36826. /**
  36827. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36828. */
  36829. baseWidth: number;
  36830. /**
  36831. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36832. */
  36833. baseHeight: number;
  36834. /**
  36835. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36836. */
  36837. baseDepth: number;
  36838. /**
  36839. * Gets a boolean indicating if the texture is inverted on Y axis
  36840. */
  36841. invertY: boolean;
  36842. /** @hidden */
  36843. _invertVScale: boolean;
  36844. /** @hidden */
  36845. _associatedChannel: number;
  36846. /** @hidden */
  36847. _source: InternalTextureSource;
  36848. /** @hidden */
  36849. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36850. /** @hidden */
  36851. _bufferView: Nullable<ArrayBufferView>;
  36852. /** @hidden */
  36853. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36854. /** @hidden */
  36855. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36856. /** @hidden */
  36857. _size: number;
  36858. /** @hidden */
  36859. _extension: string;
  36860. /** @hidden */
  36861. _files: Nullable<string[]>;
  36862. /** @hidden */
  36863. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36864. /** @hidden */
  36865. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36866. /** @hidden */
  36867. _framebuffer: Nullable<WebGLFramebuffer>;
  36868. /** @hidden */
  36869. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36870. /** @hidden */
  36871. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36872. /** @hidden */
  36873. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36874. /** @hidden */
  36875. _attachments: Nullable<number[]>;
  36876. /** @hidden */
  36877. _cachedCoordinatesMode: Nullable<number>;
  36878. /** @hidden */
  36879. _cachedWrapU: Nullable<number>;
  36880. /** @hidden */
  36881. _cachedWrapV: Nullable<number>;
  36882. /** @hidden */
  36883. _cachedWrapR: Nullable<number>;
  36884. /** @hidden */
  36885. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36886. /** @hidden */
  36887. _isDisabled: boolean;
  36888. /** @hidden */
  36889. _compression: Nullable<string>;
  36890. /** @hidden */
  36891. _generateStencilBuffer: boolean;
  36892. /** @hidden */
  36893. _generateDepthBuffer: boolean;
  36894. /** @hidden */
  36895. _comparisonFunction: number;
  36896. /** @hidden */
  36897. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36898. /** @hidden */
  36899. _lodGenerationScale: number;
  36900. /** @hidden */
  36901. _lodGenerationOffset: number;
  36902. /** @hidden */
  36903. _depthStencilTexture: Nullable<InternalTexture>;
  36904. /** @hidden */
  36905. _colorTextureArray: Nullable<WebGLTexture>;
  36906. /** @hidden */
  36907. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36908. /** @hidden */
  36909. _lodTextureHigh: Nullable<BaseTexture>;
  36910. /** @hidden */
  36911. _lodTextureMid: Nullable<BaseTexture>;
  36912. /** @hidden */
  36913. _lodTextureLow: Nullable<BaseTexture>;
  36914. /** @hidden */
  36915. _isRGBD: boolean;
  36916. /** @hidden */
  36917. _linearSpecularLOD: boolean;
  36918. /** @hidden */
  36919. _irradianceTexture: Nullable<BaseTexture>;
  36920. /** @hidden */
  36921. _webGLTexture: Nullable<WebGLTexture>;
  36922. /** @hidden */
  36923. _references: number;
  36924. private _engine;
  36925. /**
  36926. * Gets the Engine the texture belongs to.
  36927. * @returns The babylon engine
  36928. */
  36929. getEngine(): ThinEngine;
  36930. /**
  36931. * Gets the data source type of the texture
  36932. */
  36933. get source(): InternalTextureSource;
  36934. /**
  36935. * Creates a new InternalTexture
  36936. * @param engine defines the engine to use
  36937. * @param source defines the type of data that will be used
  36938. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36939. */
  36940. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36941. /**
  36942. * Increments the number of references (ie. the number of Texture that point to it)
  36943. */
  36944. incrementReferences(): void;
  36945. /**
  36946. * Change the size of the texture (not the size of the content)
  36947. * @param width defines the new width
  36948. * @param height defines the new height
  36949. * @param depth defines the new depth (1 by default)
  36950. */
  36951. updateSize(width: int, height: int, depth?: int): void;
  36952. /** @hidden */
  36953. _rebuild(): void;
  36954. /** @hidden */
  36955. _swapAndDie(target: InternalTexture): void;
  36956. /**
  36957. * Dispose the current allocated resources
  36958. */
  36959. dispose(): void;
  36960. }
  36961. }
  36962. declare module "babylonjs/Audio/analyser" {
  36963. import { Scene } from "babylonjs/scene";
  36964. /**
  36965. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36966. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36967. */
  36968. export class Analyser {
  36969. /**
  36970. * Gets or sets the smoothing
  36971. * @ignorenaming
  36972. */
  36973. SMOOTHING: number;
  36974. /**
  36975. * Gets or sets the FFT table size
  36976. * @ignorenaming
  36977. */
  36978. FFT_SIZE: number;
  36979. /**
  36980. * Gets or sets the bar graph amplitude
  36981. * @ignorenaming
  36982. */
  36983. BARGRAPHAMPLITUDE: number;
  36984. /**
  36985. * Gets or sets the position of the debug canvas
  36986. * @ignorenaming
  36987. */
  36988. DEBUGCANVASPOS: {
  36989. x: number;
  36990. y: number;
  36991. };
  36992. /**
  36993. * Gets or sets the debug canvas size
  36994. * @ignorenaming
  36995. */
  36996. DEBUGCANVASSIZE: {
  36997. width: number;
  36998. height: number;
  36999. };
  37000. private _byteFreqs;
  37001. private _byteTime;
  37002. private _floatFreqs;
  37003. private _webAudioAnalyser;
  37004. private _debugCanvas;
  37005. private _debugCanvasContext;
  37006. private _scene;
  37007. private _registerFunc;
  37008. private _audioEngine;
  37009. /**
  37010. * Creates a new analyser
  37011. * @param scene defines hosting scene
  37012. */
  37013. constructor(scene: Scene);
  37014. /**
  37015. * Get the number of data values you will have to play with for the visualization
  37016. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  37017. * @returns a number
  37018. */
  37019. getFrequencyBinCount(): number;
  37020. /**
  37021. * Gets the current frequency data as a byte array
  37022. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37023. * @returns a Uint8Array
  37024. */
  37025. getByteFrequencyData(): Uint8Array;
  37026. /**
  37027. * Gets the current waveform as a byte array
  37028. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  37029. * @returns a Uint8Array
  37030. */
  37031. getByteTimeDomainData(): Uint8Array;
  37032. /**
  37033. * Gets the current frequency data as a float array
  37034. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37035. * @returns a Float32Array
  37036. */
  37037. getFloatFrequencyData(): Float32Array;
  37038. /**
  37039. * Renders the debug canvas
  37040. */
  37041. drawDebugCanvas(): void;
  37042. /**
  37043. * Stops rendering the debug canvas and removes it
  37044. */
  37045. stopDebugCanvas(): void;
  37046. /**
  37047. * Connects two audio nodes
  37048. * @param inputAudioNode defines first node to connect
  37049. * @param outputAudioNode defines second node to connect
  37050. */
  37051. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  37052. /**
  37053. * Releases all associated resources
  37054. */
  37055. dispose(): void;
  37056. }
  37057. }
  37058. declare module "babylonjs/Audio/audioEngine" {
  37059. import { IDisposable } from "babylonjs/scene";
  37060. import { Analyser } from "babylonjs/Audio/analyser";
  37061. import { Nullable } from "babylonjs/types";
  37062. import { Observable } from "babylonjs/Misc/observable";
  37063. /**
  37064. * This represents an audio engine and it is responsible
  37065. * to play, synchronize and analyse sounds throughout the application.
  37066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37067. */
  37068. export interface IAudioEngine extends IDisposable {
  37069. /**
  37070. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37071. */
  37072. readonly canUseWebAudio: boolean;
  37073. /**
  37074. * Gets the current AudioContext if available.
  37075. */
  37076. readonly audioContext: Nullable<AudioContext>;
  37077. /**
  37078. * The master gain node defines the global audio volume of your audio engine.
  37079. */
  37080. readonly masterGain: GainNode;
  37081. /**
  37082. * Gets whether or not mp3 are supported by your browser.
  37083. */
  37084. readonly isMP3supported: boolean;
  37085. /**
  37086. * Gets whether or not ogg are supported by your browser.
  37087. */
  37088. readonly isOGGsupported: boolean;
  37089. /**
  37090. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37091. * @ignoreNaming
  37092. */
  37093. WarnedWebAudioUnsupported: boolean;
  37094. /**
  37095. * Defines if the audio engine relies on a custom unlocked button.
  37096. * In this case, the embedded button will not be displayed.
  37097. */
  37098. useCustomUnlockedButton: boolean;
  37099. /**
  37100. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  37101. */
  37102. readonly unlocked: boolean;
  37103. /**
  37104. * Event raised when audio has been unlocked on the browser.
  37105. */
  37106. onAudioUnlockedObservable: Observable<AudioEngine>;
  37107. /**
  37108. * Event raised when audio has been locked on the browser.
  37109. */
  37110. onAudioLockedObservable: Observable<AudioEngine>;
  37111. /**
  37112. * Flags the audio engine in Locked state.
  37113. * This happens due to new browser policies preventing audio to autoplay.
  37114. */
  37115. lock(): void;
  37116. /**
  37117. * Unlocks the audio engine once a user action has been done on the dom.
  37118. * This is helpful to resume play once browser policies have been satisfied.
  37119. */
  37120. unlock(): void;
  37121. /**
  37122. * Gets the global volume sets on the master gain.
  37123. * @returns the global volume if set or -1 otherwise
  37124. */
  37125. getGlobalVolume(): number;
  37126. /**
  37127. * Sets the global volume of your experience (sets on the master gain).
  37128. * @param newVolume Defines the new global volume of the application
  37129. */
  37130. setGlobalVolume(newVolume: number): void;
  37131. /**
  37132. * Connect the audio engine to an audio analyser allowing some amazing
  37133. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37134. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37135. * @param analyser The analyser to connect to the engine
  37136. */
  37137. connectToAnalyser(analyser: Analyser): void;
  37138. }
  37139. /**
  37140. * This represents the default audio engine used in babylon.
  37141. * It is responsible to play, synchronize and analyse sounds throughout the application.
  37142. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37143. */
  37144. export class AudioEngine implements IAudioEngine {
  37145. private _audioContext;
  37146. private _audioContextInitialized;
  37147. private _muteButton;
  37148. private _hostElement;
  37149. /**
  37150. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37151. */
  37152. canUseWebAudio: boolean;
  37153. /**
  37154. * The master gain node defines the global audio volume of your audio engine.
  37155. */
  37156. masterGain: GainNode;
  37157. /**
  37158. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37159. * @ignoreNaming
  37160. */
  37161. WarnedWebAudioUnsupported: boolean;
  37162. /**
  37163. * Gets whether or not mp3 are supported by your browser.
  37164. */
  37165. isMP3supported: boolean;
  37166. /**
  37167. * Gets whether or not ogg are supported by your browser.
  37168. */
  37169. isOGGsupported: boolean;
  37170. /**
  37171. * Gets whether audio has been unlocked on the device.
  37172. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37173. * a user interaction has happened.
  37174. */
  37175. unlocked: boolean;
  37176. /**
  37177. * Defines if the audio engine relies on a custom unlocked button.
  37178. * In this case, the embedded button will not be displayed.
  37179. */
  37180. useCustomUnlockedButton: boolean;
  37181. /**
  37182. * Event raised when audio has been unlocked on the browser.
  37183. */
  37184. onAudioUnlockedObservable: Observable<AudioEngine>;
  37185. /**
  37186. * Event raised when audio has been locked on the browser.
  37187. */
  37188. onAudioLockedObservable: Observable<AudioEngine>;
  37189. /**
  37190. * Gets the current AudioContext if available.
  37191. */
  37192. get audioContext(): Nullable<AudioContext>;
  37193. private _connectedAnalyser;
  37194. /**
  37195. * Instantiates a new audio engine.
  37196. *
  37197. * There should be only one per page as some browsers restrict the number
  37198. * of audio contexts you can create.
  37199. * @param hostElement defines the host element where to display the mute icon if necessary
  37200. */
  37201. constructor(hostElement?: Nullable<HTMLElement>);
  37202. /**
  37203. * Flags the audio engine in Locked state.
  37204. * This happens due to new browser policies preventing audio to autoplay.
  37205. */
  37206. lock(): void;
  37207. /**
  37208. * Unlocks the audio engine once a user action has been done on the dom.
  37209. * This is helpful to resume play once browser policies have been satisfied.
  37210. */
  37211. unlock(): void;
  37212. private _resumeAudioContext;
  37213. private _initializeAudioContext;
  37214. private _tryToRun;
  37215. private _triggerRunningState;
  37216. private _triggerSuspendedState;
  37217. private _displayMuteButton;
  37218. private _moveButtonToTopLeft;
  37219. private _onResize;
  37220. private _hideMuteButton;
  37221. /**
  37222. * Destroy and release the resources associated with the audio ccontext.
  37223. */
  37224. dispose(): void;
  37225. /**
  37226. * Gets the global volume sets on the master gain.
  37227. * @returns the global volume if set or -1 otherwise
  37228. */
  37229. getGlobalVolume(): number;
  37230. /**
  37231. * Sets the global volume of your experience (sets on the master gain).
  37232. * @param newVolume Defines the new global volume of the application
  37233. */
  37234. setGlobalVolume(newVolume: number): void;
  37235. /**
  37236. * Connect the audio engine to an audio analyser allowing some amazing
  37237. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37238. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37239. * @param analyser The analyser to connect to the engine
  37240. */
  37241. connectToAnalyser(analyser: Analyser): void;
  37242. }
  37243. }
  37244. declare module "babylonjs/Loading/loadingScreen" {
  37245. /**
  37246. * Interface used to present a loading screen while loading a scene
  37247. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37248. */
  37249. export interface ILoadingScreen {
  37250. /**
  37251. * Function called to display the loading screen
  37252. */
  37253. displayLoadingUI: () => void;
  37254. /**
  37255. * Function called to hide the loading screen
  37256. */
  37257. hideLoadingUI: () => void;
  37258. /**
  37259. * Gets or sets the color to use for the background
  37260. */
  37261. loadingUIBackgroundColor: string;
  37262. /**
  37263. * Gets or sets the text to display while loading
  37264. */
  37265. loadingUIText: string;
  37266. }
  37267. /**
  37268. * Class used for the default loading screen
  37269. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37270. */
  37271. export class DefaultLoadingScreen implements ILoadingScreen {
  37272. private _renderingCanvas;
  37273. private _loadingText;
  37274. private _loadingDivBackgroundColor;
  37275. private _loadingDiv;
  37276. private _loadingTextDiv;
  37277. /** Gets or sets the logo url to use for the default loading screen */
  37278. static DefaultLogoUrl: string;
  37279. /** Gets or sets the spinner url to use for the default loading screen */
  37280. static DefaultSpinnerUrl: string;
  37281. /**
  37282. * Creates a new default loading screen
  37283. * @param _renderingCanvas defines the canvas used to render the scene
  37284. * @param _loadingText defines the default text to display
  37285. * @param _loadingDivBackgroundColor defines the default background color
  37286. */
  37287. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37288. /**
  37289. * Function called to display the loading screen
  37290. */
  37291. displayLoadingUI(): void;
  37292. /**
  37293. * Function called to hide the loading screen
  37294. */
  37295. hideLoadingUI(): void;
  37296. /**
  37297. * Gets or sets the text to display while loading
  37298. */
  37299. set loadingUIText(text: string);
  37300. get loadingUIText(): string;
  37301. /**
  37302. * Gets or sets the color to use for the background
  37303. */
  37304. get loadingUIBackgroundColor(): string;
  37305. set loadingUIBackgroundColor(color: string);
  37306. private _resizeLoadingUI;
  37307. }
  37308. }
  37309. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  37310. /**
  37311. * Interface for any object that can request an animation frame
  37312. */
  37313. export interface ICustomAnimationFrameRequester {
  37314. /**
  37315. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37316. */
  37317. renderFunction?: Function;
  37318. /**
  37319. * Called to request the next frame to render to
  37320. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37321. */
  37322. requestAnimationFrame: Function;
  37323. /**
  37324. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37325. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37326. */
  37327. requestID?: number;
  37328. }
  37329. }
  37330. declare module "babylonjs/Misc/performanceMonitor" {
  37331. /**
  37332. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37333. */
  37334. export class PerformanceMonitor {
  37335. private _enabled;
  37336. private _rollingFrameTime;
  37337. private _lastFrameTimeMs;
  37338. /**
  37339. * constructor
  37340. * @param frameSampleSize The number of samples required to saturate the sliding window
  37341. */
  37342. constructor(frameSampleSize?: number);
  37343. /**
  37344. * Samples current frame
  37345. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37346. */
  37347. sampleFrame(timeMs?: number): void;
  37348. /**
  37349. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37350. */
  37351. get averageFrameTime(): number;
  37352. /**
  37353. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37354. */
  37355. get averageFrameTimeVariance(): number;
  37356. /**
  37357. * Returns the frame time of the most recent frame
  37358. */
  37359. get instantaneousFrameTime(): number;
  37360. /**
  37361. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37362. */
  37363. get averageFPS(): number;
  37364. /**
  37365. * Returns the average framerate in frames per second using the most recent frame time
  37366. */
  37367. get instantaneousFPS(): number;
  37368. /**
  37369. * Returns true if enough samples have been taken to completely fill the sliding window
  37370. */
  37371. get isSaturated(): boolean;
  37372. /**
  37373. * Enables contributions to the sliding window sample set
  37374. */
  37375. enable(): void;
  37376. /**
  37377. * Disables contributions to the sliding window sample set
  37378. * Samples will not be interpolated over the disabled period
  37379. */
  37380. disable(): void;
  37381. /**
  37382. * Returns true if sampling is enabled
  37383. */
  37384. get isEnabled(): boolean;
  37385. /**
  37386. * Resets performance monitor
  37387. */
  37388. reset(): void;
  37389. }
  37390. /**
  37391. * RollingAverage
  37392. *
  37393. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37394. */
  37395. export class RollingAverage {
  37396. /**
  37397. * Current average
  37398. */
  37399. average: number;
  37400. /**
  37401. * Current variance
  37402. */
  37403. variance: number;
  37404. protected _samples: Array<number>;
  37405. protected _sampleCount: number;
  37406. protected _pos: number;
  37407. protected _m2: number;
  37408. /**
  37409. * constructor
  37410. * @param length The number of samples required to saturate the sliding window
  37411. */
  37412. constructor(length: number);
  37413. /**
  37414. * Adds a sample to the sample set
  37415. * @param v The sample value
  37416. */
  37417. add(v: number): void;
  37418. /**
  37419. * Returns previously added values or null if outside of history or outside the sliding window domain
  37420. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37421. * @return Value previously recorded with add() or null if outside of range
  37422. */
  37423. history(i: number): number;
  37424. /**
  37425. * Returns true if enough samples have been taken to completely fill the sliding window
  37426. * @return true if sample-set saturated
  37427. */
  37428. isSaturated(): boolean;
  37429. /**
  37430. * Resets the rolling average (equivalent to 0 samples taken so far)
  37431. */
  37432. reset(): void;
  37433. /**
  37434. * Wraps a value around the sample range boundaries
  37435. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37436. * @return Wrapped position in sample range
  37437. */
  37438. protected _wrapPosition(i: number): number;
  37439. }
  37440. }
  37441. declare module "babylonjs/Misc/perfCounter" {
  37442. /**
  37443. * This class is used to track a performance counter which is number based.
  37444. * The user has access to many properties which give statistics of different nature.
  37445. *
  37446. * The implementer can track two kinds of Performance Counter: time and count.
  37447. * 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.
  37448. * 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.
  37449. */
  37450. export class PerfCounter {
  37451. /**
  37452. * Gets or sets a global boolean to turn on and off all the counters
  37453. */
  37454. static Enabled: boolean;
  37455. /**
  37456. * Returns the smallest value ever
  37457. */
  37458. get min(): number;
  37459. /**
  37460. * Returns the biggest value ever
  37461. */
  37462. get max(): number;
  37463. /**
  37464. * Returns the average value since the performance counter is running
  37465. */
  37466. get average(): number;
  37467. /**
  37468. * Returns the average value of the last second the counter was monitored
  37469. */
  37470. get lastSecAverage(): number;
  37471. /**
  37472. * Returns the current value
  37473. */
  37474. get current(): number;
  37475. /**
  37476. * Gets the accumulated total
  37477. */
  37478. get total(): number;
  37479. /**
  37480. * Gets the total value count
  37481. */
  37482. get count(): number;
  37483. /**
  37484. * Creates a new counter
  37485. */
  37486. constructor();
  37487. /**
  37488. * Call this method to start monitoring a new frame.
  37489. * 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.
  37490. */
  37491. fetchNewFrame(): void;
  37492. /**
  37493. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37494. * @param newCount the count value to add to the monitored count
  37495. * @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.
  37496. */
  37497. addCount(newCount: number, fetchResult: boolean): void;
  37498. /**
  37499. * Start monitoring this performance counter
  37500. */
  37501. beginMonitoring(): void;
  37502. /**
  37503. * Compute the time lapsed since the previous beginMonitoring() call.
  37504. * @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
  37505. */
  37506. endMonitoring(newFrame?: boolean): void;
  37507. private _fetchResult;
  37508. private _startMonitoringTime;
  37509. private _min;
  37510. private _max;
  37511. private _average;
  37512. private _current;
  37513. private _totalValueCount;
  37514. private _totalAccumulated;
  37515. private _lastSecAverage;
  37516. private _lastSecAccumulated;
  37517. private _lastSecTime;
  37518. private _lastSecValueCount;
  37519. }
  37520. }
  37521. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  37522. module "babylonjs/Engines/thinEngine" {
  37523. interface ThinEngine {
  37524. /**
  37525. * Sets alpha constants used by some alpha blending modes
  37526. * @param r defines the red component
  37527. * @param g defines the green component
  37528. * @param b defines the blue component
  37529. * @param a defines the alpha component
  37530. */
  37531. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37532. /**
  37533. * Sets the current alpha mode
  37534. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37535. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37536. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37537. */
  37538. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37539. /**
  37540. * Gets the current alpha mode
  37541. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37542. * @returns the current alpha mode
  37543. */
  37544. getAlphaMode(): number;
  37545. /**
  37546. * Sets the current alpha equation
  37547. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37548. */
  37549. setAlphaEquation(equation: number): void;
  37550. /**
  37551. * Gets the current alpha equation.
  37552. * @returns the current alpha equation
  37553. */
  37554. getAlphaEquation(): number;
  37555. }
  37556. }
  37557. }
  37558. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  37559. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37560. import { Nullable } from "babylonjs/types";
  37561. module "babylonjs/Engines/thinEngine" {
  37562. interface ThinEngine {
  37563. /** @hidden */
  37564. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37565. }
  37566. }
  37567. }
  37568. declare module "babylonjs/Engines/engine" {
  37569. import { Observable } from "babylonjs/Misc/observable";
  37570. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  37571. import { Scene } from "babylonjs/scene";
  37572. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37573. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  37574. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  37575. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  37576. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  37577. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  37578. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  37579. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  37580. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  37581. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  37582. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  37583. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  37584. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  37585. import "babylonjs/Engines/Extensions/engine.alpha";
  37586. import "babylonjs/Engines/Extensions/engine.readTexture";
  37587. import { Material } from "babylonjs/Materials/material";
  37588. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37589. /**
  37590. * Defines the interface used by display changed events
  37591. */
  37592. export interface IDisplayChangedEventArgs {
  37593. /** Gets the vrDisplay object (if any) */
  37594. vrDisplay: Nullable<any>;
  37595. /** Gets a boolean indicating if webVR is supported */
  37596. vrSupported: boolean;
  37597. }
  37598. /**
  37599. * Defines the interface used by objects containing a viewport (like a camera)
  37600. */
  37601. interface IViewportOwnerLike {
  37602. /**
  37603. * Gets or sets the viewport
  37604. */
  37605. viewport: IViewportLike;
  37606. }
  37607. /**
  37608. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37609. */
  37610. export class Engine extends ThinEngine {
  37611. /** Defines that alpha blending is disabled */
  37612. static readonly ALPHA_DISABLE: number;
  37613. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37614. static readonly ALPHA_ADD: number;
  37615. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37616. static readonly ALPHA_COMBINE: number;
  37617. /** Defines that alpha blending to DEST - SRC * DEST */
  37618. static readonly ALPHA_SUBTRACT: number;
  37619. /** Defines that alpha blending to SRC * DEST */
  37620. static readonly ALPHA_MULTIPLY: number;
  37621. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37622. static readonly ALPHA_MAXIMIZED: number;
  37623. /** Defines that alpha blending to SRC + DEST */
  37624. static readonly ALPHA_ONEONE: number;
  37625. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37626. static readonly ALPHA_PREMULTIPLIED: number;
  37627. /**
  37628. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37629. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37630. */
  37631. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37632. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37633. static readonly ALPHA_INTERPOLATE: number;
  37634. /**
  37635. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37636. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37637. */
  37638. static readonly ALPHA_SCREENMODE: number;
  37639. /** Defines that the ressource is not delayed*/
  37640. static readonly DELAYLOADSTATE_NONE: number;
  37641. /** Defines that the ressource was successfully delay loaded */
  37642. static readonly DELAYLOADSTATE_LOADED: number;
  37643. /** Defines that the ressource is currently delay loading */
  37644. static readonly DELAYLOADSTATE_LOADING: number;
  37645. /** Defines that the ressource is delayed and has not started loading */
  37646. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37647. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37648. static readonly NEVER: number;
  37649. /** 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 */
  37650. static readonly ALWAYS: number;
  37651. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37652. static readonly LESS: number;
  37653. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37654. static readonly EQUAL: number;
  37655. /** 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 */
  37656. static readonly LEQUAL: number;
  37657. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37658. static readonly GREATER: number;
  37659. /** 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 */
  37660. static readonly GEQUAL: number;
  37661. /** 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 */
  37662. static readonly NOTEQUAL: number;
  37663. /** Passed to stencilOperation to specify that stencil value must be kept */
  37664. static readonly KEEP: number;
  37665. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37666. static readonly REPLACE: number;
  37667. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37668. static readonly INCR: number;
  37669. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37670. static readonly DECR: number;
  37671. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37672. static readonly INVERT: number;
  37673. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37674. static readonly INCR_WRAP: number;
  37675. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37676. static readonly DECR_WRAP: number;
  37677. /** Texture is not repeating outside of 0..1 UVs */
  37678. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37679. /** Texture is repeating outside of 0..1 UVs */
  37680. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37681. /** Texture is repeating and mirrored */
  37682. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37683. /** ALPHA */
  37684. static readonly TEXTUREFORMAT_ALPHA: number;
  37685. /** LUMINANCE */
  37686. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37687. /** LUMINANCE_ALPHA */
  37688. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37689. /** RGB */
  37690. static readonly TEXTUREFORMAT_RGB: number;
  37691. /** RGBA */
  37692. static readonly TEXTUREFORMAT_RGBA: number;
  37693. /** RED */
  37694. static readonly TEXTUREFORMAT_RED: number;
  37695. /** RED (2nd reference) */
  37696. static readonly TEXTUREFORMAT_R: number;
  37697. /** RG */
  37698. static readonly TEXTUREFORMAT_RG: number;
  37699. /** RED_INTEGER */
  37700. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37701. /** RED_INTEGER (2nd reference) */
  37702. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37703. /** RG_INTEGER */
  37704. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37705. /** RGB_INTEGER */
  37706. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37707. /** RGBA_INTEGER */
  37708. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37709. /** UNSIGNED_BYTE */
  37710. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37711. /** UNSIGNED_BYTE (2nd reference) */
  37712. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37713. /** FLOAT */
  37714. static readonly TEXTURETYPE_FLOAT: number;
  37715. /** HALF_FLOAT */
  37716. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37717. /** BYTE */
  37718. static readonly TEXTURETYPE_BYTE: number;
  37719. /** SHORT */
  37720. static readonly TEXTURETYPE_SHORT: number;
  37721. /** UNSIGNED_SHORT */
  37722. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37723. /** INT */
  37724. static readonly TEXTURETYPE_INT: number;
  37725. /** UNSIGNED_INT */
  37726. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37727. /** UNSIGNED_SHORT_4_4_4_4 */
  37728. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37729. /** UNSIGNED_SHORT_5_5_5_1 */
  37730. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37731. /** UNSIGNED_SHORT_5_6_5 */
  37732. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37733. /** UNSIGNED_INT_2_10_10_10_REV */
  37734. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37735. /** UNSIGNED_INT_24_8 */
  37736. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37737. /** UNSIGNED_INT_10F_11F_11F_REV */
  37738. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37739. /** UNSIGNED_INT_5_9_9_9_REV */
  37740. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37741. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37742. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37743. /** nearest is mag = nearest and min = nearest and mip = linear */
  37744. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37745. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37746. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37747. /** Trilinear is mag = linear and min = linear and mip = linear */
  37748. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37749. /** nearest is mag = nearest and min = nearest and mip = linear */
  37750. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37751. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37752. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37753. /** Trilinear is mag = linear and min = linear and mip = linear */
  37754. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37755. /** mag = nearest and min = nearest and mip = nearest */
  37756. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37757. /** mag = nearest and min = linear and mip = nearest */
  37758. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37759. /** mag = nearest and min = linear and mip = linear */
  37760. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37761. /** mag = nearest and min = linear and mip = none */
  37762. static readonly TEXTURE_NEAREST_LINEAR: number;
  37763. /** mag = nearest and min = nearest and mip = none */
  37764. static readonly TEXTURE_NEAREST_NEAREST: number;
  37765. /** mag = linear and min = nearest and mip = nearest */
  37766. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37767. /** mag = linear and min = nearest and mip = linear */
  37768. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37769. /** mag = linear and min = linear and mip = none */
  37770. static readonly TEXTURE_LINEAR_LINEAR: number;
  37771. /** mag = linear and min = nearest and mip = none */
  37772. static readonly TEXTURE_LINEAR_NEAREST: number;
  37773. /** Explicit coordinates mode */
  37774. static readonly TEXTURE_EXPLICIT_MODE: number;
  37775. /** Spherical coordinates mode */
  37776. static readonly TEXTURE_SPHERICAL_MODE: number;
  37777. /** Planar coordinates mode */
  37778. static readonly TEXTURE_PLANAR_MODE: number;
  37779. /** Cubic coordinates mode */
  37780. static readonly TEXTURE_CUBIC_MODE: number;
  37781. /** Projection coordinates mode */
  37782. static readonly TEXTURE_PROJECTION_MODE: number;
  37783. /** Skybox coordinates mode */
  37784. static readonly TEXTURE_SKYBOX_MODE: number;
  37785. /** Inverse Cubic coordinates mode */
  37786. static readonly TEXTURE_INVCUBIC_MODE: number;
  37787. /** Equirectangular coordinates mode */
  37788. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37789. /** Equirectangular Fixed coordinates mode */
  37790. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37791. /** Equirectangular Fixed Mirrored coordinates mode */
  37792. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37793. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37794. static readonly SCALEMODE_FLOOR: number;
  37795. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37796. static readonly SCALEMODE_NEAREST: number;
  37797. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37798. static readonly SCALEMODE_CEILING: number;
  37799. /**
  37800. * Returns the current npm package of the sdk
  37801. */
  37802. static get NpmPackage(): string;
  37803. /**
  37804. * Returns the current version of the framework
  37805. */
  37806. static get Version(): string;
  37807. /** Gets the list of created engines */
  37808. static get Instances(): Engine[];
  37809. /**
  37810. * Gets the latest created engine
  37811. */
  37812. static get LastCreatedEngine(): Nullable<Engine>;
  37813. /**
  37814. * Gets the latest created scene
  37815. */
  37816. static get LastCreatedScene(): Nullable<Scene>;
  37817. /**
  37818. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37819. * @param flag defines which part of the materials must be marked as dirty
  37820. * @param predicate defines a predicate used to filter which materials should be affected
  37821. */
  37822. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37823. /**
  37824. * Method called to create the default loading screen.
  37825. * This can be overriden in your own app.
  37826. * @param canvas The rendering canvas element
  37827. * @returns The loading screen
  37828. */
  37829. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37830. /**
  37831. * Method called to create the default rescale post process on each engine.
  37832. */
  37833. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37834. /**
  37835. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37836. **/
  37837. enableOfflineSupport: boolean;
  37838. /**
  37839. * 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)
  37840. **/
  37841. disableManifestCheck: boolean;
  37842. /**
  37843. * Gets the list of created scenes
  37844. */
  37845. scenes: Scene[];
  37846. /**
  37847. * Event raised when a new scene is created
  37848. */
  37849. onNewSceneAddedObservable: Observable<Scene>;
  37850. /**
  37851. * Gets the list of created postprocesses
  37852. */
  37853. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  37854. /**
  37855. * Gets a boolean indicating if the pointer is currently locked
  37856. */
  37857. isPointerLock: boolean;
  37858. /**
  37859. * Observable event triggered each time the rendering canvas is resized
  37860. */
  37861. onResizeObservable: Observable<Engine>;
  37862. /**
  37863. * Observable event triggered each time the canvas loses focus
  37864. */
  37865. onCanvasBlurObservable: Observable<Engine>;
  37866. /**
  37867. * Observable event triggered each time the canvas gains focus
  37868. */
  37869. onCanvasFocusObservable: Observable<Engine>;
  37870. /**
  37871. * Observable event triggered each time the canvas receives pointerout event
  37872. */
  37873. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37874. /**
  37875. * Observable raised when the engine begins a new frame
  37876. */
  37877. onBeginFrameObservable: Observable<Engine>;
  37878. /**
  37879. * If set, will be used to request the next animation frame for the render loop
  37880. */
  37881. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37882. /**
  37883. * Observable raised when the engine ends the current frame
  37884. */
  37885. onEndFrameObservable: Observable<Engine>;
  37886. /**
  37887. * Observable raised when the engine is about to compile a shader
  37888. */
  37889. onBeforeShaderCompilationObservable: Observable<Engine>;
  37890. /**
  37891. * Observable raised when the engine has jsut compiled a shader
  37892. */
  37893. onAfterShaderCompilationObservable: Observable<Engine>;
  37894. /**
  37895. * Gets the audio engine
  37896. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37897. * @ignorenaming
  37898. */
  37899. static audioEngine: IAudioEngine;
  37900. /**
  37901. * Default AudioEngine factory responsible of creating the Audio Engine.
  37902. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37903. */
  37904. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37905. /**
  37906. * Default offline support factory responsible of creating a tool used to store data locally.
  37907. * By default, this will create a Database object if the workload has been embedded.
  37908. */
  37909. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37910. private _loadingScreen;
  37911. private _pointerLockRequested;
  37912. private _rescalePostProcess;
  37913. private _deterministicLockstep;
  37914. private _lockstepMaxSteps;
  37915. private _timeStep;
  37916. protected get _supportsHardwareTextureRescaling(): boolean;
  37917. private _fps;
  37918. private _deltaTime;
  37919. /** @hidden */
  37920. _drawCalls: PerfCounter;
  37921. /** 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 */
  37922. canvasTabIndex: number;
  37923. /**
  37924. * Turn this value on if you want to pause FPS computation when in background
  37925. */
  37926. disablePerformanceMonitorInBackground: boolean;
  37927. private _performanceMonitor;
  37928. /**
  37929. * Gets the performance monitor attached to this engine
  37930. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37931. */
  37932. get performanceMonitor(): PerformanceMonitor;
  37933. private _onFocus;
  37934. private _onBlur;
  37935. private _onCanvasPointerOut;
  37936. private _onCanvasBlur;
  37937. private _onCanvasFocus;
  37938. private _onFullscreenChange;
  37939. private _onPointerLockChange;
  37940. /**
  37941. * Gets the HTML element used to attach event listeners
  37942. * @returns a HTML element
  37943. */
  37944. getInputElement(): Nullable<HTMLElement>;
  37945. /**
  37946. * Creates a new engine
  37947. * @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
  37948. * @param antialias defines enable antialiasing (default: false)
  37949. * @param options defines further options to be sent to the getContext() function
  37950. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37951. */
  37952. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37953. /**
  37954. * Gets current aspect ratio
  37955. * @param viewportOwner defines the camera to use to get the aspect ratio
  37956. * @param useScreen defines if screen size must be used (or the current render target if any)
  37957. * @returns a number defining the aspect ratio
  37958. */
  37959. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37960. /**
  37961. * Gets current screen aspect ratio
  37962. * @returns a number defining the aspect ratio
  37963. */
  37964. getScreenAspectRatio(): number;
  37965. /**
  37966. * Gets the client rect of the HTML canvas attached with the current webGL context
  37967. * @returns a client rectanglee
  37968. */
  37969. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37970. /**
  37971. * Gets the client rect of the HTML element used for events
  37972. * @returns a client rectanglee
  37973. */
  37974. getInputElementClientRect(): Nullable<ClientRect>;
  37975. /**
  37976. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37977. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37978. * @returns true if engine is in deterministic lock step mode
  37979. */
  37980. isDeterministicLockStep(): boolean;
  37981. /**
  37982. * Gets the max steps when engine is running in deterministic lock step
  37983. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37984. * @returns the max steps
  37985. */
  37986. getLockstepMaxSteps(): number;
  37987. /**
  37988. * Returns the time in ms between steps when using deterministic lock step.
  37989. * @returns time step in (ms)
  37990. */
  37991. getTimeStep(): number;
  37992. /**
  37993. * Force the mipmap generation for the given render target texture
  37994. * @param texture defines the render target texture to use
  37995. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37996. */
  37997. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37998. /** States */
  37999. /**
  38000. * Set various states to the webGL context
  38001. * @param culling defines backface culling state
  38002. * @param zOffset defines the value to apply to zOffset (0 by default)
  38003. * @param force defines if states must be applied even if cache is up to date
  38004. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  38005. */
  38006. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  38007. /**
  38008. * Set the z offset to apply to current rendering
  38009. * @param value defines the offset to apply
  38010. */
  38011. setZOffset(value: number): void;
  38012. /**
  38013. * Gets the current value of the zOffset
  38014. * @returns the current zOffset state
  38015. */
  38016. getZOffset(): number;
  38017. /**
  38018. * Enable or disable depth buffering
  38019. * @param enable defines the state to set
  38020. */
  38021. setDepthBuffer(enable: boolean): void;
  38022. /**
  38023. * Gets a boolean indicating if depth writing is enabled
  38024. * @returns the current depth writing state
  38025. */
  38026. getDepthWrite(): boolean;
  38027. /**
  38028. * Enable or disable depth writing
  38029. * @param enable defines the state to set
  38030. */
  38031. setDepthWrite(enable: boolean): void;
  38032. /**
  38033. * Gets a boolean indicating if stencil buffer is enabled
  38034. * @returns the current stencil buffer state
  38035. */
  38036. getStencilBuffer(): boolean;
  38037. /**
  38038. * Enable or disable the stencil buffer
  38039. * @param enable defines if the stencil buffer must be enabled or disabled
  38040. */
  38041. setStencilBuffer(enable: boolean): void;
  38042. /**
  38043. * Gets the current stencil mask
  38044. * @returns a number defining the new stencil mask to use
  38045. */
  38046. getStencilMask(): number;
  38047. /**
  38048. * Sets the current stencil mask
  38049. * @param mask defines the new stencil mask to use
  38050. */
  38051. setStencilMask(mask: number): void;
  38052. /**
  38053. * Gets the current stencil function
  38054. * @returns a number defining the stencil function to use
  38055. */
  38056. getStencilFunction(): number;
  38057. /**
  38058. * Gets the current stencil reference value
  38059. * @returns a number defining the stencil reference value to use
  38060. */
  38061. getStencilFunctionReference(): number;
  38062. /**
  38063. * Gets the current stencil mask
  38064. * @returns a number defining the stencil mask to use
  38065. */
  38066. getStencilFunctionMask(): number;
  38067. /**
  38068. * Sets the current stencil function
  38069. * @param stencilFunc defines the new stencil function to use
  38070. */
  38071. setStencilFunction(stencilFunc: number): void;
  38072. /**
  38073. * Sets the current stencil reference
  38074. * @param reference defines the new stencil reference to use
  38075. */
  38076. setStencilFunctionReference(reference: number): void;
  38077. /**
  38078. * Sets the current stencil mask
  38079. * @param mask defines the new stencil mask to use
  38080. */
  38081. setStencilFunctionMask(mask: number): void;
  38082. /**
  38083. * Gets the current stencil operation when stencil fails
  38084. * @returns a number defining stencil operation to use when stencil fails
  38085. */
  38086. getStencilOperationFail(): number;
  38087. /**
  38088. * Gets the current stencil operation when depth fails
  38089. * @returns a number defining stencil operation to use when depth fails
  38090. */
  38091. getStencilOperationDepthFail(): number;
  38092. /**
  38093. * Gets the current stencil operation when stencil passes
  38094. * @returns a number defining stencil operation to use when stencil passes
  38095. */
  38096. getStencilOperationPass(): number;
  38097. /**
  38098. * Sets the stencil operation to use when stencil fails
  38099. * @param operation defines the stencil operation to use when stencil fails
  38100. */
  38101. setStencilOperationFail(operation: number): void;
  38102. /**
  38103. * Sets the stencil operation to use when depth fails
  38104. * @param operation defines the stencil operation to use when depth fails
  38105. */
  38106. setStencilOperationDepthFail(operation: number): void;
  38107. /**
  38108. * Sets the stencil operation to use when stencil passes
  38109. * @param operation defines the stencil operation to use when stencil passes
  38110. */
  38111. setStencilOperationPass(operation: number): void;
  38112. /**
  38113. * Sets a boolean indicating if the dithering state is enabled or disabled
  38114. * @param value defines the dithering state
  38115. */
  38116. setDitheringState(value: boolean): void;
  38117. /**
  38118. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  38119. * @param value defines the rasterizer state
  38120. */
  38121. setRasterizerState(value: boolean): void;
  38122. /**
  38123. * Gets the current depth function
  38124. * @returns a number defining the depth function
  38125. */
  38126. getDepthFunction(): Nullable<number>;
  38127. /**
  38128. * Sets the current depth function
  38129. * @param depthFunc defines the function to use
  38130. */
  38131. setDepthFunction(depthFunc: number): void;
  38132. /**
  38133. * Sets the current depth function to GREATER
  38134. */
  38135. setDepthFunctionToGreater(): void;
  38136. /**
  38137. * Sets the current depth function to GEQUAL
  38138. */
  38139. setDepthFunctionToGreaterOrEqual(): void;
  38140. /**
  38141. * Sets the current depth function to LESS
  38142. */
  38143. setDepthFunctionToLess(): void;
  38144. /**
  38145. * Sets the current depth function to LEQUAL
  38146. */
  38147. setDepthFunctionToLessOrEqual(): void;
  38148. private _cachedStencilBuffer;
  38149. private _cachedStencilFunction;
  38150. private _cachedStencilMask;
  38151. private _cachedStencilOperationPass;
  38152. private _cachedStencilOperationFail;
  38153. private _cachedStencilOperationDepthFail;
  38154. private _cachedStencilReference;
  38155. /**
  38156. * Caches the the state of the stencil buffer
  38157. */
  38158. cacheStencilState(): void;
  38159. /**
  38160. * Restores the state of the stencil buffer
  38161. */
  38162. restoreStencilState(): void;
  38163. /**
  38164. * Directly set the WebGL Viewport
  38165. * @param x defines the x coordinate of the viewport (in screen space)
  38166. * @param y defines the y coordinate of the viewport (in screen space)
  38167. * @param width defines the width of the viewport (in screen space)
  38168. * @param height defines the height of the viewport (in screen space)
  38169. * @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
  38170. */
  38171. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  38172. /**
  38173. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  38174. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38175. * @param y defines the y-coordinate of the corner of the clear rectangle
  38176. * @param width defines the width of the clear rectangle
  38177. * @param height defines the height of the clear rectangle
  38178. * @param clearColor defines the clear color
  38179. */
  38180. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  38181. /**
  38182. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  38183. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38184. * @param y defines the y-coordinate of the corner of the clear rectangle
  38185. * @param width defines the width of the clear rectangle
  38186. * @param height defines the height of the clear rectangle
  38187. */
  38188. enableScissor(x: number, y: number, width: number, height: number): void;
  38189. /**
  38190. * Disable previously set scissor test rectangle
  38191. */
  38192. disableScissor(): void;
  38193. protected _reportDrawCall(): void;
  38194. /**
  38195. * Initializes a webVR display and starts listening to display change events
  38196. * The onVRDisplayChangedObservable will be notified upon these changes
  38197. * @returns The onVRDisplayChangedObservable
  38198. */
  38199. initWebVR(): Observable<IDisplayChangedEventArgs>;
  38200. /** @hidden */
  38201. _prepareVRComponent(): void;
  38202. /** @hidden */
  38203. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  38204. /** @hidden */
  38205. _submitVRFrame(): void;
  38206. /**
  38207. * Call this function to leave webVR mode
  38208. * Will do nothing if webVR is not supported or if there is no webVR device
  38209. * @see http://doc.babylonjs.com/how_to/webvr_camera
  38210. */
  38211. disableVR(): void;
  38212. /**
  38213. * Gets a boolean indicating that the system is in VR mode and is presenting
  38214. * @returns true if VR mode is engaged
  38215. */
  38216. isVRPresenting(): boolean;
  38217. /** @hidden */
  38218. _requestVRFrame(): void;
  38219. /** @hidden */
  38220. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38221. /**
  38222. * Gets the source code of the vertex shader associated with a specific webGL program
  38223. * @param program defines the program to use
  38224. * @returns a string containing the source code of the vertex shader associated with the program
  38225. */
  38226. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  38227. /**
  38228. * Gets the source code of the fragment shader associated with a specific webGL program
  38229. * @param program defines the program to use
  38230. * @returns a string containing the source code of the fragment shader associated with the program
  38231. */
  38232. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  38233. /**
  38234. * Sets a depth stencil texture from a render target to the according uniform.
  38235. * @param channel The texture channel
  38236. * @param uniform The uniform to set
  38237. * @param texture The render target texture containing the depth stencil texture to apply
  38238. */
  38239. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  38240. /**
  38241. * Sets a texture to the webGL context from a postprocess
  38242. * @param channel defines the channel to use
  38243. * @param postProcess defines the source postprocess
  38244. */
  38245. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  38246. /**
  38247. * Binds the output of the passed in post process to the texture channel specified
  38248. * @param channel The channel the texture should be bound to
  38249. * @param postProcess The post process which's output should be bound
  38250. */
  38251. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  38252. protected _rebuildBuffers(): void;
  38253. /** @hidden */
  38254. _renderFrame(): void;
  38255. _renderLoop(): void;
  38256. /** @hidden */
  38257. _renderViews(): boolean;
  38258. /**
  38259. * Toggle full screen mode
  38260. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38261. */
  38262. switchFullscreen(requestPointerLock: boolean): void;
  38263. /**
  38264. * Enters full screen mode
  38265. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38266. */
  38267. enterFullscreen(requestPointerLock: boolean): void;
  38268. /**
  38269. * Exits full screen mode
  38270. */
  38271. exitFullscreen(): void;
  38272. /**
  38273. * Enters Pointerlock mode
  38274. */
  38275. enterPointerlock(): void;
  38276. /**
  38277. * Exits Pointerlock mode
  38278. */
  38279. exitPointerlock(): void;
  38280. /**
  38281. * Begin a new frame
  38282. */
  38283. beginFrame(): void;
  38284. /**
  38285. * Enf the current frame
  38286. */
  38287. endFrame(): void;
  38288. resize(): void;
  38289. /**
  38290. * Force a specific size of the canvas
  38291. * @param width defines the new canvas' width
  38292. * @param height defines the new canvas' height
  38293. */
  38294. setSize(width: number, height: number): void;
  38295. /**
  38296. * Updates a dynamic vertex buffer.
  38297. * @param vertexBuffer the vertex buffer to update
  38298. * @param data the data used to update the vertex buffer
  38299. * @param byteOffset the byte offset of the data
  38300. * @param byteLength the byte length of the data
  38301. */
  38302. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  38303. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38304. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38305. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38306. _releaseTexture(texture: InternalTexture): void;
  38307. /**
  38308. * @hidden
  38309. * Rescales a texture
  38310. * @param source input texutre
  38311. * @param destination destination texture
  38312. * @param scene scene to use to render the resize
  38313. * @param internalFormat format to use when resizing
  38314. * @param onComplete callback to be called when resize has completed
  38315. */
  38316. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38317. /**
  38318. * Gets the current framerate
  38319. * @returns a number representing the framerate
  38320. */
  38321. getFps(): number;
  38322. /**
  38323. * Gets the time spent between current and previous frame
  38324. * @returns a number representing the delta time in ms
  38325. */
  38326. getDeltaTime(): number;
  38327. private _measureFps;
  38328. /** @hidden */
  38329. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38330. /**
  38331. * Update a dynamic index buffer
  38332. * @param indexBuffer defines the target index buffer
  38333. * @param indices defines the data to update
  38334. * @param offset defines the offset in the target index buffer where update should start
  38335. */
  38336. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  38337. /**
  38338. * Updates the sample count of a render target texture
  38339. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38340. * @param texture defines the texture to update
  38341. * @param samples defines the sample count to set
  38342. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38343. */
  38344. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38345. /**
  38346. * Updates a depth texture Comparison Mode and Function.
  38347. * If the comparison Function is equal to 0, the mode will be set to none.
  38348. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38349. * @param texture The texture to set the comparison function for
  38350. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38351. */
  38352. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38353. /**
  38354. * Creates a webGL buffer to use with instanciation
  38355. * @param capacity defines the size of the buffer
  38356. * @returns the webGL buffer
  38357. */
  38358. createInstancesBuffer(capacity: number): DataBuffer;
  38359. /**
  38360. * Delete a webGL buffer used with instanciation
  38361. * @param buffer defines the webGL buffer to delete
  38362. */
  38363. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38364. private _clientWaitAsync;
  38365. /** @hidden */
  38366. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38367. dispose(): void;
  38368. private _disableTouchAction;
  38369. /**
  38370. * Display the loading screen
  38371. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38372. */
  38373. displayLoadingUI(): void;
  38374. /**
  38375. * Hide the loading screen
  38376. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38377. */
  38378. hideLoadingUI(): void;
  38379. /**
  38380. * Gets the current loading screen object
  38381. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38382. */
  38383. get loadingScreen(): ILoadingScreen;
  38384. /**
  38385. * Sets the current loading screen object
  38386. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38387. */
  38388. set loadingScreen(loadingScreen: ILoadingScreen);
  38389. /**
  38390. * Sets the current loading screen text
  38391. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38392. */
  38393. set loadingUIText(text: string);
  38394. /**
  38395. * Sets the current loading screen background color
  38396. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38397. */
  38398. set loadingUIBackgroundColor(color: string);
  38399. /** Pointerlock and fullscreen */
  38400. /**
  38401. * Ask the browser to promote the current element to pointerlock mode
  38402. * @param element defines the DOM element to promote
  38403. */
  38404. static _RequestPointerlock(element: HTMLElement): void;
  38405. /**
  38406. * Asks the browser to exit pointerlock mode
  38407. */
  38408. static _ExitPointerlock(): void;
  38409. /**
  38410. * Ask the browser to promote the current element to fullscreen rendering mode
  38411. * @param element defines the DOM element to promote
  38412. */
  38413. static _RequestFullscreen(element: HTMLElement): void;
  38414. /**
  38415. * Asks the browser to exit fullscreen mode
  38416. */
  38417. static _ExitFullscreen(): void;
  38418. }
  38419. }
  38420. declare module "babylonjs/Engines/engineStore" {
  38421. import { Nullable } from "babylonjs/types";
  38422. import { Engine } from "babylonjs/Engines/engine";
  38423. import { Scene } from "babylonjs/scene";
  38424. /**
  38425. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38426. * during the life time of the application.
  38427. */
  38428. export class EngineStore {
  38429. /** Gets the list of created engines */
  38430. static Instances: import("babylonjs/Engines/engine").Engine[];
  38431. /** @hidden */
  38432. static _LastCreatedScene: Nullable<Scene>;
  38433. /**
  38434. * Gets the latest created engine
  38435. */
  38436. static get LastCreatedEngine(): Nullable<Engine>;
  38437. /**
  38438. * Gets the latest created scene
  38439. */
  38440. static get LastCreatedScene(): Nullable<Scene>;
  38441. /**
  38442. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38443. * @ignorenaming
  38444. */
  38445. static UseFallbackTexture: boolean;
  38446. /**
  38447. * Texture content used if a texture cannot loaded
  38448. * @ignorenaming
  38449. */
  38450. static FallbackTexture: string;
  38451. }
  38452. }
  38453. declare module "babylonjs/Misc/promise" {
  38454. /**
  38455. * Helper class that provides a small promise polyfill
  38456. */
  38457. export class PromisePolyfill {
  38458. /**
  38459. * Static function used to check if the polyfill is required
  38460. * If this is the case then the function will inject the polyfill to window.Promise
  38461. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38462. */
  38463. static Apply(force?: boolean): void;
  38464. }
  38465. }
  38466. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  38467. /**
  38468. * Interface for screenshot methods with describe argument called `size` as object with options
  38469. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38470. */
  38471. export interface IScreenshotSize {
  38472. /**
  38473. * number in pixels for canvas height
  38474. */
  38475. height?: number;
  38476. /**
  38477. * multiplier allowing render at a higher or lower resolution
  38478. * If value is defined then height and width will be ignored and taken from camera
  38479. */
  38480. precision?: number;
  38481. /**
  38482. * number in pixels for canvas width
  38483. */
  38484. width?: number;
  38485. }
  38486. }
  38487. declare module "babylonjs/Misc/tools" {
  38488. import { Nullable, float } from "babylonjs/types";
  38489. import { DomManagement } from "babylonjs/Misc/domManagement";
  38490. import { WebRequest } from "babylonjs/Misc/webRequest";
  38491. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  38492. import { ReadFileError } from "babylonjs/Misc/fileTools";
  38493. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38494. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  38495. import { Camera } from "babylonjs/Cameras/camera";
  38496. import { Engine } from "babylonjs/Engines/engine";
  38497. interface IColor4Like {
  38498. r: float;
  38499. g: float;
  38500. b: float;
  38501. a: float;
  38502. }
  38503. /**
  38504. * Class containing a set of static utilities functions
  38505. */
  38506. export class Tools {
  38507. /**
  38508. * Gets or sets the base URL to use to load assets
  38509. */
  38510. static get BaseUrl(): string;
  38511. static set BaseUrl(value: string);
  38512. /**
  38513. * Enable/Disable Custom HTTP Request Headers globally.
  38514. * default = false
  38515. * @see CustomRequestHeaders
  38516. */
  38517. static UseCustomRequestHeaders: boolean;
  38518. /**
  38519. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38520. * i.e. when loading files, where the server/service expects an Authorization header
  38521. */
  38522. static CustomRequestHeaders: {
  38523. [key: string]: string;
  38524. };
  38525. /**
  38526. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38527. */
  38528. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38529. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38530. /**
  38531. * Default behaviour for cors in the application.
  38532. * It can be a string if the expected behavior is identical in the entire app.
  38533. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38534. */
  38535. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38536. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38537. /**
  38538. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38539. * @ignorenaming
  38540. */
  38541. static get UseFallbackTexture(): boolean;
  38542. static set UseFallbackTexture(value: boolean);
  38543. /**
  38544. * Use this object to register external classes like custom textures or material
  38545. * to allow the laoders to instantiate them
  38546. */
  38547. static get RegisteredExternalClasses(): {
  38548. [key: string]: Object;
  38549. };
  38550. static set RegisteredExternalClasses(classes: {
  38551. [key: string]: Object;
  38552. });
  38553. /**
  38554. * Texture content used if a texture cannot loaded
  38555. * @ignorenaming
  38556. */
  38557. static get fallbackTexture(): string;
  38558. static set fallbackTexture(value: string);
  38559. /**
  38560. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38561. * @param u defines the coordinate on X axis
  38562. * @param v defines the coordinate on Y axis
  38563. * @param width defines the width of the source data
  38564. * @param height defines the height of the source data
  38565. * @param pixels defines the source byte array
  38566. * @param color defines the output color
  38567. */
  38568. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38569. /**
  38570. * Interpolates between a and b via alpha
  38571. * @param a The lower value (returned when alpha = 0)
  38572. * @param b The upper value (returned when alpha = 1)
  38573. * @param alpha The interpolation-factor
  38574. * @return The mixed value
  38575. */
  38576. static Mix(a: number, b: number, alpha: number): number;
  38577. /**
  38578. * Tries to instantiate a new object from a given class name
  38579. * @param className defines the class name to instantiate
  38580. * @returns the new object or null if the system was not able to do the instantiation
  38581. */
  38582. static Instantiate(className: string): any;
  38583. /**
  38584. * Provides a slice function that will work even on IE
  38585. * @param data defines the array to slice
  38586. * @param start defines the start of the data (optional)
  38587. * @param end defines the end of the data (optional)
  38588. * @returns the new sliced array
  38589. */
  38590. static Slice<T>(data: T, start?: number, end?: number): T;
  38591. /**
  38592. * Polyfill for setImmediate
  38593. * @param action defines the action to execute after the current execution block
  38594. */
  38595. static SetImmediate(action: () => void): void;
  38596. /**
  38597. * Function indicating if a number is an exponent of 2
  38598. * @param value defines the value to test
  38599. * @returns true if the value is an exponent of 2
  38600. */
  38601. static IsExponentOfTwo(value: number): boolean;
  38602. private static _tmpFloatArray;
  38603. /**
  38604. * Returns the nearest 32-bit single precision float representation of a Number
  38605. * @param value A Number. If the parameter is of a different type, it will get converted
  38606. * to a number or to NaN if it cannot be converted
  38607. * @returns number
  38608. */
  38609. static FloatRound(value: number): number;
  38610. /**
  38611. * Extracts the filename from a path
  38612. * @param path defines the path to use
  38613. * @returns the filename
  38614. */
  38615. static GetFilename(path: string): string;
  38616. /**
  38617. * Extracts the "folder" part of a path (everything before the filename).
  38618. * @param uri The URI to extract the info from
  38619. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38620. * @returns The "folder" part of the path
  38621. */
  38622. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38623. /**
  38624. * Extracts text content from a DOM element hierarchy
  38625. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38626. */
  38627. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38628. /**
  38629. * Convert an angle in radians to degrees
  38630. * @param angle defines the angle to convert
  38631. * @returns the angle in degrees
  38632. */
  38633. static ToDegrees(angle: number): number;
  38634. /**
  38635. * Convert an angle in degrees to radians
  38636. * @param angle defines the angle to convert
  38637. * @returns the angle in radians
  38638. */
  38639. static ToRadians(angle: number): number;
  38640. /**
  38641. * Returns an array if obj is not an array
  38642. * @param obj defines the object to evaluate as an array
  38643. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38644. * @returns either obj directly if obj is an array or a new array containing obj
  38645. */
  38646. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38647. /**
  38648. * Gets the pointer prefix to use
  38649. * @param engine defines the engine we are finding the prefix for
  38650. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38651. */
  38652. static GetPointerPrefix(engine: Engine): string;
  38653. /**
  38654. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38655. * @param url define the url we are trying
  38656. * @param element define the dom element where to configure the cors policy
  38657. */
  38658. static SetCorsBehavior(url: string | string[], element: {
  38659. crossOrigin: string | null;
  38660. }): void;
  38661. /**
  38662. * Removes unwanted characters from an url
  38663. * @param url defines the url to clean
  38664. * @returns the cleaned url
  38665. */
  38666. static CleanUrl(url: string): string;
  38667. /**
  38668. * Gets or sets a function used to pre-process url before using them to load assets
  38669. */
  38670. static get PreprocessUrl(): (url: string) => string;
  38671. static set PreprocessUrl(processor: (url: string) => string);
  38672. /**
  38673. * Loads an image as an HTMLImageElement.
  38674. * @param input url string, ArrayBuffer, or Blob to load
  38675. * @param onLoad callback called when the image successfully loads
  38676. * @param onError callback called when the image fails to load
  38677. * @param offlineProvider offline provider for caching
  38678. * @param mimeType optional mime type
  38679. * @returns the HTMLImageElement of the loaded image
  38680. */
  38681. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38682. /**
  38683. * Loads a file from a url
  38684. * @param url url string, ArrayBuffer, or Blob to load
  38685. * @param onSuccess callback called when the file successfully loads
  38686. * @param onProgress callback called while file is loading (if the server supports this mode)
  38687. * @param offlineProvider defines the offline provider for caching
  38688. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38689. * @param onError callback called when the file fails to load
  38690. * @returns a file request object
  38691. */
  38692. 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;
  38693. /**
  38694. * Loads a file from a url
  38695. * @param url the file url to load
  38696. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38697. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38698. */
  38699. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38700. /**
  38701. * Load a script (identified by an url). When the url returns, the
  38702. * content of this file is added into a new script element, attached to the DOM (body element)
  38703. * @param scriptUrl defines the url of the script to laod
  38704. * @param onSuccess defines the callback called when the script is loaded
  38705. * @param onError defines the callback to call if an error occurs
  38706. * @param scriptId defines the id of the script element
  38707. */
  38708. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38709. /**
  38710. * Load an asynchronous script (identified by an url). When the url returns, the
  38711. * content of this file is added into a new script element, attached to the DOM (body element)
  38712. * @param scriptUrl defines the url of the script to laod
  38713. * @param scriptId defines the id of the script element
  38714. * @returns a promise request object
  38715. */
  38716. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38717. /**
  38718. * Loads a file from a blob
  38719. * @param fileToLoad defines the blob to use
  38720. * @param callback defines the callback to call when data is loaded
  38721. * @param progressCallback defines the callback to call during loading process
  38722. * @returns a file request object
  38723. */
  38724. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38725. /**
  38726. * Reads a file from a File object
  38727. * @param file defines the file to load
  38728. * @param onSuccess defines the callback to call when data is loaded
  38729. * @param onProgress defines the callback to call during loading process
  38730. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38731. * @param onError defines the callback to call when an error occurs
  38732. * @returns a file request object
  38733. */
  38734. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38735. /**
  38736. * Creates a data url from a given string content
  38737. * @param content defines the content to convert
  38738. * @returns the new data url link
  38739. */
  38740. static FileAsURL(content: string): string;
  38741. /**
  38742. * Format the given number to a specific decimal format
  38743. * @param value defines the number to format
  38744. * @param decimals defines the number of decimals to use
  38745. * @returns the formatted string
  38746. */
  38747. static Format(value: number, decimals?: number): string;
  38748. /**
  38749. * Tries to copy an object by duplicating every property
  38750. * @param source defines the source object
  38751. * @param destination defines the target object
  38752. * @param doNotCopyList defines a list of properties to avoid
  38753. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38754. */
  38755. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38756. /**
  38757. * Gets a boolean indicating if the given object has no own property
  38758. * @param obj defines the object to test
  38759. * @returns true if object has no own property
  38760. */
  38761. static IsEmpty(obj: any): boolean;
  38762. /**
  38763. * Function used to register events at window level
  38764. * @param windowElement defines the Window object to use
  38765. * @param events defines the events to register
  38766. */
  38767. static RegisterTopRootEvents(windowElement: Window, events: {
  38768. name: string;
  38769. handler: Nullable<(e: FocusEvent) => any>;
  38770. }[]): void;
  38771. /**
  38772. * Function used to unregister events from window level
  38773. * @param windowElement defines the Window object to use
  38774. * @param events defines the events to unregister
  38775. */
  38776. static UnregisterTopRootEvents(windowElement: Window, events: {
  38777. name: string;
  38778. handler: Nullable<(e: FocusEvent) => any>;
  38779. }[]): void;
  38780. /**
  38781. * @ignore
  38782. */
  38783. static _ScreenshotCanvas: HTMLCanvasElement;
  38784. /**
  38785. * Dumps the current bound framebuffer
  38786. * @param width defines the rendering width
  38787. * @param height defines the rendering height
  38788. * @param engine defines the hosting engine
  38789. * @param successCallback defines the callback triggered once the data are available
  38790. * @param mimeType defines the mime type of the result
  38791. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38792. */
  38793. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38794. /**
  38795. * Converts the canvas data to blob.
  38796. * This acts as a polyfill for browsers not supporting the to blob function.
  38797. * @param canvas Defines the canvas to extract the data from
  38798. * @param successCallback Defines the callback triggered once the data are available
  38799. * @param mimeType Defines the mime type of the result
  38800. */
  38801. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38802. /**
  38803. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38804. * @param successCallback defines the callback triggered once the data are available
  38805. * @param mimeType defines the mime type of the result
  38806. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38807. */
  38808. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38809. /**
  38810. * Downloads a blob in the browser
  38811. * @param blob defines the blob to download
  38812. * @param fileName defines the name of the downloaded file
  38813. */
  38814. static Download(blob: Blob, fileName: string): void;
  38815. /**
  38816. * Captures a screenshot of the current rendering
  38817. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38818. * @param engine defines the rendering engine
  38819. * @param camera defines the source camera
  38820. * @param size This parameter can be set to a single number or to an object with the
  38821. * following (optional) properties: precision, width, height. If a single number is passed,
  38822. * it will be used for both width and height. If an object is passed, the screenshot size
  38823. * will be derived from the parameters. The precision property is a multiplier allowing
  38824. * rendering at a higher or lower resolution
  38825. * @param successCallback defines the callback receives a single parameter which contains the
  38826. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38827. * src parameter of an <img> to display it
  38828. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38829. * Check your browser for supported MIME types
  38830. */
  38831. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38832. /**
  38833. * Captures a screenshot of the current rendering
  38834. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38835. * @param engine defines the rendering engine
  38836. * @param camera defines the source camera
  38837. * @param size This parameter can be set to a single number or to an object with the
  38838. * following (optional) properties: precision, width, height. If a single number is passed,
  38839. * it will be used for both width and height. If an object is passed, the screenshot size
  38840. * will be derived from the parameters. The precision property is a multiplier allowing
  38841. * rendering at a higher or lower resolution
  38842. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38843. * Check your browser for supported MIME types
  38844. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38845. * to the src parameter of an <img> to display it
  38846. */
  38847. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38848. /**
  38849. * Generates an image screenshot from the specified camera.
  38850. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38851. * @param engine The engine to use for rendering
  38852. * @param camera The camera to use for rendering
  38853. * @param size This parameter can be set to a single number or to an object with the
  38854. * following (optional) properties: precision, width, height. If a single number is passed,
  38855. * it will be used for both width and height. If an object is passed, the screenshot size
  38856. * will be derived from the parameters. The precision property is a multiplier allowing
  38857. * rendering at a higher or lower resolution
  38858. * @param successCallback The callback receives a single parameter which contains the
  38859. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38860. * src parameter of an <img> to display it
  38861. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38862. * Check your browser for supported MIME types
  38863. * @param samples Texture samples (default: 1)
  38864. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38865. * @param fileName A name for for the downloaded file.
  38866. */
  38867. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38868. /**
  38869. * Generates an image screenshot from the specified camera.
  38870. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38871. * @param engine The engine to use for rendering
  38872. * @param camera The camera to use for rendering
  38873. * @param size This parameter can be set to a single number or to an object with the
  38874. * following (optional) properties: precision, width, height. If a single number is passed,
  38875. * it will be used for both width and height. If an object is passed, the screenshot size
  38876. * will be derived from the parameters. The precision property is a multiplier allowing
  38877. * rendering at a higher or lower resolution
  38878. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38879. * Check your browser for supported MIME types
  38880. * @param samples Texture samples (default: 1)
  38881. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38882. * @param fileName A name for for the downloaded file.
  38883. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38884. * to the src parameter of an <img> to display it
  38885. */
  38886. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38887. /**
  38888. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38889. * Be aware Math.random() could cause collisions, but:
  38890. * "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"
  38891. * @returns a pseudo random id
  38892. */
  38893. static RandomId(): string;
  38894. /**
  38895. * Test if the given uri is a base64 string
  38896. * @param uri The uri to test
  38897. * @return True if the uri is a base64 string or false otherwise
  38898. */
  38899. static IsBase64(uri: string): boolean;
  38900. /**
  38901. * Decode the given base64 uri.
  38902. * @param uri The uri to decode
  38903. * @return The decoded base64 data.
  38904. */
  38905. static DecodeBase64(uri: string): ArrayBuffer;
  38906. /**
  38907. * Gets the absolute url.
  38908. * @param url the input url
  38909. * @return the absolute url
  38910. */
  38911. static GetAbsoluteUrl(url: string): string;
  38912. /**
  38913. * No log
  38914. */
  38915. static readonly NoneLogLevel: number;
  38916. /**
  38917. * Only message logs
  38918. */
  38919. static readonly MessageLogLevel: number;
  38920. /**
  38921. * Only warning logs
  38922. */
  38923. static readonly WarningLogLevel: number;
  38924. /**
  38925. * Only error logs
  38926. */
  38927. static readonly ErrorLogLevel: number;
  38928. /**
  38929. * All logs
  38930. */
  38931. static readonly AllLogLevel: number;
  38932. /**
  38933. * Gets a value indicating the number of loading errors
  38934. * @ignorenaming
  38935. */
  38936. static get errorsCount(): number;
  38937. /**
  38938. * Callback called when a new log is added
  38939. */
  38940. static OnNewCacheEntry: (entry: string) => void;
  38941. /**
  38942. * Log a message to the console
  38943. * @param message defines the message to log
  38944. */
  38945. static Log(message: string): void;
  38946. /**
  38947. * Write a warning message to the console
  38948. * @param message defines the message to log
  38949. */
  38950. static Warn(message: string): void;
  38951. /**
  38952. * Write an error message to the console
  38953. * @param message defines the message to log
  38954. */
  38955. static Error(message: string): void;
  38956. /**
  38957. * Gets current log cache (list of logs)
  38958. */
  38959. static get LogCache(): string;
  38960. /**
  38961. * Clears the log cache
  38962. */
  38963. static ClearLogCache(): void;
  38964. /**
  38965. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38966. */
  38967. static set LogLevels(level: number);
  38968. /**
  38969. * Checks if the window object exists
  38970. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38971. */
  38972. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38973. /**
  38974. * No performance log
  38975. */
  38976. static readonly PerformanceNoneLogLevel: number;
  38977. /**
  38978. * Use user marks to log performance
  38979. */
  38980. static readonly PerformanceUserMarkLogLevel: number;
  38981. /**
  38982. * Log performance to the console
  38983. */
  38984. static readonly PerformanceConsoleLogLevel: number;
  38985. private static _performance;
  38986. /**
  38987. * Sets the current performance log level
  38988. */
  38989. static set PerformanceLogLevel(level: number);
  38990. private static _StartPerformanceCounterDisabled;
  38991. private static _EndPerformanceCounterDisabled;
  38992. private static _StartUserMark;
  38993. private static _EndUserMark;
  38994. private static _StartPerformanceConsole;
  38995. private static _EndPerformanceConsole;
  38996. /**
  38997. * Starts a performance counter
  38998. */
  38999. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39000. /**
  39001. * Ends a specific performance coutner
  39002. */
  39003. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39004. /**
  39005. * Gets either window.performance.now() if supported or Date.now() else
  39006. */
  39007. static get Now(): number;
  39008. /**
  39009. * This method will return the name of the class used to create the instance of the given object.
  39010. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39011. * @param object the object to get the class name from
  39012. * @param isType defines if the object is actually a type
  39013. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39014. */
  39015. static GetClassName(object: any, isType?: boolean): string;
  39016. /**
  39017. * Gets the first element of an array satisfying a given predicate
  39018. * @param array defines the array to browse
  39019. * @param predicate defines the predicate to use
  39020. * @returns null if not found or the element
  39021. */
  39022. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39023. /**
  39024. * This method will return the name of the full name of the class, including its owning module (if any).
  39025. * 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).
  39026. * @param object the object to get the class name from
  39027. * @param isType defines if the object is actually a type
  39028. * @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.
  39029. * @ignorenaming
  39030. */
  39031. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39032. /**
  39033. * Returns a promise that resolves after the given amount of time.
  39034. * @param delay Number of milliseconds to delay
  39035. * @returns Promise that resolves after the given amount of time
  39036. */
  39037. static DelayAsync(delay: number): Promise<void>;
  39038. /**
  39039. * Utility function to detect if the current user agent is Safari
  39040. * @returns whether or not the current user agent is safari
  39041. */
  39042. static IsSafari(): boolean;
  39043. }
  39044. /**
  39045. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39046. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39047. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39048. * @param name The name of the class, case should be preserved
  39049. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39050. */
  39051. export function className(name: string, module?: string): (target: Object) => void;
  39052. /**
  39053. * An implementation of a loop for asynchronous functions.
  39054. */
  39055. export class AsyncLoop {
  39056. /**
  39057. * Defines the number of iterations for the loop
  39058. */
  39059. iterations: number;
  39060. /**
  39061. * Defines the current index of the loop.
  39062. */
  39063. index: number;
  39064. private _done;
  39065. private _fn;
  39066. private _successCallback;
  39067. /**
  39068. * Constructor.
  39069. * @param iterations the number of iterations.
  39070. * @param func the function to run each iteration
  39071. * @param successCallback the callback that will be called upon succesful execution
  39072. * @param offset starting offset.
  39073. */
  39074. constructor(
  39075. /**
  39076. * Defines the number of iterations for the loop
  39077. */
  39078. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39079. /**
  39080. * Execute the next iteration. Must be called after the last iteration was finished.
  39081. */
  39082. executeNext(): void;
  39083. /**
  39084. * Break the loop and run the success callback.
  39085. */
  39086. breakLoop(): void;
  39087. /**
  39088. * Create and run an async loop.
  39089. * @param iterations the number of iterations.
  39090. * @param fn the function to run each iteration
  39091. * @param successCallback the callback that will be called upon succesful execution
  39092. * @param offset starting offset.
  39093. * @returns the created async loop object
  39094. */
  39095. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39096. /**
  39097. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39098. * @param iterations total number of iterations
  39099. * @param syncedIterations number of synchronous iterations in each async iteration.
  39100. * @param fn the function to call each iteration.
  39101. * @param callback a success call back that will be called when iterating stops.
  39102. * @param breakFunction a break condition (optional)
  39103. * @param timeout timeout settings for the setTimeout function. default - 0.
  39104. * @returns the created async loop object
  39105. */
  39106. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39107. }
  39108. }
  39109. declare module "babylonjs/Misc/stringDictionary" {
  39110. import { Nullable } from "babylonjs/types";
  39111. /**
  39112. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39113. * The underlying implementation relies on an associative array to ensure the best performances.
  39114. * The value can be anything including 'null' but except 'undefined'
  39115. */
  39116. export class StringDictionary<T> {
  39117. /**
  39118. * This will clear this dictionary and copy the content from the 'source' one.
  39119. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39120. * @param source the dictionary to take the content from and copy to this dictionary
  39121. */
  39122. copyFrom(source: StringDictionary<T>): void;
  39123. /**
  39124. * Get a value based from its key
  39125. * @param key the given key to get the matching value from
  39126. * @return the value if found, otherwise undefined is returned
  39127. */
  39128. get(key: string): T | undefined;
  39129. /**
  39130. * Get a value from its key or add it if it doesn't exist.
  39131. * This method will ensure you that a given key/data will be present in the dictionary.
  39132. * @param key the given key to get the matching value from
  39133. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39134. * The factory will only be invoked if there's no data for the given key.
  39135. * @return the value corresponding to the key.
  39136. */
  39137. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39138. /**
  39139. * Get a value from its key if present in the dictionary otherwise add it
  39140. * @param key the key to get the value from
  39141. * @param val if there's no such key/value pair in the dictionary add it with this value
  39142. * @return the value corresponding to the key
  39143. */
  39144. getOrAdd(key: string, val: T): T;
  39145. /**
  39146. * Check if there's a given key in the dictionary
  39147. * @param key the key to check for
  39148. * @return true if the key is present, false otherwise
  39149. */
  39150. contains(key: string): boolean;
  39151. /**
  39152. * Add a new key and its corresponding value
  39153. * @param key the key to add
  39154. * @param value the value corresponding to the key
  39155. * @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
  39156. */
  39157. add(key: string, value: T): boolean;
  39158. /**
  39159. * Update a specific value associated to a key
  39160. * @param key defines the key to use
  39161. * @param value defines the value to store
  39162. * @returns true if the value was updated (or false if the key was not found)
  39163. */
  39164. set(key: string, value: T): boolean;
  39165. /**
  39166. * Get the element of the given key and remove it from the dictionary
  39167. * @param key defines the key to search
  39168. * @returns the value associated with the key or null if not found
  39169. */
  39170. getAndRemove(key: string): Nullable<T>;
  39171. /**
  39172. * Remove a key/value from the dictionary.
  39173. * @param key the key to remove
  39174. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39175. */
  39176. remove(key: string): boolean;
  39177. /**
  39178. * Clear the whole content of the dictionary
  39179. */
  39180. clear(): void;
  39181. /**
  39182. * Gets the current count
  39183. */
  39184. get count(): number;
  39185. /**
  39186. * Execute a callback on each key/val of the dictionary.
  39187. * Note that you can remove any element in this dictionary in the callback implementation
  39188. * @param callback the callback to execute on a given key/value pair
  39189. */
  39190. forEach(callback: (key: string, val: T) => void): void;
  39191. /**
  39192. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39193. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39194. * Note that you can remove any element in this dictionary in the callback implementation
  39195. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39196. * @returns the first item
  39197. */
  39198. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39199. private _count;
  39200. private _data;
  39201. }
  39202. }
  39203. declare module "babylonjs/Collisions/collisionCoordinator" {
  39204. import { Nullable } from "babylonjs/types";
  39205. import { Scene } from "babylonjs/scene";
  39206. import { Vector3 } from "babylonjs/Maths/math.vector";
  39207. import { Collider } from "babylonjs/Collisions/collider";
  39208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39209. /** @hidden */
  39210. export interface ICollisionCoordinator {
  39211. createCollider(): Collider;
  39212. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39213. init(scene: Scene): void;
  39214. }
  39215. /** @hidden */
  39216. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  39217. private _scene;
  39218. private _scaledPosition;
  39219. private _scaledVelocity;
  39220. private _finalPosition;
  39221. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39222. createCollider(): Collider;
  39223. init(scene: Scene): void;
  39224. private _collideWithWorld;
  39225. }
  39226. }
  39227. declare module "babylonjs/Inputs/scene.inputManager" {
  39228. import { Nullable } from "babylonjs/types";
  39229. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39230. import { Vector2 } from "babylonjs/Maths/math.vector";
  39231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39232. import { Scene } from "babylonjs/scene";
  39233. /**
  39234. * Class used to manage all inputs for the scene.
  39235. */
  39236. export class InputManager {
  39237. /** The distance in pixel that you have to move to prevent some events */
  39238. static DragMovementThreshold: number;
  39239. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  39240. static LongPressDelay: number;
  39241. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  39242. static DoubleClickDelay: number;
  39243. /** If you need to check double click without raising a single click at first click, enable this flag */
  39244. static ExclusiveDoubleClickMode: boolean;
  39245. private _wheelEventName;
  39246. private _onPointerMove;
  39247. private _onPointerDown;
  39248. private _onPointerUp;
  39249. private _initClickEvent;
  39250. private _initActionManager;
  39251. private _delayedSimpleClick;
  39252. private _delayedSimpleClickTimeout;
  39253. private _previousDelayedSimpleClickTimeout;
  39254. private _meshPickProceed;
  39255. private _previousButtonPressed;
  39256. private _currentPickResult;
  39257. private _previousPickResult;
  39258. private _totalPointersPressed;
  39259. private _doubleClickOccured;
  39260. private _pointerOverMesh;
  39261. private _pickedDownMesh;
  39262. private _pickedUpMesh;
  39263. private _pointerX;
  39264. private _pointerY;
  39265. private _unTranslatedPointerX;
  39266. private _unTranslatedPointerY;
  39267. private _startingPointerPosition;
  39268. private _previousStartingPointerPosition;
  39269. private _startingPointerTime;
  39270. private _previousStartingPointerTime;
  39271. private _pointerCaptures;
  39272. private _onKeyDown;
  39273. private _onKeyUp;
  39274. private _onCanvasFocusObserver;
  39275. private _onCanvasBlurObserver;
  39276. private _scene;
  39277. /**
  39278. * Creates a new InputManager
  39279. * @param scene defines the hosting scene
  39280. */
  39281. constructor(scene: Scene);
  39282. /**
  39283. * Gets the mesh that is currently under the pointer
  39284. */
  39285. get meshUnderPointer(): Nullable<AbstractMesh>;
  39286. /**
  39287. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39288. */
  39289. get unTranslatedPointer(): Vector2;
  39290. /**
  39291. * Gets or sets the current on-screen X position of the pointer
  39292. */
  39293. get pointerX(): number;
  39294. set pointerX(value: number);
  39295. /**
  39296. * Gets or sets the current on-screen Y position of the pointer
  39297. */
  39298. get pointerY(): number;
  39299. set pointerY(value: number);
  39300. private _updatePointerPosition;
  39301. private _processPointerMove;
  39302. private _setRayOnPointerInfo;
  39303. private _checkPrePointerObservable;
  39304. /**
  39305. * Use this method to simulate a pointer move on a mesh
  39306. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39307. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39308. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39309. */
  39310. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39311. /**
  39312. * Use this method to simulate a pointer down on a mesh
  39313. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39314. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39315. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39316. */
  39317. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39318. private _processPointerDown;
  39319. /** @hidden */
  39320. _isPointerSwiping(): boolean;
  39321. /**
  39322. * Use this method to simulate a pointer up on a mesh
  39323. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39324. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39325. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39326. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39327. */
  39328. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39329. private _processPointerUp;
  39330. /**
  39331. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39332. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39333. * @returns true if the pointer was captured
  39334. */
  39335. isPointerCaptured(pointerId?: number): boolean;
  39336. /**
  39337. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39338. * @param attachUp defines if you want to attach events to pointerup
  39339. * @param attachDown defines if you want to attach events to pointerdown
  39340. * @param attachMove defines if you want to attach events to pointermove
  39341. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39342. */
  39343. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39344. /**
  39345. * Detaches all event handlers
  39346. */
  39347. detachControl(): void;
  39348. /**
  39349. * Force the value of meshUnderPointer
  39350. * @param mesh defines the mesh to use
  39351. */
  39352. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39353. /**
  39354. * Gets the mesh under the pointer
  39355. * @returns a Mesh or null if no mesh is under the pointer
  39356. */
  39357. getPointerOverMesh(): Nullable<AbstractMesh>;
  39358. }
  39359. }
  39360. declare module "babylonjs/Animations/animationGroup" {
  39361. import { Animatable } from "babylonjs/Animations/animatable";
  39362. import { Animation } from "babylonjs/Animations/animation";
  39363. import { Scene, IDisposable } from "babylonjs/scene";
  39364. import { Observable } from "babylonjs/Misc/observable";
  39365. import { Nullable } from "babylonjs/types";
  39366. import "babylonjs/Animations/animatable";
  39367. /**
  39368. * This class defines the direct association between an animation and a target
  39369. */
  39370. export class TargetedAnimation {
  39371. /**
  39372. * Animation to perform
  39373. */
  39374. animation: Animation;
  39375. /**
  39376. * Target to animate
  39377. */
  39378. target: any;
  39379. /**
  39380. * Returns the string "TargetedAnimation"
  39381. * @returns "TargetedAnimation"
  39382. */
  39383. getClassName(): string;
  39384. /**
  39385. * Serialize the object
  39386. * @returns the JSON object representing the current entity
  39387. */
  39388. serialize(): any;
  39389. }
  39390. /**
  39391. * Use this class to create coordinated animations on multiple targets
  39392. */
  39393. export class AnimationGroup implements IDisposable {
  39394. /** The name of the animation group */
  39395. name: string;
  39396. private _scene;
  39397. private _targetedAnimations;
  39398. private _animatables;
  39399. private _from;
  39400. private _to;
  39401. private _isStarted;
  39402. private _isPaused;
  39403. private _speedRatio;
  39404. private _loopAnimation;
  39405. private _isAdditive;
  39406. /**
  39407. * Gets or sets the unique id of the node
  39408. */
  39409. uniqueId: number;
  39410. /**
  39411. * This observable will notify when one animation have ended
  39412. */
  39413. onAnimationEndObservable: Observable<TargetedAnimation>;
  39414. /**
  39415. * Observer raised when one animation loops
  39416. */
  39417. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39418. /**
  39419. * Observer raised when all animations have looped
  39420. */
  39421. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39422. /**
  39423. * This observable will notify when all animations have ended.
  39424. */
  39425. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39426. /**
  39427. * This observable will notify when all animations have paused.
  39428. */
  39429. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39430. /**
  39431. * This observable will notify when all animations are playing.
  39432. */
  39433. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39434. /**
  39435. * Gets the first frame
  39436. */
  39437. get from(): number;
  39438. /**
  39439. * Gets the last frame
  39440. */
  39441. get to(): number;
  39442. /**
  39443. * Define if the animations are started
  39444. */
  39445. get isStarted(): boolean;
  39446. /**
  39447. * Gets a value indicating that the current group is playing
  39448. */
  39449. get isPlaying(): boolean;
  39450. /**
  39451. * Gets or sets the speed ratio to use for all animations
  39452. */
  39453. get speedRatio(): number;
  39454. /**
  39455. * Gets or sets the speed ratio to use for all animations
  39456. */
  39457. set speedRatio(value: number);
  39458. /**
  39459. * Gets or sets if all animations should loop or not
  39460. */
  39461. get loopAnimation(): boolean;
  39462. set loopAnimation(value: boolean);
  39463. /**
  39464. * Gets or sets if all animations should be evaluated additively
  39465. */
  39466. get isAdditive(): boolean;
  39467. set isAdditive(value: boolean);
  39468. /**
  39469. * Gets the targeted animations for this animation group
  39470. */
  39471. get targetedAnimations(): Array<TargetedAnimation>;
  39472. /**
  39473. * returning the list of animatables controlled by this animation group.
  39474. */
  39475. get animatables(): Array<Animatable>;
  39476. /**
  39477. * Gets the list of target animations
  39478. */
  39479. get children(): TargetedAnimation[];
  39480. /**
  39481. * Instantiates a new Animation Group.
  39482. * This helps managing several animations at once.
  39483. * @see http://doc.babylonjs.com/how_to/group
  39484. * @param name Defines the name of the group
  39485. * @param scene Defines the scene the group belongs to
  39486. */
  39487. constructor(
  39488. /** The name of the animation group */
  39489. name: string, scene?: Nullable<Scene>);
  39490. /**
  39491. * Add an animation (with its target) in the group
  39492. * @param animation defines the animation we want to add
  39493. * @param target defines the target of the animation
  39494. * @returns the TargetedAnimation object
  39495. */
  39496. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39497. /**
  39498. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39499. * It can add constant keys at begin or end
  39500. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39501. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39502. * @returns the animation group
  39503. */
  39504. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39505. private _animationLoopCount;
  39506. private _animationLoopFlags;
  39507. private _processLoop;
  39508. /**
  39509. * Start all animations on given targets
  39510. * @param loop defines if animations must loop
  39511. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39512. * @param from defines the from key (optional)
  39513. * @param to defines the to key (optional)
  39514. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39515. * @returns the current animation group
  39516. */
  39517. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39518. /**
  39519. * Pause all animations
  39520. * @returns the animation group
  39521. */
  39522. pause(): AnimationGroup;
  39523. /**
  39524. * Play all animations to initial state
  39525. * This function will start() the animations if they were not started or will restart() them if they were paused
  39526. * @param loop defines if animations must loop
  39527. * @returns the animation group
  39528. */
  39529. play(loop?: boolean): AnimationGroup;
  39530. /**
  39531. * Reset all animations to initial state
  39532. * @returns the animation group
  39533. */
  39534. reset(): AnimationGroup;
  39535. /**
  39536. * Restart animations from key 0
  39537. * @returns the animation group
  39538. */
  39539. restart(): AnimationGroup;
  39540. /**
  39541. * Stop all animations
  39542. * @returns the animation group
  39543. */
  39544. stop(): AnimationGroup;
  39545. /**
  39546. * Set animation weight for all animatables
  39547. * @param weight defines the weight to use
  39548. * @return the animationGroup
  39549. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  39550. */
  39551. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39552. /**
  39553. * Synchronize and normalize all animatables with a source animatable
  39554. * @param root defines the root animatable to synchronize with
  39555. * @return the animationGroup
  39556. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  39557. */
  39558. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39559. /**
  39560. * Goes to a specific frame in this animation group
  39561. * @param frame the frame number to go to
  39562. * @return the animationGroup
  39563. */
  39564. goToFrame(frame: number): AnimationGroup;
  39565. /**
  39566. * Dispose all associated resources
  39567. */
  39568. dispose(): void;
  39569. private _checkAnimationGroupEnded;
  39570. /**
  39571. * Clone the current animation group and returns a copy
  39572. * @param newName defines the name of the new group
  39573. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39574. * @returns the new aniamtion group
  39575. */
  39576. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39577. /**
  39578. * Serializes the animationGroup to an object
  39579. * @returns Serialized object
  39580. */
  39581. serialize(): any;
  39582. /**
  39583. * Returns a new AnimationGroup object parsed from the source provided.
  39584. * @param parsedAnimationGroup defines the source
  39585. * @param scene defines the scene that will receive the animationGroup
  39586. * @returns a new AnimationGroup
  39587. */
  39588. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39589. /**
  39590. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39591. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39592. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39593. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39594. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39595. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39596. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39597. */
  39598. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39599. /**
  39600. * Returns the string "AnimationGroup"
  39601. * @returns "AnimationGroup"
  39602. */
  39603. getClassName(): string;
  39604. /**
  39605. * Creates a detailled string about the object
  39606. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39607. * @returns a string representing the object
  39608. */
  39609. toString(fullDetails?: boolean): string;
  39610. }
  39611. }
  39612. declare module "babylonjs/scene" {
  39613. import { Nullable } from "babylonjs/types";
  39614. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  39615. import { Observable } from "babylonjs/Misc/observable";
  39616. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  39617. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  39618. import { Geometry } from "babylonjs/Meshes/geometry";
  39619. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39620. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39622. import { Mesh } from "babylonjs/Meshes/mesh";
  39623. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  39624. import { Bone } from "babylonjs/Bones/bone";
  39625. import { Skeleton } from "babylonjs/Bones/skeleton";
  39626. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  39627. import { Camera } from "babylonjs/Cameras/camera";
  39628. import { AbstractScene } from "babylonjs/abstractScene";
  39629. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39630. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39631. import { Material } from "babylonjs/Materials/material";
  39632. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39633. import { Effect } from "babylonjs/Materials/effect";
  39634. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39635. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  39636. import { Light } from "babylonjs/Lights/light";
  39637. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39638. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  39639. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  39640. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  39641. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39642. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  39643. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39644. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  39645. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  39646. import { Engine } from "babylonjs/Engines/engine";
  39647. import { Node } from "babylonjs/node";
  39648. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  39649. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  39650. import { WebRequest } from "babylonjs/Misc/webRequest";
  39651. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  39652. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  39653. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39654. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  39655. import { Plane } from "babylonjs/Maths/math.plane";
  39656. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  39657. import { Ray } from "babylonjs/Culling/ray";
  39658. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  39659. import { Animation } from "babylonjs/Animations/animation";
  39660. import { Animatable } from "babylonjs/Animations/animatable";
  39661. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  39662. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  39663. import { Collider } from "babylonjs/Collisions/collider";
  39664. /**
  39665. * Define an interface for all classes that will hold resources
  39666. */
  39667. export interface IDisposable {
  39668. /**
  39669. * Releases all held resources
  39670. */
  39671. dispose(): void;
  39672. }
  39673. /** Interface defining initialization parameters for Scene class */
  39674. export interface SceneOptions {
  39675. /**
  39676. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39677. * It will improve performance when the number of geometries becomes important.
  39678. */
  39679. useGeometryUniqueIdsMap?: boolean;
  39680. /**
  39681. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39682. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39683. */
  39684. useMaterialMeshMap?: boolean;
  39685. /**
  39686. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39687. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39688. */
  39689. useClonedMeshMap?: boolean;
  39690. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39691. virtual?: boolean;
  39692. }
  39693. /**
  39694. * Represents a scene to be rendered by the engine.
  39695. * @see http://doc.babylonjs.com/features/scene
  39696. */
  39697. export class Scene extends AbstractScene implements IAnimatable {
  39698. /** The fog is deactivated */
  39699. static readonly FOGMODE_NONE: number;
  39700. /** The fog density is following an exponential function */
  39701. static readonly FOGMODE_EXP: number;
  39702. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39703. static readonly FOGMODE_EXP2: number;
  39704. /** The fog density is following a linear function. */
  39705. static readonly FOGMODE_LINEAR: number;
  39706. /**
  39707. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39708. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39709. */
  39710. static MinDeltaTime: number;
  39711. /**
  39712. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39713. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39714. */
  39715. static MaxDeltaTime: number;
  39716. /**
  39717. * Factory used to create the default material.
  39718. * @param name The name of the material to create
  39719. * @param scene The scene to create the material for
  39720. * @returns The default material
  39721. */
  39722. static DefaultMaterialFactory(scene: Scene): Material;
  39723. /**
  39724. * Factory used to create the a collision coordinator.
  39725. * @returns The collision coordinator
  39726. */
  39727. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39728. /** @hidden */
  39729. _inputManager: InputManager;
  39730. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39731. cameraToUseForPointers: Nullable<Camera>;
  39732. /** @hidden */
  39733. readonly _isScene: boolean;
  39734. /** @hidden */
  39735. _blockEntityCollection: boolean;
  39736. /**
  39737. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39738. */
  39739. autoClear: boolean;
  39740. /**
  39741. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39742. */
  39743. autoClearDepthAndStencil: boolean;
  39744. /**
  39745. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39746. */
  39747. clearColor: Color4;
  39748. /**
  39749. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39750. */
  39751. ambientColor: Color3;
  39752. /**
  39753. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39754. * It should only be one of the following (if not the default embedded one):
  39755. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39756. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39757. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39758. * The material properties need to be setup according to the type of texture in use.
  39759. */
  39760. environmentBRDFTexture: BaseTexture;
  39761. /** @hidden */
  39762. protected _environmentTexture: Nullable<BaseTexture>;
  39763. /**
  39764. * Texture used in all pbr material as the reflection texture.
  39765. * As in the majority of the scene they are the same (exception for multi room and so on),
  39766. * this is easier to reference from here than from all the materials.
  39767. */
  39768. get environmentTexture(): Nullable<BaseTexture>;
  39769. /**
  39770. * Texture used in all pbr material as the reflection texture.
  39771. * As in the majority of the scene they are the same (exception for multi room and so on),
  39772. * this is easier to set here than in all the materials.
  39773. */
  39774. set environmentTexture(value: Nullable<BaseTexture>);
  39775. /** @hidden */
  39776. protected _environmentIntensity: number;
  39777. /**
  39778. * Intensity of the environment in all pbr material.
  39779. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39780. * As in the majority of the scene they are the same (exception for multi room and so on),
  39781. * this is easier to reference from here than from all the materials.
  39782. */
  39783. get environmentIntensity(): number;
  39784. /**
  39785. * Intensity of the environment in all pbr material.
  39786. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39787. * As in the majority of the scene they are the same (exception for multi room and so on),
  39788. * this is easier to set here than in all the materials.
  39789. */
  39790. set environmentIntensity(value: number);
  39791. /** @hidden */
  39792. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39793. /**
  39794. * Default image processing configuration used either in the rendering
  39795. * Forward main pass or through the imageProcessingPostProcess if present.
  39796. * As in the majority of the scene they are the same (exception for multi camera),
  39797. * this is easier to reference from here than from all the materials and post process.
  39798. *
  39799. * No setter as we it is a shared configuration, you can set the values instead.
  39800. */
  39801. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39802. private _forceWireframe;
  39803. /**
  39804. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39805. */
  39806. set forceWireframe(value: boolean);
  39807. get forceWireframe(): boolean;
  39808. private _skipFrustumClipping;
  39809. /**
  39810. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39811. */
  39812. set skipFrustumClipping(value: boolean);
  39813. get skipFrustumClipping(): boolean;
  39814. private _forcePointsCloud;
  39815. /**
  39816. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39817. */
  39818. set forcePointsCloud(value: boolean);
  39819. get forcePointsCloud(): boolean;
  39820. /**
  39821. * Gets or sets the active clipplane 1
  39822. */
  39823. clipPlane: Nullable<Plane>;
  39824. /**
  39825. * Gets or sets the active clipplane 2
  39826. */
  39827. clipPlane2: Nullable<Plane>;
  39828. /**
  39829. * Gets or sets the active clipplane 3
  39830. */
  39831. clipPlane3: Nullable<Plane>;
  39832. /**
  39833. * Gets or sets the active clipplane 4
  39834. */
  39835. clipPlane4: Nullable<Plane>;
  39836. /**
  39837. * Gets or sets the active clipplane 5
  39838. */
  39839. clipPlane5: Nullable<Plane>;
  39840. /**
  39841. * Gets or sets the active clipplane 6
  39842. */
  39843. clipPlane6: Nullable<Plane>;
  39844. /**
  39845. * Gets or sets a boolean indicating if animations are enabled
  39846. */
  39847. animationsEnabled: boolean;
  39848. private _animationPropertiesOverride;
  39849. /**
  39850. * Gets or sets the animation properties override
  39851. */
  39852. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39853. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39854. /**
  39855. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39856. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39857. */
  39858. useConstantAnimationDeltaTime: boolean;
  39859. /**
  39860. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39861. * Please note that it requires to run a ray cast through the scene on every frame
  39862. */
  39863. constantlyUpdateMeshUnderPointer: boolean;
  39864. /**
  39865. * Defines the HTML cursor to use when hovering over interactive elements
  39866. */
  39867. hoverCursor: string;
  39868. /**
  39869. * Defines the HTML default cursor to use (empty by default)
  39870. */
  39871. defaultCursor: string;
  39872. /**
  39873. * Defines whether cursors are handled by the scene.
  39874. */
  39875. doNotHandleCursors: boolean;
  39876. /**
  39877. * This is used to call preventDefault() on pointer down
  39878. * in order to block unwanted artifacts like system double clicks
  39879. */
  39880. preventDefaultOnPointerDown: boolean;
  39881. /**
  39882. * This is used to call preventDefault() on pointer up
  39883. * in order to block unwanted artifacts like system double clicks
  39884. */
  39885. preventDefaultOnPointerUp: boolean;
  39886. /**
  39887. * Gets or sets user defined metadata
  39888. */
  39889. metadata: any;
  39890. /**
  39891. * For internal use only. Please do not use.
  39892. */
  39893. reservedDataStore: any;
  39894. /**
  39895. * Gets the name of the plugin used to load this scene (null by default)
  39896. */
  39897. loadingPluginName: string;
  39898. /**
  39899. * Use this array to add regular expressions used to disable offline support for specific urls
  39900. */
  39901. disableOfflineSupportExceptionRules: RegExp[];
  39902. /**
  39903. * An event triggered when the scene is disposed.
  39904. */
  39905. onDisposeObservable: Observable<Scene>;
  39906. private _onDisposeObserver;
  39907. /** Sets a function to be executed when this scene is disposed. */
  39908. set onDispose(callback: () => void);
  39909. /**
  39910. * An event triggered before rendering the scene (right after animations and physics)
  39911. */
  39912. onBeforeRenderObservable: Observable<Scene>;
  39913. private _onBeforeRenderObserver;
  39914. /** Sets a function to be executed before rendering this scene */
  39915. set beforeRender(callback: Nullable<() => void>);
  39916. /**
  39917. * An event triggered after rendering the scene
  39918. */
  39919. onAfterRenderObservable: Observable<Scene>;
  39920. /**
  39921. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39922. */
  39923. onAfterRenderCameraObservable: Observable<Camera>;
  39924. private _onAfterRenderObserver;
  39925. /** Sets a function to be executed after rendering this scene */
  39926. set afterRender(callback: Nullable<() => void>);
  39927. /**
  39928. * An event triggered before animating the scene
  39929. */
  39930. onBeforeAnimationsObservable: Observable<Scene>;
  39931. /**
  39932. * An event triggered after animations processing
  39933. */
  39934. onAfterAnimationsObservable: Observable<Scene>;
  39935. /**
  39936. * An event triggered before draw calls are ready to be sent
  39937. */
  39938. onBeforeDrawPhaseObservable: Observable<Scene>;
  39939. /**
  39940. * An event triggered after draw calls have been sent
  39941. */
  39942. onAfterDrawPhaseObservable: Observable<Scene>;
  39943. /**
  39944. * An event triggered when the scene is ready
  39945. */
  39946. onReadyObservable: Observable<Scene>;
  39947. /**
  39948. * An event triggered before rendering a camera
  39949. */
  39950. onBeforeCameraRenderObservable: Observable<Camera>;
  39951. private _onBeforeCameraRenderObserver;
  39952. /** Sets a function to be executed before rendering a camera*/
  39953. set beforeCameraRender(callback: () => void);
  39954. /**
  39955. * An event triggered after rendering a camera
  39956. */
  39957. onAfterCameraRenderObservable: Observable<Camera>;
  39958. private _onAfterCameraRenderObserver;
  39959. /** Sets a function to be executed after rendering a camera*/
  39960. set afterCameraRender(callback: () => void);
  39961. /**
  39962. * An event triggered when active meshes evaluation is about to start
  39963. */
  39964. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39965. /**
  39966. * An event triggered when active meshes evaluation is done
  39967. */
  39968. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39969. /**
  39970. * An event triggered when particles rendering is about to start
  39971. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39972. */
  39973. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39974. /**
  39975. * An event triggered when particles rendering is done
  39976. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39977. */
  39978. onAfterParticlesRenderingObservable: Observable<Scene>;
  39979. /**
  39980. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39981. */
  39982. onDataLoadedObservable: Observable<Scene>;
  39983. /**
  39984. * An event triggered when a camera is created
  39985. */
  39986. onNewCameraAddedObservable: Observable<Camera>;
  39987. /**
  39988. * An event triggered when a camera is removed
  39989. */
  39990. onCameraRemovedObservable: Observable<Camera>;
  39991. /**
  39992. * An event triggered when a light is created
  39993. */
  39994. onNewLightAddedObservable: Observable<Light>;
  39995. /**
  39996. * An event triggered when a light is removed
  39997. */
  39998. onLightRemovedObservable: Observable<Light>;
  39999. /**
  40000. * An event triggered when a geometry is created
  40001. */
  40002. onNewGeometryAddedObservable: Observable<Geometry>;
  40003. /**
  40004. * An event triggered when a geometry is removed
  40005. */
  40006. onGeometryRemovedObservable: Observable<Geometry>;
  40007. /**
  40008. * An event triggered when a transform node is created
  40009. */
  40010. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  40011. /**
  40012. * An event triggered when a transform node is removed
  40013. */
  40014. onTransformNodeRemovedObservable: Observable<TransformNode>;
  40015. /**
  40016. * An event triggered when a mesh is created
  40017. */
  40018. onNewMeshAddedObservable: Observable<AbstractMesh>;
  40019. /**
  40020. * An event triggered when a mesh is removed
  40021. */
  40022. onMeshRemovedObservable: Observable<AbstractMesh>;
  40023. /**
  40024. * An event triggered when a skeleton is created
  40025. */
  40026. onNewSkeletonAddedObservable: Observable<Skeleton>;
  40027. /**
  40028. * An event triggered when a skeleton is removed
  40029. */
  40030. onSkeletonRemovedObservable: Observable<Skeleton>;
  40031. /**
  40032. * An event triggered when a material is created
  40033. */
  40034. onNewMaterialAddedObservable: Observable<Material>;
  40035. /**
  40036. * An event triggered when a material is removed
  40037. */
  40038. onMaterialRemovedObservable: Observable<Material>;
  40039. /**
  40040. * An event triggered when a texture is created
  40041. */
  40042. onNewTextureAddedObservable: Observable<BaseTexture>;
  40043. /**
  40044. * An event triggered when a texture is removed
  40045. */
  40046. onTextureRemovedObservable: Observable<BaseTexture>;
  40047. /**
  40048. * An event triggered when render targets are about to be rendered
  40049. * Can happen multiple times per frame.
  40050. */
  40051. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  40052. /**
  40053. * An event triggered when render targets were rendered.
  40054. * Can happen multiple times per frame.
  40055. */
  40056. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  40057. /**
  40058. * An event triggered before calculating deterministic simulation step
  40059. */
  40060. onBeforeStepObservable: Observable<Scene>;
  40061. /**
  40062. * An event triggered after calculating deterministic simulation step
  40063. */
  40064. onAfterStepObservable: Observable<Scene>;
  40065. /**
  40066. * An event triggered when the activeCamera property is updated
  40067. */
  40068. onActiveCameraChanged: Observable<Scene>;
  40069. /**
  40070. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  40071. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40072. * 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)
  40073. */
  40074. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40075. /**
  40076. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  40077. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40078. * 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)
  40079. */
  40080. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40081. /**
  40082. * This Observable will when a mesh has been imported into the scene.
  40083. */
  40084. onMeshImportedObservable: Observable<AbstractMesh>;
  40085. /**
  40086. * This Observable will when an animation file has been imported into the scene.
  40087. */
  40088. onAnimationFileImportedObservable: Observable<Scene>;
  40089. /**
  40090. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  40091. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  40092. */
  40093. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  40094. /** @hidden */
  40095. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  40096. /**
  40097. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  40098. */
  40099. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  40100. /**
  40101. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  40102. */
  40103. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  40104. /**
  40105. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  40106. */
  40107. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  40108. /** Callback called when a pointer move is detected */
  40109. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40110. /** Callback called when a pointer down is detected */
  40111. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40112. /** Callback called when a pointer up is detected */
  40113. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  40114. /** Callback called when a pointer pick is detected */
  40115. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  40116. /**
  40117. * 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).
  40118. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  40119. */
  40120. onPrePointerObservable: Observable<PointerInfoPre>;
  40121. /**
  40122. * Observable event triggered each time an input event is received from the rendering canvas
  40123. */
  40124. onPointerObservable: Observable<PointerInfo>;
  40125. /**
  40126. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  40127. */
  40128. get unTranslatedPointer(): Vector2;
  40129. /**
  40130. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  40131. */
  40132. static get DragMovementThreshold(): number;
  40133. static set DragMovementThreshold(value: number);
  40134. /**
  40135. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  40136. */
  40137. static get LongPressDelay(): number;
  40138. static set LongPressDelay(value: number);
  40139. /**
  40140. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  40141. */
  40142. static get DoubleClickDelay(): number;
  40143. static set DoubleClickDelay(value: number);
  40144. /** If you need to check double click without raising a single click at first click, enable this flag */
  40145. static get ExclusiveDoubleClickMode(): boolean;
  40146. static set ExclusiveDoubleClickMode(value: boolean);
  40147. /** @hidden */
  40148. _mirroredCameraPosition: Nullable<Vector3>;
  40149. /**
  40150. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  40151. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  40152. */
  40153. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  40154. /**
  40155. * Observable event triggered each time an keyboard event is received from the hosting window
  40156. */
  40157. onKeyboardObservable: Observable<KeyboardInfo>;
  40158. private _useRightHandedSystem;
  40159. /**
  40160. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  40161. */
  40162. set useRightHandedSystem(value: boolean);
  40163. get useRightHandedSystem(): boolean;
  40164. private _timeAccumulator;
  40165. private _currentStepId;
  40166. private _currentInternalStep;
  40167. /**
  40168. * Sets the step Id used by deterministic lock step
  40169. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40170. * @param newStepId defines the step Id
  40171. */
  40172. setStepId(newStepId: number): void;
  40173. /**
  40174. * Gets the step Id used by deterministic lock step
  40175. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40176. * @returns the step Id
  40177. */
  40178. getStepId(): number;
  40179. /**
  40180. * Gets the internal step used by deterministic lock step
  40181. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40182. * @returns the internal step
  40183. */
  40184. getInternalStep(): number;
  40185. private _fogEnabled;
  40186. /**
  40187. * Gets or sets a boolean indicating if fog is enabled on this scene
  40188. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40189. * (Default is true)
  40190. */
  40191. set fogEnabled(value: boolean);
  40192. get fogEnabled(): boolean;
  40193. private _fogMode;
  40194. /**
  40195. * Gets or sets the fog mode to use
  40196. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40197. * | mode | value |
  40198. * | --- | --- |
  40199. * | FOGMODE_NONE | 0 |
  40200. * | FOGMODE_EXP | 1 |
  40201. * | FOGMODE_EXP2 | 2 |
  40202. * | FOGMODE_LINEAR | 3 |
  40203. */
  40204. set fogMode(value: number);
  40205. get fogMode(): number;
  40206. /**
  40207. * Gets or sets the fog color to use
  40208. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40209. * (Default is Color3(0.2, 0.2, 0.3))
  40210. */
  40211. fogColor: Color3;
  40212. /**
  40213. * Gets or sets the fog density to use
  40214. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40215. * (Default is 0.1)
  40216. */
  40217. fogDensity: number;
  40218. /**
  40219. * Gets or sets the fog start distance to use
  40220. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40221. * (Default is 0)
  40222. */
  40223. fogStart: number;
  40224. /**
  40225. * Gets or sets the fog end distance to use
  40226. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40227. * (Default is 1000)
  40228. */
  40229. fogEnd: number;
  40230. private _shadowsEnabled;
  40231. /**
  40232. * Gets or sets a boolean indicating if shadows are enabled on this scene
  40233. */
  40234. set shadowsEnabled(value: boolean);
  40235. get shadowsEnabled(): boolean;
  40236. private _lightsEnabled;
  40237. /**
  40238. * Gets or sets a boolean indicating if lights are enabled on this scene
  40239. */
  40240. set lightsEnabled(value: boolean);
  40241. get lightsEnabled(): boolean;
  40242. /** All of the active cameras added to this scene. */
  40243. activeCameras: Camera[];
  40244. /** @hidden */
  40245. _activeCamera: Nullable<Camera>;
  40246. /** Gets or sets the current active camera */
  40247. get activeCamera(): Nullable<Camera>;
  40248. set activeCamera(value: Nullable<Camera>);
  40249. private _defaultMaterial;
  40250. /** The default material used on meshes when no material is affected */
  40251. get defaultMaterial(): Material;
  40252. /** The default material used on meshes when no material is affected */
  40253. set defaultMaterial(value: Material);
  40254. private _texturesEnabled;
  40255. /**
  40256. * Gets or sets a boolean indicating if textures are enabled on this scene
  40257. */
  40258. set texturesEnabled(value: boolean);
  40259. get texturesEnabled(): boolean;
  40260. /**
  40261. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  40262. */
  40263. physicsEnabled: boolean;
  40264. /**
  40265. * Gets or sets a boolean indicating if particles are enabled on this scene
  40266. */
  40267. particlesEnabled: boolean;
  40268. /**
  40269. * Gets or sets a boolean indicating if sprites are enabled on this scene
  40270. */
  40271. spritesEnabled: boolean;
  40272. private _skeletonsEnabled;
  40273. /**
  40274. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  40275. */
  40276. set skeletonsEnabled(value: boolean);
  40277. get skeletonsEnabled(): boolean;
  40278. /**
  40279. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  40280. */
  40281. lensFlaresEnabled: boolean;
  40282. /**
  40283. * Gets or sets a boolean indicating if collisions are enabled on this scene
  40284. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40285. */
  40286. collisionsEnabled: boolean;
  40287. private _collisionCoordinator;
  40288. /** @hidden */
  40289. get collisionCoordinator(): ICollisionCoordinator;
  40290. /**
  40291. * Defines the gravity applied to this scene (used only for collisions)
  40292. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40293. */
  40294. gravity: Vector3;
  40295. /**
  40296. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  40297. */
  40298. postProcessesEnabled: boolean;
  40299. /**
  40300. * The list of postprocesses added to the scene
  40301. */
  40302. postProcesses: PostProcess[];
  40303. /**
  40304. * Gets the current postprocess manager
  40305. */
  40306. postProcessManager: PostProcessManager;
  40307. /**
  40308. * Gets or sets a boolean indicating if render targets are enabled on this scene
  40309. */
  40310. renderTargetsEnabled: boolean;
  40311. /**
  40312. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  40313. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40314. */
  40315. dumpNextRenderTargets: boolean;
  40316. /**
  40317. * The list of user defined render targets added to the scene
  40318. */
  40319. customRenderTargets: RenderTargetTexture[];
  40320. /**
  40321. * Defines if texture loading must be delayed
  40322. * If true, textures will only be loaded when they need to be rendered
  40323. */
  40324. useDelayedTextureLoading: boolean;
  40325. /**
  40326. * Gets the list of meshes imported to the scene through SceneLoader
  40327. */
  40328. importedMeshesFiles: String[];
  40329. /**
  40330. * Gets or sets a boolean indicating if probes are enabled on this scene
  40331. */
  40332. probesEnabled: boolean;
  40333. /**
  40334. * Gets or sets the current offline provider to use to store scene data
  40335. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40336. */
  40337. offlineProvider: IOfflineProvider;
  40338. /**
  40339. * Gets or sets the action manager associated with the scene
  40340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40341. */
  40342. actionManager: AbstractActionManager;
  40343. private _meshesForIntersections;
  40344. /**
  40345. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40346. */
  40347. proceduralTexturesEnabled: boolean;
  40348. private _engine;
  40349. private _totalVertices;
  40350. /** @hidden */
  40351. _activeIndices: PerfCounter;
  40352. /** @hidden */
  40353. _activeParticles: PerfCounter;
  40354. /** @hidden */
  40355. _activeBones: PerfCounter;
  40356. private _animationRatio;
  40357. /** @hidden */
  40358. _animationTimeLast: number;
  40359. /** @hidden */
  40360. _animationTime: number;
  40361. /**
  40362. * Gets or sets a general scale for animation speed
  40363. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40364. */
  40365. animationTimeScale: number;
  40366. /** @hidden */
  40367. _cachedMaterial: Nullable<Material>;
  40368. /** @hidden */
  40369. _cachedEffect: Nullable<Effect>;
  40370. /** @hidden */
  40371. _cachedVisibility: Nullable<number>;
  40372. private _renderId;
  40373. private _frameId;
  40374. private _executeWhenReadyTimeoutId;
  40375. private _intermediateRendering;
  40376. private _viewUpdateFlag;
  40377. private _projectionUpdateFlag;
  40378. /** @hidden */
  40379. _toBeDisposed: Nullable<IDisposable>[];
  40380. private _activeRequests;
  40381. /** @hidden */
  40382. _pendingData: any[];
  40383. private _isDisposed;
  40384. /**
  40385. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40386. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40387. */
  40388. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40389. private _activeMeshes;
  40390. private _processedMaterials;
  40391. private _renderTargets;
  40392. /** @hidden */
  40393. _activeParticleSystems: SmartArray<IParticleSystem>;
  40394. private _activeSkeletons;
  40395. private _softwareSkinnedMeshes;
  40396. private _renderingManager;
  40397. /** @hidden */
  40398. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  40399. private _transformMatrix;
  40400. private _sceneUbo;
  40401. /** @hidden */
  40402. _viewMatrix: Matrix;
  40403. private _projectionMatrix;
  40404. /** @hidden */
  40405. _forcedViewPosition: Nullable<Vector3>;
  40406. /** @hidden */
  40407. _frustumPlanes: Plane[];
  40408. /**
  40409. * Gets the list of frustum planes (built from the active camera)
  40410. */
  40411. get frustumPlanes(): Plane[];
  40412. /**
  40413. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40414. * This is useful if there are more lights that the maximum simulteanous authorized
  40415. */
  40416. requireLightSorting: boolean;
  40417. /** @hidden */
  40418. readonly useMaterialMeshMap: boolean;
  40419. /** @hidden */
  40420. readonly useClonedMeshMap: boolean;
  40421. private _externalData;
  40422. private _uid;
  40423. /**
  40424. * @hidden
  40425. * Backing store of defined scene components.
  40426. */
  40427. _components: ISceneComponent[];
  40428. /**
  40429. * @hidden
  40430. * Backing store of defined scene components.
  40431. */
  40432. _serializableComponents: ISceneSerializableComponent[];
  40433. /**
  40434. * List of components to register on the next registration step.
  40435. */
  40436. private _transientComponents;
  40437. /**
  40438. * Registers the transient components if needed.
  40439. */
  40440. private _registerTransientComponents;
  40441. /**
  40442. * @hidden
  40443. * Add a component to the scene.
  40444. * Note that the ccomponent could be registered on th next frame if this is called after
  40445. * the register component stage.
  40446. * @param component Defines the component to add to the scene
  40447. */
  40448. _addComponent(component: ISceneComponent): void;
  40449. /**
  40450. * @hidden
  40451. * Gets a component from the scene.
  40452. * @param name defines the name of the component to retrieve
  40453. * @returns the component or null if not present
  40454. */
  40455. _getComponent(name: string): Nullable<ISceneComponent>;
  40456. /**
  40457. * @hidden
  40458. * Defines the actions happening before camera updates.
  40459. */
  40460. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40461. /**
  40462. * @hidden
  40463. * Defines the actions happening before clear the canvas.
  40464. */
  40465. _beforeClearStage: Stage<SimpleStageAction>;
  40466. /**
  40467. * @hidden
  40468. * Defines the actions when collecting render targets for the frame.
  40469. */
  40470. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40471. /**
  40472. * @hidden
  40473. * Defines the actions happening for one camera in the frame.
  40474. */
  40475. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40476. /**
  40477. * @hidden
  40478. * Defines the actions happening during the per mesh ready checks.
  40479. */
  40480. _isReadyForMeshStage: Stage<MeshStageAction>;
  40481. /**
  40482. * @hidden
  40483. * Defines the actions happening before evaluate active mesh checks.
  40484. */
  40485. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40486. /**
  40487. * @hidden
  40488. * Defines the actions happening during the evaluate sub mesh checks.
  40489. */
  40490. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40491. /**
  40492. * @hidden
  40493. * Defines the actions happening during the active mesh stage.
  40494. */
  40495. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40496. /**
  40497. * @hidden
  40498. * Defines the actions happening during the per camera render target step.
  40499. */
  40500. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40501. /**
  40502. * @hidden
  40503. * Defines the actions happening just before the active camera is drawing.
  40504. */
  40505. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40506. /**
  40507. * @hidden
  40508. * Defines the actions happening just before a render target is drawing.
  40509. */
  40510. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40511. /**
  40512. * @hidden
  40513. * Defines the actions happening just before a rendering group is drawing.
  40514. */
  40515. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40516. /**
  40517. * @hidden
  40518. * Defines the actions happening just before a mesh is drawing.
  40519. */
  40520. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40521. /**
  40522. * @hidden
  40523. * Defines the actions happening just after a mesh has been drawn.
  40524. */
  40525. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40526. /**
  40527. * @hidden
  40528. * Defines the actions happening just after a rendering group has been drawn.
  40529. */
  40530. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40531. /**
  40532. * @hidden
  40533. * Defines the actions happening just after the active camera has been drawn.
  40534. */
  40535. _afterCameraDrawStage: Stage<CameraStageAction>;
  40536. /**
  40537. * @hidden
  40538. * Defines the actions happening just after a render target has been drawn.
  40539. */
  40540. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40541. /**
  40542. * @hidden
  40543. * Defines the actions happening just after rendering all cameras and computing intersections.
  40544. */
  40545. _afterRenderStage: Stage<SimpleStageAction>;
  40546. /**
  40547. * @hidden
  40548. * Defines the actions happening when a pointer move event happens.
  40549. */
  40550. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40551. /**
  40552. * @hidden
  40553. * Defines the actions happening when a pointer down event happens.
  40554. */
  40555. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40556. /**
  40557. * @hidden
  40558. * Defines the actions happening when a pointer up event happens.
  40559. */
  40560. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40561. /**
  40562. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40563. */
  40564. private geometriesByUniqueId;
  40565. /**
  40566. * Creates a new Scene
  40567. * @param engine defines the engine to use to render this scene
  40568. * @param options defines the scene options
  40569. */
  40570. constructor(engine: Engine, options?: SceneOptions);
  40571. /**
  40572. * Gets a string idenfifying the name of the class
  40573. * @returns "Scene" string
  40574. */
  40575. getClassName(): string;
  40576. private _defaultMeshCandidates;
  40577. /**
  40578. * @hidden
  40579. */
  40580. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40581. private _defaultSubMeshCandidates;
  40582. /**
  40583. * @hidden
  40584. */
  40585. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40586. /**
  40587. * Sets the default candidate providers for the scene.
  40588. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40589. * and getCollidingSubMeshCandidates to their default function
  40590. */
  40591. setDefaultCandidateProviders(): void;
  40592. /**
  40593. * Gets the mesh that is currently under the pointer
  40594. */
  40595. get meshUnderPointer(): Nullable<AbstractMesh>;
  40596. /**
  40597. * Gets or sets the current on-screen X position of the pointer
  40598. */
  40599. get pointerX(): number;
  40600. set pointerX(value: number);
  40601. /**
  40602. * Gets or sets the current on-screen Y position of the pointer
  40603. */
  40604. get pointerY(): number;
  40605. set pointerY(value: number);
  40606. /**
  40607. * Gets the cached material (ie. the latest rendered one)
  40608. * @returns the cached material
  40609. */
  40610. getCachedMaterial(): Nullable<Material>;
  40611. /**
  40612. * Gets the cached effect (ie. the latest rendered one)
  40613. * @returns the cached effect
  40614. */
  40615. getCachedEffect(): Nullable<Effect>;
  40616. /**
  40617. * Gets the cached visibility state (ie. the latest rendered one)
  40618. * @returns the cached visibility state
  40619. */
  40620. getCachedVisibility(): Nullable<number>;
  40621. /**
  40622. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40623. * @param material defines the current material
  40624. * @param effect defines the current effect
  40625. * @param visibility defines the current visibility state
  40626. * @returns true if one parameter is not cached
  40627. */
  40628. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40629. /**
  40630. * Gets the engine associated with the scene
  40631. * @returns an Engine
  40632. */
  40633. getEngine(): Engine;
  40634. /**
  40635. * Gets the total number of vertices rendered per frame
  40636. * @returns the total number of vertices rendered per frame
  40637. */
  40638. getTotalVertices(): number;
  40639. /**
  40640. * Gets the performance counter for total vertices
  40641. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40642. */
  40643. get totalVerticesPerfCounter(): PerfCounter;
  40644. /**
  40645. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40646. * @returns the total number of active indices rendered per frame
  40647. */
  40648. getActiveIndices(): number;
  40649. /**
  40650. * Gets the performance counter for active indices
  40651. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40652. */
  40653. get totalActiveIndicesPerfCounter(): PerfCounter;
  40654. /**
  40655. * Gets the total number of active particles rendered per frame
  40656. * @returns the total number of active particles rendered per frame
  40657. */
  40658. getActiveParticles(): number;
  40659. /**
  40660. * Gets the performance counter for active particles
  40661. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40662. */
  40663. get activeParticlesPerfCounter(): PerfCounter;
  40664. /**
  40665. * Gets the total number of active bones rendered per frame
  40666. * @returns the total number of active bones rendered per frame
  40667. */
  40668. getActiveBones(): number;
  40669. /**
  40670. * Gets the performance counter for active bones
  40671. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40672. */
  40673. get activeBonesPerfCounter(): PerfCounter;
  40674. /**
  40675. * Gets the array of active meshes
  40676. * @returns an array of AbstractMesh
  40677. */
  40678. getActiveMeshes(): SmartArray<AbstractMesh>;
  40679. /**
  40680. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40681. * @returns a number
  40682. */
  40683. getAnimationRatio(): number;
  40684. /**
  40685. * Gets an unique Id for the current render phase
  40686. * @returns a number
  40687. */
  40688. getRenderId(): number;
  40689. /**
  40690. * Gets an unique Id for the current frame
  40691. * @returns a number
  40692. */
  40693. getFrameId(): number;
  40694. /** Call this function if you want to manually increment the render Id*/
  40695. incrementRenderId(): void;
  40696. private _createUbo;
  40697. /**
  40698. * Use this method to simulate a pointer move on a mesh
  40699. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40700. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40701. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40702. * @returns the current scene
  40703. */
  40704. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40705. /**
  40706. * Use this method to simulate a pointer down on a mesh
  40707. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40708. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40709. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40710. * @returns the current scene
  40711. */
  40712. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40713. /**
  40714. * Use this method to simulate a pointer up on a mesh
  40715. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40716. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40717. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40718. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40719. * @returns the current scene
  40720. */
  40721. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40722. /**
  40723. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40724. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40725. * @returns true if the pointer was captured
  40726. */
  40727. isPointerCaptured(pointerId?: number): boolean;
  40728. /**
  40729. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40730. * @param attachUp defines if you want to attach events to pointerup
  40731. * @param attachDown defines if you want to attach events to pointerdown
  40732. * @param attachMove defines if you want to attach events to pointermove
  40733. */
  40734. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40735. /** Detaches all event handlers*/
  40736. detachControl(): void;
  40737. /**
  40738. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40739. * Delay loaded resources are not taking in account
  40740. * @return true if all required resources are ready
  40741. */
  40742. isReady(): boolean;
  40743. /** Resets all cached information relative to material (including effect and visibility) */
  40744. resetCachedMaterial(): void;
  40745. /**
  40746. * Registers a function to be called before every frame render
  40747. * @param func defines the function to register
  40748. */
  40749. registerBeforeRender(func: () => void): void;
  40750. /**
  40751. * Unregisters a function called before every frame render
  40752. * @param func defines the function to unregister
  40753. */
  40754. unregisterBeforeRender(func: () => void): void;
  40755. /**
  40756. * Registers a function to be called after every frame render
  40757. * @param func defines the function to register
  40758. */
  40759. registerAfterRender(func: () => void): void;
  40760. /**
  40761. * Unregisters a function called after every frame render
  40762. * @param func defines the function to unregister
  40763. */
  40764. unregisterAfterRender(func: () => void): void;
  40765. private _executeOnceBeforeRender;
  40766. /**
  40767. * The provided function will run before render once and will be disposed afterwards.
  40768. * A timeout delay can be provided so that the function will be executed in N ms.
  40769. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40770. * @param func The function to be executed.
  40771. * @param timeout optional delay in ms
  40772. */
  40773. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40774. /** @hidden */
  40775. _addPendingData(data: any): void;
  40776. /** @hidden */
  40777. _removePendingData(data: any): void;
  40778. /**
  40779. * Returns the number of items waiting to be loaded
  40780. * @returns the number of items waiting to be loaded
  40781. */
  40782. getWaitingItemsCount(): number;
  40783. /**
  40784. * Returns a boolean indicating if the scene is still loading data
  40785. */
  40786. get isLoading(): boolean;
  40787. /**
  40788. * Registers a function to be executed when the scene is ready
  40789. * @param {Function} func - the function to be executed
  40790. */
  40791. executeWhenReady(func: () => void): void;
  40792. /**
  40793. * Returns a promise that resolves when the scene is ready
  40794. * @returns A promise that resolves when the scene is ready
  40795. */
  40796. whenReadyAsync(): Promise<void>;
  40797. /** @hidden */
  40798. _checkIsReady(): void;
  40799. /**
  40800. * Gets all animatable attached to the scene
  40801. */
  40802. get animatables(): Animatable[];
  40803. /**
  40804. * Resets the last animation time frame.
  40805. * Useful to override when animations start running when loading a scene for the first time.
  40806. */
  40807. resetLastAnimationTimeFrame(): void;
  40808. /**
  40809. * Gets the current view matrix
  40810. * @returns a Matrix
  40811. */
  40812. getViewMatrix(): Matrix;
  40813. /**
  40814. * Gets the current projection matrix
  40815. * @returns a Matrix
  40816. */
  40817. getProjectionMatrix(): Matrix;
  40818. /**
  40819. * Gets the current transform matrix
  40820. * @returns a Matrix made of View * Projection
  40821. */
  40822. getTransformMatrix(): Matrix;
  40823. /**
  40824. * Sets the current transform matrix
  40825. * @param viewL defines the View matrix to use
  40826. * @param projectionL defines the Projection matrix to use
  40827. * @param viewR defines the right View matrix to use (if provided)
  40828. * @param projectionR defines the right Projection matrix to use (if provided)
  40829. */
  40830. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40831. /**
  40832. * Gets the uniform buffer used to store scene data
  40833. * @returns a UniformBuffer
  40834. */
  40835. getSceneUniformBuffer(): UniformBuffer;
  40836. /**
  40837. * Gets an unique (relatively to the current scene) Id
  40838. * @returns an unique number for the scene
  40839. */
  40840. getUniqueId(): number;
  40841. /**
  40842. * Add a mesh to the list of scene's meshes
  40843. * @param newMesh defines the mesh to add
  40844. * @param recursive if all child meshes should also be added to the scene
  40845. */
  40846. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40847. /**
  40848. * Remove a mesh for the list of scene's meshes
  40849. * @param toRemove defines the mesh to remove
  40850. * @param recursive if all child meshes should also be removed from the scene
  40851. * @returns the index where the mesh was in the mesh list
  40852. */
  40853. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40854. /**
  40855. * Add a transform node to the list of scene's transform nodes
  40856. * @param newTransformNode defines the transform node to add
  40857. */
  40858. addTransformNode(newTransformNode: TransformNode): void;
  40859. /**
  40860. * Remove a transform node for the list of scene's transform nodes
  40861. * @param toRemove defines the transform node to remove
  40862. * @returns the index where the transform node was in the transform node list
  40863. */
  40864. removeTransformNode(toRemove: TransformNode): number;
  40865. /**
  40866. * Remove a skeleton for the list of scene's skeletons
  40867. * @param toRemove defines the skeleton to remove
  40868. * @returns the index where the skeleton was in the skeleton list
  40869. */
  40870. removeSkeleton(toRemove: Skeleton): number;
  40871. /**
  40872. * Remove a morph target for the list of scene's morph targets
  40873. * @param toRemove defines the morph target to remove
  40874. * @returns the index where the morph target was in the morph target list
  40875. */
  40876. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40877. /**
  40878. * Remove a light for the list of scene's lights
  40879. * @param toRemove defines the light to remove
  40880. * @returns the index where the light was in the light list
  40881. */
  40882. removeLight(toRemove: Light): number;
  40883. /**
  40884. * Remove a camera for the list of scene's cameras
  40885. * @param toRemove defines the camera to remove
  40886. * @returns the index where the camera was in the camera list
  40887. */
  40888. removeCamera(toRemove: Camera): number;
  40889. /**
  40890. * Remove a particle system for the list of scene's particle systems
  40891. * @param toRemove defines the particle system to remove
  40892. * @returns the index where the particle system was in the particle system list
  40893. */
  40894. removeParticleSystem(toRemove: IParticleSystem): number;
  40895. /**
  40896. * Remove a animation for the list of scene's animations
  40897. * @param toRemove defines the animation to remove
  40898. * @returns the index where the animation was in the animation list
  40899. */
  40900. removeAnimation(toRemove: Animation): number;
  40901. /**
  40902. * Will stop the animation of the given target
  40903. * @param target - the target
  40904. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40905. * @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)
  40906. */
  40907. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40908. /**
  40909. * Removes the given animation group from this scene.
  40910. * @param toRemove The animation group to remove
  40911. * @returns The index of the removed animation group
  40912. */
  40913. removeAnimationGroup(toRemove: AnimationGroup): number;
  40914. /**
  40915. * Removes the given multi-material from this scene.
  40916. * @param toRemove The multi-material to remove
  40917. * @returns The index of the removed multi-material
  40918. */
  40919. removeMultiMaterial(toRemove: MultiMaterial): number;
  40920. /**
  40921. * Removes the given material from this scene.
  40922. * @param toRemove The material to remove
  40923. * @returns The index of the removed material
  40924. */
  40925. removeMaterial(toRemove: Material): number;
  40926. /**
  40927. * Removes the given action manager from this scene.
  40928. * @param toRemove The action manager to remove
  40929. * @returns The index of the removed action manager
  40930. */
  40931. removeActionManager(toRemove: AbstractActionManager): number;
  40932. /**
  40933. * Removes the given texture from this scene.
  40934. * @param toRemove The texture to remove
  40935. * @returns The index of the removed texture
  40936. */
  40937. removeTexture(toRemove: BaseTexture): number;
  40938. /**
  40939. * Adds the given light to this scene
  40940. * @param newLight The light to add
  40941. */
  40942. addLight(newLight: Light): void;
  40943. /**
  40944. * Sorts the list list based on light priorities
  40945. */
  40946. sortLightsByPriority(): void;
  40947. /**
  40948. * Adds the given camera to this scene
  40949. * @param newCamera The camera to add
  40950. */
  40951. addCamera(newCamera: Camera): void;
  40952. /**
  40953. * Adds the given skeleton to this scene
  40954. * @param newSkeleton The skeleton to add
  40955. */
  40956. addSkeleton(newSkeleton: Skeleton): void;
  40957. /**
  40958. * Adds the given particle system to this scene
  40959. * @param newParticleSystem The particle system to add
  40960. */
  40961. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40962. /**
  40963. * Adds the given animation to this scene
  40964. * @param newAnimation The animation to add
  40965. */
  40966. addAnimation(newAnimation: Animation): void;
  40967. /**
  40968. * Adds the given animation group to this scene.
  40969. * @param newAnimationGroup The animation group to add
  40970. */
  40971. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40972. /**
  40973. * Adds the given multi-material to this scene
  40974. * @param newMultiMaterial The multi-material to add
  40975. */
  40976. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40977. /**
  40978. * Adds the given material to this scene
  40979. * @param newMaterial The material to add
  40980. */
  40981. addMaterial(newMaterial: Material): void;
  40982. /**
  40983. * Adds the given morph target to this scene
  40984. * @param newMorphTargetManager The morph target to add
  40985. */
  40986. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40987. /**
  40988. * Adds the given geometry to this scene
  40989. * @param newGeometry The geometry to add
  40990. */
  40991. addGeometry(newGeometry: Geometry): void;
  40992. /**
  40993. * Adds the given action manager to this scene
  40994. * @param newActionManager The action manager to add
  40995. */
  40996. addActionManager(newActionManager: AbstractActionManager): void;
  40997. /**
  40998. * Adds the given texture to this scene.
  40999. * @param newTexture The texture to add
  41000. */
  41001. addTexture(newTexture: BaseTexture): void;
  41002. /**
  41003. * Switch active camera
  41004. * @param newCamera defines the new active camera
  41005. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  41006. */
  41007. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  41008. /**
  41009. * sets the active camera of the scene using its ID
  41010. * @param id defines the camera's ID
  41011. * @return the new active camera or null if none found.
  41012. */
  41013. setActiveCameraByID(id: string): Nullable<Camera>;
  41014. /**
  41015. * sets the active camera of the scene using its name
  41016. * @param name defines the camera's name
  41017. * @returns the new active camera or null if none found.
  41018. */
  41019. setActiveCameraByName(name: string): Nullable<Camera>;
  41020. /**
  41021. * get an animation group using its name
  41022. * @param name defines the material's name
  41023. * @return the animation group or null if none found.
  41024. */
  41025. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  41026. /**
  41027. * Get a material using its unique id
  41028. * @param uniqueId defines the material's unique id
  41029. * @return the material or null if none found.
  41030. */
  41031. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  41032. /**
  41033. * get a material using its id
  41034. * @param id defines the material's ID
  41035. * @return the material or null if none found.
  41036. */
  41037. getMaterialByID(id: string): Nullable<Material>;
  41038. /**
  41039. * Gets a the last added material using a given id
  41040. * @param id defines the material's ID
  41041. * @return the last material with the given id or null if none found.
  41042. */
  41043. getLastMaterialByID(id: string): Nullable<Material>;
  41044. /**
  41045. * Gets a material using its name
  41046. * @param name defines the material's name
  41047. * @return the material or null if none found.
  41048. */
  41049. getMaterialByName(name: string): Nullable<Material>;
  41050. /**
  41051. * Get a texture using its unique id
  41052. * @param uniqueId defines the texture's unique id
  41053. * @return the texture or null if none found.
  41054. */
  41055. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  41056. /**
  41057. * Gets a camera using its id
  41058. * @param id defines the id to look for
  41059. * @returns the camera or null if not found
  41060. */
  41061. getCameraByID(id: string): Nullable<Camera>;
  41062. /**
  41063. * Gets a camera using its unique id
  41064. * @param uniqueId defines the unique id to look for
  41065. * @returns the camera or null if not found
  41066. */
  41067. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  41068. /**
  41069. * Gets a camera using its name
  41070. * @param name defines the camera's name
  41071. * @return the camera or null if none found.
  41072. */
  41073. getCameraByName(name: string): Nullable<Camera>;
  41074. /**
  41075. * Gets a bone using its id
  41076. * @param id defines the bone's id
  41077. * @return the bone or null if not found
  41078. */
  41079. getBoneByID(id: string): Nullable<Bone>;
  41080. /**
  41081. * Gets a bone using its id
  41082. * @param name defines the bone's name
  41083. * @return the bone or null if not found
  41084. */
  41085. getBoneByName(name: string): Nullable<Bone>;
  41086. /**
  41087. * Gets a light node using its name
  41088. * @param name defines the the light's name
  41089. * @return the light or null if none found.
  41090. */
  41091. getLightByName(name: string): Nullable<Light>;
  41092. /**
  41093. * Gets a light node using its id
  41094. * @param id defines the light's id
  41095. * @return the light or null if none found.
  41096. */
  41097. getLightByID(id: string): Nullable<Light>;
  41098. /**
  41099. * Gets a light node using its scene-generated unique ID
  41100. * @param uniqueId defines the light's unique id
  41101. * @return the light or null if none found.
  41102. */
  41103. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  41104. /**
  41105. * Gets a particle system by id
  41106. * @param id defines the particle system id
  41107. * @return the corresponding system or null if none found
  41108. */
  41109. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  41110. /**
  41111. * Gets a geometry using its ID
  41112. * @param id defines the geometry's id
  41113. * @return the geometry or null if none found.
  41114. */
  41115. getGeometryByID(id: string): Nullable<Geometry>;
  41116. private _getGeometryByUniqueID;
  41117. /**
  41118. * Add a new geometry to this scene
  41119. * @param geometry defines the geometry to be added to the scene.
  41120. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  41121. * @return a boolean defining if the geometry was added or not
  41122. */
  41123. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  41124. /**
  41125. * Removes an existing geometry
  41126. * @param geometry defines the geometry to be removed from the scene
  41127. * @return a boolean defining if the geometry was removed or not
  41128. */
  41129. removeGeometry(geometry: Geometry): boolean;
  41130. /**
  41131. * Gets the list of geometries attached to the scene
  41132. * @returns an array of Geometry
  41133. */
  41134. getGeometries(): Geometry[];
  41135. /**
  41136. * Gets the first added mesh found of a given ID
  41137. * @param id defines the id to search for
  41138. * @return the mesh found or null if not found at all
  41139. */
  41140. getMeshByID(id: string): Nullable<AbstractMesh>;
  41141. /**
  41142. * Gets a list of meshes using their id
  41143. * @param id defines the id to search for
  41144. * @returns a list of meshes
  41145. */
  41146. getMeshesByID(id: string): Array<AbstractMesh>;
  41147. /**
  41148. * Gets the first added transform node found of a given ID
  41149. * @param id defines the id to search for
  41150. * @return the found transform node or null if not found at all.
  41151. */
  41152. getTransformNodeByID(id: string): Nullable<TransformNode>;
  41153. /**
  41154. * Gets a transform node with its auto-generated unique id
  41155. * @param uniqueId efines the unique id to search for
  41156. * @return the found transform node or null if not found at all.
  41157. */
  41158. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  41159. /**
  41160. * Gets a list of transform nodes using their id
  41161. * @param id defines the id to search for
  41162. * @returns a list of transform nodes
  41163. */
  41164. getTransformNodesByID(id: string): Array<TransformNode>;
  41165. /**
  41166. * Gets a mesh with its auto-generated unique id
  41167. * @param uniqueId defines the unique id to search for
  41168. * @return the found mesh or null if not found at all.
  41169. */
  41170. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  41171. /**
  41172. * Gets a the last added mesh using a given id
  41173. * @param id defines the id to search for
  41174. * @return the found mesh or null if not found at all.
  41175. */
  41176. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  41177. /**
  41178. * Gets a the last added node (Mesh, Camera, Light) using a given id
  41179. * @param id defines the id to search for
  41180. * @return the found node or null if not found at all
  41181. */
  41182. getLastEntryByID(id: string): Nullable<Node>;
  41183. /**
  41184. * Gets a node (Mesh, Camera, Light) using a given id
  41185. * @param id defines the id to search for
  41186. * @return the found node or null if not found at all
  41187. */
  41188. getNodeByID(id: string): Nullable<Node>;
  41189. /**
  41190. * Gets a node (Mesh, Camera, Light) using a given name
  41191. * @param name defines the name to search for
  41192. * @return the found node or null if not found at all.
  41193. */
  41194. getNodeByName(name: string): Nullable<Node>;
  41195. /**
  41196. * Gets a mesh using a given name
  41197. * @param name defines the name to search for
  41198. * @return the found mesh or null if not found at all.
  41199. */
  41200. getMeshByName(name: string): Nullable<AbstractMesh>;
  41201. /**
  41202. * Gets a transform node using a given name
  41203. * @param name defines the name to search for
  41204. * @return the found transform node or null if not found at all.
  41205. */
  41206. getTransformNodeByName(name: string): Nullable<TransformNode>;
  41207. /**
  41208. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  41209. * @param id defines the id to search for
  41210. * @return the found skeleton or null if not found at all.
  41211. */
  41212. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  41213. /**
  41214. * Gets a skeleton using a given auto generated unique id
  41215. * @param uniqueId defines the unique id to search for
  41216. * @return the found skeleton or null if not found at all.
  41217. */
  41218. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  41219. /**
  41220. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  41221. * @param id defines the id to search for
  41222. * @return the found skeleton or null if not found at all.
  41223. */
  41224. getSkeletonById(id: string): Nullable<Skeleton>;
  41225. /**
  41226. * Gets a skeleton using a given name
  41227. * @param name defines the name to search for
  41228. * @return the found skeleton or null if not found at all.
  41229. */
  41230. getSkeletonByName(name: string): Nullable<Skeleton>;
  41231. /**
  41232. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  41233. * @param id defines the id to search for
  41234. * @return the found morph target manager or null if not found at all.
  41235. */
  41236. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  41237. /**
  41238. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  41239. * @param id defines the id to search for
  41240. * @return the found morph target or null if not found at all.
  41241. */
  41242. getMorphTargetById(id: string): Nullable<MorphTarget>;
  41243. /**
  41244. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  41245. * @param name defines the name to search for
  41246. * @return the found morph target or null if not found at all.
  41247. */
  41248. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  41249. /**
  41250. * Gets a boolean indicating if the given mesh is active
  41251. * @param mesh defines the mesh to look for
  41252. * @returns true if the mesh is in the active list
  41253. */
  41254. isActiveMesh(mesh: AbstractMesh): boolean;
  41255. /**
  41256. * Return a unique id as a string which can serve as an identifier for the scene
  41257. */
  41258. get uid(): string;
  41259. /**
  41260. * Add an externaly attached data from its key.
  41261. * This method call will fail and return false, if such key already exists.
  41262. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  41263. * @param key the unique key that identifies the data
  41264. * @param data the data object to associate to the key for this Engine instance
  41265. * @return true if no such key were already present and the data was added successfully, false otherwise
  41266. */
  41267. addExternalData<T>(key: string, data: T): boolean;
  41268. /**
  41269. * Get an externaly attached data from its key
  41270. * @param key the unique key that identifies the data
  41271. * @return the associated data, if present (can be null), or undefined if not present
  41272. */
  41273. getExternalData<T>(key: string): Nullable<T>;
  41274. /**
  41275. * Get an externaly attached data from its key, create it using a factory if it's not already present
  41276. * @param key the unique key that identifies the data
  41277. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  41278. * @return the associated data, can be null if the factory returned null.
  41279. */
  41280. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  41281. /**
  41282. * Remove an externaly attached data from the Engine instance
  41283. * @param key the unique key that identifies the data
  41284. * @return true if the data was successfully removed, false if it doesn't exist
  41285. */
  41286. removeExternalData(key: string): boolean;
  41287. private _evaluateSubMesh;
  41288. /**
  41289. * Clear the processed materials smart array preventing retention point in material dispose.
  41290. */
  41291. freeProcessedMaterials(): void;
  41292. private _preventFreeActiveMeshesAndRenderingGroups;
  41293. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  41294. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  41295. * when disposing several meshes in a row or a hierarchy of meshes.
  41296. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  41297. */
  41298. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  41299. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  41300. /**
  41301. * Clear the active meshes smart array preventing retention point in mesh dispose.
  41302. */
  41303. freeActiveMeshes(): void;
  41304. /**
  41305. * Clear the info related to rendering groups preventing retention points during dispose.
  41306. */
  41307. freeRenderingGroups(): void;
  41308. /** @hidden */
  41309. _isInIntermediateRendering(): boolean;
  41310. /**
  41311. * Lambda returning the list of potentially active meshes.
  41312. */
  41313. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41314. /**
  41315. * Lambda returning the list of potentially active sub meshes.
  41316. */
  41317. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41318. /**
  41319. * Lambda returning the list of potentially intersecting sub meshes.
  41320. */
  41321. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41322. /**
  41323. * Lambda returning the list of potentially colliding sub meshes.
  41324. */
  41325. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41326. private _activeMeshesFrozen;
  41327. private _skipEvaluateActiveMeshesCompletely;
  41328. /**
  41329. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41330. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41331. * @returns the current scene
  41332. */
  41333. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41334. /**
  41335. * Use this function to restart evaluating active meshes on every frame
  41336. * @returns the current scene
  41337. */
  41338. unfreezeActiveMeshes(): Scene;
  41339. private _evaluateActiveMeshes;
  41340. private _activeMesh;
  41341. /**
  41342. * Update the transform matrix to update from the current active camera
  41343. * @param force defines a boolean used to force the update even if cache is up to date
  41344. */
  41345. updateTransformMatrix(force?: boolean): void;
  41346. private _bindFrameBuffer;
  41347. /** @hidden */
  41348. _allowPostProcessClearColor: boolean;
  41349. /** @hidden */
  41350. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41351. private _processSubCameras;
  41352. private _checkIntersections;
  41353. /** @hidden */
  41354. _advancePhysicsEngineStep(step: number): void;
  41355. /**
  41356. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41357. */
  41358. getDeterministicFrameTime: () => number;
  41359. /** @hidden */
  41360. _animate(): void;
  41361. /** Execute all animations (for a frame) */
  41362. animate(): void;
  41363. /**
  41364. * Render the scene
  41365. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41366. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41367. */
  41368. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41369. /**
  41370. * Freeze all materials
  41371. * A frozen material will not be updatable but should be faster to render
  41372. */
  41373. freezeMaterials(): void;
  41374. /**
  41375. * Unfreeze all materials
  41376. * A frozen material will not be updatable but should be faster to render
  41377. */
  41378. unfreezeMaterials(): void;
  41379. /**
  41380. * Releases all held ressources
  41381. */
  41382. dispose(): void;
  41383. /**
  41384. * Gets if the scene is already disposed
  41385. */
  41386. get isDisposed(): boolean;
  41387. /**
  41388. * Call this function to reduce memory footprint of the scene.
  41389. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41390. */
  41391. clearCachedVertexData(): void;
  41392. /**
  41393. * This function will remove the local cached buffer data from texture.
  41394. * It will save memory but will prevent the texture from being rebuilt
  41395. */
  41396. cleanCachedTextureBuffer(): void;
  41397. /**
  41398. * Get the world extend vectors with an optional filter
  41399. *
  41400. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41401. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41402. */
  41403. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41404. min: Vector3;
  41405. max: Vector3;
  41406. };
  41407. /**
  41408. * Creates a ray that can be used to pick in the scene
  41409. * @param x defines the x coordinate of the origin (on-screen)
  41410. * @param y defines the y coordinate of the origin (on-screen)
  41411. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41412. * @param camera defines the camera to use for the picking
  41413. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41414. * @returns a Ray
  41415. */
  41416. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41417. /**
  41418. * Creates a ray that can be used to pick in the scene
  41419. * @param x defines the x coordinate of the origin (on-screen)
  41420. * @param y defines the y coordinate of the origin (on-screen)
  41421. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41422. * @param result defines the ray where to store the picking ray
  41423. * @param camera defines the camera to use for the picking
  41424. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41425. * @returns the current scene
  41426. */
  41427. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41428. /**
  41429. * Creates a ray that can be used to pick in the scene
  41430. * @param x defines the x coordinate of the origin (on-screen)
  41431. * @param y defines the y coordinate of the origin (on-screen)
  41432. * @param camera defines the camera to use for the picking
  41433. * @returns a Ray
  41434. */
  41435. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41436. /**
  41437. * Creates a ray that can be used to pick in the scene
  41438. * @param x defines the x coordinate of the origin (on-screen)
  41439. * @param y defines the y coordinate of the origin (on-screen)
  41440. * @param result defines the ray where to store the picking ray
  41441. * @param camera defines the camera to use for the picking
  41442. * @returns the current scene
  41443. */
  41444. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41445. /** Launch a ray to try to pick a mesh in the scene
  41446. * @param x position on screen
  41447. * @param y position on screen
  41448. * @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
  41449. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41450. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41451. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41452. * @returns a PickingInfo
  41453. */
  41454. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41455. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41456. * @param x position on screen
  41457. * @param y position on screen
  41458. * @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
  41459. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41460. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41461. * @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)
  41462. */
  41463. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41464. /** Use the given ray to pick a mesh in the scene
  41465. * @param ray The ray to use to pick meshes
  41466. * @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
  41467. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41468. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41469. * @returns a PickingInfo
  41470. */
  41471. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41472. /**
  41473. * Launch a ray to try to pick a mesh in the scene
  41474. * @param x X position on screen
  41475. * @param y Y position on screen
  41476. * @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
  41477. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41478. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41479. * @returns an array of PickingInfo
  41480. */
  41481. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41482. /**
  41483. * Launch a ray to try to pick a mesh in the scene
  41484. * @param ray Ray to use
  41485. * @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
  41486. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41487. * @returns an array of PickingInfo
  41488. */
  41489. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41490. /**
  41491. * Force the value of meshUnderPointer
  41492. * @param mesh defines the mesh to use
  41493. */
  41494. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  41495. /**
  41496. * Gets the mesh under the pointer
  41497. * @returns a Mesh or null if no mesh is under the pointer
  41498. */
  41499. getPointerOverMesh(): Nullable<AbstractMesh>;
  41500. /** @hidden */
  41501. _rebuildGeometries(): void;
  41502. /** @hidden */
  41503. _rebuildTextures(): void;
  41504. private _getByTags;
  41505. /**
  41506. * Get a list of meshes by tags
  41507. * @param tagsQuery defines the tags query to use
  41508. * @param forEach defines a predicate used to filter results
  41509. * @returns an array of Mesh
  41510. */
  41511. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41512. /**
  41513. * Get a list of cameras by tags
  41514. * @param tagsQuery defines the tags query to use
  41515. * @param forEach defines a predicate used to filter results
  41516. * @returns an array of Camera
  41517. */
  41518. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41519. /**
  41520. * Get a list of lights by tags
  41521. * @param tagsQuery defines the tags query to use
  41522. * @param forEach defines a predicate used to filter results
  41523. * @returns an array of Light
  41524. */
  41525. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41526. /**
  41527. * Get a list of materials by tags
  41528. * @param tagsQuery defines the tags query to use
  41529. * @param forEach defines a predicate used to filter results
  41530. * @returns an array of Material
  41531. */
  41532. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41533. /**
  41534. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41535. * This allowed control for front to back rendering or reversly depending of the special needs.
  41536. *
  41537. * @param renderingGroupId The rendering group id corresponding to its index
  41538. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41539. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41540. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41541. */
  41542. 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;
  41543. /**
  41544. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41545. *
  41546. * @param renderingGroupId The rendering group id corresponding to its index
  41547. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41548. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41549. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41550. */
  41551. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41552. /**
  41553. * Gets the current auto clear configuration for one rendering group of the rendering
  41554. * manager.
  41555. * @param index the rendering group index to get the information for
  41556. * @returns The auto clear setup for the requested rendering group
  41557. */
  41558. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41559. private _blockMaterialDirtyMechanism;
  41560. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41561. get blockMaterialDirtyMechanism(): boolean;
  41562. set blockMaterialDirtyMechanism(value: boolean);
  41563. /**
  41564. * Will flag all materials as dirty to trigger new shader compilation
  41565. * @param flag defines the flag used to specify which material part must be marked as dirty
  41566. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41567. */
  41568. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41569. /** @hidden */
  41570. _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;
  41571. /** @hidden */
  41572. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41573. /** @hidden */
  41574. _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;
  41575. /** @hidden */
  41576. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41577. /** @hidden */
  41578. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41579. /** @hidden */
  41580. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41581. }
  41582. }
  41583. declare module "babylonjs/assetContainer" {
  41584. import { AbstractScene } from "babylonjs/abstractScene";
  41585. import { Scene } from "babylonjs/scene";
  41586. import { Mesh } from "babylonjs/Meshes/mesh";
  41587. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41588. import { Skeleton } from "babylonjs/Bones/skeleton";
  41589. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41590. import { Animatable } from "babylonjs/Animations/animatable";
  41591. import { Nullable } from "babylonjs/types";
  41592. import { Node } from "babylonjs/node";
  41593. /**
  41594. * Set of assets to keep when moving a scene into an asset container.
  41595. */
  41596. export class KeepAssets extends AbstractScene {
  41597. }
  41598. /**
  41599. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41600. */
  41601. export class InstantiatedEntries {
  41602. /**
  41603. * List of new root nodes (eg. nodes with no parent)
  41604. */
  41605. rootNodes: TransformNode[];
  41606. /**
  41607. * List of new skeletons
  41608. */
  41609. skeletons: Skeleton[];
  41610. /**
  41611. * List of new animation groups
  41612. */
  41613. animationGroups: AnimationGroup[];
  41614. }
  41615. /**
  41616. * Container with a set of assets that can be added or removed from a scene.
  41617. */
  41618. export class AssetContainer extends AbstractScene {
  41619. private _wasAddedToScene;
  41620. /**
  41621. * The scene the AssetContainer belongs to.
  41622. */
  41623. scene: Scene;
  41624. /**
  41625. * Instantiates an AssetContainer.
  41626. * @param scene The scene the AssetContainer belongs to.
  41627. */
  41628. constructor(scene: Scene);
  41629. /**
  41630. * Instantiate or clone all meshes and add the new ones to the scene.
  41631. * Skeletons and animation groups will all be cloned
  41632. * @param nameFunction defines an optional function used to get new names for clones
  41633. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41634. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41635. */
  41636. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41637. /**
  41638. * Adds all the assets from the container to the scene.
  41639. */
  41640. addAllToScene(): void;
  41641. /**
  41642. * Removes all the assets in the container from the scene
  41643. */
  41644. removeAllFromScene(): void;
  41645. /**
  41646. * Disposes all the assets in the container
  41647. */
  41648. dispose(): void;
  41649. private _moveAssets;
  41650. /**
  41651. * Removes all the assets contained in the scene and adds them to the container.
  41652. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41653. */
  41654. moveAllFromScene(keepAssets?: KeepAssets): void;
  41655. /**
  41656. * 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.
  41657. * @returns the root mesh
  41658. */
  41659. createRootMesh(): Mesh;
  41660. /**
  41661. * Merge animations (direct and animation groups) from this asset container into a scene
  41662. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41663. * @param animatables set of animatables to retarget to a node from the scene
  41664. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41665. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41666. */
  41667. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41668. }
  41669. }
  41670. declare module "babylonjs/abstractScene" {
  41671. import { Scene } from "babylonjs/scene";
  41672. import { Nullable } from "babylonjs/types";
  41673. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41674. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41675. import { Geometry } from "babylonjs/Meshes/geometry";
  41676. import { Skeleton } from "babylonjs/Bones/skeleton";
  41677. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  41678. import { AssetContainer } from "babylonjs/assetContainer";
  41679. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41680. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41681. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41682. import { Material } from "babylonjs/Materials/material";
  41683. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  41684. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  41685. import { Camera } from "babylonjs/Cameras/camera";
  41686. import { Light } from "babylonjs/Lights/light";
  41687. import { Node } from "babylonjs/node";
  41688. import { Animation } from "babylonjs/Animations/animation";
  41689. /**
  41690. * Defines how the parser contract is defined.
  41691. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41692. */
  41693. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41694. /**
  41695. * Defines how the individual parser contract is defined.
  41696. * These parser can parse an individual asset
  41697. */
  41698. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41699. /**
  41700. * Base class of the scene acting as a container for the different elements composing a scene.
  41701. * This class is dynamically extended by the different components of the scene increasing
  41702. * flexibility and reducing coupling
  41703. */
  41704. export abstract class AbstractScene {
  41705. /**
  41706. * Stores the list of available parsers in the application.
  41707. */
  41708. private static _BabylonFileParsers;
  41709. /**
  41710. * Stores the list of available individual parsers in the application.
  41711. */
  41712. private static _IndividualBabylonFileParsers;
  41713. /**
  41714. * Adds a parser in the list of available ones
  41715. * @param name Defines the name of the parser
  41716. * @param parser Defines the parser to add
  41717. */
  41718. static AddParser(name: string, parser: BabylonFileParser): void;
  41719. /**
  41720. * Gets a general parser from the list of avaialble ones
  41721. * @param name Defines the name of the parser
  41722. * @returns the requested parser or null
  41723. */
  41724. static GetParser(name: string): Nullable<BabylonFileParser>;
  41725. /**
  41726. * Adds n individual parser in the list of available ones
  41727. * @param name Defines the name of the parser
  41728. * @param parser Defines the parser to add
  41729. */
  41730. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41731. /**
  41732. * Gets an individual parser from the list of avaialble ones
  41733. * @param name Defines the name of the parser
  41734. * @returns the requested parser or null
  41735. */
  41736. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41737. /**
  41738. * Parser json data and populate both a scene and its associated container object
  41739. * @param jsonData Defines the data to parse
  41740. * @param scene Defines the scene to parse the data for
  41741. * @param container Defines the container attached to the parsing sequence
  41742. * @param rootUrl Defines the root url of the data
  41743. */
  41744. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41745. /**
  41746. * Gets the list of root nodes (ie. nodes with no parent)
  41747. */
  41748. rootNodes: Node[];
  41749. /** All of the cameras added to this scene
  41750. * @see http://doc.babylonjs.com/babylon101/cameras
  41751. */
  41752. cameras: Camera[];
  41753. /**
  41754. * All of the lights added to this scene
  41755. * @see http://doc.babylonjs.com/babylon101/lights
  41756. */
  41757. lights: Light[];
  41758. /**
  41759. * All of the (abstract) meshes added to this scene
  41760. */
  41761. meshes: AbstractMesh[];
  41762. /**
  41763. * The list of skeletons added to the scene
  41764. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41765. */
  41766. skeletons: Skeleton[];
  41767. /**
  41768. * All of the particle systems added to this scene
  41769. * @see http://doc.babylonjs.com/babylon101/particles
  41770. */
  41771. particleSystems: IParticleSystem[];
  41772. /**
  41773. * Gets a list of Animations associated with the scene
  41774. */
  41775. animations: Animation[];
  41776. /**
  41777. * All of the animation groups added to this scene
  41778. * @see http://doc.babylonjs.com/how_to/group
  41779. */
  41780. animationGroups: AnimationGroup[];
  41781. /**
  41782. * All of the multi-materials added to this scene
  41783. * @see http://doc.babylonjs.com/how_to/multi_materials
  41784. */
  41785. multiMaterials: MultiMaterial[];
  41786. /**
  41787. * All of the materials added to this scene
  41788. * In the context of a Scene, it is not supposed to be modified manually.
  41789. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41790. * Note also that the order of the Material within the array is not significant and might change.
  41791. * @see http://doc.babylonjs.com/babylon101/materials
  41792. */
  41793. materials: Material[];
  41794. /**
  41795. * The list of morph target managers added to the scene
  41796. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41797. */
  41798. morphTargetManagers: MorphTargetManager[];
  41799. /**
  41800. * The list of geometries used in the scene.
  41801. */
  41802. geometries: Geometry[];
  41803. /**
  41804. * All of the tranform nodes added to this scene
  41805. * In the context of a Scene, it is not supposed to be modified manually.
  41806. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41807. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41808. * @see http://doc.babylonjs.com/how_to/transformnode
  41809. */
  41810. transformNodes: TransformNode[];
  41811. /**
  41812. * ActionManagers available on the scene.
  41813. */
  41814. actionManagers: AbstractActionManager[];
  41815. /**
  41816. * Textures to keep.
  41817. */
  41818. textures: BaseTexture[];
  41819. /**
  41820. * Environment texture for the scene
  41821. */
  41822. environmentTexture: Nullable<BaseTexture>;
  41823. /**
  41824. * @returns all meshes, lights, cameras, transformNodes and bones
  41825. */
  41826. getNodes(): Array<Node>;
  41827. }
  41828. }
  41829. declare module "babylonjs/Audio/sound" {
  41830. import { Observable } from "babylonjs/Misc/observable";
  41831. import { Vector3 } from "babylonjs/Maths/math.vector";
  41832. import { Nullable } from "babylonjs/types";
  41833. import { Scene } from "babylonjs/scene";
  41834. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41835. /**
  41836. * Interface used to define options for Sound class
  41837. */
  41838. export interface ISoundOptions {
  41839. /**
  41840. * Does the sound autoplay once loaded.
  41841. */
  41842. autoplay?: boolean;
  41843. /**
  41844. * Does the sound loop after it finishes playing once.
  41845. */
  41846. loop?: boolean;
  41847. /**
  41848. * Sound's volume
  41849. */
  41850. volume?: number;
  41851. /**
  41852. * Is it a spatial sound?
  41853. */
  41854. spatialSound?: boolean;
  41855. /**
  41856. * Maximum distance to hear that sound
  41857. */
  41858. maxDistance?: number;
  41859. /**
  41860. * Uses user defined attenuation function
  41861. */
  41862. useCustomAttenuation?: boolean;
  41863. /**
  41864. * Define the roll off factor of spatial sounds.
  41865. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41866. */
  41867. rolloffFactor?: number;
  41868. /**
  41869. * Define the reference distance the sound should be heard perfectly.
  41870. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41871. */
  41872. refDistance?: number;
  41873. /**
  41874. * Define the distance attenuation model the sound will follow.
  41875. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41876. */
  41877. distanceModel?: string;
  41878. /**
  41879. * Defines the playback speed (1 by default)
  41880. */
  41881. playbackRate?: number;
  41882. /**
  41883. * Defines if the sound is from a streaming source
  41884. */
  41885. streaming?: boolean;
  41886. /**
  41887. * Defines an optional length (in seconds) inside the sound file
  41888. */
  41889. length?: number;
  41890. /**
  41891. * Defines an optional offset (in seconds) inside the sound file
  41892. */
  41893. offset?: number;
  41894. /**
  41895. * If true, URLs will not be required to state the audio file codec to use.
  41896. */
  41897. skipCodecCheck?: boolean;
  41898. }
  41899. /**
  41900. * Defines a sound that can be played in the application.
  41901. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41903. */
  41904. export class Sound {
  41905. /**
  41906. * The name of the sound in the scene.
  41907. */
  41908. name: string;
  41909. /**
  41910. * Does the sound autoplay once loaded.
  41911. */
  41912. autoplay: boolean;
  41913. /**
  41914. * Does the sound loop after it finishes playing once.
  41915. */
  41916. loop: boolean;
  41917. /**
  41918. * Does the sound use a custom attenuation curve to simulate the falloff
  41919. * happening when the source gets further away from the camera.
  41920. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41921. */
  41922. useCustomAttenuation: boolean;
  41923. /**
  41924. * The sound track id this sound belongs to.
  41925. */
  41926. soundTrackId: number;
  41927. /**
  41928. * Is this sound currently played.
  41929. */
  41930. isPlaying: boolean;
  41931. /**
  41932. * Is this sound currently paused.
  41933. */
  41934. isPaused: boolean;
  41935. /**
  41936. * Does this sound enables spatial sound.
  41937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41938. */
  41939. spatialSound: boolean;
  41940. /**
  41941. * Define the reference distance the sound should be heard perfectly.
  41942. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41943. */
  41944. refDistance: number;
  41945. /**
  41946. * Define the roll off factor of spatial sounds.
  41947. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41948. */
  41949. rolloffFactor: number;
  41950. /**
  41951. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41952. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41953. */
  41954. maxDistance: number;
  41955. /**
  41956. * Define the distance attenuation model the sound will follow.
  41957. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41958. */
  41959. distanceModel: string;
  41960. /**
  41961. * @hidden
  41962. * Back Compat
  41963. **/
  41964. onended: () => any;
  41965. /**
  41966. * Gets or sets an object used to store user defined information for the sound.
  41967. */
  41968. metadata: any;
  41969. /**
  41970. * Observable event when the current playing sound finishes.
  41971. */
  41972. onEndedObservable: Observable<Sound>;
  41973. private _panningModel;
  41974. private _playbackRate;
  41975. private _streaming;
  41976. private _startTime;
  41977. private _startOffset;
  41978. private _position;
  41979. /** @hidden */
  41980. _positionInEmitterSpace: boolean;
  41981. private _localDirection;
  41982. private _volume;
  41983. private _isReadyToPlay;
  41984. private _isDirectional;
  41985. private _readyToPlayCallback;
  41986. private _audioBuffer;
  41987. private _soundSource;
  41988. private _streamingSource;
  41989. private _soundPanner;
  41990. private _soundGain;
  41991. private _inputAudioNode;
  41992. private _outputAudioNode;
  41993. private _coneInnerAngle;
  41994. private _coneOuterAngle;
  41995. private _coneOuterGain;
  41996. private _scene;
  41997. private _connectedTransformNode;
  41998. private _customAttenuationFunction;
  41999. private _registerFunc;
  42000. private _isOutputConnected;
  42001. private _htmlAudioElement;
  42002. private _urlType;
  42003. private _length?;
  42004. private _offset?;
  42005. /** @hidden */
  42006. static _SceneComponentInitialization: (scene: Scene) => void;
  42007. /**
  42008. * Create a sound and attach it to a scene
  42009. * @param name Name of your sound
  42010. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  42011. * @param scene defines the scene the sound belongs to
  42012. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  42013. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  42014. */
  42015. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  42016. /**
  42017. * Release the sound and its associated resources
  42018. */
  42019. dispose(): void;
  42020. /**
  42021. * Gets if the sounds is ready to be played or not.
  42022. * @returns true if ready, otherwise false
  42023. */
  42024. isReady(): boolean;
  42025. private _soundLoaded;
  42026. /**
  42027. * Sets the data of the sound from an audiobuffer
  42028. * @param audioBuffer The audioBuffer containing the data
  42029. */
  42030. setAudioBuffer(audioBuffer: AudioBuffer): void;
  42031. /**
  42032. * Updates the current sounds options such as maxdistance, loop...
  42033. * @param options A JSON object containing values named as the object properties
  42034. */
  42035. updateOptions(options: ISoundOptions): void;
  42036. private _createSpatialParameters;
  42037. private _updateSpatialParameters;
  42038. /**
  42039. * Switch the panning model to HRTF:
  42040. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42042. */
  42043. switchPanningModelToHRTF(): void;
  42044. /**
  42045. * Switch the panning model to Equal Power:
  42046. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42048. */
  42049. switchPanningModelToEqualPower(): void;
  42050. private _switchPanningModel;
  42051. /**
  42052. * Connect this sound to a sound track audio node like gain...
  42053. * @param soundTrackAudioNode the sound track audio node to connect to
  42054. */
  42055. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  42056. /**
  42057. * Transform this sound into a directional source
  42058. * @param coneInnerAngle Size of the inner cone in degree
  42059. * @param coneOuterAngle Size of the outer cone in degree
  42060. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  42061. */
  42062. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  42063. /**
  42064. * Gets or sets the inner angle for the directional cone.
  42065. */
  42066. get directionalConeInnerAngle(): number;
  42067. /**
  42068. * Gets or sets the inner angle for the directional cone.
  42069. */
  42070. set directionalConeInnerAngle(value: number);
  42071. /**
  42072. * Gets or sets the outer angle for the directional cone.
  42073. */
  42074. get directionalConeOuterAngle(): number;
  42075. /**
  42076. * Gets or sets the outer angle for the directional cone.
  42077. */
  42078. set directionalConeOuterAngle(value: number);
  42079. /**
  42080. * Sets the position of the emitter if spatial sound is enabled
  42081. * @param newPosition Defines the new posisiton
  42082. */
  42083. setPosition(newPosition: Vector3): void;
  42084. /**
  42085. * Sets the local direction of the emitter if spatial sound is enabled
  42086. * @param newLocalDirection Defines the new local direction
  42087. */
  42088. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  42089. private _updateDirection;
  42090. /** @hidden */
  42091. updateDistanceFromListener(): void;
  42092. /**
  42093. * Sets a new custom attenuation function for the sound.
  42094. * @param callback Defines the function used for the attenuation
  42095. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42096. */
  42097. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  42098. /**
  42099. * Play the sound
  42100. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  42101. * @param offset (optional) Start the sound at a specific time in seconds
  42102. * @param length (optional) Sound duration (in seconds)
  42103. */
  42104. play(time?: number, offset?: number, length?: number): void;
  42105. private _onended;
  42106. /**
  42107. * Stop the sound
  42108. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  42109. */
  42110. stop(time?: number): void;
  42111. /**
  42112. * Put the sound in pause
  42113. */
  42114. pause(): void;
  42115. /**
  42116. * Sets a dedicated volume for this sounds
  42117. * @param newVolume Define the new volume of the sound
  42118. * @param time Define time for gradual change to new volume
  42119. */
  42120. setVolume(newVolume: number, time?: number): void;
  42121. /**
  42122. * Set the sound play back rate
  42123. * @param newPlaybackRate Define the playback rate the sound should be played at
  42124. */
  42125. setPlaybackRate(newPlaybackRate: number): void;
  42126. /**
  42127. * Gets the volume of the sound.
  42128. * @returns the volume of the sound
  42129. */
  42130. getVolume(): number;
  42131. /**
  42132. * Attach the sound to a dedicated mesh
  42133. * @param transformNode The transform node to connect the sound with
  42134. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42135. */
  42136. attachToMesh(transformNode: TransformNode): void;
  42137. /**
  42138. * Detach the sound from the previously attached mesh
  42139. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42140. */
  42141. detachFromMesh(): void;
  42142. private _onRegisterAfterWorldMatrixUpdate;
  42143. /**
  42144. * Clone the current sound in the scene.
  42145. * @returns the new sound clone
  42146. */
  42147. clone(): Nullable<Sound>;
  42148. /**
  42149. * Gets the current underlying audio buffer containing the data
  42150. * @returns the audio buffer
  42151. */
  42152. getAudioBuffer(): Nullable<AudioBuffer>;
  42153. /**
  42154. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  42155. * @returns the source node
  42156. */
  42157. getSoundSource(): Nullable<AudioBufferSourceNode>;
  42158. /**
  42159. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  42160. * @returns the gain node
  42161. */
  42162. getSoundGain(): Nullable<GainNode>;
  42163. /**
  42164. * Serializes the Sound in a JSON representation
  42165. * @returns the JSON representation of the sound
  42166. */
  42167. serialize(): any;
  42168. /**
  42169. * Parse a JSON representation of a sound to innstantiate in a given scene
  42170. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  42171. * @param scene Define the scene the new parsed sound should be created in
  42172. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  42173. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  42174. * @returns the newly parsed sound
  42175. */
  42176. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  42177. }
  42178. }
  42179. declare module "babylonjs/Actions/directAudioActions" {
  42180. import { Action } from "babylonjs/Actions/action";
  42181. import { Condition } from "babylonjs/Actions/condition";
  42182. import { Sound } from "babylonjs/Audio/sound";
  42183. /**
  42184. * This defines an action helpful to play a defined sound on a triggered action.
  42185. */
  42186. export class PlaySoundAction extends Action {
  42187. private _sound;
  42188. /**
  42189. * Instantiate the action
  42190. * @param triggerOptions defines the trigger options
  42191. * @param sound defines the sound to play
  42192. * @param condition defines the trigger related conditions
  42193. */
  42194. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42195. /** @hidden */
  42196. _prepare(): void;
  42197. /**
  42198. * Execute the action and play the sound.
  42199. */
  42200. execute(): void;
  42201. /**
  42202. * Serializes the actions and its related information.
  42203. * @param parent defines the object to serialize in
  42204. * @returns the serialized object
  42205. */
  42206. serialize(parent: any): any;
  42207. }
  42208. /**
  42209. * This defines an action helpful to stop a defined sound on a triggered action.
  42210. */
  42211. export class StopSoundAction extends Action {
  42212. private _sound;
  42213. /**
  42214. * Instantiate the action
  42215. * @param triggerOptions defines the trigger options
  42216. * @param sound defines the sound to stop
  42217. * @param condition defines the trigger related conditions
  42218. */
  42219. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42220. /** @hidden */
  42221. _prepare(): void;
  42222. /**
  42223. * Execute the action and stop the sound.
  42224. */
  42225. execute(): void;
  42226. /**
  42227. * Serializes the actions and its related information.
  42228. * @param parent defines the object to serialize in
  42229. * @returns the serialized object
  42230. */
  42231. serialize(parent: any): any;
  42232. }
  42233. }
  42234. declare module "babylonjs/Actions/interpolateValueAction" {
  42235. import { Action } from "babylonjs/Actions/action";
  42236. import { Condition } from "babylonjs/Actions/condition";
  42237. import { Observable } from "babylonjs/Misc/observable";
  42238. /**
  42239. * This defines an action responsible to change the value of a property
  42240. * by interpolating between its current value and the newly set one once triggered.
  42241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  42242. */
  42243. export class InterpolateValueAction extends Action {
  42244. /**
  42245. * Defines the path of the property where the value should be interpolated
  42246. */
  42247. propertyPath: string;
  42248. /**
  42249. * Defines the target value at the end of the interpolation.
  42250. */
  42251. value: any;
  42252. /**
  42253. * Defines the time it will take for the property to interpolate to the value.
  42254. */
  42255. duration: number;
  42256. /**
  42257. * Defines if the other scene animations should be stopped when the action has been triggered
  42258. */
  42259. stopOtherAnimations?: boolean;
  42260. /**
  42261. * Defines a callback raised once the interpolation animation has been done.
  42262. */
  42263. onInterpolationDone?: () => void;
  42264. /**
  42265. * Observable triggered once the interpolation animation has been done.
  42266. */
  42267. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  42268. private _target;
  42269. private _effectiveTarget;
  42270. private _property;
  42271. /**
  42272. * Instantiate the action
  42273. * @param triggerOptions defines the trigger options
  42274. * @param target defines the object containing the value to interpolate
  42275. * @param propertyPath defines the path to the property in the target object
  42276. * @param value defines the target value at the end of the interpolation
  42277. * @param duration deines the time it will take for the property to interpolate to the value.
  42278. * @param condition defines the trigger related conditions
  42279. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  42280. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  42281. */
  42282. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  42283. /** @hidden */
  42284. _prepare(): void;
  42285. /**
  42286. * Execute the action starts the value interpolation.
  42287. */
  42288. execute(): void;
  42289. /**
  42290. * Serializes the actions and its related information.
  42291. * @param parent defines the object to serialize in
  42292. * @returns the serialized object
  42293. */
  42294. serialize(parent: any): any;
  42295. }
  42296. }
  42297. declare module "babylonjs/Actions/index" {
  42298. export * from "babylonjs/Actions/abstractActionManager";
  42299. export * from "babylonjs/Actions/action";
  42300. export * from "babylonjs/Actions/actionEvent";
  42301. export * from "babylonjs/Actions/actionManager";
  42302. export * from "babylonjs/Actions/condition";
  42303. export * from "babylonjs/Actions/directActions";
  42304. export * from "babylonjs/Actions/directAudioActions";
  42305. export * from "babylonjs/Actions/interpolateValueAction";
  42306. }
  42307. declare module "babylonjs/Animations/index" {
  42308. export * from "babylonjs/Animations/animatable";
  42309. export * from "babylonjs/Animations/animation";
  42310. export * from "babylonjs/Animations/animationGroup";
  42311. export * from "babylonjs/Animations/animationPropertiesOverride";
  42312. export * from "babylonjs/Animations/easing";
  42313. export * from "babylonjs/Animations/runtimeAnimation";
  42314. export * from "babylonjs/Animations/animationEvent";
  42315. export * from "babylonjs/Animations/animationGroup";
  42316. export * from "babylonjs/Animations/animationKey";
  42317. export * from "babylonjs/Animations/animationRange";
  42318. export * from "babylonjs/Animations/animatable.interface";
  42319. }
  42320. declare module "babylonjs/Audio/soundTrack" {
  42321. import { Sound } from "babylonjs/Audio/sound";
  42322. import { Analyser } from "babylonjs/Audio/analyser";
  42323. import { Scene } from "babylonjs/scene";
  42324. /**
  42325. * Options allowed during the creation of a sound track.
  42326. */
  42327. export interface ISoundTrackOptions {
  42328. /**
  42329. * The volume the sound track should take during creation
  42330. */
  42331. volume?: number;
  42332. /**
  42333. * Define if the sound track is the main sound track of the scene
  42334. */
  42335. mainTrack?: boolean;
  42336. }
  42337. /**
  42338. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42339. * It will be also used in a future release to apply effects on a specific track.
  42340. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42341. */
  42342. export class SoundTrack {
  42343. /**
  42344. * The unique identifier of the sound track in the scene.
  42345. */
  42346. id: number;
  42347. /**
  42348. * The list of sounds included in the sound track.
  42349. */
  42350. soundCollection: Array<Sound>;
  42351. private _outputAudioNode;
  42352. private _scene;
  42353. private _connectedAnalyser;
  42354. private _options;
  42355. private _isInitialized;
  42356. /**
  42357. * Creates a new sound track.
  42358. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42359. * @param scene Define the scene the sound track belongs to
  42360. * @param options
  42361. */
  42362. constructor(scene: Scene, options?: ISoundTrackOptions);
  42363. private _initializeSoundTrackAudioGraph;
  42364. /**
  42365. * Release the sound track and its associated resources
  42366. */
  42367. dispose(): void;
  42368. /**
  42369. * Adds a sound to this sound track
  42370. * @param sound define the cound to add
  42371. * @ignoreNaming
  42372. */
  42373. AddSound(sound: Sound): void;
  42374. /**
  42375. * Removes a sound to this sound track
  42376. * @param sound define the cound to remove
  42377. * @ignoreNaming
  42378. */
  42379. RemoveSound(sound: Sound): void;
  42380. /**
  42381. * Set a global volume for the full sound track.
  42382. * @param newVolume Define the new volume of the sound track
  42383. */
  42384. setVolume(newVolume: number): void;
  42385. /**
  42386. * Switch the panning model to HRTF:
  42387. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42388. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42389. */
  42390. switchPanningModelToHRTF(): void;
  42391. /**
  42392. * Switch the panning model to Equal Power:
  42393. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42394. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42395. */
  42396. switchPanningModelToEqualPower(): void;
  42397. /**
  42398. * Connect the sound track to an audio analyser allowing some amazing
  42399. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42400. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42401. * @param analyser The analyser to connect to the engine
  42402. */
  42403. connectToAnalyser(analyser: Analyser): void;
  42404. }
  42405. }
  42406. declare module "babylonjs/Audio/audioSceneComponent" {
  42407. import { Sound } from "babylonjs/Audio/sound";
  42408. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  42409. import { Nullable } from "babylonjs/types";
  42410. import { Vector3 } from "babylonjs/Maths/math.vector";
  42411. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  42412. import { Scene } from "babylonjs/scene";
  42413. import { AbstractScene } from "babylonjs/abstractScene";
  42414. import "babylonjs/Audio/audioEngine";
  42415. module "babylonjs/abstractScene" {
  42416. interface AbstractScene {
  42417. /**
  42418. * The list of sounds used in the scene.
  42419. */
  42420. sounds: Nullable<Array<Sound>>;
  42421. }
  42422. }
  42423. module "babylonjs/scene" {
  42424. interface Scene {
  42425. /**
  42426. * @hidden
  42427. * Backing field
  42428. */
  42429. _mainSoundTrack: SoundTrack;
  42430. /**
  42431. * The main sound track played by the scene.
  42432. * It cotains your primary collection of sounds.
  42433. */
  42434. mainSoundTrack: SoundTrack;
  42435. /**
  42436. * The list of sound tracks added to the scene
  42437. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42438. */
  42439. soundTracks: Nullable<Array<SoundTrack>>;
  42440. /**
  42441. * Gets a sound using a given name
  42442. * @param name defines the name to search for
  42443. * @return the found sound or null if not found at all.
  42444. */
  42445. getSoundByName(name: string): Nullable<Sound>;
  42446. /**
  42447. * Gets or sets if audio support is enabled
  42448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42449. */
  42450. audioEnabled: boolean;
  42451. /**
  42452. * Gets or sets if audio will be output to headphones
  42453. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42454. */
  42455. headphone: boolean;
  42456. /**
  42457. * Gets or sets custom audio listener position provider
  42458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42459. */
  42460. audioListenerPositionProvider: Nullable<() => Vector3>;
  42461. /**
  42462. * Gets or sets a refresh rate when using 3D audio positioning
  42463. */
  42464. audioPositioningRefreshRate: number;
  42465. }
  42466. }
  42467. /**
  42468. * Defines the sound scene component responsible to manage any sounds
  42469. * in a given scene.
  42470. */
  42471. export class AudioSceneComponent implements ISceneSerializableComponent {
  42472. /**
  42473. * The component name helpfull to identify the component in the list of scene components.
  42474. */
  42475. readonly name: string;
  42476. /**
  42477. * The scene the component belongs to.
  42478. */
  42479. scene: Scene;
  42480. private _audioEnabled;
  42481. /**
  42482. * Gets whether audio is enabled or not.
  42483. * Please use related enable/disable method to switch state.
  42484. */
  42485. get audioEnabled(): boolean;
  42486. private _headphone;
  42487. /**
  42488. * Gets whether audio is outputing to headphone or not.
  42489. * Please use the according Switch methods to change output.
  42490. */
  42491. get headphone(): boolean;
  42492. /**
  42493. * Gets or sets a refresh rate when using 3D audio positioning
  42494. */
  42495. audioPositioningRefreshRate: number;
  42496. private _audioListenerPositionProvider;
  42497. /**
  42498. * Gets the current audio listener position provider
  42499. */
  42500. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42501. /**
  42502. * Sets a custom listener position for all sounds in the scene
  42503. * By default, this is the position of the first active camera
  42504. */
  42505. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42506. /**
  42507. * Creates a new instance of the component for the given scene
  42508. * @param scene Defines the scene to register the component in
  42509. */
  42510. constructor(scene: Scene);
  42511. /**
  42512. * Registers the component in a given scene
  42513. */
  42514. register(): void;
  42515. /**
  42516. * Rebuilds the elements related to this component in case of
  42517. * context lost for instance.
  42518. */
  42519. rebuild(): void;
  42520. /**
  42521. * Serializes the component data to the specified json object
  42522. * @param serializationObject The object to serialize to
  42523. */
  42524. serialize(serializationObject: any): void;
  42525. /**
  42526. * Adds all the elements from the container to the scene
  42527. * @param container the container holding the elements
  42528. */
  42529. addFromContainer(container: AbstractScene): void;
  42530. /**
  42531. * Removes all the elements in the container from the scene
  42532. * @param container contains the elements to remove
  42533. * @param dispose if the removed element should be disposed (default: false)
  42534. */
  42535. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42536. /**
  42537. * Disposes the component and the associated ressources.
  42538. */
  42539. dispose(): void;
  42540. /**
  42541. * Disables audio in the associated scene.
  42542. */
  42543. disableAudio(): void;
  42544. /**
  42545. * Enables audio in the associated scene.
  42546. */
  42547. enableAudio(): void;
  42548. /**
  42549. * Switch audio to headphone output.
  42550. */
  42551. switchAudioModeForHeadphones(): void;
  42552. /**
  42553. * Switch audio to normal speakers.
  42554. */
  42555. switchAudioModeForNormalSpeakers(): void;
  42556. private _cachedCameraDirection;
  42557. private _cachedCameraPosition;
  42558. private _lastCheck;
  42559. private _afterRender;
  42560. }
  42561. }
  42562. declare module "babylonjs/Audio/weightedsound" {
  42563. import { Sound } from "babylonjs/Audio/sound";
  42564. /**
  42565. * Wraps one or more Sound objects and selects one with random weight for playback.
  42566. */
  42567. export class WeightedSound {
  42568. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42569. loop: boolean;
  42570. private _coneInnerAngle;
  42571. private _coneOuterAngle;
  42572. private _volume;
  42573. /** A Sound is currently playing. */
  42574. isPlaying: boolean;
  42575. /** A Sound is currently paused. */
  42576. isPaused: boolean;
  42577. private _sounds;
  42578. private _weights;
  42579. private _currentIndex?;
  42580. /**
  42581. * Creates a new WeightedSound from the list of sounds given.
  42582. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42583. * @param sounds Array of Sounds that will be selected from.
  42584. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42585. */
  42586. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42587. /**
  42588. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42589. */
  42590. get directionalConeInnerAngle(): number;
  42591. /**
  42592. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42593. */
  42594. set directionalConeInnerAngle(value: number);
  42595. /**
  42596. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42597. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42598. */
  42599. get directionalConeOuterAngle(): number;
  42600. /**
  42601. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42602. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42603. */
  42604. set directionalConeOuterAngle(value: number);
  42605. /**
  42606. * Playback volume.
  42607. */
  42608. get volume(): number;
  42609. /**
  42610. * Playback volume.
  42611. */
  42612. set volume(value: number);
  42613. private _onended;
  42614. /**
  42615. * Suspend playback
  42616. */
  42617. pause(): void;
  42618. /**
  42619. * Stop playback
  42620. */
  42621. stop(): void;
  42622. /**
  42623. * Start playback.
  42624. * @param startOffset Position the clip head at a specific time in seconds.
  42625. */
  42626. play(startOffset?: number): void;
  42627. }
  42628. }
  42629. declare module "babylonjs/Audio/index" {
  42630. export * from "babylonjs/Audio/analyser";
  42631. export * from "babylonjs/Audio/audioEngine";
  42632. export * from "babylonjs/Audio/audioSceneComponent";
  42633. export * from "babylonjs/Audio/sound";
  42634. export * from "babylonjs/Audio/soundTrack";
  42635. export * from "babylonjs/Audio/weightedsound";
  42636. }
  42637. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  42638. import { Behavior } from "babylonjs/Behaviors/behavior";
  42639. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42640. import { BackEase } from "babylonjs/Animations/easing";
  42641. /**
  42642. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42643. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42644. */
  42645. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42646. /**
  42647. * Gets the name of the behavior.
  42648. */
  42649. get name(): string;
  42650. /**
  42651. * The easing function used by animations
  42652. */
  42653. static EasingFunction: BackEase;
  42654. /**
  42655. * The easing mode used by animations
  42656. */
  42657. static EasingMode: number;
  42658. /**
  42659. * The duration of the animation, in milliseconds
  42660. */
  42661. transitionDuration: number;
  42662. /**
  42663. * Length of the distance animated by the transition when lower radius is reached
  42664. */
  42665. lowerRadiusTransitionRange: number;
  42666. /**
  42667. * Length of the distance animated by the transition when upper radius is reached
  42668. */
  42669. upperRadiusTransitionRange: number;
  42670. private _autoTransitionRange;
  42671. /**
  42672. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42673. */
  42674. get autoTransitionRange(): boolean;
  42675. /**
  42676. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42677. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42678. */
  42679. set autoTransitionRange(value: boolean);
  42680. private _attachedCamera;
  42681. private _onAfterCheckInputsObserver;
  42682. private _onMeshTargetChangedObserver;
  42683. /**
  42684. * Initializes the behavior.
  42685. */
  42686. init(): void;
  42687. /**
  42688. * Attaches the behavior to its arc rotate camera.
  42689. * @param camera Defines the camera to attach the behavior to
  42690. */
  42691. attach(camera: ArcRotateCamera): void;
  42692. /**
  42693. * Detaches the behavior from its current arc rotate camera.
  42694. */
  42695. detach(): void;
  42696. private _radiusIsAnimating;
  42697. private _radiusBounceTransition;
  42698. private _animatables;
  42699. private _cachedWheelPrecision;
  42700. /**
  42701. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42702. * @param radiusLimit The limit to check against.
  42703. * @return Bool to indicate if at limit.
  42704. */
  42705. private _isRadiusAtLimit;
  42706. /**
  42707. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42708. * @param radiusDelta The delta by which to animate to. Can be negative.
  42709. */
  42710. private _applyBoundRadiusAnimation;
  42711. /**
  42712. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42713. */
  42714. protected _clearAnimationLocks(): void;
  42715. /**
  42716. * Stops and removes all animations that have been applied to the camera
  42717. */
  42718. stopAllAnimations(): void;
  42719. }
  42720. }
  42721. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  42722. import { Behavior } from "babylonjs/Behaviors/behavior";
  42723. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42724. import { ExponentialEase } from "babylonjs/Animations/easing";
  42725. import { Nullable } from "babylonjs/types";
  42726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42727. import { Vector3 } from "babylonjs/Maths/math.vector";
  42728. /**
  42729. * 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.
  42730. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42731. */
  42732. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42733. /**
  42734. * Gets the name of the behavior.
  42735. */
  42736. get name(): string;
  42737. private _mode;
  42738. private _radiusScale;
  42739. private _positionScale;
  42740. private _defaultElevation;
  42741. private _elevationReturnTime;
  42742. private _elevationReturnWaitTime;
  42743. private _zoomStopsAnimation;
  42744. private _framingTime;
  42745. /**
  42746. * The easing function used by animations
  42747. */
  42748. static EasingFunction: ExponentialEase;
  42749. /**
  42750. * The easing mode used by animations
  42751. */
  42752. static EasingMode: number;
  42753. /**
  42754. * Sets the current mode used by the behavior
  42755. */
  42756. set mode(mode: number);
  42757. /**
  42758. * Gets current mode used by the behavior.
  42759. */
  42760. get mode(): number;
  42761. /**
  42762. * Sets the scale applied to the radius (1 by default)
  42763. */
  42764. set radiusScale(radius: number);
  42765. /**
  42766. * Gets the scale applied to the radius
  42767. */
  42768. get radiusScale(): number;
  42769. /**
  42770. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42771. */
  42772. set positionScale(scale: number);
  42773. /**
  42774. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42775. */
  42776. get positionScale(): number;
  42777. /**
  42778. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42779. * behaviour is triggered, in radians.
  42780. */
  42781. set defaultElevation(elevation: number);
  42782. /**
  42783. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42784. * behaviour is triggered, in radians.
  42785. */
  42786. get defaultElevation(): number;
  42787. /**
  42788. * Sets the time (in milliseconds) taken to return to the default beta position.
  42789. * Negative value indicates camera should not return to default.
  42790. */
  42791. set elevationReturnTime(speed: number);
  42792. /**
  42793. * Gets the time (in milliseconds) taken to return to the default beta position.
  42794. * Negative value indicates camera should not return to default.
  42795. */
  42796. get elevationReturnTime(): number;
  42797. /**
  42798. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42799. */
  42800. set elevationReturnWaitTime(time: number);
  42801. /**
  42802. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42803. */
  42804. get elevationReturnWaitTime(): number;
  42805. /**
  42806. * Sets the flag that indicates if user zooming should stop animation.
  42807. */
  42808. set zoomStopsAnimation(flag: boolean);
  42809. /**
  42810. * Gets the flag that indicates if user zooming should stop animation.
  42811. */
  42812. get zoomStopsAnimation(): boolean;
  42813. /**
  42814. * Sets the transition time when framing the mesh, in milliseconds
  42815. */
  42816. set framingTime(time: number);
  42817. /**
  42818. * Gets the transition time when framing the mesh, in milliseconds
  42819. */
  42820. get framingTime(): number;
  42821. /**
  42822. * Define if the behavior should automatically change the configured
  42823. * camera limits and sensibilities.
  42824. */
  42825. autoCorrectCameraLimitsAndSensibility: boolean;
  42826. private _onPrePointerObservableObserver;
  42827. private _onAfterCheckInputsObserver;
  42828. private _onMeshTargetChangedObserver;
  42829. private _attachedCamera;
  42830. private _isPointerDown;
  42831. private _lastInteractionTime;
  42832. /**
  42833. * Initializes the behavior.
  42834. */
  42835. init(): void;
  42836. /**
  42837. * Attaches the behavior to its arc rotate camera.
  42838. * @param camera Defines the camera to attach the behavior to
  42839. */
  42840. attach(camera: ArcRotateCamera): void;
  42841. /**
  42842. * Detaches the behavior from its current arc rotate camera.
  42843. */
  42844. detach(): void;
  42845. private _animatables;
  42846. private _betaIsAnimating;
  42847. private _betaTransition;
  42848. private _radiusTransition;
  42849. private _vectorTransition;
  42850. /**
  42851. * Targets the given mesh and updates zoom level accordingly.
  42852. * @param mesh The mesh to target.
  42853. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42854. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42855. */
  42856. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42857. /**
  42858. * Targets the given mesh with its children and updates zoom level accordingly.
  42859. * @param mesh The mesh to target.
  42860. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42861. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42862. */
  42863. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42864. /**
  42865. * Targets the given meshes with their children and updates zoom level accordingly.
  42866. * @param meshes The mesh to target.
  42867. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42868. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42869. */
  42870. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42871. /**
  42872. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42873. * @param minimumWorld Determines the smaller position of the bounding box extend
  42874. * @param maximumWorld Determines the bigger position of the bounding box extend
  42875. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42876. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42877. */
  42878. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42879. /**
  42880. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42881. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42882. * frustum width.
  42883. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42884. * to fully enclose the mesh in the viewing frustum.
  42885. */
  42886. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42887. /**
  42888. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42889. * is automatically returned to its default position (expected to be above ground plane).
  42890. */
  42891. private _maintainCameraAboveGround;
  42892. /**
  42893. * Returns the frustum slope based on the canvas ratio and camera FOV
  42894. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42895. */
  42896. private _getFrustumSlope;
  42897. /**
  42898. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42899. */
  42900. private _clearAnimationLocks;
  42901. /**
  42902. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42903. */
  42904. private _applyUserInteraction;
  42905. /**
  42906. * Stops and removes all animations that have been applied to the camera
  42907. */
  42908. stopAllAnimations(): void;
  42909. /**
  42910. * Gets a value indicating if the user is moving the camera
  42911. */
  42912. get isUserIsMoving(): boolean;
  42913. /**
  42914. * The camera can move all the way towards the mesh.
  42915. */
  42916. static IgnoreBoundsSizeMode: number;
  42917. /**
  42918. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42919. */
  42920. static FitFrustumSidesMode: number;
  42921. }
  42922. }
  42923. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  42924. import { Nullable } from "babylonjs/types";
  42925. import { Camera } from "babylonjs/Cameras/camera";
  42926. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42927. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42928. /**
  42929. * Base class for Camera Pointer Inputs.
  42930. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42931. * for example usage.
  42932. */
  42933. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42934. /**
  42935. * Defines the camera the input is attached to.
  42936. */
  42937. abstract camera: Camera;
  42938. /**
  42939. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42940. */
  42941. protected _altKey: boolean;
  42942. protected _ctrlKey: boolean;
  42943. protected _metaKey: boolean;
  42944. protected _shiftKey: boolean;
  42945. /**
  42946. * Which mouse buttons were pressed at time of last mouse event.
  42947. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42948. */
  42949. protected _buttonsPressed: number;
  42950. /**
  42951. * Defines the buttons associated with the input to handle camera move.
  42952. */
  42953. buttons: number[];
  42954. /**
  42955. * Attach the input controls to a specific dom element to get the input from.
  42956. * @param element Defines the element the controls should be listened from
  42957. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42958. */
  42959. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42960. /**
  42961. * Detach the current controls from the specified dom element.
  42962. * @param element Defines the element to stop listening the inputs from
  42963. */
  42964. detachControl(element: Nullable<HTMLElement>): void;
  42965. /**
  42966. * Gets the class name of the current input.
  42967. * @returns the class name
  42968. */
  42969. getClassName(): string;
  42970. /**
  42971. * Get the friendly name associated with the input class.
  42972. * @returns the input friendly name
  42973. */
  42974. getSimpleName(): string;
  42975. /**
  42976. * Called on pointer POINTERDOUBLETAP event.
  42977. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42978. */
  42979. protected onDoubleTap(type: string): void;
  42980. /**
  42981. * Called on pointer POINTERMOVE event if only a single touch is active.
  42982. * Override this method to provide functionality.
  42983. */
  42984. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42985. /**
  42986. * Called on pointer POINTERMOVE event if multiple touches are active.
  42987. * Override this method to provide functionality.
  42988. */
  42989. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42990. /**
  42991. * Called on JS contextmenu event.
  42992. * Override this method to provide functionality.
  42993. */
  42994. protected onContextMenu(evt: PointerEvent): void;
  42995. /**
  42996. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42997. * press.
  42998. * Override this method to provide functionality.
  42999. */
  43000. protected onButtonDown(evt: PointerEvent): void;
  43001. /**
  43002. * Called each time a new POINTERUP event occurs. Ie, for each button
  43003. * release.
  43004. * Override this method to provide functionality.
  43005. */
  43006. protected onButtonUp(evt: PointerEvent): void;
  43007. /**
  43008. * Called when window becomes inactive.
  43009. * Override this method to provide functionality.
  43010. */
  43011. protected onLostFocus(): void;
  43012. private _pointerInput;
  43013. private _observer;
  43014. private _onLostFocus;
  43015. private pointA;
  43016. private pointB;
  43017. }
  43018. }
  43019. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  43020. import { Nullable } from "babylonjs/types";
  43021. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43022. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  43023. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43024. /**
  43025. * Manage the pointers inputs to control an arc rotate camera.
  43026. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43027. */
  43028. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  43029. /**
  43030. * Defines the camera the input is attached to.
  43031. */
  43032. camera: ArcRotateCamera;
  43033. /**
  43034. * Gets the class name of the current input.
  43035. * @returns the class name
  43036. */
  43037. getClassName(): string;
  43038. /**
  43039. * Defines the buttons associated with the input to handle camera move.
  43040. */
  43041. buttons: number[];
  43042. /**
  43043. * Defines the pointer angular sensibility along the X axis or how fast is
  43044. * the camera rotating.
  43045. */
  43046. angularSensibilityX: number;
  43047. /**
  43048. * Defines the pointer angular sensibility along the Y axis or how fast is
  43049. * the camera rotating.
  43050. */
  43051. angularSensibilityY: number;
  43052. /**
  43053. * Defines the pointer pinch precision or how fast is the camera zooming.
  43054. */
  43055. pinchPrecision: number;
  43056. /**
  43057. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43058. * from 0.
  43059. * It defines the percentage of current camera.radius to use as delta when
  43060. * pinch zoom is used.
  43061. */
  43062. pinchDeltaPercentage: number;
  43063. /**
  43064. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43065. * that any object in the plane at the camera's target point will scale
  43066. * perfectly with finger motion.
  43067. * Overrides pinchDeltaPercentage and pinchPrecision.
  43068. */
  43069. useNaturalPinchZoom: boolean;
  43070. /**
  43071. * Defines the pointer panning sensibility or how fast is the camera moving.
  43072. */
  43073. panningSensibility: number;
  43074. /**
  43075. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  43076. */
  43077. multiTouchPanning: boolean;
  43078. /**
  43079. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  43080. * zoom (pinch) through multitouch.
  43081. */
  43082. multiTouchPanAndZoom: boolean;
  43083. /**
  43084. * Revers pinch action direction.
  43085. */
  43086. pinchInwards: boolean;
  43087. private _isPanClick;
  43088. private _twoFingerActivityCount;
  43089. private _isPinching;
  43090. /**
  43091. * Called on pointer POINTERMOVE event if only a single touch is active.
  43092. */
  43093. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43094. /**
  43095. * Called on pointer POINTERDOUBLETAP event.
  43096. */
  43097. protected onDoubleTap(type: string): void;
  43098. /**
  43099. * Called on pointer POINTERMOVE event if multiple touches are active.
  43100. */
  43101. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43102. /**
  43103. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43104. * press.
  43105. */
  43106. protected onButtonDown(evt: PointerEvent): void;
  43107. /**
  43108. * Called each time a new POINTERUP event occurs. Ie, for each button
  43109. * release.
  43110. */
  43111. protected onButtonUp(evt: PointerEvent): void;
  43112. /**
  43113. * Called when window becomes inactive.
  43114. */
  43115. protected onLostFocus(): void;
  43116. }
  43117. }
  43118. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  43119. import { Nullable } from "babylonjs/types";
  43120. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43121. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43122. /**
  43123. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  43124. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43125. */
  43126. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  43127. /**
  43128. * Defines the camera the input is attached to.
  43129. */
  43130. camera: ArcRotateCamera;
  43131. /**
  43132. * Defines the list of key codes associated with the up action (increase alpha)
  43133. */
  43134. keysUp: number[];
  43135. /**
  43136. * Defines the list of key codes associated with the down action (decrease alpha)
  43137. */
  43138. keysDown: number[];
  43139. /**
  43140. * Defines the list of key codes associated with the left action (increase beta)
  43141. */
  43142. keysLeft: number[];
  43143. /**
  43144. * Defines the list of key codes associated with the right action (decrease beta)
  43145. */
  43146. keysRight: number[];
  43147. /**
  43148. * Defines the list of key codes associated with the reset action.
  43149. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  43150. */
  43151. keysReset: number[];
  43152. /**
  43153. * Defines the panning sensibility of the inputs.
  43154. * (How fast is the camera panning)
  43155. */
  43156. panningSensibility: number;
  43157. /**
  43158. * Defines the zooming sensibility of the inputs.
  43159. * (How fast is the camera zooming)
  43160. */
  43161. zoomingSensibility: number;
  43162. /**
  43163. * Defines whether maintaining the alt key down switch the movement mode from
  43164. * orientation to zoom.
  43165. */
  43166. useAltToZoom: boolean;
  43167. /**
  43168. * Rotation speed of the camera
  43169. */
  43170. angularSpeed: number;
  43171. private _keys;
  43172. private _ctrlPressed;
  43173. private _altPressed;
  43174. private _onCanvasBlurObserver;
  43175. private _onKeyboardObserver;
  43176. private _engine;
  43177. private _scene;
  43178. /**
  43179. * Attach the input controls to a specific dom element to get the input from.
  43180. * @param element Defines the element the controls should be listened from
  43181. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43182. */
  43183. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43184. /**
  43185. * Detach the current controls from the specified dom element.
  43186. * @param element Defines the element to stop listening the inputs from
  43187. */
  43188. detachControl(element: Nullable<HTMLElement>): void;
  43189. /**
  43190. * Update the current camera state depending on the inputs that have been used this frame.
  43191. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43192. */
  43193. checkInputs(): void;
  43194. /**
  43195. * Gets the class name of the current intput.
  43196. * @returns the class name
  43197. */
  43198. getClassName(): string;
  43199. /**
  43200. * Get the friendly name associated with the input class.
  43201. * @returns the input friendly name
  43202. */
  43203. getSimpleName(): string;
  43204. }
  43205. }
  43206. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  43207. import { Nullable } from "babylonjs/types";
  43208. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43209. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43210. /**
  43211. * Manage the mouse wheel inputs to control an arc rotate camera.
  43212. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43213. */
  43214. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  43215. /**
  43216. * Defines the camera the input is attached to.
  43217. */
  43218. camera: ArcRotateCamera;
  43219. /**
  43220. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43221. */
  43222. wheelPrecision: number;
  43223. /**
  43224. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43225. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43226. */
  43227. wheelDeltaPercentage: number;
  43228. private _wheel;
  43229. private _observer;
  43230. private computeDeltaFromMouseWheelLegacyEvent;
  43231. /**
  43232. * Attach the input controls to a specific dom element to get the input from.
  43233. * @param element Defines the element the controls should be listened from
  43234. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43235. */
  43236. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43237. /**
  43238. * Detach the current controls from the specified dom element.
  43239. * @param element Defines the element to stop listening the inputs from
  43240. */
  43241. detachControl(element: Nullable<HTMLElement>): void;
  43242. /**
  43243. * Gets the class name of the current intput.
  43244. * @returns the class name
  43245. */
  43246. getClassName(): string;
  43247. /**
  43248. * Get the friendly name associated with the input class.
  43249. * @returns the input friendly name
  43250. */
  43251. getSimpleName(): string;
  43252. }
  43253. }
  43254. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43255. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43256. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  43257. /**
  43258. * Default Inputs manager for the ArcRotateCamera.
  43259. * It groups all the default supported inputs for ease of use.
  43260. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43261. */
  43262. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  43263. /**
  43264. * Instantiates a new ArcRotateCameraInputsManager.
  43265. * @param camera Defines the camera the inputs belong to
  43266. */
  43267. constructor(camera: ArcRotateCamera);
  43268. /**
  43269. * Add mouse wheel input support to the input manager.
  43270. * @returns the current input manager
  43271. */
  43272. addMouseWheel(): ArcRotateCameraInputsManager;
  43273. /**
  43274. * Add pointers input support to the input manager.
  43275. * @returns the current input manager
  43276. */
  43277. addPointers(): ArcRotateCameraInputsManager;
  43278. /**
  43279. * Add keyboard input support to the input manager.
  43280. * @returns the current input manager
  43281. */
  43282. addKeyboard(): ArcRotateCameraInputsManager;
  43283. }
  43284. }
  43285. declare module "babylonjs/Cameras/arcRotateCamera" {
  43286. import { Observable } from "babylonjs/Misc/observable";
  43287. import { Nullable } from "babylonjs/types";
  43288. import { Scene } from "babylonjs/scene";
  43289. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  43290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43291. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43292. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43293. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  43294. import { Camera } from "babylonjs/Cameras/camera";
  43295. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  43296. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43297. import { Collider } from "babylonjs/Collisions/collider";
  43298. /**
  43299. * This represents an orbital type of camera.
  43300. *
  43301. * 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.
  43302. * 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.
  43303. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  43304. */
  43305. export class ArcRotateCamera extends TargetCamera {
  43306. /**
  43307. * Defines the rotation angle of the camera along the longitudinal axis.
  43308. */
  43309. alpha: number;
  43310. /**
  43311. * Defines the rotation angle of the camera along the latitudinal axis.
  43312. */
  43313. beta: number;
  43314. /**
  43315. * Defines the radius of the camera from it s target point.
  43316. */
  43317. radius: number;
  43318. protected _target: Vector3;
  43319. protected _targetHost: Nullable<AbstractMesh>;
  43320. /**
  43321. * Defines the target point of the camera.
  43322. * The camera looks towards it form the radius distance.
  43323. */
  43324. get target(): Vector3;
  43325. set target(value: Vector3);
  43326. /**
  43327. * Define the current local position of the camera in the scene
  43328. */
  43329. get position(): Vector3;
  43330. set position(newPosition: Vector3);
  43331. protected _upVector: Vector3;
  43332. protected _upToYMatrix: Matrix;
  43333. protected _YToUpMatrix: Matrix;
  43334. /**
  43335. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  43336. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  43337. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  43338. */
  43339. set upVector(vec: Vector3);
  43340. get upVector(): Vector3;
  43341. /**
  43342. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  43343. */
  43344. setMatUp(): void;
  43345. /**
  43346. * Current inertia value on the longitudinal axis.
  43347. * The bigger this number the longer it will take for the camera to stop.
  43348. */
  43349. inertialAlphaOffset: number;
  43350. /**
  43351. * Current inertia value on the latitudinal axis.
  43352. * The bigger this number the longer it will take for the camera to stop.
  43353. */
  43354. inertialBetaOffset: number;
  43355. /**
  43356. * Current inertia value on the radius axis.
  43357. * The bigger this number the longer it will take for the camera to stop.
  43358. */
  43359. inertialRadiusOffset: number;
  43360. /**
  43361. * Minimum allowed angle on the longitudinal axis.
  43362. * This can help limiting how the Camera is able to move in the scene.
  43363. */
  43364. lowerAlphaLimit: Nullable<number>;
  43365. /**
  43366. * Maximum allowed angle on the longitudinal axis.
  43367. * This can help limiting how the Camera is able to move in the scene.
  43368. */
  43369. upperAlphaLimit: Nullable<number>;
  43370. /**
  43371. * Minimum allowed angle on the latitudinal axis.
  43372. * This can help limiting how the Camera is able to move in the scene.
  43373. */
  43374. lowerBetaLimit: number;
  43375. /**
  43376. * Maximum allowed angle on the latitudinal axis.
  43377. * This can help limiting how the Camera is able to move in the scene.
  43378. */
  43379. upperBetaLimit: number;
  43380. /**
  43381. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43382. * This can help limiting how the Camera is able to move in the scene.
  43383. */
  43384. lowerRadiusLimit: Nullable<number>;
  43385. /**
  43386. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43387. * This can help limiting how the Camera is able to move in the scene.
  43388. */
  43389. upperRadiusLimit: Nullable<number>;
  43390. /**
  43391. * Defines the current inertia value used during panning of the camera along the X axis.
  43392. */
  43393. inertialPanningX: number;
  43394. /**
  43395. * Defines the current inertia value used during panning of the camera along the Y axis.
  43396. */
  43397. inertialPanningY: number;
  43398. /**
  43399. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43400. * Basically if your fingers moves away from more than this distance you will be considered
  43401. * in pinch mode.
  43402. */
  43403. pinchToPanMaxDistance: number;
  43404. /**
  43405. * Defines the maximum distance the camera can pan.
  43406. * This could help keeping the cammera always in your scene.
  43407. */
  43408. panningDistanceLimit: Nullable<number>;
  43409. /**
  43410. * Defines the target of the camera before paning.
  43411. */
  43412. panningOriginTarget: Vector3;
  43413. /**
  43414. * Defines the value of the inertia used during panning.
  43415. * 0 would mean stop inertia and one would mean no decelleration at all.
  43416. */
  43417. panningInertia: number;
  43418. /**
  43419. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43420. */
  43421. get angularSensibilityX(): number;
  43422. set angularSensibilityX(value: number);
  43423. /**
  43424. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43425. */
  43426. get angularSensibilityY(): number;
  43427. set angularSensibilityY(value: number);
  43428. /**
  43429. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43430. */
  43431. get pinchPrecision(): number;
  43432. set pinchPrecision(value: number);
  43433. /**
  43434. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43435. * It will be used instead of pinchDeltaPrecision if different from 0.
  43436. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43437. */
  43438. get pinchDeltaPercentage(): number;
  43439. set pinchDeltaPercentage(value: number);
  43440. /**
  43441. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43442. * and pinch delta percentage.
  43443. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43444. * that any object in the plane at the camera's target point will scale
  43445. * perfectly with finger motion.
  43446. */
  43447. get useNaturalPinchZoom(): boolean;
  43448. set useNaturalPinchZoom(value: boolean);
  43449. /**
  43450. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43451. */
  43452. get panningSensibility(): number;
  43453. set panningSensibility(value: number);
  43454. /**
  43455. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43456. */
  43457. get keysUp(): number[];
  43458. set keysUp(value: number[]);
  43459. /**
  43460. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43461. */
  43462. get keysDown(): number[];
  43463. set keysDown(value: number[]);
  43464. /**
  43465. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43466. */
  43467. get keysLeft(): number[];
  43468. set keysLeft(value: number[]);
  43469. /**
  43470. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43471. */
  43472. get keysRight(): number[];
  43473. set keysRight(value: number[]);
  43474. /**
  43475. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43476. */
  43477. get wheelPrecision(): number;
  43478. set wheelPrecision(value: number);
  43479. /**
  43480. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43481. * It will be used instead of pinchDeltaPrecision if different from 0.
  43482. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43483. */
  43484. get wheelDeltaPercentage(): number;
  43485. set wheelDeltaPercentage(value: number);
  43486. /**
  43487. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43488. */
  43489. zoomOnFactor: number;
  43490. /**
  43491. * Defines a screen offset for the camera position.
  43492. */
  43493. targetScreenOffset: Vector2;
  43494. /**
  43495. * Allows the camera to be completely reversed.
  43496. * If false the camera can not arrive upside down.
  43497. */
  43498. allowUpsideDown: boolean;
  43499. /**
  43500. * Define if double tap/click is used to restore the previously saved state of the camera.
  43501. */
  43502. useInputToRestoreState: boolean;
  43503. /** @hidden */
  43504. _viewMatrix: Matrix;
  43505. /** @hidden */
  43506. _useCtrlForPanning: boolean;
  43507. /** @hidden */
  43508. _panningMouseButton: number;
  43509. /**
  43510. * Defines the input associated to the camera.
  43511. */
  43512. inputs: ArcRotateCameraInputsManager;
  43513. /** @hidden */
  43514. _reset: () => void;
  43515. /**
  43516. * Defines the allowed panning axis.
  43517. */
  43518. panningAxis: Vector3;
  43519. protected _localDirection: Vector3;
  43520. protected _transformedDirection: Vector3;
  43521. private _bouncingBehavior;
  43522. /**
  43523. * Gets the bouncing behavior of the camera if it has been enabled.
  43524. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43525. */
  43526. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43527. /**
  43528. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43529. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43530. */
  43531. get useBouncingBehavior(): boolean;
  43532. set useBouncingBehavior(value: boolean);
  43533. private _framingBehavior;
  43534. /**
  43535. * Gets the framing behavior of the camera if it has been enabled.
  43536. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43537. */
  43538. get framingBehavior(): Nullable<FramingBehavior>;
  43539. /**
  43540. * Defines if the framing behavior of the camera is enabled on the camera.
  43541. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43542. */
  43543. get useFramingBehavior(): boolean;
  43544. set useFramingBehavior(value: boolean);
  43545. private _autoRotationBehavior;
  43546. /**
  43547. * Gets the auto rotation behavior of the camera if it has been enabled.
  43548. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43549. */
  43550. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43551. /**
  43552. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43553. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43554. */
  43555. get useAutoRotationBehavior(): boolean;
  43556. set useAutoRotationBehavior(value: boolean);
  43557. /**
  43558. * Observable triggered when the mesh target has been changed on the camera.
  43559. */
  43560. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43561. /**
  43562. * Event raised when the camera is colliding with a mesh.
  43563. */
  43564. onCollide: (collidedMesh: AbstractMesh) => void;
  43565. /**
  43566. * Defines whether the camera should check collision with the objects oh the scene.
  43567. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43568. */
  43569. checkCollisions: boolean;
  43570. /**
  43571. * Defines the collision radius of the camera.
  43572. * This simulates a sphere around the camera.
  43573. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43574. */
  43575. collisionRadius: Vector3;
  43576. protected _collider: Collider;
  43577. protected _previousPosition: Vector3;
  43578. protected _collisionVelocity: Vector3;
  43579. protected _newPosition: Vector3;
  43580. protected _previousAlpha: number;
  43581. protected _previousBeta: number;
  43582. protected _previousRadius: number;
  43583. protected _collisionTriggered: boolean;
  43584. protected _targetBoundingCenter: Nullable<Vector3>;
  43585. private _computationVector;
  43586. /**
  43587. * Instantiates a new ArcRotateCamera in a given scene
  43588. * @param name Defines the name of the camera
  43589. * @param alpha Defines the camera rotation along the logitudinal axis
  43590. * @param beta Defines the camera rotation along the latitudinal axis
  43591. * @param radius Defines the camera distance from its target
  43592. * @param target Defines the camera target
  43593. * @param scene Defines the scene the camera belongs to
  43594. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43595. */
  43596. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43597. /** @hidden */
  43598. _initCache(): void;
  43599. /** @hidden */
  43600. _updateCache(ignoreParentClass?: boolean): void;
  43601. protected _getTargetPosition(): Vector3;
  43602. private _storedAlpha;
  43603. private _storedBeta;
  43604. private _storedRadius;
  43605. private _storedTarget;
  43606. private _storedTargetScreenOffset;
  43607. /**
  43608. * Stores the current state of the camera (alpha, beta, radius and target)
  43609. * @returns the camera itself
  43610. */
  43611. storeState(): Camera;
  43612. /**
  43613. * @hidden
  43614. * Restored camera state. You must call storeState() first
  43615. */
  43616. _restoreStateValues(): boolean;
  43617. /** @hidden */
  43618. _isSynchronizedViewMatrix(): boolean;
  43619. /**
  43620. * Attached controls to the current camera.
  43621. * @param element Defines the element the controls should be listened from
  43622. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43623. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43624. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43625. */
  43626. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43627. /**
  43628. * Detach the current controls from the camera.
  43629. * The camera will stop reacting to inputs.
  43630. * @param element Defines the element to stop listening the inputs from
  43631. */
  43632. detachControl(element: HTMLElement): void;
  43633. /** @hidden */
  43634. _checkInputs(): void;
  43635. protected _checkLimits(): void;
  43636. /**
  43637. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43638. */
  43639. rebuildAnglesAndRadius(): void;
  43640. /**
  43641. * Use a position to define the current camera related information like alpha, beta and radius
  43642. * @param position Defines the position to set the camera at
  43643. */
  43644. setPosition(position: Vector3): void;
  43645. /**
  43646. * Defines the target the camera should look at.
  43647. * This will automatically adapt alpha beta and radius to fit within the new target.
  43648. * @param target Defines the new target as a Vector or a mesh
  43649. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43650. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43651. */
  43652. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43653. /** @hidden */
  43654. _getViewMatrix(): Matrix;
  43655. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43656. /**
  43657. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43658. * @param meshes Defines the mesh to zoom on
  43659. * @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)
  43660. */
  43661. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43662. /**
  43663. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43664. * The target will be changed but the radius
  43665. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43666. * @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)
  43667. */
  43668. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43669. min: Vector3;
  43670. max: Vector3;
  43671. distance: number;
  43672. }, doNotUpdateMaxZ?: boolean): void;
  43673. /**
  43674. * @override
  43675. * Override Camera.createRigCamera
  43676. */
  43677. createRigCamera(name: string, cameraIndex: number): Camera;
  43678. /**
  43679. * @hidden
  43680. * @override
  43681. * Override Camera._updateRigCameras
  43682. */
  43683. _updateRigCameras(): void;
  43684. /**
  43685. * Destroy the camera and release the current resources hold by it.
  43686. */
  43687. dispose(): void;
  43688. /**
  43689. * Gets the current object class name.
  43690. * @return the class name
  43691. */
  43692. getClassName(): string;
  43693. }
  43694. }
  43695. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  43696. import { Behavior } from "babylonjs/Behaviors/behavior";
  43697. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43698. /**
  43699. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43700. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43701. */
  43702. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43703. /**
  43704. * Gets the name of the behavior.
  43705. */
  43706. get name(): string;
  43707. private _zoomStopsAnimation;
  43708. private _idleRotationSpeed;
  43709. private _idleRotationWaitTime;
  43710. private _idleRotationSpinupTime;
  43711. /**
  43712. * Sets the flag that indicates if user zooming should stop animation.
  43713. */
  43714. set zoomStopsAnimation(flag: boolean);
  43715. /**
  43716. * Gets the flag that indicates if user zooming should stop animation.
  43717. */
  43718. get zoomStopsAnimation(): boolean;
  43719. /**
  43720. * Sets the default speed at which the camera rotates around the model.
  43721. */
  43722. set idleRotationSpeed(speed: number);
  43723. /**
  43724. * Gets the default speed at which the camera rotates around the model.
  43725. */
  43726. get idleRotationSpeed(): number;
  43727. /**
  43728. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43729. */
  43730. set idleRotationWaitTime(time: number);
  43731. /**
  43732. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43733. */
  43734. get idleRotationWaitTime(): number;
  43735. /**
  43736. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43737. */
  43738. set idleRotationSpinupTime(time: number);
  43739. /**
  43740. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43741. */
  43742. get idleRotationSpinupTime(): number;
  43743. /**
  43744. * Gets a value indicating if the camera is currently rotating because of this behavior
  43745. */
  43746. get rotationInProgress(): boolean;
  43747. private _onPrePointerObservableObserver;
  43748. private _onAfterCheckInputsObserver;
  43749. private _attachedCamera;
  43750. private _isPointerDown;
  43751. private _lastFrameTime;
  43752. private _lastInteractionTime;
  43753. private _cameraRotationSpeed;
  43754. /**
  43755. * Initializes the behavior.
  43756. */
  43757. init(): void;
  43758. /**
  43759. * Attaches the behavior to its arc rotate camera.
  43760. * @param camera Defines the camera to attach the behavior to
  43761. */
  43762. attach(camera: ArcRotateCamera): void;
  43763. /**
  43764. * Detaches the behavior from its current arc rotate camera.
  43765. */
  43766. detach(): void;
  43767. /**
  43768. * Returns true if user is scrolling.
  43769. * @return true if user is scrolling.
  43770. */
  43771. private _userIsZooming;
  43772. private _lastFrameRadius;
  43773. private _shouldAnimationStopForInteraction;
  43774. /**
  43775. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43776. */
  43777. private _applyUserInteraction;
  43778. private _userIsMoving;
  43779. }
  43780. }
  43781. declare module "babylonjs/Behaviors/Cameras/index" {
  43782. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43783. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43784. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  43785. }
  43786. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  43787. import { Mesh } from "babylonjs/Meshes/mesh";
  43788. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43789. import { Behavior } from "babylonjs/Behaviors/behavior";
  43790. /**
  43791. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43792. */
  43793. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43794. private ui;
  43795. /**
  43796. * The name of the behavior
  43797. */
  43798. name: string;
  43799. /**
  43800. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43801. */
  43802. distanceAwayFromFace: number;
  43803. /**
  43804. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43805. */
  43806. distanceAwayFromBottomOfFace: number;
  43807. private _faceVectors;
  43808. private _target;
  43809. private _scene;
  43810. private _onRenderObserver;
  43811. private _tmpMatrix;
  43812. private _tmpVector;
  43813. /**
  43814. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43815. * @param ui The transform node that should be attched to the mesh
  43816. */
  43817. constructor(ui: TransformNode);
  43818. /**
  43819. * Initializes the behavior
  43820. */
  43821. init(): void;
  43822. private _closestFace;
  43823. private _zeroVector;
  43824. private _lookAtTmpMatrix;
  43825. private _lookAtToRef;
  43826. /**
  43827. * Attaches the AttachToBoxBehavior to the passed in mesh
  43828. * @param target The mesh that the specified node will be attached to
  43829. */
  43830. attach(target: Mesh): void;
  43831. /**
  43832. * Detaches the behavior from the mesh
  43833. */
  43834. detach(): void;
  43835. }
  43836. }
  43837. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  43838. import { Behavior } from "babylonjs/Behaviors/behavior";
  43839. import { Mesh } from "babylonjs/Meshes/mesh";
  43840. /**
  43841. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43842. */
  43843. export class FadeInOutBehavior implements Behavior<Mesh> {
  43844. /**
  43845. * Time in milliseconds to delay before fading in (Default: 0)
  43846. */
  43847. delay: number;
  43848. /**
  43849. * Time in milliseconds for the mesh to fade in (Default: 300)
  43850. */
  43851. fadeInTime: number;
  43852. private _millisecondsPerFrame;
  43853. private _hovered;
  43854. private _hoverValue;
  43855. private _ownerNode;
  43856. /**
  43857. * Instatiates the FadeInOutBehavior
  43858. */
  43859. constructor();
  43860. /**
  43861. * The name of the behavior
  43862. */
  43863. get name(): string;
  43864. /**
  43865. * Initializes the behavior
  43866. */
  43867. init(): void;
  43868. /**
  43869. * Attaches the fade behavior on the passed in mesh
  43870. * @param ownerNode The mesh that will be faded in/out once attached
  43871. */
  43872. attach(ownerNode: Mesh): void;
  43873. /**
  43874. * Detaches the behavior from the mesh
  43875. */
  43876. detach(): void;
  43877. /**
  43878. * Triggers the mesh to begin fading in or out
  43879. * @param value if the object should fade in or out (true to fade in)
  43880. */
  43881. fadeIn(value: boolean): void;
  43882. private _update;
  43883. private _setAllVisibility;
  43884. }
  43885. }
  43886. declare module "babylonjs/Misc/pivotTools" {
  43887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43888. /**
  43889. * Class containing a set of static utilities functions for managing Pivots
  43890. * @hidden
  43891. */
  43892. export class PivotTools {
  43893. private static _PivotCached;
  43894. private static _OldPivotPoint;
  43895. private static _PivotTranslation;
  43896. private static _PivotTmpVector;
  43897. /** @hidden */
  43898. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43899. /** @hidden */
  43900. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43901. }
  43902. }
  43903. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  43904. import { Scene } from "babylonjs/scene";
  43905. import { Vector4 } from "babylonjs/Maths/math.vector";
  43906. import { Mesh } from "babylonjs/Meshes/mesh";
  43907. import { Nullable } from "babylonjs/types";
  43908. import { Plane } from "babylonjs/Maths/math.plane";
  43909. /**
  43910. * Class containing static functions to help procedurally build meshes
  43911. */
  43912. export class PlaneBuilder {
  43913. /**
  43914. * Creates a plane mesh
  43915. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43916. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43917. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43918. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43919. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43921. * @param name defines the name of the mesh
  43922. * @param options defines the options used to create the mesh
  43923. * @param scene defines the hosting scene
  43924. * @returns the plane mesh
  43925. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43926. */
  43927. static CreatePlane(name: string, options: {
  43928. size?: number;
  43929. width?: number;
  43930. height?: number;
  43931. sideOrientation?: number;
  43932. frontUVs?: Vector4;
  43933. backUVs?: Vector4;
  43934. updatable?: boolean;
  43935. sourcePlane?: Plane;
  43936. }, scene?: Nullable<Scene>): Mesh;
  43937. }
  43938. }
  43939. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  43940. import { Behavior } from "babylonjs/Behaviors/behavior";
  43941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43942. import { Observable } from "babylonjs/Misc/observable";
  43943. import { Vector3 } from "babylonjs/Maths/math.vector";
  43944. import { Ray } from "babylonjs/Culling/ray";
  43945. import "babylonjs/Meshes/Builders/planeBuilder";
  43946. /**
  43947. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43948. */
  43949. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43950. private static _AnyMouseID;
  43951. /**
  43952. * Abstract mesh the behavior is set on
  43953. */
  43954. attachedNode: AbstractMesh;
  43955. private _dragPlane;
  43956. private _scene;
  43957. private _pointerObserver;
  43958. private _beforeRenderObserver;
  43959. private static _planeScene;
  43960. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43961. /**
  43962. * 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)
  43963. */
  43964. maxDragAngle: number;
  43965. /**
  43966. * @hidden
  43967. */
  43968. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43969. /**
  43970. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43971. */
  43972. currentDraggingPointerID: number;
  43973. /**
  43974. * The last position where the pointer hit the drag plane in world space
  43975. */
  43976. lastDragPosition: Vector3;
  43977. /**
  43978. * If the behavior is currently in a dragging state
  43979. */
  43980. dragging: boolean;
  43981. /**
  43982. * 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)
  43983. */
  43984. dragDeltaRatio: number;
  43985. /**
  43986. * If the drag plane orientation should be updated during the dragging (Default: true)
  43987. */
  43988. updateDragPlane: boolean;
  43989. private _debugMode;
  43990. private _moving;
  43991. /**
  43992. * Fires each time the attached mesh is dragged with the pointer
  43993. * * delta between last drag position and current drag position in world space
  43994. * * dragDistance along the drag axis
  43995. * * dragPlaneNormal normal of the current drag plane used during the drag
  43996. * * dragPlanePoint in world space where the drag intersects the drag plane
  43997. */
  43998. onDragObservable: Observable<{
  43999. delta: Vector3;
  44000. dragPlanePoint: Vector3;
  44001. dragPlaneNormal: Vector3;
  44002. dragDistance: number;
  44003. pointerId: number;
  44004. }>;
  44005. /**
  44006. * Fires each time a drag begins (eg. mouse down on mesh)
  44007. */
  44008. onDragStartObservable: Observable<{
  44009. dragPlanePoint: Vector3;
  44010. pointerId: number;
  44011. }>;
  44012. /**
  44013. * Fires each time a drag ends (eg. mouse release after drag)
  44014. */
  44015. onDragEndObservable: Observable<{
  44016. dragPlanePoint: Vector3;
  44017. pointerId: number;
  44018. }>;
  44019. /**
  44020. * If the attached mesh should be moved when dragged
  44021. */
  44022. moveAttached: boolean;
  44023. /**
  44024. * If the drag behavior will react to drag events (Default: true)
  44025. */
  44026. enabled: boolean;
  44027. /**
  44028. * If pointer events should start and release the drag (Default: true)
  44029. */
  44030. startAndReleaseDragOnPointerEvents: boolean;
  44031. /**
  44032. * If camera controls should be detached during the drag
  44033. */
  44034. detachCameraControls: boolean;
  44035. /**
  44036. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  44037. */
  44038. useObjectOrientationForDragging: boolean;
  44039. private _options;
  44040. /**
  44041. * Gets the options used by the behavior
  44042. */
  44043. get options(): {
  44044. dragAxis?: Vector3;
  44045. dragPlaneNormal?: Vector3;
  44046. };
  44047. /**
  44048. * Sets the options used by the behavior
  44049. */
  44050. set options(options: {
  44051. dragAxis?: Vector3;
  44052. dragPlaneNormal?: Vector3;
  44053. });
  44054. /**
  44055. * Creates a pointer drag behavior that can be attached to a mesh
  44056. * @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)
  44057. */
  44058. constructor(options?: {
  44059. dragAxis?: Vector3;
  44060. dragPlaneNormal?: Vector3;
  44061. });
  44062. /**
  44063. * Predicate to determine if it is valid to move the object to a new position when it is moved
  44064. */
  44065. validateDrag: (targetPosition: Vector3) => boolean;
  44066. /**
  44067. * The name of the behavior
  44068. */
  44069. get name(): string;
  44070. /**
  44071. * Initializes the behavior
  44072. */
  44073. init(): void;
  44074. private _tmpVector;
  44075. private _alternatePickedPoint;
  44076. private _worldDragAxis;
  44077. private _targetPosition;
  44078. private _attachedElement;
  44079. /**
  44080. * Attaches the drag behavior the passed in mesh
  44081. * @param ownerNode The mesh that will be dragged around once attached
  44082. * @param predicate Predicate to use for pick filtering
  44083. */
  44084. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  44085. /**
  44086. * Force relase the drag action by code.
  44087. */
  44088. releaseDrag(): void;
  44089. private _startDragRay;
  44090. private _lastPointerRay;
  44091. /**
  44092. * Simulates the start of a pointer drag event on the behavior
  44093. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  44094. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  44095. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  44096. */
  44097. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  44098. private _startDrag;
  44099. private _dragDelta;
  44100. private _moveDrag;
  44101. private _pickWithRayOnDragPlane;
  44102. private _pointA;
  44103. private _pointB;
  44104. private _pointC;
  44105. private _lineA;
  44106. private _lineB;
  44107. private _localAxis;
  44108. private _lookAt;
  44109. private _updateDragPlanePosition;
  44110. /**
  44111. * Detaches the behavior from the mesh
  44112. */
  44113. detach(): void;
  44114. }
  44115. }
  44116. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  44117. import { Mesh } from "babylonjs/Meshes/mesh";
  44118. import { Behavior } from "babylonjs/Behaviors/behavior";
  44119. /**
  44120. * A behavior that when attached to a mesh will allow the mesh to be scaled
  44121. */
  44122. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  44123. private _dragBehaviorA;
  44124. private _dragBehaviorB;
  44125. private _startDistance;
  44126. private _initialScale;
  44127. private _targetScale;
  44128. private _ownerNode;
  44129. private _sceneRenderObserver;
  44130. /**
  44131. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  44132. */
  44133. constructor();
  44134. /**
  44135. * The name of the behavior
  44136. */
  44137. get name(): string;
  44138. /**
  44139. * Initializes the behavior
  44140. */
  44141. init(): void;
  44142. private _getCurrentDistance;
  44143. /**
  44144. * Attaches the scale behavior the passed in mesh
  44145. * @param ownerNode The mesh that will be scaled around once attached
  44146. */
  44147. attach(ownerNode: Mesh): void;
  44148. /**
  44149. * Detaches the behavior from the mesh
  44150. */
  44151. detach(): void;
  44152. }
  44153. }
  44154. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  44155. import { Behavior } from "babylonjs/Behaviors/behavior";
  44156. import { Mesh } from "babylonjs/Meshes/mesh";
  44157. import { Observable } from "babylonjs/Misc/observable";
  44158. /**
  44159. * 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
  44160. */
  44161. export class SixDofDragBehavior implements Behavior<Mesh> {
  44162. private static _virtualScene;
  44163. private _ownerNode;
  44164. private _sceneRenderObserver;
  44165. private _scene;
  44166. private _targetPosition;
  44167. private _virtualOriginMesh;
  44168. private _virtualDragMesh;
  44169. private _pointerObserver;
  44170. private _moving;
  44171. private _startingOrientation;
  44172. private _attachedElement;
  44173. /**
  44174. * 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)
  44175. */
  44176. private zDragFactor;
  44177. /**
  44178. * If the object should rotate to face the drag origin
  44179. */
  44180. rotateDraggedObject: boolean;
  44181. /**
  44182. * If the behavior is currently in a dragging state
  44183. */
  44184. dragging: boolean;
  44185. /**
  44186. * 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)
  44187. */
  44188. dragDeltaRatio: number;
  44189. /**
  44190. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44191. */
  44192. currentDraggingPointerID: number;
  44193. /**
  44194. * If camera controls should be detached during the drag
  44195. */
  44196. detachCameraControls: boolean;
  44197. /**
  44198. * Fires each time a drag starts
  44199. */
  44200. onDragStartObservable: Observable<{}>;
  44201. /**
  44202. * Fires each time a drag ends (eg. mouse release after drag)
  44203. */
  44204. onDragEndObservable: Observable<{}>;
  44205. /**
  44206. * 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
  44207. */
  44208. constructor();
  44209. /**
  44210. * The name of the behavior
  44211. */
  44212. get name(): string;
  44213. /**
  44214. * Initializes the behavior
  44215. */
  44216. init(): void;
  44217. /**
  44218. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  44219. */
  44220. private get _pointerCamera();
  44221. /**
  44222. * Attaches the scale behavior the passed in mesh
  44223. * @param ownerNode The mesh that will be scaled around once attached
  44224. */
  44225. attach(ownerNode: Mesh): void;
  44226. /**
  44227. * Detaches the behavior from the mesh
  44228. */
  44229. detach(): void;
  44230. }
  44231. }
  44232. declare module "babylonjs/Behaviors/Meshes/index" {
  44233. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  44234. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  44235. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  44236. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44237. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44238. }
  44239. declare module "babylonjs/Behaviors/index" {
  44240. export * from "babylonjs/Behaviors/behavior";
  44241. export * from "babylonjs/Behaviors/Cameras/index";
  44242. export * from "babylonjs/Behaviors/Meshes/index";
  44243. }
  44244. declare module "babylonjs/Bones/boneIKController" {
  44245. import { Bone } from "babylonjs/Bones/bone";
  44246. import { Vector3 } from "babylonjs/Maths/math.vector";
  44247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44248. import { Nullable } from "babylonjs/types";
  44249. /**
  44250. * Class used to apply inverse kinematics to bones
  44251. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  44252. */
  44253. export class BoneIKController {
  44254. private static _tmpVecs;
  44255. private static _tmpQuat;
  44256. private static _tmpMats;
  44257. /**
  44258. * Gets or sets the target mesh
  44259. */
  44260. targetMesh: AbstractMesh;
  44261. /** Gets or sets the mesh used as pole */
  44262. poleTargetMesh: AbstractMesh;
  44263. /**
  44264. * Gets or sets the bone used as pole
  44265. */
  44266. poleTargetBone: Nullable<Bone>;
  44267. /**
  44268. * Gets or sets the target position
  44269. */
  44270. targetPosition: Vector3;
  44271. /**
  44272. * Gets or sets the pole target position
  44273. */
  44274. poleTargetPosition: Vector3;
  44275. /**
  44276. * Gets or sets the pole target local offset
  44277. */
  44278. poleTargetLocalOffset: Vector3;
  44279. /**
  44280. * Gets or sets the pole angle
  44281. */
  44282. poleAngle: number;
  44283. /**
  44284. * Gets or sets the mesh associated with the controller
  44285. */
  44286. mesh: AbstractMesh;
  44287. /**
  44288. * 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)
  44289. */
  44290. slerpAmount: number;
  44291. private _bone1Quat;
  44292. private _bone1Mat;
  44293. private _bone2Ang;
  44294. private _bone1;
  44295. private _bone2;
  44296. private _bone1Length;
  44297. private _bone2Length;
  44298. private _maxAngle;
  44299. private _maxReach;
  44300. private _rightHandedSystem;
  44301. private _bendAxis;
  44302. private _slerping;
  44303. private _adjustRoll;
  44304. /**
  44305. * Gets or sets maximum allowed angle
  44306. */
  44307. get maxAngle(): number;
  44308. set maxAngle(value: number);
  44309. /**
  44310. * Creates a new BoneIKController
  44311. * @param mesh defines the mesh to control
  44312. * @param bone defines the bone to control
  44313. * @param options defines options to set up the controller
  44314. */
  44315. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  44316. targetMesh?: AbstractMesh;
  44317. poleTargetMesh?: AbstractMesh;
  44318. poleTargetBone?: Bone;
  44319. poleTargetLocalOffset?: Vector3;
  44320. poleAngle?: number;
  44321. bendAxis?: Vector3;
  44322. maxAngle?: number;
  44323. slerpAmount?: number;
  44324. });
  44325. private _setMaxAngle;
  44326. /**
  44327. * Force the controller to update the bones
  44328. */
  44329. update(): void;
  44330. }
  44331. }
  44332. declare module "babylonjs/Bones/boneLookController" {
  44333. import { Vector3 } from "babylonjs/Maths/math.vector";
  44334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44335. import { Bone } from "babylonjs/Bones/bone";
  44336. import { Space } from "babylonjs/Maths/math.axis";
  44337. /**
  44338. * Class used to make a bone look toward a point in space
  44339. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  44340. */
  44341. export class BoneLookController {
  44342. private static _tmpVecs;
  44343. private static _tmpQuat;
  44344. private static _tmpMats;
  44345. /**
  44346. * The target Vector3 that the bone will look at
  44347. */
  44348. target: Vector3;
  44349. /**
  44350. * The mesh that the bone is attached to
  44351. */
  44352. mesh: AbstractMesh;
  44353. /**
  44354. * The bone that will be looking to the target
  44355. */
  44356. bone: Bone;
  44357. /**
  44358. * The up axis of the coordinate system that is used when the bone is rotated
  44359. */
  44360. upAxis: Vector3;
  44361. /**
  44362. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  44363. */
  44364. upAxisSpace: Space;
  44365. /**
  44366. * Used to make an adjustment to the yaw of the bone
  44367. */
  44368. adjustYaw: number;
  44369. /**
  44370. * Used to make an adjustment to the pitch of the bone
  44371. */
  44372. adjustPitch: number;
  44373. /**
  44374. * Used to make an adjustment to the roll of the bone
  44375. */
  44376. adjustRoll: number;
  44377. /**
  44378. * 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)
  44379. */
  44380. slerpAmount: number;
  44381. private _minYaw;
  44382. private _maxYaw;
  44383. private _minPitch;
  44384. private _maxPitch;
  44385. private _minYawSin;
  44386. private _minYawCos;
  44387. private _maxYawSin;
  44388. private _maxYawCos;
  44389. private _midYawConstraint;
  44390. private _minPitchTan;
  44391. private _maxPitchTan;
  44392. private _boneQuat;
  44393. private _slerping;
  44394. private _transformYawPitch;
  44395. private _transformYawPitchInv;
  44396. private _firstFrameSkipped;
  44397. private _yawRange;
  44398. private _fowardAxis;
  44399. /**
  44400. * Gets or sets the minimum yaw angle that the bone can look to
  44401. */
  44402. get minYaw(): number;
  44403. set minYaw(value: number);
  44404. /**
  44405. * Gets or sets the maximum yaw angle that the bone can look to
  44406. */
  44407. get maxYaw(): number;
  44408. set maxYaw(value: number);
  44409. /**
  44410. * Gets or sets the minimum pitch angle that the bone can look to
  44411. */
  44412. get minPitch(): number;
  44413. set minPitch(value: number);
  44414. /**
  44415. * Gets or sets the maximum pitch angle that the bone can look to
  44416. */
  44417. get maxPitch(): number;
  44418. set maxPitch(value: number);
  44419. /**
  44420. * Create a BoneLookController
  44421. * @param mesh the mesh that the bone belongs to
  44422. * @param bone the bone that will be looking to the target
  44423. * @param target the target Vector3 to look at
  44424. * @param options optional settings:
  44425. * * maxYaw: the maximum angle the bone will yaw to
  44426. * * minYaw: the minimum angle the bone will yaw to
  44427. * * maxPitch: the maximum angle the bone will pitch to
  44428. * * minPitch: the minimum angle the bone will yaw to
  44429. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44430. * * upAxis: the up axis of the coordinate system
  44431. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44432. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44433. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44434. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44435. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44436. * * adjustRoll: used to make an adjustment to the roll of the bone
  44437. **/
  44438. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44439. maxYaw?: number;
  44440. minYaw?: number;
  44441. maxPitch?: number;
  44442. minPitch?: number;
  44443. slerpAmount?: number;
  44444. upAxis?: Vector3;
  44445. upAxisSpace?: Space;
  44446. yawAxis?: Vector3;
  44447. pitchAxis?: Vector3;
  44448. adjustYaw?: number;
  44449. adjustPitch?: number;
  44450. adjustRoll?: number;
  44451. });
  44452. /**
  44453. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44454. */
  44455. update(): void;
  44456. private _getAngleDiff;
  44457. private _getAngleBetween;
  44458. private _isAngleBetween;
  44459. }
  44460. }
  44461. declare module "babylonjs/Bones/index" {
  44462. export * from "babylonjs/Bones/bone";
  44463. export * from "babylonjs/Bones/boneIKController";
  44464. export * from "babylonjs/Bones/boneLookController";
  44465. export * from "babylonjs/Bones/skeleton";
  44466. }
  44467. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  44468. import { Nullable } from "babylonjs/types";
  44469. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44470. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44471. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  44472. /**
  44473. * Manage the gamepad inputs to control an arc rotate camera.
  44474. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44475. */
  44476. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44477. /**
  44478. * Defines the camera the input is attached to.
  44479. */
  44480. camera: ArcRotateCamera;
  44481. /**
  44482. * Defines the gamepad the input is gathering event from.
  44483. */
  44484. gamepad: Nullable<Gamepad>;
  44485. /**
  44486. * Defines the gamepad rotation sensiblity.
  44487. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44488. */
  44489. gamepadRotationSensibility: number;
  44490. /**
  44491. * Defines the gamepad move sensiblity.
  44492. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44493. */
  44494. gamepadMoveSensibility: number;
  44495. private _yAxisScale;
  44496. /**
  44497. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44498. */
  44499. get invertYAxis(): boolean;
  44500. set invertYAxis(value: boolean);
  44501. private _onGamepadConnectedObserver;
  44502. private _onGamepadDisconnectedObserver;
  44503. /**
  44504. * Attach the input controls to a specific dom element to get the input from.
  44505. * @param element Defines the element the controls should be listened from
  44506. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44507. */
  44508. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44509. /**
  44510. * Detach the current controls from the specified dom element.
  44511. * @param element Defines the element to stop listening the inputs from
  44512. */
  44513. detachControl(element: Nullable<HTMLElement>): void;
  44514. /**
  44515. * Update the current camera state depending on the inputs that have been used this frame.
  44516. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44517. */
  44518. checkInputs(): void;
  44519. /**
  44520. * Gets the class name of the current intput.
  44521. * @returns the class name
  44522. */
  44523. getClassName(): string;
  44524. /**
  44525. * Get the friendly name associated with the input class.
  44526. * @returns the input friendly name
  44527. */
  44528. getSimpleName(): string;
  44529. }
  44530. }
  44531. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  44532. import { Nullable } from "babylonjs/types";
  44533. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44534. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44535. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44536. interface ArcRotateCameraInputsManager {
  44537. /**
  44538. * Add orientation input support to the input manager.
  44539. * @returns the current input manager
  44540. */
  44541. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44542. }
  44543. }
  44544. /**
  44545. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44546. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44547. */
  44548. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44549. /**
  44550. * Defines the camera the input is attached to.
  44551. */
  44552. camera: ArcRotateCamera;
  44553. /**
  44554. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44555. */
  44556. alphaCorrection: number;
  44557. /**
  44558. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44559. */
  44560. gammaCorrection: number;
  44561. private _alpha;
  44562. private _gamma;
  44563. private _dirty;
  44564. private _deviceOrientationHandler;
  44565. /**
  44566. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44567. */
  44568. constructor();
  44569. /**
  44570. * Attach the input controls to a specific dom element to get the input from.
  44571. * @param element Defines the element the controls should be listened from
  44572. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44573. */
  44574. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44575. /** @hidden */
  44576. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44577. /**
  44578. * Update the current camera state depending on the inputs that have been used this frame.
  44579. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44580. */
  44581. checkInputs(): void;
  44582. /**
  44583. * Detach the current controls from the specified dom element.
  44584. * @param element Defines the element to stop listening the inputs from
  44585. */
  44586. detachControl(element: Nullable<HTMLElement>): void;
  44587. /**
  44588. * Gets the class name of the current intput.
  44589. * @returns the class name
  44590. */
  44591. getClassName(): string;
  44592. /**
  44593. * Get the friendly name associated with the input class.
  44594. * @returns the input friendly name
  44595. */
  44596. getSimpleName(): string;
  44597. }
  44598. }
  44599. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  44600. import { Nullable } from "babylonjs/types";
  44601. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44602. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44603. /**
  44604. * Listen to mouse events to control the camera.
  44605. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44606. */
  44607. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44608. /**
  44609. * Defines the camera the input is attached to.
  44610. */
  44611. camera: FlyCamera;
  44612. /**
  44613. * Defines if touch is enabled. (Default is true.)
  44614. */
  44615. touchEnabled: boolean;
  44616. /**
  44617. * Defines the buttons associated with the input to handle camera rotation.
  44618. */
  44619. buttons: number[];
  44620. /**
  44621. * Assign buttons for Yaw control.
  44622. */
  44623. buttonsYaw: number[];
  44624. /**
  44625. * Assign buttons for Pitch control.
  44626. */
  44627. buttonsPitch: number[];
  44628. /**
  44629. * Assign buttons for Roll control.
  44630. */
  44631. buttonsRoll: number[];
  44632. /**
  44633. * Detect if any button is being pressed while mouse is moved.
  44634. * -1 = Mouse locked.
  44635. * 0 = Left button.
  44636. * 1 = Middle Button.
  44637. * 2 = Right Button.
  44638. */
  44639. activeButton: number;
  44640. /**
  44641. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44642. * Higher values reduce its sensitivity.
  44643. */
  44644. angularSensibility: number;
  44645. private _mousemoveCallback;
  44646. private _observer;
  44647. private _rollObserver;
  44648. private previousPosition;
  44649. private noPreventDefault;
  44650. private element;
  44651. /**
  44652. * Listen to mouse events to control the camera.
  44653. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44654. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44655. */
  44656. constructor(touchEnabled?: boolean);
  44657. /**
  44658. * Attach the mouse control to the HTML DOM element.
  44659. * @param element Defines the element that listens to the input events.
  44660. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44661. */
  44662. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44663. /**
  44664. * Detach the current controls from the specified dom element.
  44665. * @param element Defines the element to stop listening the inputs from
  44666. */
  44667. detachControl(element: Nullable<HTMLElement>): void;
  44668. /**
  44669. * Gets the class name of the current input.
  44670. * @returns the class name.
  44671. */
  44672. getClassName(): string;
  44673. /**
  44674. * Get the friendly name associated with the input class.
  44675. * @returns the input's friendly name.
  44676. */
  44677. getSimpleName(): string;
  44678. private _pointerInput;
  44679. private _onMouseMove;
  44680. /**
  44681. * Rotate camera by mouse offset.
  44682. */
  44683. private rotateCamera;
  44684. }
  44685. }
  44686. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  44687. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44688. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44689. /**
  44690. * Default Inputs manager for the FlyCamera.
  44691. * It groups all the default supported inputs for ease of use.
  44692. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44693. */
  44694. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44695. /**
  44696. * Instantiates a new FlyCameraInputsManager.
  44697. * @param camera Defines the camera the inputs belong to.
  44698. */
  44699. constructor(camera: FlyCamera);
  44700. /**
  44701. * Add keyboard input support to the input manager.
  44702. * @returns the new FlyCameraKeyboardMoveInput().
  44703. */
  44704. addKeyboard(): FlyCameraInputsManager;
  44705. /**
  44706. * Add mouse input support to the input manager.
  44707. * @param touchEnabled Enable touch screen support.
  44708. * @returns the new FlyCameraMouseInput().
  44709. */
  44710. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44711. }
  44712. }
  44713. declare module "babylonjs/Cameras/flyCamera" {
  44714. import { Scene } from "babylonjs/scene";
  44715. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  44716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44717. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44718. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  44719. /**
  44720. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44721. * such as in a 3D Space Shooter or a Flight Simulator.
  44722. */
  44723. export class FlyCamera extends TargetCamera {
  44724. /**
  44725. * Define the collision ellipsoid of the camera.
  44726. * This is helpful for simulating a camera body, like a player's body.
  44727. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44728. */
  44729. ellipsoid: Vector3;
  44730. /**
  44731. * Define an offset for the position of the ellipsoid around the camera.
  44732. * This can be helpful if the camera is attached away from the player's body center,
  44733. * such as at its head.
  44734. */
  44735. ellipsoidOffset: Vector3;
  44736. /**
  44737. * Enable or disable collisions of the camera with the rest of the scene objects.
  44738. */
  44739. checkCollisions: boolean;
  44740. /**
  44741. * Enable or disable gravity on the camera.
  44742. */
  44743. applyGravity: boolean;
  44744. /**
  44745. * Define the current direction the camera is moving to.
  44746. */
  44747. cameraDirection: Vector3;
  44748. /**
  44749. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44750. * This overrides and empties cameraRotation.
  44751. */
  44752. rotationQuaternion: Quaternion;
  44753. /**
  44754. * Track Roll to maintain the wanted Rolling when looking around.
  44755. */
  44756. _trackRoll: number;
  44757. /**
  44758. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44759. */
  44760. rollCorrect: number;
  44761. /**
  44762. * Mimic a banked turn, Rolling the camera when Yawing.
  44763. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44764. */
  44765. bankedTurn: boolean;
  44766. /**
  44767. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44768. */
  44769. bankedTurnLimit: number;
  44770. /**
  44771. * Value of 0 disables the banked Roll.
  44772. * Value of 1 is equal to the Yaw angle in radians.
  44773. */
  44774. bankedTurnMultiplier: number;
  44775. /**
  44776. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44777. */
  44778. inputs: FlyCameraInputsManager;
  44779. /**
  44780. * Gets the input sensibility for mouse input.
  44781. * Higher values reduce sensitivity.
  44782. */
  44783. get angularSensibility(): number;
  44784. /**
  44785. * Sets the input sensibility for a mouse input.
  44786. * Higher values reduce sensitivity.
  44787. */
  44788. set angularSensibility(value: number);
  44789. /**
  44790. * Get the keys for camera movement forward.
  44791. */
  44792. get keysForward(): number[];
  44793. /**
  44794. * Set the keys for camera movement forward.
  44795. */
  44796. set keysForward(value: number[]);
  44797. /**
  44798. * Get the keys for camera movement backward.
  44799. */
  44800. get keysBackward(): number[];
  44801. set keysBackward(value: number[]);
  44802. /**
  44803. * Get the keys for camera movement up.
  44804. */
  44805. get keysUp(): number[];
  44806. /**
  44807. * Set the keys for camera movement up.
  44808. */
  44809. set keysUp(value: number[]);
  44810. /**
  44811. * Get the keys for camera movement down.
  44812. */
  44813. get keysDown(): number[];
  44814. /**
  44815. * Set the keys for camera movement down.
  44816. */
  44817. set keysDown(value: number[]);
  44818. /**
  44819. * Get the keys for camera movement left.
  44820. */
  44821. get keysLeft(): number[];
  44822. /**
  44823. * Set the keys for camera movement left.
  44824. */
  44825. set keysLeft(value: number[]);
  44826. /**
  44827. * Set the keys for camera movement right.
  44828. */
  44829. get keysRight(): number[];
  44830. /**
  44831. * Set the keys for camera movement right.
  44832. */
  44833. set keysRight(value: number[]);
  44834. /**
  44835. * Event raised when the camera collides with a mesh in the scene.
  44836. */
  44837. onCollide: (collidedMesh: AbstractMesh) => void;
  44838. private _collider;
  44839. private _needMoveForGravity;
  44840. private _oldPosition;
  44841. private _diffPosition;
  44842. private _newPosition;
  44843. /** @hidden */
  44844. _localDirection: Vector3;
  44845. /** @hidden */
  44846. _transformedDirection: Vector3;
  44847. /**
  44848. * Instantiates a FlyCamera.
  44849. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44850. * such as in a 3D Space Shooter or a Flight Simulator.
  44851. * @param name Define the name of the camera in the scene.
  44852. * @param position Define the starting position of the camera in the scene.
  44853. * @param scene Define the scene the camera belongs to.
  44854. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44855. */
  44856. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44857. /**
  44858. * Attach a control to the HTML DOM element.
  44859. * @param element Defines the element that listens to the input events.
  44860. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44861. */
  44862. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44863. /**
  44864. * Detach a control from the HTML DOM element.
  44865. * The camera will stop reacting to that input.
  44866. * @param element Defines the element that listens to the input events.
  44867. */
  44868. detachControl(element: HTMLElement): void;
  44869. private _collisionMask;
  44870. /**
  44871. * Get the mask that the camera ignores in collision events.
  44872. */
  44873. get collisionMask(): number;
  44874. /**
  44875. * Set the mask that the camera ignores in collision events.
  44876. */
  44877. set collisionMask(mask: number);
  44878. /** @hidden */
  44879. _collideWithWorld(displacement: Vector3): void;
  44880. /** @hidden */
  44881. private _onCollisionPositionChange;
  44882. /** @hidden */
  44883. _checkInputs(): void;
  44884. /** @hidden */
  44885. _decideIfNeedsToMove(): boolean;
  44886. /** @hidden */
  44887. _updatePosition(): void;
  44888. /**
  44889. * Restore the Roll to its target value at the rate specified.
  44890. * @param rate - Higher means slower restoring.
  44891. * @hidden
  44892. */
  44893. restoreRoll(rate: number): void;
  44894. /**
  44895. * Destroy the camera and release the current resources held by it.
  44896. */
  44897. dispose(): void;
  44898. /**
  44899. * Get the current object class name.
  44900. * @returns the class name.
  44901. */
  44902. getClassName(): string;
  44903. }
  44904. }
  44905. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  44906. import { Nullable } from "babylonjs/types";
  44907. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44908. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44909. /**
  44910. * Listen to keyboard events to control the camera.
  44911. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44912. */
  44913. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44914. /**
  44915. * Defines the camera the input is attached to.
  44916. */
  44917. camera: FlyCamera;
  44918. /**
  44919. * The list of keyboard keys used to control the forward move of the camera.
  44920. */
  44921. keysForward: number[];
  44922. /**
  44923. * The list of keyboard keys used to control the backward move of the camera.
  44924. */
  44925. keysBackward: number[];
  44926. /**
  44927. * The list of keyboard keys used to control the forward move of the camera.
  44928. */
  44929. keysUp: number[];
  44930. /**
  44931. * The list of keyboard keys used to control the backward move of the camera.
  44932. */
  44933. keysDown: number[];
  44934. /**
  44935. * The list of keyboard keys used to control the right strafe move of the camera.
  44936. */
  44937. keysRight: number[];
  44938. /**
  44939. * The list of keyboard keys used to control the left strafe move of the camera.
  44940. */
  44941. keysLeft: number[];
  44942. private _keys;
  44943. private _onCanvasBlurObserver;
  44944. private _onKeyboardObserver;
  44945. private _engine;
  44946. private _scene;
  44947. /**
  44948. * Attach the input controls to a specific dom element to get the input from.
  44949. * @param element Defines the element the controls should be listened from
  44950. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44951. */
  44952. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44953. /**
  44954. * Detach the current controls from the specified dom element.
  44955. * @param element Defines the element to stop listening the inputs from
  44956. */
  44957. detachControl(element: Nullable<HTMLElement>): void;
  44958. /**
  44959. * Gets the class name of the current intput.
  44960. * @returns the class name
  44961. */
  44962. getClassName(): string;
  44963. /** @hidden */
  44964. _onLostFocus(e: FocusEvent): void;
  44965. /**
  44966. * Get the friendly name associated with the input class.
  44967. * @returns the input friendly name
  44968. */
  44969. getSimpleName(): string;
  44970. /**
  44971. * Update the current camera state depending on the inputs that have been used this frame.
  44972. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44973. */
  44974. checkInputs(): void;
  44975. }
  44976. }
  44977. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  44978. import { Nullable } from "babylonjs/types";
  44979. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44980. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44981. /**
  44982. * Manage the mouse wheel inputs to control a follow camera.
  44983. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44984. */
  44985. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44986. /**
  44987. * Defines the camera the input is attached to.
  44988. */
  44989. camera: FollowCamera;
  44990. /**
  44991. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44992. */
  44993. axisControlRadius: boolean;
  44994. /**
  44995. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44996. */
  44997. axisControlHeight: boolean;
  44998. /**
  44999. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  45000. */
  45001. axisControlRotation: boolean;
  45002. /**
  45003. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  45004. * relation to mouseWheel events.
  45005. */
  45006. wheelPrecision: number;
  45007. /**
  45008. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  45009. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  45010. */
  45011. wheelDeltaPercentage: number;
  45012. private _wheel;
  45013. private _observer;
  45014. /**
  45015. * Attach the input controls to a specific dom element to get the input from.
  45016. * @param element Defines the element the controls should be listened from
  45017. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45018. */
  45019. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45020. /**
  45021. * Detach the current controls from the specified dom element.
  45022. * @param element Defines the element to stop listening the inputs from
  45023. */
  45024. detachControl(element: Nullable<HTMLElement>): void;
  45025. /**
  45026. * Gets the class name of the current intput.
  45027. * @returns the class name
  45028. */
  45029. getClassName(): string;
  45030. /**
  45031. * Get the friendly name associated with the input class.
  45032. * @returns the input friendly name
  45033. */
  45034. getSimpleName(): string;
  45035. }
  45036. }
  45037. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  45038. import { Nullable } from "babylonjs/types";
  45039. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45040. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  45041. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  45042. /**
  45043. * Manage the pointers inputs to control an follow camera.
  45044. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45045. */
  45046. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  45047. /**
  45048. * Defines the camera the input is attached to.
  45049. */
  45050. camera: FollowCamera;
  45051. /**
  45052. * Gets the class name of the current input.
  45053. * @returns the class name
  45054. */
  45055. getClassName(): string;
  45056. /**
  45057. * Defines the pointer angular sensibility along the X axis or how fast is
  45058. * the camera rotating.
  45059. * A negative number will reverse the axis direction.
  45060. */
  45061. angularSensibilityX: number;
  45062. /**
  45063. * Defines the pointer angular sensibility along the Y axis or how fast is
  45064. * the camera rotating.
  45065. * A negative number will reverse the axis direction.
  45066. */
  45067. angularSensibilityY: number;
  45068. /**
  45069. * Defines the pointer pinch precision or how fast is the camera zooming.
  45070. * A negative number will reverse the axis direction.
  45071. */
  45072. pinchPrecision: number;
  45073. /**
  45074. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45075. * from 0.
  45076. * It defines the percentage of current camera.radius to use as delta when
  45077. * pinch zoom is used.
  45078. */
  45079. pinchDeltaPercentage: number;
  45080. /**
  45081. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  45082. */
  45083. axisXControlRadius: boolean;
  45084. /**
  45085. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  45086. */
  45087. axisXControlHeight: boolean;
  45088. /**
  45089. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  45090. */
  45091. axisXControlRotation: boolean;
  45092. /**
  45093. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  45094. */
  45095. axisYControlRadius: boolean;
  45096. /**
  45097. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  45098. */
  45099. axisYControlHeight: boolean;
  45100. /**
  45101. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  45102. */
  45103. axisYControlRotation: boolean;
  45104. /**
  45105. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  45106. */
  45107. axisPinchControlRadius: boolean;
  45108. /**
  45109. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  45110. */
  45111. axisPinchControlHeight: boolean;
  45112. /**
  45113. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  45114. */
  45115. axisPinchControlRotation: boolean;
  45116. /**
  45117. * Log error messages if basic misconfiguration has occurred.
  45118. */
  45119. warningEnable: boolean;
  45120. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45121. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45122. private _warningCounter;
  45123. private _warning;
  45124. }
  45125. }
  45126. declare module "babylonjs/Cameras/followCameraInputsManager" {
  45127. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45128. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45129. /**
  45130. * Default Inputs manager for the FollowCamera.
  45131. * It groups all the default supported inputs for ease of use.
  45132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45133. */
  45134. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  45135. /**
  45136. * Instantiates a new FollowCameraInputsManager.
  45137. * @param camera Defines the camera the inputs belong to
  45138. */
  45139. constructor(camera: FollowCamera);
  45140. /**
  45141. * Add keyboard input support to the input manager.
  45142. * @returns the current input manager
  45143. */
  45144. addKeyboard(): FollowCameraInputsManager;
  45145. /**
  45146. * Add mouse wheel input support to the input manager.
  45147. * @returns the current input manager
  45148. */
  45149. addMouseWheel(): FollowCameraInputsManager;
  45150. /**
  45151. * Add pointers input support to the input manager.
  45152. * @returns the current input manager
  45153. */
  45154. addPointers(): FollowCameraInputsManager;
  45155. /**
  45156. * Add orientation input support to the input manager.
  45157. * @returns the current input manager
  45158. */
  45159. addVRDeviceOrientation(): FollowCameraInputsManager;
  45160. }
  45161. }
  45162. declare module "babylonjs/Cameras/followCamera" {
  45163. import { Nullable } from "babylonjs/types";
  45164. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45165. import { Scene } from "babylonjs/scene";
  45166. import { Vector3 } from "babylonjs/Maths/math.vector";
  45167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45168. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  45169. /**
  45170. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  45171. * an arc rotate version arcFollowCamera are available.
  45172. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45173. */
  45174. export class FollowCamera extends TargetCamera {
  45175. /**
  45176. * Distance the follow camera should follow an object at
  45177. */
  45178. radius: number;
  45179. /**
  45180. * Minimum allowed distance of the camera to the axis of rotation
  45181. * (The camera can not get closer).
  45182. * This can help limiting how the Camera is able to move in the scene.
  45183. */
  45184. lowerRadiusLimit: Nullable<number>;
  45185. /**
  45186. * Maximum allowed distance of the camera to the axis of rotation
  45187. * (The camera can not get further).
  45188. * This can help limiting how the Camera is able to move in the scene.
  45189. */
  45190. upperRadiusLimit: Nullable<number>;
  45191. /**
  45192. * Define a rotation offset between the camera and the object it follows
  45193. */
  45194. rotationOffset: number;
  45195. /**
  45196. * Minimum allowed angle to camera position relative to target object.
  45197. * This can help limiting how the Camera is able to move in the scene.
  45198. */
  45199. lowerRotationOffsetLimit: Nullable<number>;
  45200. /**
  45201. * Maximum allowed angle to camera position relative to target object.
  45202. * This can help limiting how the Camera is able to move in the scene.
  45203. */
  45204. upperRotationOffsetLimit: Nullable<number>;
  45205. /**
  45206. * Define a height offset between the camera and the object it follows.
  45207. * It can help following an object from the top (like a car chaing a plane)
  45208. */
  45209. heightOffset: number;
  45210. /**
  45211. * Minimum allowed height of camera position relative to target object.
  45212. * This can help limiting how the Camera is able to move in the scene.
  45213. */
  45214. lowerHeightOffsetLimit: Nullable<number>;
  45215. /**
  45216. * Maximum allowed height of camera position relative to target object.
  45217. * This can help limiting how the Camera is able to move in the scene.
  45218. */
  45219. upperHeightOffsetLimit: Nullable<number>;
  45220. /**
  45221. * Define how fast the camera can accelerate to follow it s target.
  45222. */
  45223. cameraAcceleration: number;
  45224. /**
  45225. * Define the speed limit of the camera following an object.
  45226. */
  45227. maxCameraSpeed: number;
  45228. /**
  45229. * Define the target of the camera.
  45230. */
  45231. lockedTarget: Nullable<AbstractMesh>;
  45232. /**
  45233. * Defines the input associated with the camera.
  45234. */
  45235. inputs: FollowCameraInputsManager;
  45236. /**
  45237. * Instantiates the follow camera.
  45238. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45239. * @param name Define the name of the camera in the scene
  45240. * @param position Define the position of the camera
  45241. * @param scene Define the scene the camera belong to
  45242. * @param lockedTarget Define the target of the camera
  45243. */
  45244. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  45245. private _follow;
  45246. /**
  45247. * Attached controls to the current camera.
  45248. * @param element Defines the element the controls should be listened from
  45249. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45250. */
  45251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45252. /**
  45253. * Detach the current controls from the camera.
  45254. * The camera will stop reacting to inputs.
  45255. * @param element Defines the element to stop listening the inputs from
  45256. */
  45257. detachControl(element: HTMLElement): void;
  45258. /** @hidden */
  45259. _checkInputs(): void;
  45260. private _checkLimits;
  45261. /**
  45262. * Gets the camera class name.
  45263. * @returns the class name
  45264. */
  45265. getClassName(): string;
  45266. }
  45267. /**
  45268. * Arc Rotate version of the follow camera.
  45269. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  45270. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45271. */
  45272. export class ArcFollowCamera extends TargetCamera {
  45273. /** The longitudinal angle of the camera */
  45274. alpha: number;
  45275. /** The latitudinal angle of the camera */
  45276. beta: number;
  45277. /** The radius of the camera from its target */
  45278. radius: number;
  45279. /** Define the camera target (the mesh it should follow) */
  45280. target: Nullable<AbstractMesh>;
  45281. private _cartesianCoordinates;
  45282. /**
  45283. * Instantiates a new ArcFollowCamera
  45284. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45285. * @param name Define the name of the camera
  45286. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  45287. * @param beta Define the rotation angle of the camera around the elevation axis
  45288. * @param radius Define the radius of the camera from its target point
  45289. * @param target Define the target of the camera
  45290. * @param scene Define the scene the camera belongs to
  45291. */
  45292. constructor(name: string,
  45293. /** The longitudinal angle of the camera */
  45294. alpha: number,
  45295. /** The latitudinal angle of the camera */
  45296. beta: number,
  45297. /** The radius of the camera from its target */
  45298. radius: number,
  45299. /** Define the camera target (the mesh it should follow) */
  45300. target: Nullable<AbstractMesh>, scene: Scene);
  45301. private _follow;
  45302. /** @hidden */
  45303. _checkInputs(): void;
  45304. /**
  45305. * Returns the class name of the object.
  45306. * It is mostly used internally for serialization purposes.
  45307. */
  45308. getClassName(): string;
  45309. }
  45310. }
  45311. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  45312. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45313. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45314. import { Nullable } from "babylonjs/types";
  45315. /**
  45316. * Manage the keyboard inputs to control the movement of a follow camera.
  45317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45318. */
  45319. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  45320. /**
  45321. * Defines the camera the input is attached to.
  45322. */
  45323. camera: FollowCamera;
  45324. /**
  45325. * Defines the list of key codes associated with the up action (increase heightOffset)
  45326. */
  45327. keysHeightOffsetIncr: number[];
  45328. /**
  45329. * Defines the list of key codes associated with the down action (decrease heightOffset)
  45330. */
  45331. keysHeightOffsetDecr: number[];
  45332. /**
  45333. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  45334. */
  45335. keysHeightOffsetModifierAlt: boolean;
  45336. /**
  45337. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  45338. */
  45339. keysHeightOffsetModifierCtrl: boolean;
  45340. /**
  45341. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  45342. */
  45343. keysHeightOffsetModifierShift: boolean;
  45344. /**
  45345. * Defines the list of key codes associated with the left action (increase rotationOffset)
  45346. */
  45347. keysRotationOffsetIncr: number[];
  45348. /**
  45349. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  45350. */
  45351. keysRotationOffsetDecr: number[];
  45352. /**
  45353. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  45354. */
  45355. keysRotationOffsetModifierAlt: boolean;
  45356. /**
  45357. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  45358. */
  45359. keysRotationOffsetModifierCtrl: boolean;
  45360. /**
  45361. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  45362. */
  45363. keysRotationOffsetModifierShift: boolean;
  45364. /**
  45365. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  45366. */
  45367. keysRadiusIncr: number[];
  45368. /**
  45369. * Defines the list of key codes associated with the zoom-out action (increase radius)
  45370. */
  45371. keysRadiusDecr: number[];
  45372. /**
  45373. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  45374. */
  45375. keysRadiusModifierAlt: boolean;
  45376. /**
  45377. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  45378. */
  45379. keysRadiusModifierCtrl: boolean;
  45380. /**
  45381. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  45382. */
  45383. keysRadiusModifierShift: boolean;
  45384. /**
  45385. * Defines the rate of change of heightOffset.
  45386. */
  45387. heightSensibility: number;
  45388. /**
  45389. * Defines the rate of change of rotationOffset.
  45390. */
  45391. rotationSensibility: number;
  45392. /**
  45393. * Defines the rate of change of radius.
  45394. */
  45395. radiusSensibility: number;
  45396. private _keys;
  45397. private _ctrlPressed;
  45398. private _altPressed;
  45399. private _shiftPressed;
  45400. private _onCanvasBlurObserver;
  45401. private _onKeyboardObserver;
  45402. private _engine;
  45403. private _scene;
  45404. /**
  45405. * Attach the input controls to a specific dom element to get the input from.
  45406. * @param element Defines the element the controls should be listened from
  45407. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45408. */
  45409. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45410. /**
  45411. * Detach the current controls from the specified dom element.
  45412. * @param element Defines the element to stop listening the inputs from
  45413. */
  45414. detachControl(element: Nullable<HTMLElement>): void;
  45415. /**
  45416. * Update the current camera state depending on the inputs that have been used this frame.
  45417. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45418. */
  45419. checkInputs(): void;
  45420. /**
  45421. * Gets the class name of the current input.
  45422. * @returns the class name
  45423. */
  45424. getClassName(): string;
  45425. /**
  45426. * Get the friendly name associated with the input class.
  45427. * @returns the input friendly name
  45428. */
  45429. getSimpleName(): string;
  45430. /**
  45431. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45432. * allow modification of the heightOffset value.
  45433. */
  45434. private _modifierHeightOffset;
  45435. /**
  45436. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45437. * allow modification of the rotationOffset value.
  45438. */
  45439. private _modifierRotationOffset;
  45440. /**
  45441. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45442. * allow modification of the radius value.
  45443. */
  45444. private _modifierRadius;
  45445. }
  45446. }
  45447. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  45448. import { Nullable } from "babylonjs/types";
  45449. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45450. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45451. import { Observable } from "babylonjs/Misc/observable";
  45452. module "babylonjs/Cameras/freeCameraInputsManager" {
  45453. interface FreeCameraInputsManager {
  45454. /**
  45455. * @hidden
  45456. */
  45457. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  45458. /**
  45459. * Add orientation input support to the input manager.
  45460. * @returns the current input manager
  45461. */
  45462. addDeviceOrientation(): FreeCameraInputsManager;
  45463. }
  45464. }
  45465. /**
  45466. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45467. * Screen rotation is taken into account.
  45468. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45469. */
  45470. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45471. private _camera;
  45472. private _screenOrientationAngle;
  45473. private _constantTranform;
  45474. private _screenQuaternion;
  45475. private _alpha;
  45476. private _beta;
  45477. private _gamma;
  45478. /**
  45479. * Can be used to detect if a device orientation sensor is available on a device
  45480. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45481. * @returns a promise that will resolve on orientation change
  45482. */
  45483. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45484. /**
  45485. * @hidden
  45486. */
  45487. _onDeviceOrientationChangedObservable: Observable<void>;
  45488. /**
  45489. * Instantiates a new input
  45490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45491. */
  45492. constructor();
  45493. /**
  45494. * Define the camera controlled by the input.
  45495. */
  45496. get camera(): FreeCamera;
  45497. set camera(camera: FreeCamera);
  45498. /**
  45499. * Attach the input controls to a specific dom element to get the input from.
  45500. * @param element Defines the element the controls should be listened from
  45501. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45502. */
  45503. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45504. private _orientationChanged;
  45505. private _deviceOrientation;
  45506. /**
  45507. * Detach the current controls from the specified dom element.
  45508. * @param element Defines the element to stop listening the inputs from
  45509. */
  45510. detachControl(element: Nullable<HTMLElement>): void;
  45511. /**
  45512. * Update the current camera state depending on the inputs that have been used this frame.
  45513. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45514. */
  45515. checkInputs(): void;
  45516. /**
  45517. * Gets the class name of the current intput.
  45518. * @returns the class name
  45519. */
  45520. getClassName(): string;
  45521. /**
  45522. * Get the friendly name associated with the input class.
  45523. * @returns the input friendly name
  45524. */
  45525. getSimpleName(): string;
  45526. }
  45527. }
  45528. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  45529. import { Nullable } from "babylonjs/types";
  45530. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45531. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45532. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45533. /**
  45534. * Manage the gamepad inputs to control a free camera.
  45535. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45536. */
  45537. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45538. /**
  45539. * Define the camera the input is attached to.
  45540. */
  45541. camera: FreeCamera;
  45542. /**
  45543. * Define the Gamepad controlling the input
  45544. */
  45545. gamepad: Nullable<Gamepad>;
  45546. /**
  45547. * Defines the gamepad rotation sensiblity.
  45548. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45549. */
  45550. gamepadAngularSensibility: number;
  45551. /**
  45552. * Defines the gamepad move sensiblity.
  45553. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45554. */
  45555. gamepadMoveSensibility: number;
  45556. private _yAxisScale;
  45557. /**
  45558. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45559. */
  45560. get invertYAxis(): boolean;
  45561. set invertYAxis(value: boolean);
  45562. private _onGamepadConnectedObserver;
  45563. private _onGamepadDisconnectedObserver;
  45564. private _cameraTransform;
  45565. private _deltaTransform;
  45566. private _vector3;
  45567. private _vector2;
  45568. /**
  45569. * Attach the input controls to a specific dom element to get the input from.
  45570. * @param element Defines the element the controls should be listened from
  45571. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45572. */
  45573. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45574. /**
  45575. * Detach the current controls from the specified dom element.
  45576. * @param element Defines the element to stop listening the inputs from
  45577. */
  45578. detachControl(element: Nullable<HTMLElement>): void;
  45579. /**
  45580. * Update the current camera state depending on the inputs that have been used this frame.
  45581. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45582. */
  45583. checkInputs(): void;
  45584. /**
  45585. * Gets the class name of the current intput.
  45586. * @returns the class name
  45587. */
  45588. getClassName(): string;
  45589. /**
  45590. * Get the friendly name associated with the input class.
  45591. * @returns the input friendly name
  45592. */
  45593. getSimpleName(): string;
  45594. }
  45595. }
  45596. declare module "babylonjs/Misc/virtualJoystick" {
  45597. import { Nullable } from "babylonjs/types";
  45598. import { Vector3 } from "babylonjs/Maths/math.vector";
  45599. /**
  45600. * Defines the potential axis of a Joystick
  45601. */
  45602. export enum JoystickAxis {
  45603. /** X axis */
  45604. X = 0,
  45605. /** Y axis */
  45606. Y = 1,
  45607. /** Z axis */
  45608. Z = 2
  45609. }
  45610. /**
  45611. * Class used to define virtual joystick (used in touch mode)
  45612. */
  45613. export class VirtualJoystick {
  45614. /**
  45615. * Gets or sets a boolean indicating that left and right values must be inverted
  45616. */
  45617. reverseLeftRight: boolean;
  45618. /**
  45619. * Gets or sets a boolean indicating that up and down values must be inverted
  45620. */
  45621. reverseUpDown: boolean;
  45622. /**
  45623. * Gets the offset value for the position (ie. the change of the position value)
  45624. */
  45625. deltaPosition: Vector3;
  45626. /**
  45627. * Gets a boolean indicating if the virtual joystick was pressed
  45628. */
  45629. pressed: boolean;
  45630. /**
  45631. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45632. */
  45633. static Canvas: Nullable<HTMLCanvasElement>;
  45634. private static _globalJoystickIndex;
  45635. private static vjCanvasContext;
  45636. private static vjCanvasWidth;
  45637. private static vjCanvasHeight;
  45638. private static halfWidth;
  45639. private _action;
  45640. private _axisTargetedByLeftAndRight;
  45641. private _axisTargetedByUpAndDown;
  45642. private _joystickSensibility;
  45643. private _inversedSensibility;
  45644. private _joystickPointerID;
  45645. private _joystickColor;
  45646. private _joystickPointerPos;
  45647. private _joystickPreviousPointerPos;
  45648. private _joystickPointerStartPos;
  45649. private _deltaJoystickVector;
  45650. private _leftJoystick;
  45651. private _touches;
  45652. private _onPointerDownHandlerRef;
  45653. private _onPointerMoveHandlerRef;
  45654. private _onPointerUpHandlerRef;
  45655. private _onResize;
  45656. /**
  45657. * Creates a new virtual joystick
  45658. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45659. */
  45660. constructor(leftJoystick?: boolean);
  45661. /**
  45662. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45663. * @param newJoystickSensibility defines the new sensibility
  45664. */
  45665. setJoystickSensibility(newJoystickSensibility: number): void;
  45666. private _onPointerDown;
  45667. private _onPointerMove;
  45668. private _onPointerUp;
  45669. /**
  45670. * Change the color of the virtual joystick
  45671. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45672. */
  45673. setJoystickColor(newColor: string): void;
  45674. /**
  45675. * Defines a callback to call when the joystick is touched
  45676. * @param action defines the callback
  45677. */
  45678. setActionOnTouch(action: () => any): void;
  45679. /**
  45680. * Defines which axis you'd like to control for left & right
  45681. * @param axis defines the axis to use
  45682. */
  45683. setAxisForLeftRight(axis: JoystickAxis): void;
  45684. /**
  45685. * Defines which axis you'd like to control for up & down
  45686. * @param axis defines the axis to use
  45687. */
  45688. setAxisForUpDown(axis: JoystickAxis): void;
  45689. private _drawVirtualJoystick;
  45690. /**
  45691. * Release internal HTML canvas
  45692. */
  45693. releaseCanvas(): void;
  45694. }
  45695. }
  45696. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  45697. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  45698. import { Nullable } from "babylonjs/types";
  45699. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45700. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45701. module "babylonjs/Cameras/freeCameraInputsManager" {
  45702. interface FreeCameraInputsManager {
  45703. /**
  45704. * Add virtual joystick input support to the input manager.
  45705. * @returns the current input manager
  45706. */
  45707. addVirtualJoystick(): FreeCameraInputsManager;
  45708. }
  45709. }
  45710. /**
  45711. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45712. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45713. */
  45714. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45715. /**
  45716. * Defines the camera the input is attached to.
  45717. */
  45718. camera: FreeCamera;
  45719. private _leftjoystick;
  45720. private _rightjoystick;
  45721. /**
  45722. * Gets the left stick of the virtual joystick.
  45723. * @returns The virtual Joystick
  45724. */
  45725. getLeftJoystick(): VirtualJoystick;
  45726. /**
  45727. * Gets the right stick of the virtual joystick.
  45728. * @returns The virtual Joystick
  45729. */
  45730. getRightJoystick(): VirtualJoystick;
  45731. /**
  45732. * Update the current camera state depending on the inputs that have been used this frame.
  45733. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45734. */
  45735. checkInputs(): void;
  45736. /**
  45737. * Attach the input controls to a specific dom element to get the input from.
  45738. * @param element Defines the element the controls should be listened from
  45739. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45740. */
  45741. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45742. /**
  45743. * Detach the current controls from the specified dom element.
  45744. * @param element Defines the element to stop listening the inputs from
  45745. */
  45746. detachControl(element: Nullable<HTMLElement>): void;
  45747. /**
  45748. * Gets the class name of the current intput.
  45749. * @returns the class name
  45750. */
  45751. getClassName(): string;
  45752. /**
  45753. * Get the friendly name associated with the input class.
  45754. * @returns the input friendly name
  45755. */
  45756. getSimpleName(): string;
  45757. }
  45758. }
  45759. declare module "babylonjs/Cameras/Inputs/index" {
  45760. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  45761. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  45762. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  45763. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  45764. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  45765. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  45766. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  45767. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  45768. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  45769. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  45770. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45771. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  45772. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  45773. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  45774. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  45775. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  45776. }
  45777. declare module "babylonjs/Cameras/touchCamera" {
  45778. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45779. import { Scene } from "babylonjs/scene";
  45780. import { Vector3 } from "babylonjs/Maths/math.vector";
  45781. /**
  45782. * This represents a FPS type of camera controlled by touch.
  45783. * This is like a universal camera minus the Gamepad controls.
  45784. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45785. */
  45786. export class TouchCamera extends FreeCamera {
  45787. /**
  45788. * Defines the touch sensibility for rotation.
  45789. * The higher the faster.
  45790. */
  45791. get touchAngularSensibility(): number;
  45792. set touchAngularSensibility(value: number);
  45793. /**
  45794. * Defines the touch sensibility for move.
  45795. * The higher the faster.
  45796. */
  45797. get touchMoveSensibility(): number;
  45798. set touchMoveSensibility(value: number);
  45799. /**
  45800. * Instantiates a new touch camera.
  45801. * This represents a FPS type of camera controlled by touch.
  45802. * This is like a universal camera minus the Gamepad controls.
  45803. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45804. * @param name Define the name of the camera in the scene
  45805. * @param position Define the start position of the camera in the scene
  45806. * @param scene Define the scene the camera belongs to
  45807. */
  45808. constructor(name: string, position: Vector3, scene: Scene);
  45809. /**
  45810. * Gets the current object class name.
  45811. * @return the class name
  45812. */
  45813. getClassName(): string;
  45814. /** @hidden */
  45815. _setupInputs(): void;
  45816. }
  45817. }
  45818. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  45819. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45820. import { Scene } from "babylonjs/scene";
  45821. import { Vector3 } from "babylonjs/Maths/math.vector";
  45822. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45823. import { Axis } from "babylonjs/Maths/math.axis";
  45824. /**
  45825. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45826. * being tilted forward or back and left or right.
  45827. */
  45828. export class DeviceOrientationCamera extends FreeCamera {
  45829. private _initialQuaternion;
  45830. private _quaternionCache;
  45831. private _tmpDragQuaternion;
  45832. private _disablePointerInputWhenUsingDeviceOrientation;
  45833. /**
  45834. * Creates a new device orientation camera
  45835. * @param name The name of the camera
  45836. * @param position The start position camera
  45837. * @param scene The scene the camera belongs to
  45838. */
  45839. constructor(name: string, position: Vector3, scene: Scene);
  45840. /**
  45841. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45842. */
  45843. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45844. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45845. private _dragFactor;
  45846. /**
  45847. * Enabled turning on the y axis when the orientation sensor is active
  45848. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45849. */
  45850. enableHorizontalDragging(dragFactor?: number): void;
  45851. /**
  45852. * Gets the current instance class name ("DeviceOrientationCamera").
  45853. * This helps avoiding instanceof at run time.
  45854. * @returns the class name
  45855. */
  45856. getClassName(): string;
  45857. /**
  45858. * @hidden
  45859. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45860. */
  45861. _checkInputs(): void;
  45862. /**
  45863. * Reset the camera to its default orientation on the specified axis only.
  45864. * @param axis The axis to reset
  45865. */
  45866. resetToCurrentRotation(axis?: Axis): void;
  45867. }
  45868. }
  45869. declare module "babylonjs/Gamepads/xboxGamepad" {
  45870. import { Observable } from "babylonjs/Misc/observable";
  45871. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45872. /**
  45873. * Defines supported buttons for XBox360 compatible gamepads
  45874. */
  45875. export enum Xbox360Button {
  45876. /** A */
  45877. A = 0,
  45878. /** B */
  45879. B = 1,
  45880. /** X */
  45881. X = 2,
  45882. /** Y */
  45883. Y = 3,
  45884. /** Left button */
  45885. LB = 4,
  45886. /** Right button */
  45887. RB = 5,
  45888. /** Back */
  45889. Back = 8,
  45890. /** Start */
  45891. Start = 9,
  45892. /** Left stick */
  45893. LeftStick = 10,
  45894. /** Right stick */
  45895. RightStick = 11
  45896. }
  45897. /** Defines values for XBox360 DPad */
  45898. export enum Xbox360Dpad {
  45899. /** Up */
  45900. Up = 12,
  45901. /** Down */
  45902. Down = 13,
  45903. /** Left */
  45904. Left = 14,
  45905. /** Right */
  45906. Right = 15
  45907. }
  45908. /**
  45909. * Defines a XBox360 gamepad
  45910. */
  45911. export class Xbox360Pad extends Gamepad {
  45912. private _leftTrigger;
  45913. private _rightTrigger;
  45914. private _onlefttriggerchanged;
  45915. private _onrighttriggerchanged;
  45916. private _onbuttondown;
  45917. private _onbuttonup;
  45918. private _ondpaddown;
  45919. private _ondpadup;
  45920. /** Observable raised when a button is pressed */
  45921. onButtonDownObservable: Observable<Xbox360Button>;
  45922. /** Observable raised when a button is released */
  45923. onButtonUpObservable: Observable<Xbox360Button>;
  45924. /** Observable raised when a pad is pressed */
  45925. onPadDownObservable: Observable<Xbox360Dpad>;
  45926. /** Observable raised when a pad is released */
  45927. onPadUpObservable: Observable<Xbox360Dpad>;
  45928. private _buttonA;
  45929. private _buttonB;
  45930. private _buttonX;
  45931. private _buttonY;
  45932. private _buttonBack;
  45933. private _buttonStart;
  45934. private _buttonLB;
  45935. private _buttonRB;
  45936. private _buttonLeftStick;
  45937. private _buttonRightStick;
  45938. private _dPadUp;
  45939. private _dPadDown;
  45940. private _dPadLeft;
  45941. private _dPadRight;
  45942. private _isXboxOnePad;
  45943. /**
  45944. * Creates a new XBox360 gamepad object
  45945. * @param id defines the id of this gamepad
  45946. * @param index defines its index
  45947. * @param gamepad defines the internal HTML gamepad object
  45948. * @param xboxOne defines if it is a XBox One gamepad
  45949. */
  45950. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45951. /**
  45952. * Defines the callback to call when left trigger is pressed
  45953. * @param callback defines the callback to use
  45954. */
  45955. onlefttriggerchanged(callback: (value: number) => void): void;
  45956. /**
  45957. * Defines the callback to call when right trigger is pressed
  45958. * @param callback defines the callback to use
  45959. */
  45960. onrighttriggerchanged(callback: (value: number) => void): void;
  45961. /**
  45962. * Gets the left trigger value
  45963. */
  45964. get leftTrigger(): number;
  45965. /**
  45966. * Sets the left trigger value
  45967. */
  45968. set leftTrigger(newValue: number);
  45969. /**
  45970. * Gets the right trigger value
  45971. */
  45972. get rightTrigger(): number;
  45973. /**
  45974. * Sets the right trigger value
  45975. */
  45976. set rightTrigger(newValue: number);
  45977. /**
  45978. * Defines the callback to call when a button is pressed
  45979. * @param callback defines the callback to use
  45980. */
  45981. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45982. /**
  45983. * Defines the callback to call when a button is released
  45984. * @param callback defines the callback to use
  45985. */
  45986. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45987. /**
  45988. * Defines the callback to call when a pad is pressed
  45989. * @param callback defines the callback to use
  45990. */
  45991. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45992. /**
  45993. * Defines the callback to call when a pad is released
  45994. * @param callback defines the callback to use
  45995. */
  45996. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45997. private _setButtonValue;
  45998. private _setDPadValue;
  45999. /**
  46000. * Gets the value of the `A` button
  46001. */
  46002. get buttonA(): number;
  46003. /**
  46004. * Sets the value of the `A` button
  46005. */
  46006. set buttonA(value: number);
  46007. /**
  46008. * Gets the value of the `B` button
  46009. */
  46010. get buttonB(): number;
  46011. /**
  46012. * Sets the value of the `B` button
  46013. */
  46014. set buttonB(value: number);
  46015. /**
  46016. * Gets the value of the `X` button
  46017. */
  46018. get buttonX(): number;
  46019. /**
  46020. * Sets the value of the `X` button
  46021. */
  46022. set buttonX(value: number);
  46023. /**
  46024. * Gets the value of the `Y` button
  46025. */
  46026. get buttonY(): number;
  46027. /**
  46028. * Sets the value of the `Y` button
  46029. */
  46030. set buttonY(value: number);
  46031. /**
  46032. * Gets the value of the `Start` button
  46033. */
  46034. get buttonStart(): number;
  46035. /**
  46036. * Sets the value of the `Start` button
  46037. */
  46038. set buttonStart(value: number);
  46039. /**
  46040. * Gets the value of the `Back` button
  46041. */
  46042. get buttonBack(): number;
  46043. /**
  46044. * Sets the value of the `Back` button
  46045. */
  46046. set buttonBack(value: number);
  46047. /**
  46048. * Gets the value of the `Left` button
  46049. */
  46050. get buttonLB(): number;
  46051. /**
  46052. * Sets the value of the `Left` button
  46053. */
  46054. set buttonLB(value: number);
  46055. /**
  46056. * Gets the value of the `Right` button
  46057. */
  46058. get buttonRB(): number;
  46059. /**
  46060. * Sets the value of the `Right` button
  46061. */
  46062. set buttonRB(value: number);
  46063. /**
  46064. * Gets the value of the Left joystick
  46065. */
  46066. get buttonLeftStick(): number;
  46067. /**
  46068. * Sets the value of the Left joystick
  46069. */
  46070. set buttonLeftStick(value: number);
  46071. /**
  46072. * Gets the value of the Right joystick
  46073. */
  46074. get buttonRightStick(): number;
  46075. /**
  46076. * Sets the value of the Right joystick
  46077. */
  46078. set buttonRightStick(value: number);
  46079. /**
  46080. * Gets the value of D-pad up
  46081. */
  46082. get dPadUp(): number;
  46083. /**
  46084. * Sets the value of D-pad up
  46085. */
  46086. set dPadUp(value: number);
  46087. /**
  46088. * Gets the value of D-pad down
  46089. */
  46090. get dPadDown(): number;
  46091. /**
  46092. * Sets the value of D-pad down
  46093. */
  46094. set dPadDown(value: number);
  46095. /**
  46096. * Gets the value of D-pad left
  46097. */
  46098. get dPadLeft(): number;
  46099. /**
  46100. * Sets the value of D-pad left
  46101. */
  46102. set dPadLeft(value: number);
  46103. /**
  46104. * Gets the value of D-pad right
  46105. */
  46106. get dPadRight(): number;
  46107. /**
  46108. * Sets the value of D-pad right
  46109. */
  46110. set dPadRight(value: number);
  46111. /**
  46112. * Force the gamepad to synchronize with device values
  46113. */
  46114. update(): void;
  46115. /**
  46116. * Disposes the gamepad
  46117. */
  46118. dispose(): void;
  46119. }
  46120. }
  46121. declare module "babylonjs/Gamepads/dualShockGamepad" {
  46122. import { Observable } from "babylonjs/Misc/observable";
  46123. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46124. /**
  46125. * Defines supported buttons for DualShock compatible gamepads
  46126. */
  46127. export enum DualShockButton {
  46128. /** Cross */
  46129. Cross = 0,
  46130. /** Circle */
  46131. Circle = 1,
  46132. /** Square */
  46133. Square = 2,
  46134. /** Triangle */
  46135. Triangle = 3,
  46136. /** L1 */
  46137. L1 = 4,
  46138. /** R1 */
  46139. R1 = 5,
  46140. /** Share */
  46141. Share = 8,
  46142. /** Options */
  46143. Options = 9,
  46144. /** Left stick */
  46145. LeftStick = 10,
  46146. /** Right stick */
  46147. RightStick = 11
  46148. }
  46149. /** Defines values for DualShock DPad */
  46150. export enum DualShockDpad {
  46151. /** Up */
  46152. Up = 12,
  46153. /** Down */
  46154. Down = 13,
  46155. /** Left */
  46156. Left = 14,
  46157. /** Right */
  46158. Right = 15
  46159. }
  46160. /**
  46161. * Defines a DualShock gamepad
  46162. */
  46163. export class DualShockPad extends Gamepad {
  46164. private _leftTrigger;
  46165. private _rightTrigger;
  46166. private _onlefttriggerchanged;
  46167. private _onrighttriggerchanged;
  46168. private _onbuttondown;
  46169. private _onbuttonup;
  46170. private _ondpaddown;
  46171. private _ondpadup;
  46172. /** Observable raised when a button is pressed */
  46173. onButtonDownObservable: Observable<DualShockButton>;
  46174. /** Observable raised when a button is released */
  46175. onButtonUpObservable: Observable<DualShockButton>;
  46176. /** Observable raised when a pad is pressed */
  46177. onPadDownObservable: Observable<DualShockDpad>;
  46178. /** Observable raised when a pad is released */
  46179. onPadUpObservable: Observable<DualShockDpad>;
  46180. private _buttonCross;
  46181. private _buttonCircle;
  46182. private _buttonSquare;
  46183. private _buttonTriangle;
  46184. private _buttonShare;
  46185. private _buttonOptions;
  46186. private _buttonL1;
  46187. private _buttonR1;
  46188. private _buttonLeftStick;
  46189. private _buttonRightStick;
  46190. private _dPadUp;
  46191. private _dPadDown;
  46192. private _dPadLeft;
  46193. private _dPadRight;
  46194. /**
  46195. * Creates a new DualShock gamepad object
  46196. * @param id defines the id of this gamepad
  46197. * @param index defines its index
  46198. * @param gamepad defines the internal HTML gamepad object
  46199. */
  46200. constructor(id: string, index: number, gamepad: any);
  46201. /**
  46202. * Defines the callback to call when left trigger is pressed
  46203. * @param callback defines the callback to use
  46204. */
  46205. onlefttriggerchanged(callback: (value: number) => void): void;
  46206. /**
  46207. * Defines the callback to call when right trigger is pressed
  46208. * @param callback defines the callback to use
  46209. */
  46210. onrighttriggerchanged(callback: (value: number) => void): void;
  46211. /**
  46212. * Gets the left trigger value
  46213. */
  46214. get leftTrigger(): number;
  46215. /**
  46216. * Sets the left trigger value
  46217. */
  46218. set leftTrigger(newValue: number);
  46219. /**
  46220. * Gets the right trigger value
  46221. */
  46222. get rightTrigger(): number;
  46223. /**
  46224. * Sets the right trigger value
  46225. */
  46226. set rightTrigger(newValue: number);
  46227. /**
  46228. * Defines the callback to call when a button is pressed
  46229. * @param callback defines the callback to use
  46230. */
  46231. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  46232. /**
  46233. * Defines the callback to call when a button is released
  46234. * @param callback defines the callback to use
  46235. */
  46236. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  46237. /**
  46238. * Defines the callback to call when a pad is pressed
  46239. * @param callback defines the callback to use
  46240. */
  46241. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  46242. /**
  46243. * Defines the callback to call when a pad is released
  46244. * @param callback defines the callback to use
  46245. */
  46246. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  46247. private _setButtonValue;
  46248. private _setDPadValue;
  46249. /**
  46250. * Gets the value of the `Cross` button
  46251. */
  46252. get buttonCross(): number;
  46253. /**
  46254. * Sets the value of the `Cross` button
  46255. */
  46256. set buttonCross(value: number);
  46257. /**
  46258. * Gets the value of the `Circle` button
  46259. */
  46260. get buttonCircle(): number;
  46261. /**
  46262. * Sets the value of the `Circle` button
  46263. */
  46264. set buttonCircle(value: number);
  46265. /**
  46266. * Gets the value of the `Square` button
  46267. */
  46268. get buttonSquare(): number;
  46269. /**
  46270. * Sets the value of the `Square` button
  46271. */
  46272. set buttonSquare(value: number);
  46273. /**
  46274. * Gets the value of the `Triangle` button
  46275. */
  46276. get buttonTriangle(): number;
  46277. /**
  46278. * Sets the value of the `Triangle` button
  46279. */
  46280. set buttonTriangle(value: number);
  46281. /**
  46282. * Gets the value of the `Options` button
  46283. */
  46284. get buttonOptions(): number;
  46285. /**
  46286. * Sets the value of the `Options` button
  46287. */
  46288. set buttonOptions(value: number);
  46289. /**
  46290. * Gets the value of the `Share` button
  46291. */
  46292. get buttonShare(): number;
  46293. /**
  46294. * Sets the value of the `Share` button
  46295. */
  46296. set buttonShare(value: number);
  46297. /**
  46298. * Gets the value of the `L1` button
  46299. */
  46300. get buttonL1(): number;
  46301. /**
  46302. * Sets the value of the `L1` button
  46303. */
  46304. set buttonL1(value: number);
  46305. /**
  46306. * Gets the value of the `R1` button
  46307. */
  46308. get buttonR1(): number;
  46309. /**
  46310. * Sets the value of the `R1` button
  46311. */
  46312. set buttonR1(value: number);
  46313. /**
  46314. * Gets the value of the Left joystick
  46315. */
  46316. get buttonLeftStick(): number;
  46317. /**
  46318. * Sets the value of the Left joystick
  46319. */
  46320. set buttonLeftStick(value: number);
  46321. /**
  46322. * Gets the value of the Right joystick
  46323. */
  46324. get buttonRightStick(): number;
  46325. /**
  46326. * Sets the value of the Right joystick
  46327. */
  46328. set buttonRightStick(value: number);
  46329. /**
  46330. * Gets the value of D-pad up
  46331. */
  46332. get dPadUp(): number;
  46333. /**
  46334. * Sets the value of D-pad up
  46335. */
  46336. set dPadUp(value: number);
  46337. /**
  46338. * Gets the value of D-pad down
  46339. */
  46340. get dPadDown(): number;
  46341. /**
  46342. * Sets the value of D-pad down
  46343. */
  46344. set dPadDown(value: number);
  46345. /**
  46346. * Gets the value of D-pad left
  46347. */
  46348. get dPadLeft(): number;
  46349. /**
  46350. * Sets the value of D-pad left
  46351. */
  46352. set dPadLeft(value: number);
  46353. /**
  46354. * Gets the value of D-pad right
  46355. */
  46356. get dPadRight(): number;
  46357. /**
  46358. * Sets the value of D-pad right
  46359. */
  46360. set dPadRight(value: number);
  46361. /**
  46362. * Force the gamepad to synchronize with device values
  46363. */
  46364. update(): void;
  46365. /**
  46366. * Disposes the gamepad
  46367. */
  46368. dispose(): void;
  46369. }
  46370. }
  46371. declare module "babylonjs/Gamepads/gamepadManager" {
  46372. import { Observable } from "babylonjs/Misc/observable";
  46373. import { Nullable } from "babylonjs/types";
  46374. import { Scene } from "babylonjs/scene";
  46375. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46376. /**
  46377. * Manager for handling gamepads
  46378. */
  46379. export class GamepadManager {
  46380. private _scene?;
  46381. private _babylonGamepads;
  46382. private _oneGamepadConnected;
  46383. /** @hidden */
  46384. _isMonitoring: boolean;
  46385. private _gamepadEventSupported;
  46386. private _gamepadSupport?;
  46387. /**
  46388. * observable to be triggered when the gamepad controller has been connected
  46389. */
  46390. onGamepadConnectedObservable: Observable<Gamepad>;
  46391. /**
  46392. * observable to be triggered when the gamepad controller has been disconnected
  46393. */
  46394. onGamepadDisconnectedObservable: Observable<Gamepad>;
  46395. private _onGamepadConnectedEvent;
  46396. private _onGamepadDisconnectedEvent;
  46397. /**
  46398. * Initializes the gamepad manager
  46399. * @param _scene BabylonJS scene
  46400. */
  46401. constructor(_scene?: Scene | undefined);
  46402. /**
  46403. * The gamepads in the game pad manager
  46404. */
  46405. get gamepads(): Gamepad[];
  46406. /**
  46407. * Get the gamepad controllers based on type
  46408. * @param type The type of gamepad controller
  46409. * @returns Nullable gamepad
  46410. */
  46411. getGamepadByType(type?: number): Nullable<Gamepad>;
  46412. /**
  46413. * Disposes the gamepad manager
  46414. */
  46415. dispose(): void;
  46416. private _addNewGamepad;
  46417. private _startMonitoringGamepads;
  46418. private _stopMonitoringGamepads;
  46419. /** @hidden */
  46420. _checkGamepadsStatus(): void;
  46421. private _updateGamepadObjects;
  46422. }
  46423. }
  46424. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  46425. import { Nullable } from "babylonjs/types";
  46426. import { Scene } from "babylonjs/scene";
  46427. import { ISceneComponent } from "babylonjs/sceneComponent";
  46428. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  46429. module "babylonjs/scene" {
  46430. interface Scene {
  46431. /** @hidden */
  46432. _gamepadManager: Nullable<GamepadManager>;
  46433. /**
  46434. * Gets the gamepad manager associated with the scene
  46435. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  46436. */
  46437. gamepadManager: GamepadManager;
  46438. }
  46439. }
  46440. module "babylonjs/Cameras/freeCameraInputsManager" {
  46441. /**
  46442. * Interface representing a free camera inputs manager
  46443. */
  46444. interface FreeCameraInputsManager {
  46445. /**
  46446. * Adds gamepad input support to the FreeCameraInputsManager.
  46447. * @returns the FreeCameraInputsManager
  46448. */
  46449. addGamepad(): FreeCameraInputsManager;
  46450. }
  46451. }
  46452. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  46453. /**
  46454. * Interface representing an arc rotate camera inputs manager
  46455. */
  46456. interface ArcRotateCameraInputsManager {
  46457. /**
  46458. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46459. * @returns the camera inputs manager
  46460. */
  46461. addGamepad(): ArcRotateCameraInputsManager;
  46462. }
  46463. }
  46464. /**
  46465. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46466. */
  46467. export class GamepadSystemSceneComponent implements ISceneComponent {
  46468. /**
  46469. * The component name helpfull to identify the component in the list of scene components.
  46470. */
  46471. readonly name: string;
  46472. /**
  46473. * The scene the component belongs to.
  46474. */
  46475. scene: Scene;
  46476. /**
  46477. * Creates a new instance of the component for the given scene
  46478. * @param scene Defines the scene to register the component in
  46479. */
  46480. constructor(scene: Scene);
  46481. /**
  46482. * Registers the component in a given scene
  46483. */
  46484. register(): void;
  46485. /**
  46486. * Rebuilds the elements related to this component in case of
  46487. * context lost for instance.
  46488. */
  46489. rebuild(): void;
  46490. /**
  46491. * Disposes the component and the associated ressources
  46492. */
  46493. dispose(): void;
  46494. private _beforeCameraUpdate;
  46495. }
  46496. }
  46497. declare module "babylonjs/Cameras/universalCamera" {
  46498. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  46499. import { Scene } from "babylonjs/scene";
  46500. import { Vector3 } from "babylonjs/Maths/math.vector";
  46501. import "babylonjs/Gamepads/gamepadSceneComponent";
  46502. /**
  46503. * 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,
  46504. * which still works and will still be found in many Playgrounds.
  46505. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46506. */
  46507. export class UniversalCamera extends TouchCamera {
  46508. /**
  46509. * Defines the gamepad rotation sensiblity.
  46510. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46511. */
  46512. get gamepadAngularSensibility(): number;
  46513. set gamepadAngularSensibility(value: number);
  46514. /**
  46515. * Defines the gamepad move sensiblity.
  46516. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46517. */
  46518. get gamepadMoveSensibility(): number;
  46519. set gamepadMoveSensibility(value: number);
  46520. /**
  46521. * 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,
  46522. * which still works and will still be found in many Playgrounds.
  46523. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46524. * @param name Define the name of the camera in the scene
  46525. * @param position Define the start position of the camera in the scene
  46526. * @param scene Define the scene the camera belongs to
  46527. */
  46528. constructor(name: string, position: Vector3, scene: Scene);
  46529. /**
  46530. * Gets the current object class name.
  46531. * @return the class name
  46532. */
  46533. getClassName(): string;
  46534. }
  46535. }
  46536. declare module "babylonjs/Cameras/gamepadCamera" {
  46537. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46538. import { Scene } from "babylonjs/scene";
  46539. import { Vector3 } from "babylonjs/Maths/math.vector";
  46540. /**
  46541. * This represents a FPS type of camera. This is only here for back compat purpose.
  46542. * Please use the UniversalCamera instead as both are identical.
  46543. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46544. */
  46545. export class GamepadCamera extends UniversalCamera {
  46546. /**
  46547. * Instantiates a new Gamepad Camera
  46548. * This represents a FPS type of camera. This is only here for back compat purpose.
  46549. * Please use the UniversalCamera instead as both are identical.
  46550. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46551. * @param name Define the name of the camera in the scene
  46552. * @param position Define the start position of the camera in the scene
  46553. * @param scene Define the scene the camera belongs to
  46554. */
  46555. constructor(name: string, position: Vector3, scene: Scene);
  46556. /**
  46557. * Gets the current object class name.
  46558. * @return the class name
  46559. */
  46560. getClassName(): string;
  46561. }
  46562. }
  46563. declare module "babylonjs/Shaders/pass.fragment" {
  46564. /** @hidden */
  46565. export var passPixelShader: {
  46566. name: string;
  46567. shader: string;
  46568. };
  46569. }
  46570. declare module "babylonjs/Shaders/passCube.fragment" {
  46571. /** @hidden */
  46572. export var passCubePixelShader: {
  46573. name: string;
  46574. shader: string;
  46575. };
  46576. }
  46577. declare module "babylonjs/PostProcesses/passPostProcess" {
  46578. import { Nullable } from "babylonjs/types";
  46579. import { Camera } from "babylonjs/Cameras/camera";
  46580. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46581. import { Engine } from "babylonjs/Engines/engine";
  46582. import "babylonjs/Shaders/pass.fragment";
  46583. import "babylonjs/Shaders/passCube.fragment";
  46584. /**
  46585. * PassPostProcess which produces an output the same as it's input
  46586. */
  46587. export class PassPostProcess extends PostProcess {
  46588. /**
  46589. * Creates the PassPostProcess
  46590. * @param name The name of the effect.
  46591. * @param options The required width/height ratio to downsize to before computing the render pass.
  46592. * @param camera The camera to apply the render pass to.
  46593. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46594. * @param engine The engine which the post process will be applied. (default: current engine)
  46595. * @param reusable If the post process can be reused on the same frame. (default: false)
  46596. * @param textureType The type of texture to be used when performing the post processing.
  46597. * @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)
  46598. */
  46599. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46600. }
  46601. /**
  46602. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46603. */
  46604. export class PassCubePostProcess extends PostProcess {
  46605. private _face;
  46606. /**
  46607. * Gets or sets the cube face to display.
  46608. * * 0 is +X
  46609. * * 1 is -X
  46610. * * 2 is +Y
  46611. * * 3 is -Y
  46612. * * 4 is +Z
  46613. * * 5 is -Z
  46614. */
  46615. get face(): number;
  46616. set face(value: number);
  46617. /**
  46618. * Creates the PassCubePostProcess
  46619. * @param name The name of the effect.
  46620. * @param options The required width/height ratio to downsize to before computing the render pass.
  46621. * @param camera The camera to apply the render pass to.
  46622. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46623. * @param engine The engine which the post process will be applied. (default: current engine)
  46624. * @param reusable If the post process can be reused on the same frame. (default: false)
  46625. * @param textureType The type of texture to be used when performing the post processing.
  46626. * @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)
  46627. */
  46628. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46629. }
  46630. }
  46631. declare module "babylonjs/Shaders/anaglyph.fragment" {
  46632. /** @hidden */
  46633. export var anaglyphPixelShader: {
  46634. name: string;
  46635. shader: string;
  46636. };
  46637. }
  46638. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  46639. import { Engine } from "babylonjs/Engines/engine";
  46640. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46641. import { Camera } from "babylonjs/Cameras/camera";
  46642. import "babylonjs/Shaders/anaglyph.fragment";
  46643. /**
  46644. * Postprocess used to generate anaglyphic rendering
  46645. */
  46646. export class AnaglyphPostProcess extends PostProcess {
  46647. private _passedProcess;
  46648. /**
  46649. * Creates a new AnaglyphPostProcess
  46650. * @param name defines postprocess name
  46651. * @param options defines creation options or target ratio scale
  46652. * @param rigCameras defines cameras using this postprocess
  46653. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46654. * @param engine defines hosting engine
  46655. * @param reusable defines if the postprocess will be reused multiple times per frame
  46656. */
  46657. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46658. }
  46659. }
  46660. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  46661. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  46662. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46663. import { Scene } from "babylonjs/scene";
  46664. import { Vector3 } from "babylonjs/Maths/math.vector";
  46665. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46666. /**
  46667. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46668. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46669. */
  46670. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46671. /**
  46672. * Creates a new AnaglyphArcRotateCamera
  46673. * @param name defines camera name
  46674. * @param alpha defines alpha angle (in radians)
  46675. * @param beta defines beta angle (in radians)
  46676. * @param radius defines radius
  46677. * @param target defines camera target
  46678. * @param interaxialDistance defines distance between each color axis
  46679. * @param scene defines the hosting scene
  46680. */
  46681. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46682. /**
  46683. * Gets camera class name
  46684. * @returns AnaglyphArcRotateCamera
  46685. */
  46686. getClassName(): string;
  46687. }
  46688. }
  46689. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  46690. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46691. import { Scene } from "babylonjs/scene";
  46692. import { Vector3 } from "babylonjs/Maths/math.vector";
  46693. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46694. /**
  46695. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46696. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46697. */
  46698. export class AnaglyphFreeCamera extends FreeCamera {
  46699. /**
  46700. * Creates a new AnaglyphFreeCamera
  46701. * @param name defines camera name
  46702. * @param position defines initial position
  46703. * @param interaxialDistance defines distance between each color axis
  46704. * @param scene defines the hosting scene
  46705. */
  46706. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46707. /**
  46708. * Gets camera class name
  46709. * @returns AnaglyphFreeCamera
  46710. */
  46711. getClassName(): string;
  46712. }
  46713. }
  46714. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  46715. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46716. import { Scene } from "babylonjs/scene";
  46717. import { Vector3 } from "babylonjs/Maths/math.vector";
  46718. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46719. /**
  46720. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46721. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46722. */
  46723. export class AnaglyphGamepadCamera extends GamepadCamera {
  46724. /**
  46725. * Creates a new AnaglyphGamepadCamera
  46726. * @param name defines camera name
  46727. * @param position defines initial position
  46728. * @param interaxialDistance defines distance between each color axis
  46729. * @param scene defines the hosting scene
  46730. */
  46731. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46732. /**
  46733. * Gets camera class name
  46734. * @returns AnaglyphGamepadCamera
  46735. */
  46736. getClassName(): string;
  46737. }
  46738. }
  46739. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  46740. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46741. import { Scene } from "babylonjs/scene";
  46742. import { Vector3 } from "babylonjs/Maths/math.vector";
  46743. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46744. /**
  46745. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46746. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46747. */
  46748. export class AnaglyphUniversalCamera extends UniversalCamera {
  46749. /**
  46750. * Creates a new AnaglyphUniversalCamera
  46751. * @param name defines camera name
  46752. * @param position defines initial position
  46753. * @param interaxialDistance defines distance between each color axis
  46754. * @param scene defines the hosting scene
  46755. */
  46756. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46757. /**
  46758. * Gets camera class name
  46759. * @returns AnaglyphUniversalCamera
  46760. */
  46761. getClassName(): string;
  46762. }
  46763. }
  46764. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  46765. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  46766. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46767. import { Scene } from "babylonjs/scene";
  46768. import { Vector3 } from "babylonjs/Maths/math.vector";
  46769. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46770. /**
  46771. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46772. * @see http://doc.babylonjs.com/features/cameras
  46773. */
  46774. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46775. /**
  46776. * Creates a new StereoscopicArcRotateCamera
  46777. * @param name defines camera name
  46778. * @param alpha defines alpha angle (in radians)
  46779. * @param beta defines beta angle (in radians)
  46780. * @param radius defines radius
  46781. * @param target defines camera target
  46782. * @param interaxialDistance defines distance between each color axis
  46783. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46784. * @param scene defines the hosting scene
  46785. */
  46786. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46787. /**
  46788. * Gets camera class name
  46789. * @returns StereoscopicArcRotateCamera
  46790. */
  46791. getClassName(): string;
  46792. }
  46793. }
  46794. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  46795. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46796. import { Scene } from "babylonjs/scene";
  46797. import { Vector3 } from "babylonjs/Maths/math.vector";
  46798. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46799. /**
  46800. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46801. * @see http://doc.babylonjs.com/features/cameras
  46802. */
  46803. export class StereoscopicFreeCamera extends FreeCamera {
  46804. /**
  46805. * Creates a new StereoscopicFreeCamera
  46806. * @param name defines camera name
  46807. * @param position defines initial position
  46808. * @param interaxialDistance defines distance between each color axis
  46809. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46810. * @param scene defines the hosting scene
  46811. */
  46812. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46813. /**
  46814. * Gets camera class name
  46815. * @returns StereoscopicFreeCamera
  46816. */
  46817. getClassName(): string;
  46818. }
  46819. }
  46820. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  46821. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46822. import { Scene } from "babylonjs/scene";
  46823. import { Vector3 } from "babylonjs/Maths/math.vector";
  46824. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46825. /**
  46826. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46827. * @see http://doc.babylonjs.com/features/cameras
  46828. */
  46829. export class StereoscopicGamepadCamera extends GamepadCamera {
  46830. /**
  46831. * Creates a new StereoscopicGamepadCamera
  46832. * @param name defines camera name
  46833. * @param position defines initial position
  46834. * @param interaxialDistance defines distance between each color axis
  46835. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46836. * @param scene defines the hosting scene
  46837. */
  46838. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46839. /**
  46840. * Gets camera class name
  46841. * @returns StereoscopicGamepadCamera
  46842. */
  46843. getClassName(): string;
  46844. }
  46845. }
  46846. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  46847. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46848. import { Scene } from "babylonjs/scene";
  46849. import { Vector3 } from "babylonjs/Maths/math.vector";
  46850. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46851. /**
  46852. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46853. * @see http://doc.babylonjs.com/features/cameras
  46854. */
  46855. export class StereoscopicUniversalCamera extends UniversalCamera {
  46856. /**
  46857. * Creates a new StereoscopicUniversalCamera
  46858. * @param name defines camera name
  46859. * @param position defines initial position
  46860. * @param interaxialDistance defines distance between each color axis
  46861. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46862. * @param scene defines the hosting scene
  46863. */
  46864. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46865. /**
  46866. * Gets camera class name
  46867. * @returns StereoscopicUniversalCamera
  46868. */
  46869. getClassName(): string;
  46870. }
  46871. }
  46872. declare module "babylonjs/Cameras/Stereoscopic/index" {
  46873. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  46874. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  46875. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  46876. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  46877. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  46878. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  46879. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  46880. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  46881. }
  46882. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  46883. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46884. import { Scene } from "babylonjs/scene";
  46885. import { Vector3 } from "babylonjs/Maths/math.vector";
  46886. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46887. /**
  46888. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46889. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46890. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46891. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46892. */
  46893. export class VirtualJoysticksCamera extends FreeCamera {
  46894. /**
  46895. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46896. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46897. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46898. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46899. * @param name Define the name of the camera in the scene
  46900. * @param position Define the start position of the camera in the scene
  46901. * @param scene Define the scene the camera belongs to
  46902. */
  46903. constructor(name: string, position: Vector3, scene: Scene);
  46904. /**
  46905. * Gets the current object class name.
  46906. * @return the class name
  46907. */
  46908. getClassName(): string;
  46909. }
  46910. }
  46911. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  46912. import { Matrix } from "babylonjs/Maths/math.vector";
  46913. /**
  46914. * This represents all the required metrics to create a VR camera.
  46915. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46916. */
  46917. export class VRCameraMetrics {
  46918. /**
  46919. * Define the horizontal resolution off the screen.
  46920. */
  46921. hResolution: number;
  46922. /**
  46923. * Define the vertical resolution off the screen.
  46924. */
  46925. vResolution: number;
  46926. /**
  46927. * Define the horizontal screen size.
  46928. */
  46929. hScreenSize: number;
  46930. /**
  46931. * Define the vertical screen size.
  46932. */
  46933. vScreenSize: number;
  46934. /**
  46935. * Define the vertical screen center position.
  46936. */
  46937. vScreenCenter: number;
  46938. /**
  46939. * Define the distance of the eyes to the screen.
  46940. */
  46941. eyeToScreenDistance: number;
  46942. /**
  46943. * Define the distance between both lenses
  46944. */
  46945. lensSeparationDistance: number;
  46946. /**
  46947. * Define the distance between both viewer's eyes.
  46948. */
  46949. interpupillaryDistance: number;
  46950. /**
  46951. * Define the distortion factor of the VR postprocess.
  46952. * Please, touch with care.
  46953. */
  46954. distortionK: number[];
  46955. /**
  46956. * Define the chromatic aberration correction factors for the VR post process.
  46957. */
  46958. chromaAbCorrection: number[];
  46959. /**
  46960. * Define the scale factor of the post process.
  46961. * The smaller the better but the slower.
  46962. */
  46963. postProcessScaleFactor: number;
  46964. /**
  46965. * Define an offset for the lens center.
  46966. */
  46967. lensCenterOffset: number;
  46968. /**
  46969. * Define if the current vr camera should compensate the distortion of the lense or not.
  46970. */
  46971. compensateDistortion: boolean;
  46972. /**
  46973. * Defines if multiview should be enabled when rendering (Default: false)
  46974. */
  46975. multiviewEnabled: boolean;
  46976. /**
  46977. * Gets the rendering aspect ratio based on the provided resolutions.
  46978. */
  46979. get aspectRatio(): number;
  46980. /**
  46981. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46982. */
  46983. get aspectRatioFov(): number;
  46984. /**
  46985. * @hidden
  46986. */
  46987. get leftHMatrix(): Matrix;
  46988. /**
  46989. * @hidden
  46990. */
  46991. get rightHMatrix(): Matrix;
  46992. /**
  46993. * @hidden
  46994. */
  46995. get leftPreViewMatrix(): Matrix;
  46996. /**
  46997. * @hidden
  46998. */
  46999. get rightPreViewMatrix(): Matrix;
  47000. /**
  47001. * Get the default VRMetrics based on the most generic setup.
  47002. * @returns the default vr metrics
  47003. */
  47004. static GetDefault(): VRCameraMetrics;
  47005. }
  47006. }
  47007. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  47008. /** @hidden */
  47009. export var vrDistortionCorrectionPixelShader: {
  47010. name: string;
  47011. shader: string;
  47012. };
  47013. }
  47014. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  47015. import { Camera } from "babylonjs/Cameras/camera";
  47016. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47017. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47018. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  47019. /**
  47020. * VRDistortionCorrectionPostProcess used for mobile VR
  47021. */
  47022. export class VRDistortionCorrectionPostProcess extends PostProcess {
  47023. private _isRightEye;
  47024. private _distortionFactors;
  47025. private _postProcessScaleFactor;
  47026. private _lensCenterOffset;
  47027. private _scaleIn;
  47028. private _scaleFactor;
  47029. private _lensCenter;
  47030. /**
  47031. * Initializes the VRDistortionCorrectionPostProcess
  47032. * @param name The name of the effect.
  47033. * @param camera The camera to apply the render pass to.
  47034. * @param isRightEye If this is for the right eye distortion
  47035. * @param vrMetrics All the required metrics for the VR camera
  47036. */
  47037. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  47038. }
  47039. }
  47040. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  47041. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  47042. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47043. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47044. import { Scene } from "babylonjs/scene";
  47045. import { Vector3 } from "babylonjs/Maths/math.vector";
  47046. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47047. import "babylonjs/Cameras/RigModes/vrRigMode";
  47048. /**
  47049. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  47050. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47051. */
  47052. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  47053. /**
  47054. * Creates a new VRDeviceOrientationArcRotateCamera
  47055. * @param name defines camera name
  47056. * @param alpha defines the camera rotation along the logitudinal axis
  47057. * @param beta defines the camera rotation along the latitudinal axis
  47058. * @param radius defines the camera distance from its target
  47059. * @param target defines the camera target
  47060. * @param scene defines the scene the camera belongs to
  47061. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47062. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47063. */
  47064. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47065. /**
  47066. * Gets camera class name
  47067. * @returns VRDeviceOrientationArcRotateCamera
  47068. */
  47069. getClassName(): string;
  47070. }
  47071. }
  47072. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  47073. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47074. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47075. import { Scene } from "babylonjs/scene";
  47076. import { Vector3 } from "babylonjs/Maths/math.vector";
  47077. import "babylonjs/Cameras/RigModes/vrRigMode";
  47078. /**
  47079. * Camera used to simulate VR rendering (based on FreeCamera)
  47080. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47081. */
  47082. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  47083. /**
  47084. * Creates a new VRDeviceOrientationFreeCamera
  47085. * @param name defines camera name
  47086. * @param position defines the start position of the camera
  47087. * @param scene defines the scene the camera belongs to
  47088. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47089. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47090. */
  47091. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47092. /**
  47093. * Gets camera class name
  47094. * @returns VRDeviceOrientationFreeCamera
  47095. */
  47096. getClassName(): string;
  47097. }
  47098. }
  47099. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  47100. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47101. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47102. import { Scene } from "babylonjs/scene";
  47103. import { Vector3 } from "babylonjs/Maths/math.vector";
  47104. import "babylonjs/Gamepads/gamepadSceneComponent";
  47105. /**
  47106. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  47107. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47108. */
  47109. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  47110. /**
  47111. * Creates a new VRDeviceOrientationGamepadCamera
  47112. * @param name defines camera name
  47113. * @param position defines the start position of the camera
  47114. * @param scene defines the scene the camera belongs to
  47115. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47116. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47117. */
  47118. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47119. /**
  47120. * Gets camera class name
  47121. * @returns VRDeviceOrientationGamepadCamera
  47122. */
  47123. getClassName(): string;
  47124. }
  47125. }
  47126. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  47127. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47128. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47129. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47130. /** @hidden */
  47131. export var imageProcessingPixelShader: {
  47132. name: string;
  47133. shader: string;
  47134. };
  47135. }
  47136. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  47137. import { Nullable } from "babylonjs/types";
  47138. import { Color4 } from "babylonjs/Maths/math.color";
  47139. import { Camera } from "babylonjs/Cameras/camera";
  47140. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47141. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47142. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47143. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47144. import { Engine } from "babylonjs/Engines/engine";
  47145. import "babylonjs/Shaders/imageProcessing.fragment";
  47146. import "babylonjs/Shaders/postprocess.vertex";
  47147. /**
  47148. * ImageProcessingPostProcess
  47149. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  47150. */
  47151. export class ImageProcessingPostProcess extends PostProcess {
  47152. /**
  47153. * Default configuration related to image processing available in the PBR Material.
  47154. */
  47155. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47156. /**
  47157. * Gets the image processing configuration used either in this material.
  47158. */
  47159. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  47160. /**
  47161. * Sets the Default image processing configuration used either in the this material.
  47162. *
  47163. * If sets to null, the scene one is in use.
  47164. */
  47165. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  47166. /**
  47167. * Keep track of the image processing observer to allow dispose and replace.
  47168. */
  47169. private _imageProcessingObserver;
  47170. /**
  47171. * Attaches a new image processing configuration to the PBR Material.
  47172. * @param configuration
  47173. */
  47174. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  47175. /**
  47176. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  47177. */
  47178. get colorCurves(): Nullable<ColorCurves>;
  47179. /**
  47180. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  47181. */
  47182. set colorCurves(value: Nullable<ColorCurves>);
  47183. /**
  47184. * Gets wether the color curves effect is enabled.
  47185. */
  47186. get colorCurvesEnabled(): boolean;
  47187. /**
  47188. * Sets wether the color curves effect is enabled.
  47189. */
  47190. set colorCurvesEnabled(value: boolean);
  47191. /**
  47192. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  47193. */
  47194. get colorGradingTexture(): Nullable<BaseTexture>;
  47195. /**
  47196. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  47197. */
  47198. set colorGradingTexture(value: Nullable<BaseTexture>);
  47199. /**
  47200. * Gets wether the color grading effect is enabled.
  47201. */
  47202. get colorGradingEnabled(): boolean;
  47203. /**
  47204. * Gets wether the color grading effect is enabled.
  47205. */
  47206. set colorGradingEnabled(value: boolean);
  47207. /**
  47208. * Gets exposure used in the effect.
  47209. */
  47210. get exposure(): number;
  47211. /**
  47212. * Sets exposure used in the effect.
  47213. */
  47214. set exposure(value: number);
  47215. /**
  47216. * Gets wether tonemapping is enabled or not.
  47217. */
  47218. get toneMappingEnabled(): boolean;
  47219. /**
  47220. * Sets wether tonemapping is enabled or not
  47221. */
  47222. set toneMappingEnabled(value: boolean);
  47223. /**
  47224. * Gets the type of tone mapping effect.
  47225. */
  47226. get toneMappingType(): number;
  47227. /**
  47228. * Sets the type of tone mapping effect.
  47229. */
  47230. set toneMappingType(value: number);
  47231. /**
  47232. * Gets contrast used in the effect.
  47233. */
  47234. get contrast(): number;
  47235. /**
  47236. * Sets contrast used in the effect.
  47237. */
  47238. set contrast(value: number);
  47239. /**
  47240. * Gets Vignette stretch size.
  47241. */
  47242. get vignetteStretch(): number;
  47243. /**
  47244. * Sets Vignette stretch size.
  47245. */
  47246. set vignetteStretch(value: number);
  47247. /**
  47248. * Gets Vignette centre X Offset.
  47249. */
  47250. get vignetteCentreX(): number;
  47251. /**
  47252. * Sets Vignette centre X Offset.
  47253. */
  47254. set vignetteCentreX(value: number);
  47255. /**
  47256. * Gets Vignette centre Y Offset.
  47257. */
  47258. get vignetteCentreY(): number;
  47259. /**
  47260. * Sets Vignette centre Y Offset.
  47261. */
  47262. set vignetteCentreY(value: number);
  47263. /**
  47264. * Gets Vignette weight or intensity of the vignette effect.
  47265. */
  47266. get vignetteWeight(): number;
  47267. /**
  47268. * Sets Vignette weight or intensity of the vignette effect.
  47269. */
  47270. set vignetteWeight(value: number);
  47271. /**
  47272. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47273. * if vignetteEnabled is set to true.
  47274. */
  47275. get vignetteColor(): Color4;
  47276. /**
  47277. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47278. * if vignetteEnabled is set to true.
  47279. */
  47280. set vignetteColor(value: Color4);
  47281. /**
  47282. * Gets Camera field of view used by the Vignette effect.
  47283. */
  47284. get vignetteCameraFov(): number;
  47285. /**
  47286. * Sets Camera field of view used by the Vignette effect.
  47287. */
  47288. set vignetteCameraFov(value: number);
  47289. /**
  47290. * Gets the vignette blend mode allowing different kind of effect.
  47291. */
  47292. get vignetteBlendMode(): number;
  47293. /**
  47294. * Sets the vignette blend mode allowing different kind of effect.
  47295. */
  47296. set vignetteBlendMode(value: number);
  47297. /**
  47298. * Gets wether the vignette effect is enabled.
  47299. */
  47300. get vignetteEnabled(): boolean;
  47301. /**
  47302. * Sets wether the vignette effect is enabled.
  47303. */
  47304. set vignetteEnabled(value: boolean);
  47305. private _fromLinearSpace;
  47306. /**
  47307. * Gets wether the input of the processing is in Gamma or Linear Space.
  47308. */
  47309. get fromLinearSpace(): boolean;
  47310. /**
  47311. * Sets wether the input of the processing is in Gamma or Linear Space.
  47312. */
  47313. set fromLinearSpace(value: boolean);
  47314. /**
  47315. * Defines cache preventing GC.
  47316. */
  47317. private _defines;
  47318. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  47319. /**
  47320. * "ImageProcessingPostProcess"
  47321. * @returns "ImageProcessingPostProcess"
  47322. */
  47323. getClassName(): string;
  47324. protected _updateParameters(): void;
  47325. dispose(camera?: Camera): void;
  47326. }
  47327. }
  47328. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  47329. import { Scene } from "babylonjs/scene";
  47330. import { Color3 } from "babylonjs/Maths/math.color";
  47331. import { Mesh } from "babylonjs/Meshes/mesh";
  47332. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  47333. import { Nullable } from "babylonjs/types";
  47334. /**
  47335. * Class containing static functions to help procedurally build meshes
  47336. */
  47337. export class GroundBuilder {
  47338. /**
  47339. * Creates a ground mesh
  47340. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  47341. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  47342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47343. * @param name defines the name of the mesh
  47344. * @param options defines the options used to create the mesh
  47345. * @param scene defines the hosting scene
  47346. * @returns the ground mesh
  47347. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  47348. */
  47349. static CreateGround(name: string, options: {
  47350. width?: number;
  47351. height?: number;
  47352. subdivisions?: number;
  47353. subdivisionsX?: number;
  47354. subdivisionsY?: number;
  47355. updatable?: boolean;
  47356. }, scene: any): Mesh;
  47357. /**
  47358. * Creates a tiled ground mesh
  47359. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  47360. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  47361. * * 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
  47362. * * 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
  47363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47364. * @param name defines the name of the mesh
  47365. * @param options defines the options used to create the mesh
  47366. * @param scene defines the hosting scene
  47367. * @returns the tiled ground mesh
  47368. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  47369. */
  47370. static CreateTiledGround(name: string, options: {
  47371. xmin: number;
  47372. zmin: number;
  47373. xmax: number;
  47374. zmax: number;
  47375. subdivisions?: {
  47376. w: number;
  47377. h: number;
  47378. };
  47379. precision?: {
  47380. w: number;
  47381. h: number;
  47382. };
  47383. updatable?: boolean;
  47384. }, scene?: Nullable<Scene>): Mesh;
  47385. /**
  47386. * Creates a ground mesh from a height map
  47387. * * The parameter `url` sets the URL of the height map image resource.
  47388. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  47389. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  47390. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  47391. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  47392. * * 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.
  47393. * * 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).
  47394. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  47395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47396. * @param name defines the name of the mesh
  47397. * @param url defines the url to the height map
  47398. * @param options defines the options used to create the mesh
  47399. * @param scene defines the hosting scene
  47400. * @returns the ground mesh
  47401. * @see https://doc.babylonjs.com/babylon101/height_map
  47402. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  47403. */
  47404. static CreateGroundFromHeightMap(name: string, url: string, options: {
  47405. width?: number;
  47406. height?: number;
  47407. subdivisions?: number;
  47408. minHeight?: number;
  47409. maxHeight?: number;
  47410. colorFilter?: Color3;
  47411. alphaFilter?: number;
  47412. updatable?: boolean;
  47413. onReady?: (mesh: GroundMesh) => void;
  47414. }, scene?: Nullable<Scene>): GroundMesh;
  47415. }
  47416. }
  47417. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  47418. import { Vector4 } from "babylonjs/Maths/math.vector";
  47419. import { Mesh } from "babylonjs/Meshes/mesh";
  47420. /**
  47421. * Class containing static functions to help procedurally build meshes
  47422. */
  47423. export class TorusBuilder {
  47424. /**
  47425. * Creates a torus mesh
  47426. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  47427. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  47428. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  47429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47430. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47432. * @param name defines the name of the mesh
  47433. * @param options defines the options used to create the mesh
  47434. * @param scene defines the hosting scene
  47435. * @returns the torus mesh
  47436. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  47437. */
  47438. static CreateTorus(name: string, options: {
  47439. diameter?: number;
  47440. thickness?: number;
  47441. tessellation?: number;
  47442. updatable?: boolean;
  47443. sideOrientation?: number;
  47444. frontUVs?: Vector4;
  47445. backUVs?: Vector4;
  47446. }, scene: any): Mesh;
  47447. }
  47448. }
  47449. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  47450. import { Vector4 } from "babylonjs/Maths/math.vector";
  47451. import { Color4 } from "babylonjs/Maths/math.color";
  47452. import { Mesh } from "babylonjs/Meshes/mesh";
  47453. /**
  47454. * Class containing static functions to help procedurally build meshes
  47455. */
  47456. export class CylinderBuilder {
  47457. /**
  47458. * Creates a cylinder or a cone mesh
  47459. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  47460. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  47461. * * 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.
  47462. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  47463. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  47464. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  47465. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  47466. * * 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).
  47467. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  47468. * * 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).
  47469. * * 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
  47470. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  47471. * * 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
  47472. * * 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.
  47473. * * If `enclose` is false, a ring surface is one element.
  47474. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  47475. * * 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
  47476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47477. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47479. * @param name defines the name of the mesh
  47480. * @param options defines the options used to create the mesh
  47481. * @param scene defines the hosting scene
  47482. * @returns the cylinder mesh
  47483. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  47484. */
  47485. static CreateCylinder(name: string, options: {
  47486. height?: number;
  47487. diameterTop?: number;
  47488. diameterBottom?: number;
  47489. diameter?: number;
  47490. tessellation?: number;
  47491. subdivisions?: number;
  47492. arc?: number;
  47493. faceColors?: Color4[];
  47494. faceUV?: Vector4[];
  47495. updatable?: boolean;
  47496. hasRings?: boolean;
  47497. enclose?: boolean;
  47498. cap?: number;
  47499. sideOrientation?: number;
  47500. frontUVs?: Vector4;
  47501. backUVs?: Vector4;
  47502. }, scene: any): Mesh;
  47503. }
  47504. }
  47505. declare module "babylonjs/XR/webXRTypes" {
  47506. import { Nullable } from "babylonjs/types";
  47507. import { IDisposable } from "babylonjs/scene";
  47508. /**
  47509. * States of the webXR experience
  47510. */
  47511. export enum WebXRState {
  47512. /**
  47513. * Transitioning to being in XR mode
  47514. */
  47515. ENTERING_XR = 0,
  47516. /**
  47517. * Transitioning to non XR mode
  47518. */
  47519. EXITING_XR = 1,
  47520. /**
  47521. * In XR mode and presenting
  47522. */
  47523. IN_XR = 2,
  47524. /**
  47525. * Not entered XR mode
  47526. */
  47527. NOT_IN_XR = 3
  47528. }
  47529. /**
  47530. * Abstraction of the XR render target
  47531. */
  47532. export interface WebXRRenderTarget extends IDisposable {
  47533. /**
  47534. * xrpresent context of the canvas which can be used to display/mirror xr content
  47535. */
  47536. canvasContext: WebGLRenderingContext;
  47537. /**
  47538. * xr layer for the canvas
  47539. */
  47540. xrLayer: Nullable<XRWebGLLayer>;
  47541. /**
  47542. * Initializes the xr layer for the session
  47543. * @param xrSession xr session
  47544. * @returns a promise that will resolve once the XR Layer has been created
  47545. */
  47546. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47547. }
  47548. }
  47549. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  47550. import { Nullable } from "babylonjs/types";
  47551. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47552. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47553. /**
  47554. * COnfiguration object for WebXR output canvas
  47555. */
  47556. export class WebXRManagedOutputCanvasOptions {
  47557. /**
  47558. * An optional canvas in case you wish to create it yourself and provide it here.
  47559. * If not provided, a new canvas will be created
  47560. */
  47561. canvasElement?: HTMLCanvasElement;
  47562. /**
  47563. * Options for this XR Layer output
  47564. */
  47565. canvasOptions?: XRWebGLLayerOptions;
  47566. /**
  47567. * CSS styling for a newly created canvas (if not provided)
  47568. */
  47569. newCanvasCssStyle?: string;
  47570. /**
  47571. * Get the default values of the configuration object
  47572. * @returns default values of this configuration object
  47573. */
  47574. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  47575. }
  47576. /**
  47577. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  47578. */
  47579. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  47580. private _options;
  47581. private _canvas;
  47582. private _engine;
  47583. /**
  47584. * Rendering context of the canvas which can be used to display/mirror xr content
  47585. */
  47586. canvasContext: WebGLRenderingContext;
  47587. /**
  47588. * xr layer for the canvas
  47589. */
  47590. xrLayer: Nullable<XRWebGLLayer>;
  47591. /**
  47592. * Initializes the canvas to be added/removed upon entering/exiting xr
  47593. * @param _xrSessionManager The XR Session manager
  47594. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  47595. */
  47596. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  47597. /**
  47598. * Disposes of the object
  47599. */
  47600. dispose(): void;
  47601. /**
  47602. * Initializes the xr layer for the session
  47603. * @param xrSession xr session
  47604. * @returns a promise that will resolve once the XR Layer has been created
  47605. */
  47606. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47607. private _addCanvas;
  47608. private _removeCanvas;
  47609. private _setManagedOutputCanvas;
  47610. }
  47611. }
  47612. declare module "babylonjs/XR/webXRSessionManager" {
  47613. import { Observable } from "babylonjs/Misc/observable";
  47614. import { Nullable } from "babylonjs/types";
  47615. import { IDisposable, Scene } from "babylonjs/scene";
  47616. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47617. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47618. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47619. /**
  47620. * Manages an XRSession to work with Babylon's engine
  47621. * @see https://doc.babylonjs.com/how_to/webxr
  47622. */
  47623. export class WebXRSessionManager implements IDisposable {
  47624. /** The scene which the session should be created for */
  47625. scene: Scene;
  47626. private _referenceSpace;
  47627. private _rttProvider;
  47628. private _sessionEnded;
  47629. private _xrNavigator;
  47630. private baseLayer;
  47631. /**
  47632. * The base reference space from which the session started. good if you want to reset your
  47633. * reference space
  47634. */
  47635. baseReferenceSpace: XRReferenceSpace;
  47636. /**
  47637. * Current XR frame
  47638. */
  47639. currentFrame: Nullable<XRFrame>;
  47640. /** WebXR timestamp updated every frame */
  47641. currentTimestamp: number;
  47642. /**
  47643. * Used just in case of a failure to initialize an immersive session.
  47644. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47645. */
  47646. defaultHeightCompensation: number;
  47647. /**
  47648. * Fires every time a new xrFrame arrives which can be used to update the camera
  47649. */
  47650. onXRFrameObservable: Observable<XRFrame>;
  47651. /**
  47652. * Fires when the reference space changed
  47653. */
  47654. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47655. /**
  47656. * Fires when the xr session is ended either by the device or manually done
  47657. */
  47658. onXRSessionEnded: Observable<any>;
  47659. /**
  47660. * Fires when the xr session is ended either by the device or manually done
  47661. */
  47662. onXRSessionInit: Observable<XRSession>;
  47663. /**
  47664. * Underlying xr session
  47665. */
  47666. session: XRSession;
  47667. /**
  47668. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47669. * or get the offset the player is currently at.
  47670. */
  47671. viewerReferenceSpace: XRReferenceSpace;
  47672. /**
  47673. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47674. * @param scene The scene which the session should be created for
  47675. */
  47676. constructor(
  47677. /** The scene which the session should be created for */
  47678. scene: Scene);
  47679. /**
  47680. * The current reference space used in this session. This reference space can constantly change!
  47681. * It is mainly used to offset the camera's position.
  47682. */
  47683. get referenceSpace(): XRReferenceSpace;
  47684. /**
  47685. * Set a new reference space and triggers the observable
  47686. */
  47687. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47688. /**
  47689. * Disposes of the session manager
  47690. */
  47691. dispose(): void;
  47692. /**
  47693. * Stops the xrSession and restores the render loop
  47694. * @returns Promise which resolves after it exits XR
  47695. */
  47696. exitXRAsync(): Promise<void>;
  47697. /**
  47698. * Gets the correct render target texture to be rendered this frame for this eye
  47699. * @param eye the eye for which to get the render target
  47700. * @returns the render target for the specified eye
  47701. */
  47702. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47703. /**
  47704. * Creates a WebXRRenderTarget object for the XR session
  47705. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47706. * @param options optional options to provide when creating a new render target
  47707. * @returns a WebXR render target to which the session can render
  47708. */
  47709. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47710. /**
  47711. * Initializes the manager
  47712. * After initialization enterXR can be called to start an XR session
  47713. * @returns Promise which resolves after it is initialized
  47714. */
  47715. initializeAsync(): Promise<void>;
  47716. /**
  47717. * Initializes an xr session
  47718. * @param xrSessionMode mode to initialize
  47719. * @param xrSessionInit defines optional and required values to pass to the session builder
  47720. * @returns a promise which will resolve once the session has been initialized
  47721. */
  47722. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47723. /**
  47724. * Checks if a session would be supported for the creation options specified
  47725. * @param sessionMode session mode to check if supported eg. immersive-vr
  47726. * @returns A Promise that resolves to true if supported and false if not
  47727. */
  47728. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47729. /**
  47730. * Resets the reference space to the one started the session
  47731. */
  47732. resetReferenceSpace(): void;
  47733. /**
  47734. * Starts rendering to the xr layer
  47735. */
  47736. runXRRenderLoop(): void;
  47737. /**
  47738. * Sets the reference space on the xr session
  47739. * @param referenceSpaceType space to set
  47740. * @returns a promise that will resolve once the reference space has been set
  47741. */
  47742. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47743. /**
  47744. * Updates the render state of the session
  47745. * @param state state to set
  47746. * @returns a promise that resolves once the render state has been updated
  47747. */
  47748. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47749. /**
  47750. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47751. * @param sessionMode defines the session to test
  47752. * @returns a promise with boolean as final value
  47753. */
  47754. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47755. private _createRenderTargetTexture;
  47756. }
  47757. }
  47758. declare module "babylonjs/XR/webXRCamera" {
  47759. import { Matrix } from "babylonjs/Maths/math.vector";
  47760. import { Scene } from "babylonjs/scene";
  47761. import { Camera } from "babylonjs/Cameras/camera";
  47762. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47763. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47764. /**
  47765. * WebXR Camera which holds the views for the xrSession
  47766. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47767. */
  47768. export class WebXRCamera extends FreeCamera {
  47769. private _xrSessionManager;
  47770. private _firstFrame;
  47771. private _referenceQuaternion;
  47772. private _referencedPosition;
  47773. private _xrInvPositionCache;
  47774. private _xrInvQuaternionCache;
  47775. /**
  47776. * Should position compensation execute on first frame.
  47777. * This is used when copying the position from a native (non XR) camera
  47778. */
  47779. compensateOnFirstFrame: boolean;
  47780. /**
  47781. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47782. * @param name the name of the camera
  47783. * @param scene the scene to add the camera to
  47784. * @param _xrSessionManager a constructed xr session manager
  47785. */
  47786. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47787. /**
  47788. * Return the user's height, unrelated to the current ground.
  47789. * This will be the y position of this camera, when ground level is 0.
  47790. */
  47791. get realWorldHeight(): number;
  47792. /** @hidden */
  47793. _updateForDualEyeDebugging(): void;
  47794. /**
  47795. * Sets this camera's transformation based on a non-vr camera
  47796. * @param otherCamera the non-vr camera to copy the transformation from
  47797. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47798. */
  47799. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47800. /**
  47801. * Gets the current instance class name ("WebXRCamera").
  47802. * @returns the class name
  47803. */
  47804. getClassName(): string;
  47805. /**
  47806. * Overriding the _getViewMatrix function, as it is computed by WebXR
  47807. */
  47808. _getViewMatrix(): Matrix;
  47809. private _updateFromXRSession;
  47810. private _updateNumberOfRigCameras;
  47811. private _updateReferenceSpace;
  47812. private _updateReferenceSpaceOffset;
  47813. }
  47814. }
  47815. declare module "babylonjs/XR/webXRFeaturesManager" {
  47816. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47817. import { IDisposable } from "babylonjs/scene";
  47818. /**
  47819. * Defining the interface required for a (webxr) feature
  47820. */
  47821. export interface IWebXRFeature extends IDisposable {
  47822. /**
  47823. * Is this feature attached
  47824. */
  47825. attached: boolean;
  47826. /**
  47827. * Should auto-attach be disabled?
  47828. */
  47829. disableAutoAttach: boolean;
  47830. /**
  47831. * Attach the feature to the session
  47832. * Will usually be called by the features manager
  47833. *
  47834. * @param force should attachment be forced (even when already attached)
  47835. * @returns true if successful.
  47836. */
  47837. attach(force?: boolean): boolean;
  47838. /**
  47839. * Detach the feature from the session
  47840. * Will usually be called by the features manager
  47841. *
  47842. * @returns true if successful.
  47843. */
  47844. detach(): boolean;
  47845. }
  47846. /**
  47847. * A list of the currently available features without referencing them
  47848. */
  47849. export class WebXRFeatureName {
  47850. /**
  47851. * The name of the anchor system feature
  47852. */
  47853. static ANCHOR_SYSTEM: string;
  47854. /**
  47855. * The name of the background remover feature
  47856. */
  47857. static BACKGROUND_REMOVER: string;
  47858. /**
  47859. * The name of the hit test feature
  47860. */
  47861. static HIT_TEST: string;
  47862. /**
  47863. * physics impostors for xr controllers feature
  47864. */
  47865. static PHYSICS_CONTROLLERS: string;
  47866. /**
  47867. * The name of the plane detection feature
  47868. */
  47869. static PLANE_DETECTION: string;
  47870. /**
  47871. * The name of the pointer selection feature
  47872. */
  47873. static POINTER_SELECTION: string;
  47874. /**
  47875. * The name of the teleportation feature
  47876. */
  47877. static TELEPORTATION: string;
  47878. }
  47879. /**
  47880. * Defining the constructor of a feature. Used to register the modules.
  47881. */
  47882. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  47883. /**
  47884. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47885. * It is mainly used in AR sessions.
  47886. *
  47887. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47888. */
  47889. export class WebXRFeaturesManager implements IDisposable {
  47890. private _xrSessionManager;
  47891. private static readonly _AvailableFeatures;
  47892. private _features;
  47893. /**
  47894. * constructs a new features manages.
  47895. *
  47896. * @param _xrSessionManager an instance of WebXRSessionManager
  47897. */
  47898. constructor(_xrSessionManager: WebXRSessionManager);
  47899. /**
  47900. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47901. * Mainly used internally.
  47902. *
  47903. * @param featureName the name of the feature to register
  47904. * @param constructorFunction the function used to construct the module
  47905. * @param version the (babylon) version of the module
  47906. * @param stable is that a stable version of this module
  47907. */
  47908. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47909. /**
  47910. * Returns a constructor of a specific feature.
  47911. *
  47912. * @param featureName the name of the feature to construct
  47913. * @param version the version of the feature to load
  47914. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47915. * @param options optional options provided to the module.
  47916. * @returns a function that, when called, will return a new instance of this feature
  47917. */
  47918. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  47919. /**
  47920. * Can be used to return the list of features currently registered
  47921. *
  47922. * @returns an Array of available features
  47923. */
  47924. static GetAvailableFeatures(): string[];
  47925. /**
  47926. * Gets the versions available for a specific feature
  47927. * @param featureName the name of the feature
  47928. * @returns an array with the available versions
  47929. */
  47930. static GetAvailableVersions(featureName: string): string[];
  47931. /**
  47932. * Return the latest unstable version of this feature
  47933. * @param featureName the name of the feature to search
  47934. * @returns the version number. if not found will return -1
  47935. */
  47936. static GetLatestVersionOfFeature(featureName: string): number;
  47937. /**
  47938. * Return the latest stable version of this feature
  47939. * @param featureName the name of the feature to search
  47940. * @returns the version number. if not found will return -1
  47941. */
  47942. static GetStableVersionOfFeature(featureName: string): number;
  47943. /**
  47944. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47945. * Can be used during a session to start a feature
  47946. * @param featureName the name of feature to attach
  47947. */
  47948. attachFeature(featureName: string): void;
  47949. /**
  47950. * Can be used inside a session or when the session ends to detach a specific feature
  47951. * @param featureName the name of the feature to detach
  47952. */
  47953. detachFeature(featureName: string): void;
  47954. /**
  47955. * Used to disable an already-enabled feature
  47956. * The feature will be disposed and will be recreated once enabled.
  47957. * @param featureName the feature to disable
  47958. * @returns true if disable was successful
  47959. */
  47960. disableFeature(featureName: string | {
  47961. Name: string;
  47962. }): boolean;
  47963. /**
  47964. * dispose this features manager
  47965. */
  47966. dispose(): void;
  47967. /**
  47968. * 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.
  47969. * 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.
  47970. *
  47971. * @param featureName the name of the feature to load or the class of the feature
  47972. * @param version optional version to load. if not provided the latest version will be enabled
  47973. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47974. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47975. * @returns a new constructed feature or throws an error if feature not found.
  47976. */
  47977. enableFeature(featureName: string | {
  47978. Name: string;
  47979. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  47980. /**
  47981. * get the implementation of an enabled feature.
  47982. * @param featureName the name of the feature to load
  47983. * @returns the feature class, if found
  47984. */
  47985. getEnabledFeature(featureName: string): IWebXRFeature;
  47986. /**
  47987. * Get the list of enabled features
  47988. * @returns an array of enabled features
  47989. */
  47990. getEnabledFeatures(): string[];
  47991. }
  47992. }
  47993. declare module "babylonjs/XR/webXRExperienceHelper" {
  47994. import { Observable } from "babylonjs/Misc/observable";
  47995. import { IDisposable, Scene } from "babylonjs/scene";
  47996. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47997. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  47998. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47999. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  48000. /**
  48001. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  48002. * @see https://doc.babylonjs.com/how_to/webxr
  48003. */
  48004. export class WebXRExperienceHelper implements IDisposable {
  48005. private scene;
  48006. private _nonVRCamera;
  48007. private _originalSceneAutoClear;
  48008. private _supported;
  48009. /**
  48010. * Camera used to render xr content
  48011. */
  48012. camera: WebXRCamera;
  48013. /** A features manager for this xr session */
  48014. featuresManager: WebXRFeaturesManager;
  48015. /**
  48016. * Observers registered here will be triggered after the camera's initial transformation is set
  48017. * This can be used to set a different ground level or an extra rotation.
  48018. *
  48019. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  48020. * to the position set after this observable is done executing.
  48021. */
  48022. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  48023. /**
  48024. * Fires when the state of the experience helper has changed
  48025. */
  48026. onStateChangedObservable: Observable<WebXRState>;
  48027. /** Session manager used to keep track of xr session */
  48028. sessionManager: WebXRSessionManager;
  48029. /**
  48030. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  48031. */
  48032. state: WebXRState;
  48033. /**
  48034. * Creates a WebXRExperienceHelper
  48035. * @param scene The scene the helper should be created in
  48036. */
  48037. private constructor();
  48038. /**
  48039. * Creates the experience helper
  48040. * @param scene the scene to attach the experience helper to
  48041. * @returns a promise for the experience helper
  48042. */
  48043. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  48044. /**
  48045. * Disposes of the experience helper
  48046. */
  48047. dispose(): void;
  48048. /**
  48049. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  48050. * @param sessionMode options for the XR session
  48051. * @param referenceSpaceType frame of reference of the XR session
  48052. * @param renderTarget the output canvas that will be used to enter XR mode
  48053. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  48054. * @returns promise that resolves after xr mode has entered
  48055. */
  48056. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  48057. /**
  48058. * Exits XR mode and returns the scene to its original state
  48059. * @returns promise that resolves after xr mode has exited
  48060. */
  48061. exitXRAsync(): Promise<void>;
  48062. private _nonXRToXRCamera;
  48063. private _setState;
  48064. }
  48065. }
  48066. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  48067. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48068. import { Observable } from "babylonjs/Misc/observable";
  48069. import { IDisposable } from "babylonjs/scene";
  48070. /**
  48071. * X-Y values for axes in WebXR
  48072. */
  48073. export interface IWebXRMotionControllerAxesValue {
  48074. /**
  48075. * The value of the x axis
  48076. */
  48077. x: number;
  48078. /**
  48079. * The value of the y-axis
  48080. */
  48081. y: number;
  48082. }
  48083. /**
  48084. * changed / previous values for the values of this component
  48085. */
  48086. export interface IWebXRMotionControllerComponentChangesValues<T> {
  48087. /**
  48088. * current (this frame) value
  48089. */
  48090. current: T;
  48091. /**
  48092. * previous (last change) value
  48093. */
  48094. previous: T;
  48095. }
  48096. /**
  48097. * Represents changes in the component between current frame and last values recorded
  48098. */
  48099. export interface IWebXRMotionControllerComponentChanges {
  48100. /**
  48101. * will be populated with previous and current values if axes changed
  48102. */
  48103. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  48104. /**
  48105. * will be populated with previous and current values if pressed changed
  48106. */
  48107. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48108. /**
  48109. * will be populated with previous and current values if touched changed
  48110. */
  48111. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48112. /**
  48113. * will be populated with previous and current values if value changed
  48114. */
  48115. value?: IWebXRMotionControllerComponentChangesValues<number>;
  48116. }
  48117. /**
  48118. * This class represents a single component (for example button or thumbstick) of a motion controller
  48119. */
  48120. export class WebXRControllerComponent implements IDisposable {
  48121. /**
  48122. * the id of this component
  48123. */
  48124. id: string;
  48125. /**
  48126. * the type of the component
  48127. */
  48128. type: MotionControllerComponentType;
  48129. private _buttonIndex;
  48130. private _axesIndices;
  48131. private _axes;
  48132. private _changes;
  48133. private _currentValue;
  48134. private _hasChanges;
  48135. private _pressed;
  48136. private _touched;
  48137. /**
  48138. * button component type
  48139. */
  48140. static BUTTON_TYPE: MotionControllerComponentType;
  48141. /**
  48142. * squeeze component type
  48143. */
  48144. static SQUEEZE_TYPE: MotionControllerComponentType;
  48145. /**
  48146. * Thumbstick component type
  48147. */
  48148. static THUMBSTICK_TYPE: MotionControllerComponentType;
  48149. /**
  48150. * Touchpad component type
  48151. */
  48152. static TOUCHPAD_TYPE: MotionControllerComponentType;
  48153. /**
  48154. * trigger component type
  48155. */
  48156. static TRIGGER_TYPE: MotionControllerComponentType;
  48157. /**
  48158. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  48159. * the axes data changes
  48160. */
  48161. onAxisValueChangedObservable: Observable<{
  48162. x: number;
  48163. y: number;
  48164. }>;
  48165. /**
  48166. * Observers registered here will be triggered when the state of a button changes
  48167. * State change is either pressed / touched / value
  48168. */
  48169. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  48170. /**
  48171. * Creates a new component for a motion controller.
  48172. * It is created by the motion controller itself
  48173. *
  48174. * @param id the id of this component
  48175. * @param type the type of the component
  48176. * @param _buttonIndex index in the buttons array of the gamepad
  48177. * @param _axesIndices indices of the values in the axes array of the gamepad
  48178. */
  48179. constructor(
  48180. /**
  48181. * the id of this component
  48182. */
  48183. id: string,
  48184. /**
  48185. * the type of the component
  48186. */
  48187. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  48188. /**
  48189. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  48190. */
  48191. get axes(): IWebXRMotionControllerAxesValue;
  48192. /**
  48193. * Get the changes. Elements will be populated only if they changed with their previous and current value
  48194. */
  48195. get changes(): IWebXRMotionControllerComponentChanges;
  48196. /**
  48197. * Return whether or not the component changed the last frame
  48198. */
  48199. get hasChanges(): boolean;
  48200. /**
  48201. * is the button currently pressed
  48202. */
  48203. get pressed(): boolean;
  48204. /**
  48205. * is the button currently touched
  48206. */
  48207. get touched(): boolean;
  48208. /**
  48209. * Get the current value of this component
  48210. */
  48211. get value(): number;
  48212. /**
  48213. * Dispose this component
  48214. */
  48215. dispose(): void;
  48216. /**
  48217. * Are there axes correlating to this component
  48218. * @return true is axes data is available
  48219. */
  48220. isAxes(): boolean;
  48221. /**
  48222. * Is this component a button (hence - pressable)
  48223. * @returns true if can be pressed
  48224. */
  48225. isButton(): boolean;
  48226. /**
  48227. * update this component using the gamepad object it is in. Called on every frame
  48228. * @param nativeController the native gamepad controller object
  48229. */
  48230. update(nativeController: IMinimalMotionControllerObject): void;
  48231. }
  48232. }
  48233. declare module "babylonjs/Loading/sceneLoader" {
  48234. import { Observable } from "babylonjs/Misc/observable";
  48235. import { Nullable } from "babylonjs/types";
  48236. import { Scene } from "babylonjs/scene";
  48237. import { Engine } from "babylonjs/Engines/engine";
  48238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48239. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  48240. import { AssetContainer } from "babylonjs/assetContainer";
  48241. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  48242. import { Skeleton } from "babylonjs/Bones/skeleton";
  48243. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  48244. import { WebRequest } from "babylonjs/Misc/webRequest";
  48245. /**
  48246. * Class used to represent data loading progression
  48247. */
  48248. export class SceneLoaderProgressEvent {
  48249. /** defines if data length to load can be evaluated */
  48250. readonly lengthComputable: boolean;
  48251. /** defines the loaded data length */
  48252. readonly loaded: number;
  48253. /** defines the data length to load */
  48254. readonly total: number;
  48255. /**
  48256. * Create a new progress event
  48257. * @param lengthComputable defines if data length to load can be evaluated
  48258. * @param loaded defines the loaded data length
  48259. * @param total defines the data length to load
  48260. */
  48261. constructor(
  48262. /** defines if data length to load can be evaluated */
  48263. lengthComputable: boolean,
  48264. /** defines the loaded data length */
  48265. loaded: number,
  48266. /** defines the data length to load */
  48267. total: number);
  48268. /**
  48269. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  48270. * @param event defines the source event
  48271. * @returns a new SceneLoaderProgressEvent
  48272. */
  48273. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  48274. }
  48275. /**
  48276. * Interface used by SceneLoader plugins to define supported file extensions
  48277. */
  48278. export interface ISceneLoaderPluginExtensions {
  48279. /**
  48280. * Defines the list of supported extensions
  48281. */
  48282. [extension: string]: {
  48283. isBinary: boolean;
  48284. };
  48285. }
  48286. /**
  48287. * Interface used by SceneLoader plugin factory
  48288. */
  48289. export interface ISceneLoaderPluginFactory {
  48290. /**
  48291. * Defines the name of the factory
  48292. */
  48293. name: string;
  48294. /**
  48295. * Function called to create a new plugin
  48296. * @return the new plugin
  48297. */
  48298. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  48299. /**
  48300. * The callback that returns true if the data can be directly loaded.
  48301. * @param data string containing the file data
  48302. * @returns if the data can be loaded directly
  48303. */
  48304. canDirectLoad?(data: string): boolean;
  48305. }
  48306. /**
  48307. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  48308. */
  48309. export interface ISceneLoaderPluginBase {
  48310. /**
  48311. * The friendly name of this plugin.
  48312. */
  48313. name: string;
  48314. /**
  48315. * The file extensions supported by this plugin.
  48316. */
  48317. extensions: string | ISceneLoaderPluginExtensions;
  48318. /**
  48319. * The callback called when loading from a url.
  48320. * @param scene scene loading this url
  48321. * @param url url to load
  48322. * @param onSuccess callback called when the file successfully loads
  48323. * @param onProgress callback called while file is loading (if the server supports this mode)
  48324. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  48325. * @param onError callback called when the file fails to load
  48326. * @returns a file request object
  48327. */
  48328. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48329. /**
  48330. * The callback called when loading from a file object.
  48331. * @param scene scene loading this file
  48332. * @param file defines the file to load
  48333. * @param onSuccess defines the callback to call when data is loaded
  48334. * @param onProgress defines the callback to call during loading process
  48335. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  48336. * @param onError defines the callback to call when an error occurs
  48337. * @returns a file request object
  48338. */
  48339. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48340. /**
  48341. * The callback that returns true if the data can be directly loaded.
  48342. * @param data string containing the file data
  48343. * @returns if the data can be loaded directly
  48344. */
  48345. canDirectLoad?(data: string): boolean;
  48346. /**
  48347. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  48348. * @param scene scene loading this data
  48349. * @param data string containing the data
  48350. * @returns data to pass to the plugin
  48351. */
  48352. directLoad?(scene: Scene, data: string): any;
  48353. /**
  48354. * The callback that allows custom handling of the root url based on the response url.
  48355. * @param rootUrl the original root url
  48356. * @param responseURL the response url if available
  48357. * @returns the new root url
  48358. */
  48359. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  48360. }
  48361. /**
  48362. * Interface used to define a SceneLoader plugin
  48363. */
  48364. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  48365. /**
  48366. * Import meshes into a scene.
  48367. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48368. * @param scene The scene to import into
  48369. * @param data The data to import
  48370. * @param rootUrl The root url for scene and resources
  48371. * @param meshes The meshes array to import into
  48372. * @param particleSystems The particle systems array to import into
  48373. * @param skeletons The skeletons array to import into
  48374. * @param onError The callback when import fails
  48375. * @returns True if successful or false otherwise
  48376. */
  48377. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  48378. /**
  48379. * Load into a scene.
  48380. * @param scene The scene to load into
  48381. * @param data The data to import
  48382. * @param rootUrl The root url for scene and resources
  48383. * @param onError The callback when import fails
  48384. * @returns True if successful or false otherwise
  48385. */
  48386. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  48387. /**
  48388. * Load into an asset container.
  48389. * @param scene The scene to load into
  48390. * @param data The data to import
  48391. * @param rootUrl The root url for scene and resources
  48392. * @param onError The callback when import fails
  48393. * @returns The loaded asset container
  48394. */
  48395. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  48396. }
  48397. /**
  48398. * Interface used to define an async SceneLoader plugin
  48399. */
  48400. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  48401. /**
  48402. * Import meshes into a scene.
  48403. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48404. * @param scene The scene to import into
  48405. * @param data The data to import
  48406. * @param rootUrl The root url for scene and resources
  48407. * @param onProgress The callback when the load progresses
  48408. * @param fileName Defines the name of the file to load
  48409. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  48410. */
  48411. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  48412. meshes: AbstractMesh[];
  48413. particleSystems: IParticleSystem[];
  48414. skeletons: Skeleton[];
  48415. animationGroups: AnimationGroup[];
  48416. }>;
  48417. /**
  48418. * Load into a scene.
  48419. * @param scene The scene to load into
  48420. * @param data The data to import
  48421. * @param rootUrl The root url for scene and resources
  48422. * @param onProgress The callback when the load progresses
  48423. * @param fileName Defines the name of the file to load
  48424. * @returns Nothing
  48425. */
  48426. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  48427. /**
  48428. * Load into an asset container.
  48429. * @param scene The scene to load into
  48430. * @param data The data to import
  48431. * @param rootUrl The root url for scene and resources
  48432. * @param onProgress The callback when the load progresses
  48433. * @param fileName Defines the name of the file to load
  48434. * @returns The loaded asset container
  48435. */
  48436. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  48437. }
  48438. /**
  48439. * Mode that determines how to handle old animation groups before loading new ones.
  48440. */
  48441. export enum SceneLoaderAnimationGroupLoadingMode {
  48442. /**
  48443. * Reset all old animations to initial state then dispose them.
  48444. */
  48445. Clean = 0,
  48446. /**
  48447. * Stop all old animations.
  48448. */
  48449. Stop = 1,
  48450. /**
  48451. * Restart old animations from first frame.
  48452. */
  48453. Sync = 2,
  48454. /**
  48455. * Old animations remains untouched.
  48456. */
  48457. NoSync = 3
  48458. }
  48459. /**
  48460. * Class used to load scene from various file formats using registered plugins
  48461. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  48462. */
  48463. export class SceneLoader {
  48464. /**
  48465. * No logging while loading
  48466. */
  48467. static readonly NO_LOGGING: number;
  48468. /**
  48469. * Minimal logging while loading
  48470. */
  48471. static readonly MINIMAL_LOGGING: number;
  48472. /**
  48473. * Summary logging while loading
  48474. */
  48475. static readonly SUMMARY_LOGGING: number;
  48476. /**
  48477. * Detailled logging while loading
  48478. */
  48479. static readonly DETAILED_LOGGING: number;
  48480. /**
  48481. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48482. */
  48483. static get ForceFullSceneLoadingForIncremental(): boolean;
  48484. static set ForceFullSceneLoadingForIncremental(value: boolean);
  48485. /**
  48486. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48487. */
  48488. static get ShowLoadingScreen(): boolean;
  48489. static set ShowLoadingScreen(value: boolean);
  48490. /**
  48491. * Defines the current logging level (while loading the scene)
  48492. * @ignorenaming
  48493. */
  48494. static get loggingLevel(): number;
  48495. static set loggingLevel(value: number);
  48496. /**
  48497. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48498. */
  48499. static get CleanBoneMatrixWeights(): boolean;
  48500. static set CleanBoneMatrixWeights(value: boolean);
  48501. /**
  48502. * Event raised when a plugin is used to load a scene
  48503. */
  48504. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48505. private static _registeredPlugins;
  48506. private static _getDefaultPlugin;
  48507. private static _getPluginForExtension;
  48508. private static _getPluginForDirectLoad;
  48509. private static _getPluginForFilename;
  48510. private static _getDirectLoad;
  48511. private static _loadData;
  48512. private static _getFileInfo;
  48513. /**
  48514. * Gets a plugin that can load the given extension
  48515. * @param extension defines the extension to load
  48516. * @returns a plugin or null if none works
  48517. */
  48518. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  48519. /**
  48520. * Gets a boolean indicating that the given extension can be loaded
  48521. * @param extension defines the extension to load
  48522. * @returns true if the extension is supported
  48523. */
  48524. static IsPluginForExtensionAvailable(extension: string): boolean;
  48525. /**
  48526. * Adds a new plugin to the list of registered plugins
  48527. * @param plugin defines the plugin to add
  48528. */
  48529. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  48530. /**
  48531. * Import meshes into a scene
  48532. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48533. * @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)
  48534. * @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)
  48535. * @param scene the instance of BABYLON.Scene to append to
  48536. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48537. * @param onProgress a callback with a progress event for each file being loaded
  48538. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48539. * @param pluginExtension the extension used to determine the plugin
  48540. * @returns The loaded plugin
  48541. */
  48542. 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>;
  48543. /**
  48544. * Import meshes into a scene
  48545. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48546. * @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)
  48547. * @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)
  48548. * @param scene the instance of BABYLON.Scene to append to
  48549. * @param onProgress a callback with a progress event for each file being loaded
  48550. * @param pluginExtension the extension used to determine the plugin
  48551. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48552. */
  48553. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  48554. meshes: AbstractMesh[];
  48555. particleSystems: IParticleSystem[];
  48556. skeletons: Skeleton[];
  48557. animationGroups: AnimationGroup[];
  48558. }>;
  48559. /**
  48560. * Load a scene
  48561. * @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)
  48562. * @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)
  48563. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48564. * @param onSuccess a callback with the scene when import succeeds
  48565. * @param onProgress a callback with a progress event for each file being loaded
  48566. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48567. * @param pluginExtension the extension used to determine the plugin
  48568. * @returns The loaded plugin
  48569. */
  48570. 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>;
  48571. /**
  48572. * Load a scene
  48573. * @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)
  48574. * @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)
  48575. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48576. * @param onProgress a callback with a progress event for each file being loaded
  48577. * @param pluginExtension the extension used to determine the plugin
  48578. * @returns The loaded scene
  48579. */
  48580. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48581. /**
  48582. * Append a scene
  48583. * @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)
  48584. * @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)
  48585. * @param scene is the instance of BABYLON.Scene to append to
  48586. * @param onSuccess a callback with the scene when import succeeds
  48587. * @param onProgress a callback with a progress event for each file being loaded
  48588. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48589. * @param pluginExtension the extension used to determine the plugin
  48590. * @returns The loaded plugin
  48591. */
  48592. 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>;
  48593. /**
  48594. * Append a scene
  48595. * @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)
  48596. * @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)
  48597. * @param scene is the instance of BABYLON.Scene to append to
  48598. * @param onProgress a callback with a progress event for each file being loaded
  48599. * @param pluginExtension the extension used to determine the plugin
  48600. * @returns The given scene
  48601. */
  48602. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48603. /**
  48604. * Load a scene into an asset container
  48605. * @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)
  48606. * @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)
  48607. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48608. * @param onSuccess a callback with the scene when import succeeds
  48609. * @param onProgress a callback with a progress event for each file being loaded
  48610. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48611. * @param pluginExtension the extension used to determine the plugin
  48612. * @returns The loaded plugin
  48613. */
  48614. 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>;
  48615. /**
  48616. * Load a scene into an asset container
  48617. * @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)
  48618. * @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)
  48619. * @param scene is the instance of Scene to append to
  48620. * @param onProgress a callback with a progress event for each file being loaded
  48621. * @param pluginExtension the extension used to determine the plugin
  48622. * @returns The loaded asset container
  48623. */
  48624. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48625. /**
  48626. * Import animations from a file into a scene
  48627. * @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)
  48628. * @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)
  48629. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48630. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48631. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48632. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48633. * @param onSuccess a callback with the scene when import succeeds
  48634. * @param onProgress a callback with a progress event for each file being loaded
  48635. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48636. */
  48637. 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;
  48638. /**
  48639. * Import animations from a file into a scene
  48640. * @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)
  48641. * @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)
  48642. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48643. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48644. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48645. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48646. * @param onSuccess a callback with the scene when import succeeds
  48647. * @param onProgress a callback with a progress event for each file being loaded
  48648. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48649. * @returns the updated scene with imported animations
  48650. */
  48651. 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>;
  48652. }
  48653. }
  48654. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  48655. import { IDisposable, Scene } from "babylonjs/scene";
  48656. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  48657. import { Observable } from "babylonjs/Misc/observable";
  48658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48659. import { Nullable } from "babylonjs/types";
  48660. /**
  48661. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48662. */
  48663. export type MotionControllerHandedness = "none" | "left" | "right";
  48664. /**
  48665. * The type of components available in motion controllers.
  48666. * This is not the name of the component.
  48667. */
  48668. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48669. /**
  48670. * The state of a controller component
  48671. */
  48672. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48673. /**
  48674. * The schema of motion controller layout.
  48675. * No object will be initialized using this interface
  48676. * This is used just to define the profile.
  48677. */
  48678. export interface IMotionControllerLayout {
  48679. /**
  48680. * Path to load the assets. Usually relative to the base path
  48681. */
  48682. assetPath: string;
  48683. /**
  48684. * Available components (unsorted)
  48685. */
  48686. components: {
  48687. /**
  48688. * A map of component Ids
  48689. */
  48690. [componentId: string]: {
  48691. /**
  48692. * The type of input the component outputs
  48693. */
  48694. type: MotionControllerComponentType;
  48695. /**
  48696. * The indices of this component in the gamepad object
  48697. */
  48698. gamepadIndices: {
  48699. /**
  48700. * Index of button
  48701. */
  48702. button?: number;
  48703. /**
  48704. * If available, index of x-axis
  48705. */
  48706. xAxis?: number;
  48707. /**
  48708. * If available, index of y-axis
  48709. */
  48710. yAxis?: number;
  48711. };
  48712. /**
  48713. * The mesh's root node name
  48714. */
  48715. rootNodeName: string;
  48716. /**
  48717. * Animation definitions for this model
  48718. */
  48719. visualResponses: {
  48720. [stateKey: string]: {
  48721. /**
  48722. * What property will be animated
  48723. */
  48724. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48725. /**
  48726. * What states influence this visual response
  48727. */
  48728. states: MotionControllerComponentStateType[];
  48729. /**
  48730. * Type of animation - movement or visibility
  48731. */
  48732. valueNodeProperty: "transform" | "visibility";
  48733. /**
  48734. * Base node name to move. Its position will be calculated according to the min and max nodes
  48735. */
  48736. valueNodeName?: string;
  48737. /**
  48738. * Minimum movement node
  48739. */
  48740. minNodeName?: string;
  48741. /**
  48742. * Max movement node
  48743. */
  48744. maxNodeName?: string;
  48745. };
  48746. };
  48747. /**
  48748. * If touch enabled, what is the name of node to display user feedback
  48749. */
  48750. touchPointNodeName?: string;
  48751. };
  48752. };
  48753. /**
  48754. * Is it xr standard mapping or not
  48755. */
  48756. gamepadMapping: "" | "xr-standard";
  48757. /**
  48758. * Base root node of this entire model
  48759. */
  48760. rootNodeName: string;
  48761. /**
  48762. * Defines the main button component id
  48763. */
  48764. selectComponentId: string;
  48765. }
  48766. /**
  48767. * A definition for the layout map in the input profile
  48768. */
  48769. export interface IMotionControllerLayoutMap {
  48770. /**
  48771. * Layouts with handedness type as a key
  48772. */
  48773. [handedness: string]: IMotionControllerLayout;
  48774. }
  48775. /**
  48776. * The XR Input profile schema
  48777. * Profiles can be found here:
  48778. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48779. */
  48780. export interface IMotionControllerProfile {
  48781. /**
  48782. * fallback profiles for this profileId
  48783. */
  48784. fallbackProfileIds: string[];
  48785. /**
  48786. * The layout map, with handedness as key
  48787. */
  48788. layouts: IMotionControllerLayoutMap;
  48789. /**
  48790. * The id of this profile
  48791. * correlates to the profile(s) in the xrInput.profiles array
  48792. */
  48793. profileId: string;
  48794. }
  48795. /**
  48796. * A helper-interface for the 3 meshes needed for controller button animation
  48797. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48798. */
  48799. export interface IMotionControllerButtonMeshMap {
  48800. /**
  48801. * the mesh that defines the pressed value mesh position.
  48802. * This is used to find the max-position of this button
  48803. */
  48804. pressedMesh: AbstractMesh;
  48805. /**
  48806. * the mesh that defines the unpressed value mesh position.
  48807. * This is used to find the min (or initial) position of this button
  48808. */
  48809. unpressedMesh: AbstractMesh;
  48810. /**
  48811. * The mesh that will be changed when value changes
  48812. */
  48813. valueMesh: AbstractMesh;
  48814. }
  48815. /**
  48816. * A helper-interface for the 3 meshes needed for controller axis animation.
  48817. * This will be expanded when touchpad animations are fully supported
  48818. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48819. */
  48820. export interface IMotionControllerMeshMap {
  48821. /**
  48822. * the mesh that defines the maximum value mesh position.
  48823. */
  48824. maxMesh?: AbstractMesh;
  48825. /**
  48826. * the mesh that defines the minimum value mesh position.
  48827. */
  48828. minMesh?: AbstractMesh;
  48829. /**
  48830. * The mesh that will be changed when axis value changes
  48831. */
  48832. valueMesh: AbstractMesh;
  48833. }
  48834. /**
  48835. * The elements needed for change-detection of the gamepad objects in motion controllers
  48836. */
  48837. export interface IMinimalMotionControllerObject {
  48838. /**
  48839. * Available axes of this controller
  48840. */
  48841. axes: number[];
  48842. /**
  48843. * An array of available buttons
  48844. */
  48845. buttons: Array<{
  48846. /**
  48847. * Value of the button/trigger
  48848. */
  48849. value: number;
  48850. /**
  48851. * If the button/trigger is currently touched
  48852. */
  48853. touched: boolean;
  48854. /**
  48855. * If the button/trigger is currently pressed
  48856. */
  48857. pressed: boolean;
  48858. }>;
  48859. /**
  48860. * EXPERIMENTAL haptic support.
  48861. */
  48862. hapticActuators?: Array<{
  48863. pulse: (value: number, duration: number) => Promise<boolean>;
  48864. }>;
  48865. }
  48866. /**
  48867. * An Abstract Motion controller
  48868. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48869. * Each component has an observable to check for changes in value and state
  48870. */
  48871. export abstract class WebXRAbstractMotionController implements IDisposable {
  48872. protected scene: Scene;
  48873. protected layout: IMotionControllerLayout;
  48874. /**
  48875. * The gamepad object correlating to this controller
  48876. */
  48877. gamepadObject: IMinimalMotionControllerObject;
  48878. /**
  48879. * handedness (left/right/none) of this controller
  48880. */
  48881. handedness: MotionControllerHandedness;
  48882. private _initComponent;
  48883. private _modelReady;
  48884. /**
  48885. * A map of components (WebXRControllerComponent) in this motion controller
  48886. * Components have a ComponentType and can also have both button and axis definitions
  48887. */
  48888. readonly components: {
  48889. [id: string]: WebXRControllerComponent;
  48890. };
  48891. /**
  48892. * Disable the model's animation. Can be set at any time.
  48893. */
  48894. disableAnimation: boolean;
  48895. /**
  48896. * Observers registered here will be triggered when the model of this controller is done loading
  48897. */
  48898. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48899. /**
  48900. * The profile id of this motion controller
  48901. */
  48902. abstract profileId: string;
  48903. /**
  48904. * The root mesh of the model. It is null if the model was not yet initialized
  48905. */
  48906. rootMesh: Nullable<AbstractMesh>;
  48907. /**
  48908. * constructs a new abstract motion controller
  48909. * @param scene the scene to which the model of the controller will be added
  48910. * @param layout The profile layout to load
  48911. * @param gamepadObject The gamepad object correlating to this controller
  48912. * @param handedness handedness (left/right/none) of this controller
  48913. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48914. */
  48915. constructor(scene: Scene, layout: IMotionControllerLayout,
  48916. /**
  48917. * The gamepad object correlating to this controller
  48918. */
  48919. gamepadObject: IMinimalMotionControllerObject,
  48920. /**
  48921. * handedness (left/right/none) of this controller
  48922. */
  48923. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48924. /**
  48925. * Dispose this controller, the model mesh and all its components
  48926. */
  48927. dispose(): void;
  48928. /**
  48929. * Returns all components of specific type
  48930. * @param type the type to search for
  48931. * @return an array of components with this type
  48932. */
  48933. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48934. /**
  48935. * get a component based an its component id as defined in layout.components
  48936. * @param id the id of the component
  48937. * @returns the component correlates to the id or undefined if not found
  48938. */
  48939. getComponent(id: string): WebXRControllerComponent;
  48940. /**
  48941. * Get the list of components available in this motion controller
  48942. * @returns an array of strings correlating to available components
  48943. */
  48944. getComponentIds(): string[];
  48945. /**
  48946. * Get the first component of specific type
  48947. * @param type type of component to find
  48948. * @return a controller component or null if not found
  48949. */
  48950. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48951. /**
  48952. * Get the main (Select) component of this controller as defined in the layout
  48953. * @returns the main component of this controller
  48954. */
  48955. getMainComponent(): WebXRControllerComponent;
  48956. /**
  48957. * Loads the model correlating to this controller
  48958. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48959. * @returns A promise fulfilled with the result of the model loading
  48960. */
  48961. loadModel(): Promise<boolean>;
  48962. /**
  48963. * Update this model using the current XRFrame
  48964. * @param xrFrame the current xr frame to use and update the model
  48965. */
  48966. updateFromXRFrame(xrFrame: XRFrame): void;
  48967. /**
  48968. * Backwards compatibility due to a deeply-integrated typo
  48969. */
  48970. get handness(): XREye;
  48971. /**
  48972. * Pulse (vibrate) this controller
  48973. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48974. * Consecutive calls to this function will cancel the last pulse call
  48975. *
  48976. * @param value the strength of the pulse in 0.0...1.0 range
  48977. * @param duration Duration of the pulse in milliseconds
  48978. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48979. * @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
  48980. */
  48981. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48982. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48983. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48984. /**
  48985. * Moves the axis on the controller mesh based on its current state
  48986. * @param axis the index of the axis
  48987. * @param axisValue the value of the axis which determines the meshes new position
  48988. * @hidden
  48989. */
  48990. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48991. /**
  48992. * Update the model itself with the current frame data
  48993. * @param xrFrame the frame to use for updating the model mesh
  48994. */
  48995. protected updateModel(xrFrame: XRFrame): void;
  48996. /**
  48997. * Get the filename and path for this controller's model
  48998. * @returns a map of filename and path
  48999. */
  49000. protected abstract _getFilenameAndPath(): {
  49001. filename: string;
  49002. path: string;
  49003. };
  49004. /**
  49005. * This function is called before the mesh is loaded. It checks for loading constraints.
  49006. * For example, this function can check if the GLB loader is available
  49007. * If this function returns false, the generic controller will be loaded instead
  49008. * @returns Is the client ready to load the mesh
  49009. */
  49010. protected abstract _getModelLoadingConstraints(): boolean;
  49011. /**
  49012. * This function will be called after the model was successfully loaded and can be used
  49013. * for mesh transformations before it is available for the user
  49014. * @param meshes the loaded meshes
  49015. */
  49016. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  49017. /**
  49018. * Set the root mesh for this controller. Important for the WebXR controller class
  49019. * @param meshes the loaded meshes
  49020. */
  49021. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  49022. /**
  49023. * A function executed each frame that updates the mesh (if needed)
  49024. * @param xrFrame the current xrFrame
  49025. */
  49026. protected abstract _updateModel(xrFrame: XRFrame): void;
  49027. private _getGenericFilenameAndPath;
  49028. private _getGenericParentMesh;
  49029. }
  49030. }
  49031. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  49032. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49034. import { Scene } from "babylonjs/scene";
  49035. /**
  49036. * A generic trigger-only motion controller for WebXR
  49037. */
  49038. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  49039. /**
  49040. * Static version of the profile id of this controller
  49041. */
  49042. static ProfileId: string;
  49043. profileId: string;
  49044. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  49045. protected _getFilenameAndPath(): {
  49046. filename: string;
  49047. path: string;
  49048. };
  49049. protected _getModelLoadingConstraints(): boolean;
  49050. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  49051. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49052. protected _updateModel(): void;
  49053. }
  49054. }
  49055. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  49056. import { Vector4 } from "babylonjs/Maths/math.vector";
  49057. import { Mesh } from "babylonjs/Meshes/mesh";
  49058. import { Scene } from "babylonjs/scene";
  49059. import { Nullable } from "babylonjs/types";
  49060. /**
  49061. * Class containing static functions to help procedurally build meshes
  49062. */
  49063. export class SphereBuilder {
  49064. /**
  49065. * Creates a sphere mesh
  49066. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49067. * * 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`)
  49068. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49069. * * 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
  49070. * * 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)
  49071. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49072. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49074. * @param name defines the name of the mesh
  49075. * @param options defines the options used to create the mesh
  49076. * @param scene defines the hosting scene
  49077. * @returns the sphere mesh
  49078. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49079. */
  49080. static CreateSphere(name: string, options: {
  49081. segments?: number;
  49082. diameter?: number;
  49083. diameterX?: number;
  49084. diameterY?: number;
  49085. diameterZ?: number;
  49086. arc?: number;
  49087. slice?: number;
  49088. sideOrientation?: number;
  49089. frontUVs?: Vector4;
  49090. backUVs?: Vector4;
  49091. updatable?: boolean;
  49092. }, scene?: Nullable<Scene>): Mesh;
  49093. }
  49094. }
  49095. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  49096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49097. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49098. import { Scene } from "babylonjs/scene";
  49099. /**
  49100. * A profiled motion controller has its profile loaded from an online repository.
  49101. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  49102. */
  49103. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  49104. private _repositoryUrl;
  49105. private _buttonMeshMapping;
  49106. private _touchDots;
  49107. /**
  49108. * The profile ID of this controller. Will be populated when the controller initializes.
  49109. */
  49110. profileId: string;
  49111. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  49112. dispose(): void;
  49113. protected _getFilenameAndPath(): {
  49114. filename: string;
  49115. path: string;
  49116. };
  49117. protected _getModelLoadingConstraints(): boolean;
  49118. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  49119. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49120. protected _updateModel(_xrFrame: XRFrame): void;
  49121. }
  49122. }
  49123. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  49124. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49125. import { Scene } from "babylonjs/scene";
  49126. /**
  49127. * A construction function type to create a new controller based on an xrInput object
  49128. */
  49129. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  49130. /**
  49131. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  49132. *
  49133. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  49134. * it should be replaced with auto-loaded controllers.
  49135. *
  49136. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  49137. */
  49138. export class WebXRMotionControllerManager {
  49139. private static _AvailableControllers;
  49140. private static _Fallbacks;
  49141. private static _ProfileLoadingPromises;
  49142. private static _ProfilesList;
  49143. /**
  49144. * The base URL of the online controller repository. Can be changed at any time.
  49145. */
  49146. static BaseRepositoryUrl: string;
  49147. /**
  49148. * Which repository gets priority - local or online
  49149. */
  49150. static PrioritizeOnlineRepository: boolean;
  49151. /**
  49152. * Use the online repository, or use only locally-defined controllers
  49153. */
  49154. static UseOnlineRepository: boolean;
  49155. /**
  49156. * Clear the cache used for profile loading and reload when requested again
  49157. */
  49158. static ClearProfilesCache(): void;
  49159. /**
  49160. * Register the default fallbacks.
  49161. * This function is called automatically when this file is imported.
  49162. */
  49163. static DefaultFallbacks(): void;
  49164. /**
  49165. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  49166. * @param profileId the profile to which a fallback needs to be found
  49167. * @return an array with corresponding fallback profiles
  49168. */
  49169. static FindFallbackWithProfileId(profileId: string): string[];
  49170. /**
  49171. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  49172. * The order of search:
  49173. *
  49174. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  49175. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  49176. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  49177. * 4) return the generic trigger controller if none were found
  49178. *
  49179. * @param xrInput the xrInput to which a new controller is initialized
  49180. * @param scene the scene to which the model will be added
  49181. * @param forceProfile force a certain profile for this controller
  49182. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  49183. */
  49184. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  49185. /**
  49186. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  49187. *
  49188. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  49189. *
  49190. * @param type the profile type to register
  49191. * @param constructFunction the function to be called when loading this profile
  49192. */
  49193. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  49194. /**
  49195. * Register a fallback to a specific profile.
  49196. * @param profileId the profileId that will receive the fallbacks
  49197. * @param fallbacks A list of fallback profiles
  49198. */
  49199. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  49200. /**
  49201. * Will update the list of profiles available in the repository
  49202. * @return a promise that resolves to a map of profiles available online
  49203. */
  49204. static UpdateProfilesList(): Promise<{
  49205. [profile: string]: string;
  49206. }>;
  49207. private static _LoadProfileFromRepository;
  49208. private static _LoadProfilesFromAvailableControllers;
  49209. }
  49210. }
  49211. declare module "babylonjs/XR/webXRInputSource" {
  49212. import { Observable } from "babylonjs/Misc/observable";
  49213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49214. import { Ray } from "babylonjs/Culling/ray";
  49215. import { Scene } from "babylonjs/scene";
  49216. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49217. /**
  49218. * Configuration options for the WebXR controller creation
  49219. */
  49220. export interface IWebXRControllerOptions {
  49221. /**
  49222. * Should the controller mesh be animated when a user interacts with it
  49223. * The pressed buttons / thumbstick and touchpad animations will be disabled
  49224. */
  49225. disableMotionControllerAnimation?: boolean;
  49226. /**
  49227. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  49228. */
  49229. doNotLoadControllerMesh?: boolean;
  49230. /**
  49231. * Force a specific controller type for this controller.
  49232. * This can be used when creating your own profile or when testing different controllers
  49233. */
  49234. forceControllerProfile?: string;
  49235. /**
  49236. * Defines a rendering group ID for meshes that will be loaded.
  49237. * This is for the default controllers only.
  49238. */
  49239. renderingGroupId?: number;
  49240. }
  49241. /**
  49242. * Represents an XR controller
  49243. */
  49244. export class WebXRInputSource {
  49245. private _scene;
  49246. /** The underlying input source for the controller */
  49247. inputSource: XRInputSource;
  49248. private _options;
  49249. private _tmpVector;
  49250. private _uniqueId;
  49251. /**
  49252. * 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
  49253. */
  49254. grip?: AbstractMesh;
  49255. /**
  49256. * If available, this is the gamepad object related to this controller.
  49257. * Using this object it is possible to get click events and trackpad changes of the
  49258. * webxr controller that is currently being used.
  49259. */
  49260. motionController?: WebXRAbstractMotionController;
  49261. /**
  49262. * Event that fires when the controller is removed/disposed.
  49263. * The object provided as event data is this controller, after associated assets were disposed.
  49264. * uniqueId is still available.
  49265. */
  49266. onDisposeObservable: Observable<WebXRInputSource>;
  49267. /**
  49268. * Will be triggered when the mesh associated with the motion controller is done loading.
  49269. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  49270. * A shortened version of controller -> motion controller -> on mesh loaded.
  49271. */
  49272. onMeshLoadedObservable: Observable<AbstractMesh>;
  49273. /**
  49274. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  49275. */
  49276. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  49277. /**
  49278. * Pointer which can be used to select objects or attach a visible laser to
  49279. */
  49280. pointer: AbstractMesh;
  49281. /**
  49282. * Creates the controller
  49283. * @see https://doc.babylonjs.com/how_to/webxr
  49284. * @param _scene the scene which the controller should be associated to
  49285. * @param inputSource the underlying input source for the controller
  49286. * @param _options options for this controller creation
  49287. */
  49288. constructor(_scene: Scene,
  49289. /** The underlying input source for the controller */
  49290. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  49291. /**
  49292. * Get this controllers unique id
  49293. */
  49294. get uniqueId(): string;
  49295. /**
  49296. * Disposes of the object
  49297. */
  49298. dispose(): void;
  49299. /**
  49300. * Gets a world space ray coming from the pointer or grip
  49301. * @param result the resulting ray
  49302. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  49303. */
  49304. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  49305. /**
  49306. * Updates the controller pose based on the given XRFrame
  49307. * @param xrFrame xr frame to update the pose with
  49308. * @param referenceSpace reference space to use
  49309. */
  49310. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  49311. }
  49312. }
  49313. declare module "babylonjs/XR/webXRInput" {
  49314. import { Observable } from "babylonjs/Misc/observable";
  49315. import { IDisposable } from "babylonjs/scene";
  49316. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  49317. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49318. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49319. /**
  49320. * The schema for initialization options of the XR Input class
  49321. */
  49322. export interface IWebXRInputOptions {
  49323. /**
  49324. * If set to true no model will be automatically loaded
  49325. */
  49326. doNotLoadControllerMeshes?: boolean;
  49327. /**
  49328. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  49329. * If not found, the xr input profile data will be used.
  49330. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  49331. */
  49332. forceInputProfile?: string;
  49333. /**
  49334. * Do not send a request to the controller repository to load the profile.
  49335. *
  49336. * Instead, use the controllers available in babylon itself.
  49337. */
  49338. disableOnlineControllerRepository?: boolean;
  49339. /**
  49340. * A custom URL for the controllers repository
  49341. */
  49342. customControllersRepositoryURL?: string;
  49343. /**
  49344. * Should the controller model's components not move according to the user input
  49345. */
  49346. disableControllerAnimation?: boolean;
  49347. /**
  49348. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  49349. */
  49350. controllerOptions?: IWebXRControllerOptions;
  49351. }
  49352. /**
  49353. * XR input used to track XR inputs such as controllers/rays
  49354. */
  49355. export class WebXRInput implements IDisposable {
  49356. /**
  49357. * the xr session manager for this session
  49358. */
  49359. xrSessionManager: WebXRSessionManager;
  49360. /**
  49361. * the WebXR camera for this session. Mainly used for teleportation
  49362. */
  49363. xrCamera: WebXRCamera;
  49364. private readonly options;
  49365. /**
  49366. * XR controllers being tracked
  49367. */
  49368. controllers: Array<WebXRInputSource>;
  49369. private _frameObserver;
  49370. private _sessionEndedObserver;
  49371. private _sessionInitObserver;
  49372. /**
  49373. * Event when a controller has been connected/added
  49374. */
  49375. onControllerAddedObservable: Observable<WebXRInputSource>;
  49376. /**
  49377. * Event when a controller has been removed/disconnected
  49378. */
  49379. onControllerRemovedObservable: Observable<WebXRInputSource>;
  49380. /**
  49381. * Initializes the WebXRInput
  49382. * @param xrSessionManager the xr session manager for this session
  49383. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  49384. * @param options = initialization options for this xr input
  49385. */
  49386. constructor(
  49387. /**
  49388. * the xr session manager for this session
  49389. */
  49390. xrSessionManager: WebXRSessionManager,
  49391. /**
  49392. * the WebXR camera for this session. Mainly used for teleportation
  49393. */
  49394. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  49395. private _onInputSourcesChange;
  49396. private _addAndRemoveControllers;
  49397. /**
  49398. * Disposes of the object
  49399. */
  49400. dispose(): void;
  49401. }
  49402. }
  49403. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  49404. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49405. import { Observable, EventState } from "babylonjs/Misc/observable";
  49406. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49407. /**
  49408. * This is the base class for all WebXR features.
  49409. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  49410. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  49411. */
  49412. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  49413. protected _xrSessionManager: WebXRSessionManager;
  49414. private _attached;
  49415. private _removeOnDetach;
  49416. /**
  49417. * Should auto-attach be disabled?
  49418. */
  49419. disableAutoAttach: boolean;
  49420. /**
  49421. * Construct a new (abstract) WebXR feature
  49422. * @param _xrSessionManager the xr session manager for this feature
  49423. */
  49424. constructor(_xrSessionManager: WebXRSessionManager);
  49425. /**
  49426. * Is this feature attached
  49427. */
  49428. get attached(): boolean;
  49429. /**
  49430. * attach this feature
  49431. *
  49432. * @param force should attachment be forced (even when already attached)
  49433. * @returns true if successful, false is failed or already attached
  49434. */
  49435. attach(force?: boolean): boolean;
  49436. /**
  49437. * detach this feature.
  49438. *
  49439. * @returns true if successful, false if failed or already detached
  49440. */
  49441. detach(): boolean;
  49442. /**
  49443. * Dispose this feature and all of the resources attached
  49444. */
  49445. dispose(): void;
  49446. /**
  49447. * This is used to register callbacks that will automatically be removed when detach is called.
  49448. * @param observable the observable to which the observer will be attached
  49449. * @param callback the callback to register
  49450. */
  49451. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  49452. /**
  49453. * Code in this function will be executed on each xrFrame received from the browser.
  49454. * This function will not execute after the feature is detached.
  49455. * @param _xrFrame the current frame
  49456. */
  49457. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  49458. }
  49459. }
  49460. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  49461. import { IDisposable, Scene } from "babylonjs/scene";
  49462. import { Nullable } from "babylonjs/types";
  49463. import { Observable } from "babylonjs/Misc/observable";
  49464. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49465. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  49466. import { Camera } from "babylonjs/Cameras/camera";
  49467. /**
  49468. * Renders a layer on top of an existing scene
  49469. */
  49470. export class UtilityLayerRenderer implements IDisposable {
  49471. /** the original scene that will be rendered on top of */
  49472. originalScene: Scene;
  49473. private _pointerCaptures;
  49474. private _lastPointerEvents;
  49475. private static _DefaultUtilityLayer;
  49476. private static _DefaultKeepDepthUtilityLayer;
  49477. private _sharedGizmoLight;
  49478. private _renderCamera;
  49479. /**
  49480. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  49481. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  49482. * @returns the camera that is used when rendering the utility layer
  49483. */
  49484. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  49485. /**
  49486. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  49487. * @param cam the camera that should be used when rendering the utility layer
  49488. */
  49489. setRenderCamera(cam: Nullable<Camera>): void;
  49490. /**
  49491. * @hidden
  49492. * Light which used by gizmos to get light shading
  49493. */
  49494. _getSharedGizmoLight(): HemisphericLight;
  49495. /**
  49496. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  49497. */
  49498. pickUtilitySceneFirst: boolean;
  49499. /**
  49500. * 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)
  49501. */
  49502. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  49503. /**
  49504. * 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)
  49505. */
  49506. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  49507. /**
  49508. * The scene that is rendered on top of the original scene
  49509. */
  49510. utilityLayerScene: Scene;
  49511. /**
  49512. * If the utility layer should automatically be rendered on top of existing scene
  49513. */
  49514. shouldRender: boolean;
  49515. /**
  49516. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  49517. */
  49518. onlyCheckPointerDownEvents: boolean;
  49519. /**
  49520. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  49521. */
  49522. processAllEvents: boolean;
  49523. /**
  49524. * Observable raised when the pointer move from the utility layer scene to the main scene
  49525. */
  49526. onPointerOutObservable: Observable<number>;
  49527. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  49528. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  49529. private _afterRenderObserver;
  49530. private _sceneDisposeObserver;
  49531. private _originalPointerObserver;
  49532. /**
  49533. * Instantiates a UtilityLayerRenderer
  49534. * @param originalScene the original scene that will be rendered on top of
  49535. * @param handleEvents boolean indicating if the utility layer should handle events
  49536. */
  49537. constructor(
  49538. /** the original scene that will be rendered on top of */
  49539. originalScene: Scene, handleEvents?: boolean);
  49540. private _notifyObservers;
  49541. /**
  49542. * Renders the utility layers scene on top of the original scene
  49543. */
  49544. render(): void;
  49545. /**
  49546. * Disposes of the renderer
  49547. */
  49548. dispose(): void;
  49549. private _updateCamera;
  49550. }
  49551. }
  49552. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  49553. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49555. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49556. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  49557. import { Scene } from "babylonjs/scene";
  49558. import { Nullable } from "babylonjs/types";
  49559. import { Color3 } from "babylonjs/Maths/math.color";
  49560. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49561. /**
  49562. * Options interface for the pointer selection module
  49563. */
  49564. export interface IWebXRControllerPointerSelectionOptions {
  49565. /**
  49566. * if provided, this scene will be used to render meshes.
  49567. */
  49568. customUtilityLayerScene?: Scene;
  49569. /**
  49570. * 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)
  49571. * If not disabled, the last picked point will be used to execute a pointer up event
  49572. * If disabled, pointer up event will be triggered right after the pointer down event.
  49573. * Used in screen and gaze target ray mode only
  49574. */
  49575. disablePointerUpOnTouchOut: boolean;
  49576. /**
  49577. * For gaze mode (time to select instead of press)
  49578. */
  49579. forceGazeMode: boolean;
  49580. /**
  49581. * 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
  49582. * to start a new countdown to the pointer down event.
  49583. * Defaults to 1.
  49584. */
  49585. gazeModePointerMovedFactor?: number;
  49586. /**
  49587. * Different button type to use instead of the main component
  49588. */
  49589. overrideButtonId?: string;
  49590. /**
  49591. * use this rendering group id for the meshes (optional)
  49592. */
  49593. renderingGroupId?: number;
  49594. /**
  49595. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  49596. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  49597. * 3000 means 3 seconds between pointing at something and selecting it
  49598. */
  49599. timeToSelect?: number;
  49600. /**
  49601. * Should meshes created here be added to a utility layer or the main scene
  49602. */
  49603. useUtilityLayer?: boolean;
  49604. /**
  49605. * the xr input to use with this pointer selection
  49606. */
  49607. xrInput: WebXRInput;
  49608. }
  49609. /**
  49610. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49611. */
  49612. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49613. private readonly _options;
  49614. private static _idCounter;
  49615. private _attachController;
  49616. private _controllers;
  49617. private _scene;
  49618. private _tmpVectorForPickCompare;
  49619. /**
  49620. * The module's name
  49621. */
  49622. static readonly Name: string;
  49623. /**
  49624. * The (Babylon) version of this module.
  49625. * This is an integer representing the implementation version.
  49626. * This number does not correspond to the WebXR specs version
  49627. */
  49628. static readonly Version: number;
  49629. /**
  49630. * Disable lighting on the laser pointer (so it will always be visible)
  49631. */
  49632. disablePointerLighting: boolean;
  49633. /**
  49634. * Disable lighting on the selection mesh (so it will always be visible)
  49635. */
  49636. disableSelectionMeshLighting: boolean;
  49637. /**
  49638. * Should the laser pointer be displayed
  49639. */
  49640. displayLaserPointer: boolean;
  49641. /**
  49642. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49643. */
  49644. displaySelectionMesh: boolean;
  49645. /**
  49646. * This color will be set to the laser pointer when selection is triggered
  49647. */
  49648. laserPointerPickedColor: Color3;
  49649. /**
  49650. * Default color of the laser pointer
  49651. */
  49652. laserPointerDefaultColor: Color3;
  49653. /**
  49654. * default color of the selection ring
  49655. */
  49656. selectionMeshDefaultColor: Color3;
  49657. /**
  49658. * This color will be applied to the selection ring when selection is triggered
  49659. */
  49660. selectionMeshPickedColor: Color3;
  49661. /**
  49662. * Optional filter to be used for ray selection. This predicate shares behavior with
  49663. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49664. */
  49665. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49666. /**
  49667. * constructs a new background remover module
  49668. * @param _xrSessionManager the session manager for this module
  49669. * @param _options read-only options to be used in this module
  49670. */
  49671. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49672. /**
  49673. * attach this feature
  49674. * Will usually be called by the features manager
  49675. *
  49676. * @returns true if successful.
  49677. */
  49678. attach(): boolean;
  49679. /**
  49680. * detach this feature.
  49681. * Will usually be called by the features manager
  49682. *
  49683. * @returns true if successful.
  49684. */
  49685. detach(): boolean;
  49686. /**
  49687. * Will get the mesh under a specific pointer.
  49688. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49689. * @param controllerId the controllerId to check
  49690. * @returns The mesh under pointer or null if no mesh is under the pointer
  49691. */
  49692. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49693. /**
  49694. * Get the xr controller that correlates to the pointer id in the pointer event
  49695. *
  49696. * @param id the pointer id to search for
  49697. * @returns the controller that correlates to this id or null if not found
  49698. */
  49699. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49700. protected _onXRFrame(_xrFrame: XRFrame): void;
  49701. private _attachGazeMode;
  49702. private _attachScreenRayMode;
  49703. private _attachTrackedPointerRayMode;
  49704. private _convertNormalToDirectionOfRay;
  49705. private _detachController;
  49706. private _generateNewMeshPair;
  49707. private _pickingMoved;
  49708. private _updatePointerDistance;
  49709. /** @hidden */
  49710. get lasterPointerDefaultColor(): Color3;
  49711. }
  49712. }
  49713. declare module "babylonjs/XR/webXREnterExitUI" {
  49714. import { Nullable } from "babylonjs/types";
  49715. import { Observable } from "babylonjs/Misc/observable";
  49716. import { IDisposable, Scene } from "babylonjs/scene";
  49717. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  49718. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49719. /**
  49720. * Button which can be used to enter a different mode of XR
  49721. */
  49722. export class WebXREnterExitUIButton {
  49723. /** button element */
  49724. element: HTMLElement;
  49725. /** XR initialization options for the button */
  49726. sessionMode: XRSessionMode;
  49727. /** Reference space type */
  49728. referenceSpaceType: XRReferenceSpaceType;
  49729. /**
  49730. * Creates a WebXREnterExitUIButton
  49731. * @param element button element
  49732. * @param sessionMode XR initialization session mode
  49733. * @param referenceSpaceType the type of reference space to be used
  49734. */
  49735. constructor(
  49736. /** button element */
  49737. element: HTMLElement,
  49738. /** XR initialization options for the button */
  49739. sessionMode: XRSessionMode,
  49740. /** Reference space type */
  49741. referenceSpaceType: XRReferenceSpaceType);
  49742. /**
  49743. * Extendable function which can be used to update the button's visuals when the state changes
  49744. * @param activeButton the current active button in the UI
  49745. */
  49746. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49747. }
  49748. /**
  49749. * Options to create the webXR UI
  49750. */
  49751. export class WebXREnterExitUIOptions {
  49752. /**
  49753. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49754. */
  49755. customButtons?: Array<WebXREnterExitUIButton>;
  49756. /**
  49757. * A reference space type to use when creating the default button.
  49758. * Default is local-floor
  49759. */
  49760. referenceSpaceType?: XRReferenceSpaceType;
  49761. /**
  49762. * Context to enter xr with
  49763. */
  49764. renderTarget?: Nullable<WebXRRenderTarget>;
  49765. /**
  49766. * A session mode to use when creating the default button.
  49767. * Default is immersive-vr
  49768. */
  49769. sessionMode?: XRSessionMode;
  49770. /**
  49771. * A list of optional features to init the session with
  49772. */
  49773. optionalFeatures?: string[];
  49774. }
  49775. /**
  49776. * UI to allow the user to enter/exit XR mode
  49777. */
  49778. export class WebXREnterExitUI implements IDisposable {
  49779. private scene;
  49780. /** version of the options passed to this UI */
  49781. options: WebXREnterExitUIOptions;
  49782. private _activeButton;
  49783. private _buttons;
  49784. private _overlay;
  49785. /**
  49786. * Fired every time the active button is changed.
  49787. *
  49788. * When xr is entered via a button that launches xr that button will be the callback parameter
  49789. *
  49790. * When exiting xr the callback parameter will be null)
  49791. */
  49792. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49793. /**
  49794. *
  49795. * @param scene babylon scene object to use
  49796. * @param options (read-only) version of the options passed to this UI
  49797. */
  49798. private constructor();
  49799. /**
  49800. * Creates UI to allow the user to enter/exit XR mode
  49801. * @param scene the scene to add the ui to
  49802. * @param helper the xr experience helper to enter/exit xr with
  49803. * @param options options to configure the UI
  49804. * @returns the created ui
  49805. */
  49806. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49807. /**
  49808. * Disposes of the XR UI component
  49809. */
  49810. dispose(): void;
  49811. private _updateButtons;
  49812. }
  49813. }
  49814. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  49815. import { Vector3 } from "babylonjs/Maths/math.vector";
  49816. import { Color4 } from "babylonjs/Maths/math.color";
  49817. import { Nullable } from "babylonjs/types";
  49818. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49819. import { Scene } from "babylonjs/scene";
  49820. /**
  49821. * Class containing static functions to help procedurally build meshes
  49822. */
  49823. export class LinesBuilder {
  49824. /**
  49825. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49826. * * 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
  49827. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49828. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49829. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49830. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49831. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49832. * * 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
  49833. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49835. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49836. * @param name defines the name of the new line system
  49837. * @param options defines the options used to create the line system
  49838. * @param scene defines the hosting scene
  49839. * @returns a new line system mesh
  49840. */
  49841. static CreateLineSystem(name: string, options: {
  49842. lines: Vector3[][];
  49843. updatable?: boolean;
  49844. instance?: Nullable<LinesMesh>;
  49845. colors?: Nullable<Color4[][]>;
  49846. useVertexAlpha?: boolean;
  49847. }, scene: Nullable<Scene>): LinesMesh;
  49848. /**
  49849. * Creates a line mesh
  49850. * 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
  49851. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49852. * * The parameter `points` is an array successive Vector3
  49853. * * 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
  49854. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49855. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49856. * * When updating an instance, remember that only point positions can change, not the number of points
  49857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49858. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49859. * @param name defines the name of the new line system
  49860. * @param options defines the options used to create the line system
  49861. * @param scene defines the hosting scene
  49862. * @returns a new line mesh
  49863. */
  49864. static CreateLines(name: string, options: {
  49865. points: Vector3[];
  49866. updatable?: boolean;
  49867. instance?: Nullable<LinesMesh>;
  49868. colors?: Color4[];
  49869. useVertexAlpha?: boolean;
  49870. }, scene?: Nullable<Scene>): LinesMesh;
  49871. /**
  49872. * Creates a dashed line mesh
  49873. * * 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
  49874. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49875. * * The parameter `points` is an array successive Vector3
  49876. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49877. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49878. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49879. * * 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
  49880. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49881. * * When updating an instance, remember that only point positions can change, not the number of points
  49882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49883. * @param name defines the name of the mesh
  49884. * @param options defines the options used to create the mesh
  49885. * @param scene defines the hosting scene
  49886. * @returns the dashed line mesh
  49887. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49888. */
  49889. static CreateDashedLines(name: string, options: {
  49890. points: Vector3[];
  49891. dashSize?: number;
  49892. gapSize?: number;
  49893. dashNb?: number;
  49894. updatable?: boolean;
  49895. instance?: LinesMesh;
  49896. useVertexAlpha?: boolean;
  49897. }, scene?: Nullable<Scene>): LinesMesh;
  49898. }
  49899. }
  49900. declare module "babylonjs/Misc/timer" {
  49901. import { Observable, Observer } from "babylonjs/Misc/observable";
  49902. import { Nullable } from "babylonjs/types";
  49903. import { IDisposable } from "babylonjs/scene";
  49904. /**
  49905. * Construction options for a timer
  49906. */
  49907. export interface ITimerOptions<T> {
  49908. /**
  49909. * Time-to-end
  49910. */
  49911. timeout: number;
  49912. /**
  49913. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  49914. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  49915. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  49916. */
  49917. contextObservable: Observable<T>;
  49918. /**
  49919. * Optional parameters when adding an observer to the observable
  49920. */
  49921. observableParameters?: {
  49922. mask?: number;
  49923. insertFirst?: boolean;
  49924. scope?: any;
  49925. };
  49926. /**
  49927. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  49928. */
  49929. breakCondition?: (data?: ITimerData<T>) => boolean;
  49930. /**
  49931. * Will be triggered when the time condition has met
  49932. */
  49933. onEnded?: (data: ITimerData<any>) => void;
  49934. /**
  49935. * Will be triggered when the break condition has met (prematurely ended)
  49936. */
  49937. onAborted?: (data: ITimerData<any>) => void;
  49938. /**
  49939. * Optional function to execute on each tick (or count)
  49940. */
  49941. onTick?: (data: ITimerData<any>) => void;
  49942. }
  49943. /**
  49944. * An interface defining the data sent by the timer
  49945. */
  49946. export interface ITimerData<T> {
  49947. /**
  49948. * When did it start
  49949. */
  49950. startTime: number;
  49951. /**
  49952. * Time now
  49953. */
  49954. currentTime: number;
  49955. /**
  49956. * Time passed since started
  49957. */
  49958. deltaTime: number;
  49959. /**
  49960. * How much is completed, in [0.0...1.0].
  49961. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49962. */
  49963. completeRate: number;
  49964. /**
  49965. * What the registered observable sent in the last count
  49966. */
  49967. payload: T;
  49968. }
  49969. /**
  49970. * The current state of the timer
  49971. */
  49972. export enum TimerState {
  49973. /**
  49974. * Timer initialized, not yet started
  49975. */
  49976. INIT = 0,
  49977. /**
  49978. * Timer started and counting
  49979. */
  49980. STARTED = 1,
  49981. /**
  49982. * Timer ended (whether aborted or time reached)
  49983. */
  49984. ENDED = 2
  49985. }
  49986. /**
  49987. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49988. *
  49989. * @param options options with which to initialize this timer
  49990. */
  49991. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49992. /**
  49993. * An advanced implementation of a timer class
  49994. */
  49995. export class AdvancedTimer<T = any> implements IDisposable {
  49996. /**
  49997. * Will notify each time the timer calculates the remaining time
  49998. */
  49999. onEachCountObservable: Observable<ITimerData<T>>;
  50000. /**
  50001. * Will trigger when the timer was aborted due to the break condition
  50002. */
  50003. onTimerAbortedObservable: Observable<ITimerData<T>>;
  50004. /**
  50005. * Will trigger when the timer ended successfully
  50006. */
  50007. onTimerEndedObservable: Observable<ITimerData<T>>;
  50008. /**
  50009. * Will trigger when the timer state has changed
  50010. */
  50011. onStateChangedObservable: Observable<TimerState>;
  50012. private _observer;
  50013. private _contextObservable;
  50014. private _observableParameters;
  50015. private _startTime;
  50016. private _timer;
  50017. private _state;
  50018. private _breakCondition;
  50019. private _timeToEnd;
  50020. private _breakOnNextTick;
  50021. /**
  50022. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  50023. * @param options construction options for this advanced timer
  50024. */
  50025. constructor(options: ITimerOptions<T>);
  50026. /**
  50027. * set a breaking condition for this timer. Default is to never break during count
  50028. * @param predicate the new break condition. Returns true to break, false otherwise
  50029. */
  50030. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  50031. /**
  50032. * Reset ALL associated observables in this advanced timer
  50033. */
  50034. clearObservables(): void;
  50035. /**
  50036. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  50037. *
  50038. * @param timeToEnd how much time to measure until timer ended
  50039. */
  50040. start(timeToEnd?: number): void;
  50041. /**
  50042. * Will force a stop on the next tick.
  50043. */
  50044. stop(): void;
  50045. /**
  50046. * Dispose this timer, clearing all resources
  50047. */
  50048. dispose(): void;
  50049. private _setState;
  50050. private _tick;
  50051. private _stop;
  50052. }
  50053. }
  50054. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  50055. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50056. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50057. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50059. import { Vector3 } from "babylonjs/Maths/math.vector";
  50060. import { Material } from "babylonjs/Materials/material";
  50061. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50062. import { Scene } from "babylonjs/scene";
  50063. /**
  50064. * The options container for the teleportation module
  50065. */
  50066. export interface IWebXRTeleportationOptions {
  50067. /**
  50068. * if provided, this scene will be used to render meshes.
  50069. */
  50070. customUtilityLayerScene?: Scene;
  50071. /**
  50072. * Values to configure the default target mesh
  50073. */
  50074. defaultTargetMeshOptions?: {
  50075. /**
  50076. * Fill color of the teleportation area
  50077. */
  50078. teleportationFillColor?: string;
  50079. /**
  50080. * Border color for the teleportation area
  50081. */
  50082. teleportationBorderColor?: string;
  50083. /**
  50084. * Disable the mesh's animation sequence
  50085. */
  50086. disableAnimation?: boolean;
  50087. /**
  50088. * Disable lighting on the material or the ring and arrow
  50089. */
  50090. disableLighting?: boolean;
  50091. /**
  50092. * Override the default material of the torus and arrow
  50093. */
  50094. torusArrowMaterial?: Material;
  50095. };
  50096. /**
  50097. * A list of meshes to use as floor meshes.
  50098. * Meshes can be added and removed after initializing the feature using the
  50099. * addFloorMesh and removeFloorMesh functions
  50100. * If empty, rotation will still work
  50101. */
  50102. floorMeshes?: AbstractMesh[];
  50103. /**
  50104. * use this rendering group id for the meshes (optional)
  50105. */
  50106. renderingGroupId?: number;
  50107. /**
  50108. * Should teleportation move only to snap points
  50109. */
  50110. snapPointsOnly?: boolean;
  50111. /**
  50112. * An array of points to which the teleportation will snap to.
  50113. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  50114. */
  50115. snapPositions?: Vector3[];
  50116. /**
  50117. * How close should the teleportation ray be in order to snap to position.
  50118. * Default to 0.8 units (meters)
  50119. */
  50120. snapToPositionRadius?: number;
  50121. /**
  50122. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  50123. * If you want to support rotation, make sure your mesh has a direction indicator.
  50124. *
  50125. * When left untouched, the default mesh will be initialized.
  50126. */
  50127. teleportationTargetMesh?: AbstractMesh;
  50128. /**
  50129. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  50130. */
  50131. timeToTeleport?: number;
  50132. /**
  50133. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  50134. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  50135. */
  50136. useMainComponentOnly?: boolean;
  50137. /**
  50138. * Should meshes created here be added to a utility layer or the main scene
  50139. */
  50140. useUtilityLayer?: boolean;
  50141. /**
  50142. * Babylon XR Input class for controller
  50143. */
  50144. xrInput: WebXRInput;
  50145. }
  50146. /**
  50147. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  50148. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  50149. * the input of the attached controllers.
  50150. */
  50151. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  50152. private _options;
  50153. private _controllers;
  50154. private _currentTeleportationControllerId;
  50155. private _floorMeshes;
  50156. private _quadraticBezierCurve;
  50157. private _selectionFeature;
  50158. private _snapToPositions;
  50159. private _snappedToPoint;
  50160. private _teleportationRingMaterial?;
  50161. private _tmpRay;
  50162. private _tmpVector;
  50163. /**
  50164. * The module's name
  50165. */
  50166. static readonly Name: string;
  50167. /**
  50168. * The (Babylon) version of this module.
  50169. * This is an integer representing the implementation version.
  50170. * This number does not correspond to the webxr specs version
  50171. */
  50172. static readonly Version: number;
  50173. /**
  50174. * Is movement backwards enabled
  50175. */
  50176. backwardsMovementEnabled: boolean;
  50177. /**
  50178. * Distance to travel when moving backwards
  50179. */
  50180. backwardsTeleportationDistance: number;
  50181. /**
  50182. * The distance from the user to the inspection point in the direction of the controller
  50183. * A higher number will allow the user to move further
  50184. * defaults to 5 (meters, in xr units)
  50185. */
  50186. parabolicCheckRadius: number;
  50187. /**
  50188. * Should the module support parabolic ray on top of direct ray
  50189. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  50190. * Very helpful when moving between floors / different heights
  50191. */
  50192. parabolicRayEnabled: boolean;
  50193. /**
  50194. * How much rotation should be applied when rotating right and left
  50195. */
  50196. rotationAngle: number;
  50197. /**
  50198. * Is rotation enabled when moving forward?
  50199. * Disabling this feature will prevent the user from deciding the direction when teleporting
  50200. */
  50201. rotationEnabled: boolean;
  50202. /**
  50203. * constructs a new anchor system
  50204. * @param _xrSessionManager an instance of WebXRSessionManager
  50205. * @param _options configuration object for this feature
  50206. */
  50207. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  50208. /**
  50209. * Get the snapPointsOnly flag
  50210. */
  50211. get snapPointsOnly(): boolean;
  50212. /**
  50213. * Sets the snapPointsOnly flag
  50214. * @param snapToPoints should teleportation be exclusively to snap points
  50215. */
  50216. set snapPointsOnly(snapToPoints: boolean);
  50217. /**
  50218. * Add a new mesh to the floor meshes array
  50219. * @param mesh the mesh to use as floor mesh
  50220. */
  50221. addFloorMesh(mesh: AbstractMesh): void;
  50222. /**
  50223. * Add a new snap-to point to fix teleportation to this position
  50224. * @param newSnapPoint The new Snap-To point
  50225. */
  50226. addSnapPoint(newSnapPoint: Vector3): void;
  50227. attach(): boolean;
  50228. detach(): boolean;
  50229. dispose(): void;
  50230. /**
  50231. * Remove a mesh from the floor meshes array
  50232. * @param mesh the mesh to remove
  50233. */
  50234. removeFloorMesh(mesh: AbstractMesh): void;
  50235. /**
  50236. * Remove a mesh from the floor meshes array using its name
  50237. * @param name the mesh name to remove
  50238. */
  50239. removeFloorMeshByName(name: string): void;
  50240. /**
  50241. * 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
  50242. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  50243. * @returns was the point found and removed or not
  50244. */
  50245. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  50246. /**
  50247. * This function sets a selection feature that will be disabled when
  50248. * the forward ray is shown and will be reattached when hidden.
  50249. * This is used to remove the selection rays when moving.
  50250. * @param selectionFeature the feature to disable when forward movement is enabled
  50251. */
  50252. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  50253. protected _onXRFrame(_xrFrame: XRFrame): void;
  50254. private _attachController;
  50255. private _createDefaultTargetMesh;
  50256. private _detachController;
  50257. private _findClosestSnapPointWithRadius;
  50258. private _setTargetMeshPosition;
  50259. private _setTargetMeshVisibility;
  50260. private _showParabolicPath;
  50261. private _teleportForward;
  50262. }
  50263. }
  50264. declare module "babylonjs/XR/webXRDefaultExperience" {
  50265. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50266. import { Scene } from "babylonjs/scene";
  50267. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  50268. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  50269. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50270. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  50271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50272. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  50273. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  50274. /**
  50275. * Options for the default xr helper
  50276. */
  50277. export class WebXRDefaultExperienceOptions {
  50278. /**
  50279. * Enable or disable default UI to enter XR
  50280. */
  50281. disableDefaultUI?: boolean;
  50282. /**
  50283. * Should teleportation not initialize. defaults to false.
  50284. */
  50285. disableTeleportation?: boolean;
  50286. /**
  50287. * Floor meshes that will be used for teleport
  50288. */
  50289. floorMeshes?: Array<AbstractMesh>;
  50290. /**
  50291. * If set to true, the first frame will not be used to reset position
  50292. * The first frame is mainly used when copying transformation from the old camera
  50293. * Mainly used in AR
  50294. */
  50295. ignoreNativeCameraTransformation?: boolean;
  50296. /**
  50297. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  50298. */
  50299. inputOptions?: IWebXRInputOptions;
  50300. /**
  50301. * optional configuration for the output canvas
  50302. */
  50303. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  50304. /**
  50305. * optional UI options. This can be used among other to change session mode and reference space type
  50306. */
  50307. uiOptions?: WebXREnterExitUIOptions;
  50308. /**
  50309. * When loading teleportation and pointer select, use stable versions instead of latest.
  50310. */
  50311. useStablePlugins?: boolean;
  50312. /**
  50313. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  50314. */
  50315. renderingGroupId?: number;
  50316. /**
  50317. * A list of optional features to init the session with
  50318. * If set to true, all features we support will be added
  50319. */
  50320. optionalFeatures?: boolean | string[];
  50321. }
  50322. /**
  50323. * Default experience which provides a similar setup to the previous webVRExperience
  50324. */
  50325. export class WebXRDefaultExperience {
  50326. /**
  50327. * Base experience
  50328. */
  50329. baseExperience: WebXRExperienceHelper;
  50330. /**
  50331. * Enables ui for entering/exiting xr
  50332. */
  50333. enterExitUI: WebXREnterExitUI;
  50334. /**
  50335. * Input experience extension
  50336. */
  50337. input: WebXRInput;
  50338. /**
  50339. * Enables laser pointer and selection
  50340. */
  50341. pointerSelection: WebXRControllerPointerSelection;
  50342. /**
  50343. * Default target xr should render to
  50344. */
  50345. renderTarget: WebXRRenderTarget;
  50346. /**
  50347. * Enables teleportation
  50348. */
  50349. teleportation: WebXRMotionControllerTeleportation;
  50350. private constructor();
  50351. /**
  50352. * Creates the default xr experience
  50353. * @param scene scene
  50354. * @param options options for basic configuration
  50355. * @returns resulting WebXRDefaultExperience
  50356. */
  50357. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50358. /**
  50359. * DIsposes of the experience helper
  50360. */
  50361. dispose(): void;
  50362. }
  50363. }
  50364. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  50365. import { Observable } from "babylonjs/Misc/observable";
  50366. import { Nullable } from "babylonjs/types";
  50367. import { Camera } from "babylonjs/Cameras/camera";
  50368. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  50369. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50370. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  50371. import { Scene } from "babylonjs/scene";
  50372. import { Vector3 } from "babylonjs/Maths/math.vector";
  50373. import { Color3 } from "babylonjs/Maths/math.color";
  50374. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50376. import { Mesh } from "babylonjs/Meshes/mesh";
  50377. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  50378. import { EasingFunction } from "babylonjs/Animations/easing";
  50379. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  50380. import "babylonjs/Meshes/Builders/groundBuilder";
  50381. import "babylonjs/Meshes/Builders/torusBuilder";
  50382. import "babylonjs/Meshes/Builders/cylinderBuilder";
  50383. import "babylonjs/Gamepads/gamepadSceneComponent";
  50384. import "babylonjs/Animations/animatable";
  50385. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  50386. /**
  50387. * Options to modify the vr teleportation behavior.
  50388. */
  50389. export interface VRTeleportationOptions {
  50390. /**
  50391. * The name of the mesh which should be used as the teleportation floor. (default: null)
  50392. */
  50393. floorMeshName?: string;
  50394. /**
  50395. * A list of meshes to be used as the teleportation floor. (default: empty)
  50396. */
  50397. floorMeshes?: Mesh[];
  50398. /**
  50399. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  50400. */
  50401. teleportationMode?: number;
  50402. /**
  50403. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  50404. */
  50405. teleportationTime?: number;
  50406. /**
  50407. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  50408. */
  50409. teleportationSpeed?: number;
  50410. /**
  50411. * The easing function used in the animation or null for Linear. (default CircleEase)
  50412. */
  50413. easingFunction?: EasingFunction;
  50414. }
  50415. /**
  50416. * Options to modify the vr experience helper's behavior.
  50417. */
  50418. export interface VRExperienceHelperOptions extends WebVROptions {
  50419. /**
  50420. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  50421. */
  50422. createDeviceOrientationCamera?: boolean;
  50423. /**
  50424. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  50425. */
  50426. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  50427. /**
  50428. * Uses the main button on the controller to toggle the laser casted. (default: true)
  50429. */
  50430. laserToggle?: boolean;
  50431. /**
  50432. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  50433. */
  50434. floorMeshes?: Mesh[];
  50435. /**
  50436. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  50437. */
  50438. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  50439. /**
  50440. * Defines if WebXR should be used instead of WebVR (if available)
  50441. */
  50442. useXR?: boolean;
  50443. }
  50444. /**
  50445. * Event containing information after VR has been entered
  50446. */
  50447. export class OnAfterEnteringVRObservableEvent {
  50448. /**
  50449. * If entering vr was successful
  50450. */
  50451. success: boolean;
  50452. }
  50453. /**
  50454. * Helps to quickly add VR support to an existing scene.
  50455. * See http://doc.babylonjs.com/how_to/webvr_helper
  50456. */
  50457. export class VRExperienceHelper {
  50458. /** Options to modify the vr experience helper's behavior. */
  50459. webVROptions: VRExperienceHelperOptions;
  50460. private _scene;
  50461. private _position;
  50462. private _btnVR;
  50463. private _btnVRDisplayed;
  50464. private _webVRsupported;
  50465. private _webVRready;
  50466. private _webVRrequesting;
  50467. private _webVRpresenting;
  50468. private _hasEnteredVR;
  50469. private _fullscreenVRpresenting;
  50470. private _inputElement;
  50471. private _webVRCamera;
  50472. private _vrDeviceOrientationCamera;
  50473. private _deviceOrientationCamera;
  50474. private _existingCamera;
  50475. private _onKeyDown;
  50476. private _onVrDisplayPresentChange;
  50477. private _onVRDisplayChanged;
  50478. private _onVRRequestPresentStart;
  50479. private _onVRRequestPresentComplete;
  50480. /**
  50481. * 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)
  50482. */
  50483. enableGazeEvenWhenNoPointerLock: boolean;
  50484. /**
  50485. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  50486. */
  50487. exitVROnDoubleTap: boolean;
  50488. /**
  50489. * Observable raised right before entering VR.
  50490. */
  50491. onEnteringVRObservable: Observable<VRExperienceHelper>;
  50492. /**
  50493. * Observable raised when entering VR has completed.
  50494. */
  50495. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  50496. /**
  50497. * Observable raised when exiting VR.
  50498. */
  50499. onExitingVRObservable: Observable<VRExperienceHelper>;
  50500. /**
  50501. * Observable raised when controller mesh is loaded.
  50502. */
  50503. onControllerMeshLoadedObservable: Observable<WebVRController>;
  50504. /** Return this.onEnteringVRObservable
  50505. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  50506. */
  50507. get onEnteringVR(): Observable<VRExperienceHelper>;
  50508. /** Return this.onExitingVRObservable
  50509. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  50510. */
  50511. get onExitingVR(): Observable<VRExperienceHelper>;
  50512. /** Return this.onControllerMeshLoadedObservable
  50513. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  50514. */
  50515. get onControllerMeshLoaded(): Observable<WebVRController>;
  50516. private _rayLength;
  50517. private _useCustomVRButton;
  50518. private _teleportationRequested;
  50519. private _teleportActive;
  50520. private _floorMeshName;
  50521. private _floorMeshesCollection;
  50522. private _teleportationMode;
  50523. private _teleportationTime;
  50524. private _teleportationSpeed;
  50525. private _teleportationEasing;
  50526. private _rotationAllowed;
  50527. private _teleportBackwardsVector;
  50528. private _teleportationTarget;
  50529. private _isDefaultTeleportationTarget;
  50530. private _postProcessMove;
  50531. private _teleportationFillColor;
  50532. private _teleportationBorderColor;
  50533. private _rotationAngle;
  50534. private _haloCenter;
  50535. private _cameraGazer;
  50536. private _padSensibilityUp;
  50537. private _padSensibilityDown;
  50538. private _leftController;
  50539. private _rightController;
  50540. private _gazeColor;
  50541. private _laserColor;
  50542. private _pickedLaserColor;
  50543. private _pickedGazeColor;
  50544. /**
  50545. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  50546. */
  50547. onNewMeshSelected: Observable<AbstractMesh>;
  50548. /**
  50549. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  50550. * This observable will provide the mesh and the controller used to select the mesh
  50551. */
  50552. onMeshSelectedWithController: Observable<{
  50553. mesh: AbstractMesh;
  50554. controller: WebVRController;
  50555. }>;
  50556. /**
  50557. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  50558. */
  50559. onNewMeshPicked: Observable<PickingInfo>;
  50560. private _circleEase;
  50561. /**
  50562. * Observable raised before camera teleportation
  50563. */
  50564. onBeforeCameraTeleport: Observable<Vector3>;
  50565. /**
  50566. * Observable raised after camera teleportation
  50567. */
  50568. onAfterCameraTeleport: Observable<Vector3>;
  50569. /**
  50570. * Observable raised when current selected mesh gets unselected
  50571. */
  50572. onSelectedMeshUnselected: Observable<AbstractMesh>;
  50573. private _raySelectionPredicate;
  50574. /**
  50575. * To be optionaly changed by user to define custom ray selection
  50576. */
  50577. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50578. /**
  50579. * To be optionaly changed by user to define custom selection logic (after ray selection)
  50580. */
  50581. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50582. /**
  50583. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  50584. */
  50585. teleportationEnabled: boolean;
  50586. private _defaultHeight;
  50587. private _teleportationInitialized;
  50588. private _interactionsEnabled;
  50589. private _interactionsRequested;
  50590. private _displayGaze;
  50591. private _displayLaserPointer;
  50592. /**
  50593. * The mesh used to display where the user is going to teleport.
  50594. */
  50595. get teleportationTarget(): Mesh;
  50596. /**
  50597. * Sets the mesh to be used to display where the user is going to teleport.
  50598. */
  50599. set teleportationTarget(value: Mesh);
  50600. /**
  50601. * 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
  50602. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  50603. * See http://doc.babylonjs.com/resources/baking_transformations
  50604. */
  50605. get gazeTrackerMesh(): Mesh;
  50606. set gazeTrackerMesh(value: Mesh);
  50607. /**
  50608. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  50609. */
  50610. updateGazeTrackerScale: boolean;
  50611. /**
  50612. * If the gaze trackers color should be updated when selecting meshes
  50613. */
  50614. updateGazeTrackerColor: boolean;
  50615. /**
  50616. * If the controller laser color should be updated when selecting meshes
  50617. */
  50618. updateControllerLaserColor: boolean;
  50619. /**
  50620. * The gaze tracking mesh corresponding to the left controller
  50621. */
  50622. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  50623. /**
  50624. * The gaze tracking mesh corresponding to the right controller
  50625. */
  50626. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  50627. /**
  50628. * If the ray of the gaze should be displayed.
  50629. */
  50630. get displayGaze(): boolean;
  50631. /**
  50632. * Sets if the ray of the gaze should be displayed.
  50633. */
  50634. set displayGaze(value: boolean);
  50635. /**
  50636. * If the ray of the LaserPointer should be displayed.
  50637. */
  50638. get displayLaserPointer(): boolean;
  50639. /**
  50640. * Sets if the ray of the LaserPointer should be displayed.
  50641. */
  50642. set displayLaserPointer(value: boolean);
  50643. /**
  50644. * The deviceOrientationCamera used as the camera when not in VR.
  50645. */
  50646. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50647. /**
  50648. * Based on the current WebVR support, returns the current VR camera used.
  50649. */
  50650. get currentVRCamera(): Nullable<Camera>;
  50651. /**
  50652. * The webVRCamera which is used when in VR.
  50653. */
  50654. get webVRCamera(): WebVRFreeCamera;
  50655. /**
  50656. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50657. */
  50658. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50659. /**
  50660. * The html button that is used to trigger entering into VR.
  50661. */
  50662. get vrButton(): Nullable<HTMLButtonElement>;
  50663. private get _teleportationRequestInitiated();
  50664. /**
  50665. * Defines whether or not Pointer lock should be requested when switching to
  50666. * full screen.
  50667. */
  50668. requestPointerLockOnFullScreen: boolean;
  50669. /**
  50670. * If asking to force XR, this will be populated with the default xr experience
  50671. */
  50672. xr: WebXRDefaultExperience;
  50673. /**
  50674. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50675. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50676. */
  50677. xrTestDone: boolean;
  50678. /**
  50679. * Instantiates a VRExperienceHelper.
  50680. * Helps to quickly add VR support to an existing scene.
  50681. * @param scene The scene the VRExperienceHelper belongs to.
  50682. * @param webVROptions Options to modify the vr experience helper's behavior.
  50683. */
  50684. constructor(scene: Scene,
  50685. /** Options to modify the vr experience helper's behavior. */
  50686. webVROptions?: VRExperienceHelperOptions);
  50687. private completeVRInit;
  50688. private _onDefaultMeshLoaded;
  50689. private _onResize;
  50690. private _onFullscreenChange;
  50691. /**
  50692. * Gets a value indicating if we are currently in VR mode.
  50693. */
  50694. get isInVRMode(): boolean;
  50695. private onVrDisplayPresentChange;
  50696. private onVRDisplayChanged;
  50697. private moveButtonToBottomRight;
  50698. private displayVRButton;
  50699. private updateButtonVisibility;
  50700. private _cachedAngularSensibility;
  50701. /**
  50702. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50703. * Otherwise, will use the fullscreen API.
  50704. */
  50705. enterVR(): void;
  50706. /**
  50707. * Attempt to exit VR, or fullscreen.
  50708. */
  50709. exitVR(): void;
  50710. /**
  50711. * The position of the vr experience helper.
  50712. */
  50713. get position(): Vector3;
  50714. /**
  50715. * Sets the position of the vr experience helper.
  50716. */
  50717. set position(value: Vector3);
  50718. /**
  50719. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50720. */
  50721. enableInteractions(): void;
  50722. private get _noControllerIsActive();
  50723. private beforeRender;
  50724. private _isTeleportationFloor;
  50725. /**
  50726. * Adds a floor mesh to be used for teleportation.
  50727. * @param floorMesh the mesh to be used for teleportation.
  50728. */
  50729. addFloorMesh(floorMesh: Mesh): void;
  50730. /**
  50731. * Removes a floor mesh from being used for teleportation.
  50732. * @param floorMesh the mesh to be removed.
  50733. */
  50734. removeFloorMesh(floorMesh: Mesh): void;
  50735. /**
  50736. * Enables interactions and teleportation using the VR controllers and gaze.
  50737. * @param vrTeleportationOptions options to modify teleportation behavior.
  50738. */
  50739. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50740. private _onNewGamepadConnected;
  50741. private _tryEnableInteractionOnController;
  50742. private _onNewGamepadDisconnected;
  50743. private _enableInteractionOnController;
  50744. private _checkTeleportWithRay;
  50745. private _checkRotate;
  50746. private _checkTeleportBackwards;
  50747. private _enableTeleportationOnController;
  50748. private _createTeleportationCircles;
  50749. private _displayTeleportationTarget;
  50750. private _hideTeleportationTarget;
  50751. private _rotateCamera;
  50752. private _moveTeleportationSelectorTo;
  50753. private _workingVector;
  50754. private _workingQuaternion;
  50755. private _workingMatrix;
  50756. /**
  50757. * Time Constant Teleportation Mode
  50758. */
  50759. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50760. /**
  50761. * Speed Constant Teleportation Mode
  50762. */
  50763. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50764. /**
  50765. * Teleports the users feet to the desired location
  50766. * @param location The location where the user's feet should be placed
  50767. */
  50768. teleportCamera(location: Vector3): void;
  50769. private _convertNormalToDirectionOfRay;
  50770. private _castRayAndSelectObject;
  50771. private _notifySelectedMeshUnselected;
  50772. /**
  50773. * Permanently set new colors for the laser pointer
  50774. * @param color the new laser color
  50775. * @param pickedColor the new laser color when picked mesh detected
  50776. */
  50777. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50778. /**
  50779. * Set lighting enabled / disabled on the laser pointer of both controllers
  50780. * @param enabled should the lighting be enabled on the laser pointer
  50781. */
  50782. setLaserLightingState(enabled?: boolean): void;
  50783. /**
  50784. * Permanently set new colors for the gaze pointer
  50785. * @param color the new gaze color
  50786. * @param pickedColor the new gaze color when picked mesh detected
  50787. */
  50788. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50789. /**
  50790. * Sets the color of the laser ray from the vr controllers.
  50791. * @param color new color for the ray.
  50792. */
  50793. changeLaserColor(color: Color3): void;
  50794. /**
  50795. * Sets the color of the ray from the vr headsets gaze.
  50796. * @param color new color for the ray.
  50797. */
  50798. changeGazeColor(color: Color3): void;
  50799. /**
  50800. * Exits VR and disposes of the vr experience helper
  50801. */
  50802. dispose(): void;
  50803. /**
  50804. * Gets the name of the VRExperienceHelper class
  50805. * @returns "VRExperienceHelper"
  50806. */
  50807. getClassName(): string;
  50808. }
  50809. }
  50810. declare module "babylonjs/Cameras/VR/index" {
  50811. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  50812. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  50813. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50814. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  50815. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  50816. export * from "babylonjs/Cameras/VR/webVRCamera";
  50817. }
  50818. declare module "babylonjs/Cameras/RigModes/index" {
  50819. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  50820. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  50821. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  50822. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  50823. }
  50824. declare module "babylonjs/Cameras/index" {
  50825. export * from "babylonjs/Cameras/Inputs/index";
  50826. export * from "babylonjs/Cameras/cameraInputsManager";
  50827. export * from "babylonjs/Cameras/camera";
  50828. export * from "babylonjs/Cameras/targetCamera";
  50829. export * from "babylonjs/Cameras/freeCamera";
  50830. export * from "babylonjs/Cameras/freeCameraInputsManager";
  50831. export * from "babylonjs/Cameras/touchCamera";
  50832. export * from "babylonjs/Cameras/arcRotateCamera";
  50833. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  50834. export * from "babylonjs/Cameras/deviceOrientationCamera";
  50835. export * from "babylonjs/Cameras/flyCamera";
  50836. export * from "babylonjs/Cameras/flyCameraInputsManager";
  50837. export * from "babylonjs/Cameras/followCamera";
  50838. export * from "babylonjs/Cameras/followCameraInputsManager";
  50839. export * from "babylonjs/Cameras/gamepadCamera";
  50840. export * from "babylonjs/Cameras/Stereoscopic/index";
  50841. export * from "babylonjs/Cameras/universalCamera";
  50842. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  50843. export * from "babylonjs/Cameras/VR/index";
  50844. export * from "babylonjs/Cameras/RigModes/index";
  50845. }
  50846. declare module "babylonjs/Collisions/index" {
  50847. export * from "babylonjs/Collisions/collider";
  50848. export * from "babylonjs/Collisions/collisionCoordinator";
  50849. export * from "babylonjs/Collisions/pickingInfo";
  50850. export * from "babylonjs/Collisions/intersectionInfo";
  50851. export * from "babylonjs/Collisions/meshCollisionData";
  50852. }
  50853. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  50854. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  50855. import { Vector3 } from "babylonjs/Maths/math.vector";
  50856. import { Ray } from "babylonjs/Culling/ray";
  50857. import { Plane } from "babylonjs/Maths/math.plane";
  50858. /**
  50859. * Contains an array of blocks representing the octree
  50860. */
  50861. export interface IOctreeContainer<T> {
  50862. /**
  50863. * Blocks within the octree
  50864. */
  50865. blocks: Array<OctreeBlock<T>>;
  50866. }
  50867. /**
  50868. * Class used to store a cell in an octree
  50869. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50870. */
  50871. export class OctreeBlock<T> {
  50872. /**
  50873. * Gets the content of the current block
  50874. */
  50875. entries: T[];
  50876. /**
  50877. * Gets the list of block children
  50878. */
  50879. blocks: Array<OctreeBlock<T>>;
  50880. private _depth;
  50881. private _maxDepth;
  50882. private _capacity;
  50883. private _minPoint;
  50884. private _maxPoint;
  50885. private _boundingVectors;
  50886. private _creationFunc;
  50887. /**
  50888. * Creates a new block
  50889. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50890. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50891. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50892. * @param depth defines the current depth of this block in the octree
  50893. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50894. * @param creationFunc defines a callback to call when an element is added to the block
  50895. */
  50896. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50897. /**
  50898. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50899. */
  50900. get capacity(): number;
  50901. /**
  50902. * Gets the minimum vector (in world space) of the block's bounding box
  50903. */
  50904. get minPoint(): Vector3;
  50905. /**
  50906. * Gets the maximum vector (in world space) of the block's bounding box
  50907. */
  50908. get maxPoint(): Vector3;
  50909. /**
  50910. * Add a new element to this block
  50911. * @param entry defines the element to add
  50912. */
  50913. addEntry(entry: T): void;
  50914. /**
  50915. * Remove an element from this block
  50916. * @param entry defines the element to remove
  50917. */
  50918. removeEntry(entry: T): void;
  50919. /**
  50920. * Add an array of elements to this block
  50921. * @param entries defines the array of elements to add
  50922. */
  50923. addEntries(entries: T[]): void;
  50924. /**
  50925. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50926. * @param frustumPlanes defines the frustum planes to test
  50927. * @param selection defines the array to store current content if selection is positive
  50928. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50929. */
  50930. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50931. /**
  50932. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50933. * @param sphereCenter defines the bounding sphere center
  50934. * @param sphereRadius defines the bounding sphere radius
  50935. * @param selection defines the array to store current content if selection is positive
  50936. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50937. */
  50938. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50939. /**
  50940. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50941. * @param ray defines the ray to test with
  50942. * @param selection defines the array to store current content if selection is positive
  50943. */
  50944. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50945. /**
  50946. * Subdivide the content into child blocks (this block will then be empty)
  50947. */
  50948. createInnerBlocks(): void;
  50949. /**
  50950. * @hidden
  50951. */
  50952. 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;
  50953. }
  50954. }
  50955. declare module "babylonjs/Culling/Octrees/octree" {
  50956. import { SmartArray } from "babylonjs/Misc/smartArray";
  50957. import { Vector3 } from "babylonjs/Maths/math.vector";
  50958. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50960. import { Ray } from "babylonjs/Culling/ray";
  50961. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  50962. import { Plane } from "babylonjs/Maths/math.plane";
  50963. /**
  50964. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50965. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50966. */
  50967. export class Octree<T> {
  50968. /** 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.) */
  50969. maxDepth: number;
  50970. /**
  50971. * Blocks within the octree containing objects
  50972. */
  50973. blocks: Array<OctreeBlock<T>>;
  50974. /**
  50975. * Content stored in the octree
  50976. */
  50977. dynamicContent: T[];
  50978. private _maxBlockCapacity;
  50979. private _selectionContent;
  50980. private _creationFunc;
  50981. /**
  50982. * Creates a octree
  50983. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50984. * @param creationFunc function to be used to instatiate the octree
  50985. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50986. * @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.)
  50987. */
  50988. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50989. /** 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.) */
  50990. maxDepth?: number);
  50991. /**
  50992. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50993. * @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);
  50994. * @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);
  50995. * @param entries meshes to be added to the octree blocks
  50996. */
  50997. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50998. /**
  50999. * Adds a mesh to the octree
  51000. * @param entry Mesh to add to the octree
  51001. */
  51002. addMesh(entry: T): void;
  51003. /**
  51004. * Remove an element from the octree
  51005. * @param entry defines the element to remove
  51006. */
  51007. removeMesh(entry: T): void;
  51008. /**
  51009. * Selects an array of meshes within the frustum
  51010. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  51011. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  51012. * @returns array of meshes within the frustum
  51013. */
  51014. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  51015. /**
  51016. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  51017. * @param sphereCenter defines the bounding sphere center
  51018. * @param sphereRadius defines the bounding sphere radius
  51019. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51020. * @returns an array of objects that intersect the sphere
  51021. */
  51022. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  51023. /**
  51024. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  51025. * @param ray defines the ray to test with
  51026. * @returns array of intersected objects
  51027. */
  51028. intersectsRay(ray: Ray): SmartArray<T>;
  51029. /**
  51030. * Adds a mesh into the octree block if it intersects the block
  51031. */
  51032. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  51033. /**
  51034. * Adds a submesh into the octree block if it intersects the block
  51035. */
  51036. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  51037. }
  51038. }
  51039. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  51040. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  51041. import { Scene } from "babylonjs/scene";
  51042. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51044. import { Ray } from "babylonjs/Culling/ray";
  51045. import { Octree } from "babylonjs/Culling/Octrees/octree";
  51046. import { Collider } from "babylonjs/Collisions/collider";
  51047. module "babylonjs/scene" {
  51048. interface Scene {
  51049. /**
  51050. * @hidden
  51051. * Backing Filed
  51052. */
  51053. _selectionOctree: Octree<AbstractMesh>;
  51054. /**
  51055. * Gets the octree used to boost mesh selection (picking)
  51056. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51057. */
  51058. selectionOctree: Octree<AbstractMesh>;
  51059. /**
  51060. * Creates or updates the octree used to boost selection (picking)
  51061. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51062. * @param maxCapacity defines the maximum capacity per leaf
  51063. * @param maxDepth defines the maximum depth of the octree
  51064. * @returns an octree of AbstractMesh
  51065. */
  51066. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  51067. }
  51068. }
  51069. module "babylonjs/Meshes/abstractMesh" {
  51070. interface AbstractMesh {
  51071. /**
  51072. * @hidden
  51073. * Backing Field
  51074. */
  51075. _submeshesOctree: Octree<SubMesh>;
  51076. /**
  51077. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  51078. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  51079. * @param maxCapacity defines the maximum size of each block (64 by default)
  51080. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  51081. * @returns the new octree
  51082. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  51083. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51084. */
  51085. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  51086. }
  51087. }
  51088. /**
  51089. * Defines the octree scene component responsible to manage any octrees
  51090. * in a given scene.
  51091. */
  51092. export class OctreeSceneComponent {
  51093. /**
  51094. * The component name help to identify the component in the list of scene components.
  51095. */
  51096. readonly name: string;
  51097. /**
  51098. * The scene the component belongs to.
  51099. */
  51100. scene: Scene;
  51101. /**
  51102. * Indicates if the meshes have been checked to make sure they are isEnabled()
  51103. */
  51104. readonly checksIsEnabled: boolean;
  51105. /**
  51106. * Creates a new instance of the component for the given scene
  51107. * @param scene Defines the scene to register the component in
  51108. */
  51109. constructor(scene: Scene);
  51110. /**
  51111. * Registers the component in a given scene
  51112. */
  51113. register(): void;
  51114. /**
  51115. * Return the list of active meshes
  51116. * @returns the list of active meshes
  51117. */
  51118. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  51119. /**
  51120. * Return the list of active sub meshes
  51121. * @param mesh The mesh to get the candidates sub meshes from
  51122. * @returns the list of active sub meshes
  51123. */
  51124. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  51125. private _tempRay;
  51126. /**
  51127. * Return the list of sub meshes intersecting with a given local ray
  51128. * @param mesh defines the mesh to find the submesh for
  51129. * @param localRay defines the ray in local space
  51130. * @returns the list of intersecting sub meshes
  51131. */
  51132. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  51133. /**
  51134. * Return the list of sub meshes colliding with a collider
  51135. * @param mesh defines the mesh to find the submesh for
  51136. * @param collider defines the collider to evaluate the collision against
  51137. * @returns the list of colliding sub meshes
  51138. */
  51139. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  51140. /**
  51141. * Rebuilds the elements related to this component in case of
  51142. * context lost for instance.
  51143. */
  51144. rebuild(): void;
  51145. /**
  51146. * Disposes the component and the associated ressources.
  51147. */
  51148. dispose(): void;
  51149. }
  51150. }
  51151. declare module "babylonjs/Culling/Octrees/index" {
  51152. export * from "babylonjs/Culling/Octrees/octree";
  51153. export * from "babylonjs/Culling/Octrees/octreeBlock";
  51154. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  51155. }
  51156. declare module "babylonjs/Culling/index" {
  51157. export * from "babylonjs/Culling/boundingBox";
  51158. export * from "babylonjs/Culling/boundingInfo";
  51159. export * from "babylonjs/Culling/boundingSphere";
  51160. export * from "babylonjs/Culling/Octrees/index";
  51161. export * from "babylonjs/Culling/ray";
  51162. }
  51163. declare module "babylonjs/Gizmos/gizmo" {
  51164. import { Nullable } from "babylonjs/types";
  51165. import { IDisposable } from "babylonjs/scene";
  51166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51167. import { Mesh } from "babylonjs/Meshes/mesh";
  51168. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51169. /**
  51170. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  51171. */
  51172. export class Gizmo implements IDisposable {
  51173. /** The utility layer the gizmo will be added to */
  51174. gizmoLayer: UtilityLayerRenderer;
  51175. /**
  51176. * The root mesh of the gizmo
  51177. */
  51178. _rootMesh: Mesh;
  51179. private _attachedMesh;
  51180. /**
  51181. * Ratio for the scale of the gizmo (Default: 1)
  51182. */
  51183. scaleRatio: number;
  51184. /**
  51185. * If a custom mesh has been set (Default: false)
  51186. */
  51187. protected _customMeshSet: boolean;
  51188. /**
  51189. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  51190. * * When set, interactions will be enabled
  51191. */
  51192. get attachedMesh(): Nullable<AbstractMesh>;
  51193. set attachedMesh(value: Nullable<AbstractMesh>);
  51194. /**
  51195. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51196. * @param mesh The mesh to replace the default mesh of the gizmo
  51197. */
  51198. setCustomMesh(mesh: Mesh): void;
  51199. /**
  51200. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  51201. */
  51202. updateGizmoRotationToMatchAttachedMesh: boolean;
  51203. /**
  51204. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  51205. */
  51206. updateGizmoPositionToMatchAttachedMesh: boolean;
  51207. /**
  51208. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  51209. */
  51210. updateScale: boolean;
  51211. protected _interactionsEnabled: boolean;
  51212. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51213. private _beforeRenderObserver;
  51214. private _tempVector;
  51215. /**
  51216. * Creates a gizmo
  51217. * @param gizmoLayer The utility layer the gizmo will be added to
  51218. */
  51219. constructor(
  51220. /** The utility layer the gizmo will be added to */
  51221. gizmoLayer?: UtilityLayerRenderer);
  51222. /**
  51223. * Updates the gizmo to match the attached mesh's position/rotation
  51224. */
  51225. protected _update(): void;
  51226. /**
  51227. * Disposes of the gizmo
  51228. */
  51229. dispose(): void;
  51230. }
  51231. }
  51232. declare module "babylonjs/Gizmos/planeDragGizmo" {
  51233. import { Observable } from "babylonjs/Misc/observable";
  51234. import { Nullable } from "babylonjs/types";
  51235. import { Vector3 } from "babylonjs/Maths/math.vector";
  51236. import { Color3 } from "babylonjs/Maths/math.color";
  51237. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51239. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51240. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51241. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51242. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51243. import { Scene } from "babylonjs/scene";
  51244. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51245. /**
  51246. * Single plane drag gizmo
  51247. */
  51248. export class PlaneDragGizmo extends Gizmo {
  51249. /**
  51250. * Drag behavior responsible for the gizmos dragging interactions
  51251. */
  51252. dragBehavior: PointerDragBehavior;
  51253. private _pointerObserver;
  51254. /**
  51255. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51256. */
  51257. snapDistance: number;
  51258. /**
  51259. * Event that fires each time the gizmo snaps to a new location.
  51260. * * snapDistance is the the change in distance
  51261. */
  51262. onSnapObservable: Observable<{
  51263. snapDistance: number;
  51264. }>;
  51265. private _plane;
  51266. private _coloredMaterial;
  51267. private _hoverMaterial;
  51268. private _isEnabled;
  51269. private _parent;
  51270. /** @hidden */
  51271. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  51272. /** @hidden */
  51273. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51274. /**
  51275. * Creates a PlaneDragGizmo
  51276. * @param gizmoLayer The utility layer the gizmo will be added to
  51277. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  51278. * @param color The color of the gizmo
  51279. */
  51280. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51281. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51282. /**
  51283. * If the gizmo is enabled
  51284. */
  51285. set isEnabled(value: boolean);
  51286. get isEnabled(): boolean;
  51287. /**
  51288. * Disposes of the gizmo
  51289. */
  51290. dispose(): void;
  51291. }
  51292. }
  51293. declare module "babylonjs/Gizmos/positionGizmo" {
  51294. import { Observable } from "babylonjs/Misc/observable";
  51295. import { Nullable } from "babylonjs/types";
  51296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51297. import { Mesh } from "babylonjs/Meshes/mesh";
  51298. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51299. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  51300. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  51301. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51302. /**
  51303. * Gizmo that enables dragging a mesh along 3 axis
  51304. */
  51305. export class PositionGizmo extends Gizmo {
  51306. /**
  51307. * Internal gizmo used for interactions on the x axis
  51308. */
  51309. xGizmo: AxisDragGizmo;
  51310. /**
  51311. * Internal gizmo used for interactions on the y axis
  51312. */
  51313. yGizmo: AxisDragGizmo;
  51314. /**
  51315. * Internal gizmo used for interactions on the z axis
  51316. */
  51317. zGizmo: AxisDragGizmo;
  51318. /**
  51319. * Internal gizmo used for interactions on the yz plane
  51320. */
  51321. xPlaneGizmo: PlaneDragGizmo;
  51322. /**
  51323. * Internal gizmo used for interactions on the xz plane
  51324. */
  51325. yPlaneGizmo: PlaneDragGizmo;
  51326. /**
  51327. * Internal gizmo used for interactions on the xy plane
  51328. */
  51329. zPlaneGizmo: PlaneDragGizmo;
  51330. /**
  51331. * private variables
  51332. */
  51333. private _meshAttached;
  51334. private _updateGizmoRotationToMatchAttachedMesh;
  51335. private _snapDistance;
  51336. private _scaleRatio;
  51337. /** Fires an event when any of it's sub gizmos are dragged */
  51338. onDragStartObservable: Observable<unknown>;
  51339. /** Fires an event when any of it's sub gizmos are released from dragging */
  51340. onDragEndObservable: Observable<unknown>;
  51341. /**
  51342. * If set to true, planar drag is enabled
  51343. */
  51344. private _planarGizmoEnabled;
  51345. get attachedMesh(): Nullable<AbstractMesh>;
  51346. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51347. /**
  51348. * Creates a PositionGizmo
  51349. * @param gizmoLayer The utility layer the gizmo will be added to
  51350. */
  51351. constructor(gizmoLayer?: UtilityLayerRenderer);
  51352. /**
  51353. * If the planar drag gizmo is enabled
  51354. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  51355. */
  51356. set planarGizmoEnabled(value: boolean);
  51357. get planarGizmoEnabled(): boolean;
  51358. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51359. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51360. /**
  51361. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51362. */
  51363. set snapDistance(value: number);
  51364. get snapDistance(): number;
  51365. /**
  51366. * Ratio for the scale of the gizmo (Default: 1)
  51367. */
  51368. set scaleRatio(value: number);
  51369. get scaleRatio(): number;
  51370. /**
  51371. * Disposes of the gizmo
  51372. */
  51373. dispose(): void;
  51374. /**
  51375. * CustomMeshes are not supported by this gizmo
  51376. * @param mesh The mesh to replace the default mesh of the gizmo
  51377. */
  51378. setCustomMesh(mesh: Mesh): void;
  51379. }
  51380. }
  51381. declare module "babylonjs/Gizmos/axisDragGizmo" {
  51382. import { Observable } from "babylonjs/Misc/observable";
  51383. import { Nullable } from "babylonjs/types";
  51384. import { Vector3 } from "babylonjs/Maths/math.vector";
  51385. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51387. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51388. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51389. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51390. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51391. import { Scene } from "babylonjs/scene";
  51392. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51393. import { Color3 } from "babylonjs/Maths/math.color";
  51394. /**
  51395. * Single axis drag gizmo
  51396. */
  51397. export class AxisDragGizmo extends Gizmo {
  51398. /**
  51399. * Drag behavior responsible for the gizmos dragging interactions
  51400. */
  51401. dragBehavior: PointerDragBehavior;
  51402. private _pointerObserver;
  51403. /**
  51404. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51405. */
  51406. snapDistance: number;
  51407. /**
  51408. * Event that fires each time the gizmo snaps to a new location.
  51409. * * snapDistance is the the change in distance
  51410. */
  51411. onSnapObservable: Observable<{
  51412. snapDistance: number;
  51413. }>;
  51414. private _isEnabled;
  51415. private _parent;
  51416. private _arrow;
  51417. private _coloredMaterial;
  51418. private _hoverMaterial;
  51419. /** @hidden */
  51420. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  51421. /** @hidden */
  51422. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51423. /**
  51424. * Creates an AxisDragGizmo
  51425. * @param gizmoLayer The utility layer the gizmo will be added to
  51426. * @param dragAxis The axis which the gizmo will be able to drag on
  51427. * @param color The color of the gizmo
  51428. */
  51429. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51430. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51431. /**
  51432. * If the gizmo is enabled
  51433. */
  51434. set isEnabled(value: boolean);
  51435. get isEnabled(): boolean;
  51436. /**
  51437. * Disposes of the gizmo
  51438. */
  51439. dispose(): void;
  51440. }
  51441. }
  51442. declare module "babylonjs/Debug/axesViewer" {
  51443. import { Vector3 } from "babylonjs/Maths/math.vector";
  51444. import { Nullable } from "babylonjs/types";
  51445. import { Scene } from "babylonjs/scene";
  51446. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51447. /**
  51448. * The Axes viewer will show 3 axes in a specific point in space
  51449. */
  51450. export class AxesViewer {
  51451. private _xAxis;
  51452. private _yAxis;
  51453. private _zAxis;
  51454. private _scaleLinesFactor;
  51455. private _instanced;
  51456. /**
  51457. * Gets the hosting scene
  51458. */
  51459. scene: Scene;
  51460. /**
  51461. * Gets or sets a number used to scale line length
  51462. */
  51463. scaleLines: number;
  51464. /** Gets the node hierarchy used to render x-axis */
  51465. get xAxis(): TransformNode;
  51466. /** Gets the node hierarchy used to render y-axis */
  51467. get yAxis(): TransformNode;
  51468. /** Gets the node hierarchy used to render z-axis */
  51469. get zAxis(): TransformNode;
  51470. /**
  51471. * Creates a new AxesViewer
  51472. * @param scene defines the hosting scene
  51473. * @param scaleLines defines a number used to scale line length (1 by default)
  51474. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  51475. * @param xAxis defines the node hierarchy used to render the x-axis
  51476. * @param yAxis defines the node hierarchy used to render the y-axis
  51477. * @param zAxis defines the node hierarchy used to render the z-axis
  51478. */
  51479. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  51480. /**
  51481. * Force the viewer to update
  51482. * @param position defines the position of the viewer
  51483. * @param xaxis defines the x axis of the viewer
  51484. * @param yaxis defines the y axis of the viewer
  51485. * @param zaxis defines the z axis of the viewer
  51486. */
  51487. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  51488. /**
  51489. * Creates an instance of this axes viewer.
  51490. * @returns a new axes viewer with instanced meshes
  51491. */
  51492. createInstance(): AxesViewer;
  51493. /** Releases resources */
  51494. dispose(): void;
  51495. private static _SetRenderingGroupId;
  51496. }
  51497. }
  51498. declare module "babylonjs/Debug/boneAxesViewer" {
  51499. import { Nullable } from "babylonjs/types";
  51500. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  51501. import { Vector3 } from "babylonjs/Maths/math.vector";
  51502. import { Mesh } from "babylonjs/Meshes/mesh";
  51503. import { Bone } from "babylonjs/Bones/bone";
  51504. import { Scene } from "babylonjs/scene";
  51505. /**
  51506. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  51507. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  51508. */
  51509. export class BoneAxesViewer extends AxesViewer {
  51510. /**
  51511. * Gets or sets the target mesh where to display the axes viewer
  51512. */
  51513. mesh: Nullable<Mesh>;
  51514. /**
  51515. * Gets or sets the target bone where to display the axes viewer
  51516. */
  51517. bone: Nullable<Bone>;
  51518. /** Gets current position */
  51519. pos: Vector3;
  51520. /** Gets direction of X axis */
  51521. xaxis: Vector3;
  51522. /** Gets direction of Y axis */
  51523. yaxis: Vector3;
  51524. /** Gets direction of Z axis */
  51525. zaxis: Vector3;
  51526. /**
  51527. * Creates a new BoneAxesViewer
  51528. * @param scene defines the hosting scene
  51529. * @param bone defines the target bone
  51530. * @param mesh defines the target mesh
  51531. * @param scaleLines defines a scaling factor for line length (1 by default)
  51532. */
  51533. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  51534. /**
  51535. * Force the viewer to update
  51536. */
  51537. update(): void;
  51538. /** Releases resources */
  51539. dispose(): void;
  51540. }
  51541. }
  51542. declare module "babylonjs/Debug/debugLayer" {
  51543. import { Scene } from "babylonjs/scene";
  51544. /**
  51545. * Interface used to define scene explorer extensibility option
  51546. */
  51547. export interface IExplorerExtensibilityOption {
  51548. /**
  51549. * Define the option label
  51550. */
  51551. label: string;
  51552. /**
  51553. * Defines the action to execute on click
  51554. */
  51555. action: (entity: any) => void;
  51556. }
  51557. /**
  51558. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  51559. */
  51560. export interface IExplorerExtensibilityGroup {
  51561. /**
  51562. * Defines a predicate to test if a given type mut be extended
  51563. */
  51564. predicate: (entity: any) => boolean;
  51565. /**
  51566. * Gets the list of options added to a type
  51567. */
  51568. entries: IExplorerExtensibilityOption[];
  51569. }
  51570. /**
  51571. * Interface used to define the options to use to create the Inspector
  51572. */
  51573. export interface IInspectorOptions {
  51574. /**
  51575. * Display in overlay mode (default: false)
  51576. */
  51577. overlay?: boolean;
  51578. /**
  51579. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  51580. */
  51581. globalRoot?: HTMLElement;
  51582. /**
  51583. * Display the Scene explorer
  51584. */
  51585. showExplorer?: boolean;
  51586. /**
  51587. * Display the property inspector
  51588. */
  51589. showInspector?: boolean;
  51590. /**
  51591. * Display in embed mode (both panes on the right)
  51592. */
  51593. embedMode?: boolean;
  51594. /**
  51595. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  51596. */
  51597. handleResize?: boolean;
  51598. /**
  51599. * Allow the panes to popup (default: true)
  51600. */
  51601. enablePopup?: boolean;
  51602. /**
  51603. * Allow the panes to be closed by users (default: true)
  51604. */
  51605. enableClose?: boolean;
  51606. /**
  51607. * Optional list of extensibility entries
  51608. */
  51609. explorerExtensibility?: IExplorerExtensibilityGroup[];
  51610. /**
  51611. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  51612. */
  51613. inspectorURL?: string;
  51614. /**
  51615. * Optional initial tab (default to DebugLayerTab.Properties)
  51616. */
  51617. initialTab?: DebugLayerTab;
  51618. }
  51619. module "babylonjs/scene" {
  51620. interface Scene {
  51621. /**
  51622. * @hidden
  51623. * Backing field
  51624. */
  51625. _debugLayer: DebugLayer;
  51626. /**
  51627. * Gets the debug layer (aka Inspector) associated with the scene
  51628. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51629. */
  51630. debugLayer: DebugLayer;
  51631. }
  51632. }
  51633. /**
  51634. * Enum of inspector action tab
  51635. */
  51636. export enum DebugLayerTab {
  51637. /**
  51638. * Properties tag (default)
  51639. */
  51640. Properties = 0,
  51641. /**
  51642. * Debug tab
  51643. */
  51644. Debug = 1,
  51645. /**
  51646. * Statistics tab
  51647. */
  51648. Statistics = 2,
  51649. /**
  51650. * Tools tab
  51651. */
  51652. Tools = 3,
  51653. /**
  51654. * Settings tab
  51655. */
  51656. Settings = 4
  51657. }
  51658. /**
  51659. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51660. * what is happening in your scene
  51661. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51662. */
  51663. export class DebugLayer {
  51664. /**
  51665. * Define the url to get the inspector script from.
  51666. * By default it uses the babylonjs CDN.
  51667. * @ignoreNaming
  51668. */
  51669. static InspectorURL: string;
  51670. private _scene;
  51671. private BJSINSPECTOR;
  51672. private _onPropertyChangedObservable?;
  51673. /**
  51674. * Observable triggered when a property is changed through the inspector.
  51675. */
  51676. get onPropertyChangedObservable(): any;
  51677. /**
  51678. * Instantiates a new debug layer.
  51679. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51680. * what is happening in your scene
  51681. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51682. * @param scene Defines the scene to inspect
  51683. */
  51684. constructor(scene: Scene);
  51685. /** Creates the inspector window. */
  51686. private _createInspector;
  51687. /**
  51688. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  51689. * @param entity defines the entity to select
  51690. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  51691. */
  51692. select(entity: any, lineContainerTitles?: string | string[]): void;
  51693. /** Get the inspector from bundle or global */
  51694. private _getGlobalInspector;
  51695. /**
  51696. * Get if the inspector is visible or not.
  51697. * @returns true if visible otherwise, false
  51698. */
  51699. isVisible(): boolean;
  51700. /**
  51701. * Hide the inspector and close its window.
  51702. */
  51703. hide(): void;
  51704. /**
  51705. * Update the scene in the inspector
  51706. */
  51707. setAsActiveScene(): void;
  51708. /**
  51709. * Launch the debugLayer.
  51710. * @param config Define the configuration of the inspector
  51711. * @return a promise fulfilled when the debug layer is visible
  51712. */
  51713. show(config?: IInspectorOptions): Promise<DebugLayer>;
  51714. }
  51715. }
  51716. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  51717. import { Nullable } from "babylonjs/types";
  51718. import { Scene } from "babylonjs/scene";
  51719. import { Vector4 } from "babylonjs/Maths/math.vector";
  51720. import { Color4 } from "babylonjs/Maths/math.color";
  51721. import { Mesh } from "babylonjs/Meshes/mesh";
  51722. /**
  51723. * Class containing static functions to help procedurally build meshes
  51724. */
  51725. export class BoxBuilder {
  51726. /**
  51727. * Creates a box mesh
  51728. * * The parameter `size` sets the size (float) of each box side (default 1)
  51729. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51730. * * 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)
  51731. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51735. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51736. * @param name defines the name of the mesh
  51737. * @param options defines the options used to create the mesh
  51738. * @param scene defines the hosting scene
  51739. * @returns the box mesh
  51740. */
  51741. static CreateBox(name: string, options: {
  51742. size?: number;
  51743. width?: number;
  51744. height?: number;
  51745. depth?: number;
  51746. faceUV?: Vector4[];
  51747. faceColors?: Color4[];
  51748. sideOrientation?: number;
  51749. frontUVs?: Vector4;
  51750. backUVs?: Vector4;
  51751. wrap?: boolean;
  51752. topBaseAt?: number;
  51753. bottomBaseAt?: number;
  51754. updatable?: boolean;
  51755. }, scene?: Nullable<Scene>): Mesh;
  51756. }
  51757. }
  51758. declare module "babylonjs/Debug/physicsViewer" {
  51759. import { Nullable } from "babylonjs/types";
  51760. import { Scene } from "babylonjs/scene";
  51761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51762. import { Mesh } from "babylonjs/Meshes/mesh";
  51763. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51764. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51765. /**
  51766. * Used to show the physics impostor around the specific mesh
  51767. */
  51768. export class PhysicsViewer {
  51769. /** @hidden */
  51770. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51771. /** @hidden */
  51772. protected _meshes: Array<Nullable<AbstractMesh>>;
  51773. /** @hidden */
  51774. protected _scene: Nullable<Scene>;
  51775. /** @hidden */
  51776. protected _numMeshes: number;
  51777. /** @hidden */
  51778. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51779. private _renderFunction;
  51780. private _utilityLayer;
  51781. private _debugBoxMesh;
  51782. private _debugSphereMesh;
  51783. private _debugCylinderMesh;
  51784. private _debugMaterial;
  51785. private _debugMeshMeshes;
  51786. /**
  51787. * Creates a new PhysicsViewer
  51788. * @param scene defines the hosting scene
  51789. */
  51790. constructor(scene: Scene);
  51791. /** @hidden */
  51792. protected _updateDebugMeshes(): void;
  51793. /**
  51794. * Renders a specified physic impostor
  51795. * @param impostor defines the impostor to render
  51796. * @param targetMesh defines the mesh represented by the impostor
  51797. * @returns the new debug mesh used to render the impostor
  51798. */
  51799. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51800. /**
  51801. * Hides a specified physic impostor
  51802. * @param impostor defines the impostor to hide
  51803. */
  51804. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51805. private _getDebugMaterial;
  51806. private _getDebugBoxMesh;
  51807. private _getDebugSphereMesh;
  51808. private _getDebugCylinderMesh;
  51809. private _getDebugMeshMesh;
  51810. private _getDebugMesh;
  51811. /** Releases all resources */
  51812. dispose(): void;
  51813. }
  51814. }
  51815. declare module "babylonjs/Debug/rayHelper" {
  51816. import { Nullable } from "babylonjs/types";
  51817. import { Ray } from "babylonjs/Culling/ray";
  51818. import { Vector3 } from "babylonjs/Maths/math.vector";
  51819. import { Color3 } from "babylonjs/Maths/math.color";
  51820. import { Scene } from "babylonjs/scene";
  51821. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51822. import "babylonjs/Meshes/Builders/linesBuilder";
  51823. /**
  51824. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51825. * in order to better appreciate the issue one might have.
  51826. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  51827. */
  51828. export class RayHelper {
  51829. /**
  51830. * Defines the ray we are currently tryin to visualize.
  51831. */
  51832. ray: Nullable<Ray>;
  51833. private _renderPoints;
  51834. private _renderLine;
  51835. private _renderFunction;
  51836. private _scene;
  51837. private _updateToMeshFunction;
  51838. private _attachedToMesh;
  51839. private _meshSpaceDirection;
  51840. private _meshSpaceOrigin;
  51841. /**
  51842. * Helper function to create a colored helper in a scene in one line.
  51843. * @param ray Defines the ray we are currently tryin to visualize
  51844. * @param scene Defines the scene the ray is used in
  51845. * @param color Defines the color we want to see the ray in
  51846. * @returns The newly created ray helper.
  51847. */
  51848. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  51849. /**
  51850. * Instantiate a new ray helper.
  51851. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51852. * in order to better appreciate the issue one might have.
  51853. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  51854. * @param ray Defines the ray we are currently tryin to visualize
  51855. */
  51856. constructor(ray: Ray);
  51857. /**
  51858. * Shows the ray we are willing to debug.
  51859. * @param scene Defines the scene the ray needs to be rendered in
  51860. * @param color Defines the color the ray needs to be rendered in
  51861. */
  51862. show(scene: Scene, color?: Color3): void;
  51863. /**
  51864. * Hides the ray we are debugging.
  51865. */
  51866. hide(): void;
  51867. private _render;
  51868. /**
  51869. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  51870. * @param mesh Defines the mesh we want the helper attached to
  51871. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  51872. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  51873. * @param length Defines the length of the ray
  51874. */
  51875. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  51876. /**
  51877. * Detach the ray helper from the mesh it has previously been attached to.
  51878. */
  51879. detachFromMesh(): void;
  51880. private _updateToMesh;
  51881. /**
  51882. * Dispose the helper and release its associated resources.
  51883. */
  51884. dispose(): void;
  51885. }
  51886. }
  51887. declare module "babylonjs/Debug/skeletonViewer" {
  51888. import { Color3 } from "babylonjs/Maths/math.color";
  51889. import { Scene } from "babylonjs/scene";
  51890. import { Nullable } from "babylonjs/types";
  51891. import { Skeleton } from "babylonjs/Bones/skeleton";
  51892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51893. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51894. /**
  51895. * Class used to render a debug view of a given skeleton
  51896. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51897. */
  51898. export class SkeletonViewer {
  51899. /** defines the skeleton to render */
  51900. skeleton: Skeleton;
  51901. /** defines the mesh attached to the skeleton */
  51902. mesh: AbstractMesh;
  51903. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51904. autoUpdateBonesMatrices: boolean;
  51905. /** defines the rendering group id to use with the viewer */
  51906. renderingGroupId: number;
  51907. /** Gets or sets the color used to render the skeleton */
  51908. color: Color3;
  51909. private _scene;
  51910. private _debugLines;
  51911. private _debugMesh;
  51912. private _isEnabled;
  51913. private _renderFunction;
  51914. private _utilityLayer;
  51915. /**
  51916. * Returns the mesh used to render the bones
  51917. */
  51918. get debugMesh(): Nullable<LinesMesh>;
  51919. /**
  51920. * Creates a new SkeletonViewer
  51921. * @param skeleton defines the skeleton to render
  51922. * @param mesh defines the mesh attached to the skeleton
  51923. * @param scene defines the hosting scene
  51924. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51925. * @param renderingGroupId defines the rendering group id to use with the viewer
  51926. */
  51927. constructor(
  51928. /** defines the skeleton to render */
  51929. skeleton: Skeleton,
  51930. /** defines the mesh attached to the skeleton */
  51931. mesh: AbstractMesh, scene: Scene,
  51932. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51933. autoUpdateBonesMatrices?: boolean,
  51934. /** defines the rendering group id to use with the viewer */
  51935. renderingGroupId?: number);
  51936. /** Gets or sets a boolean indicating if the viewer is enabled */
  51937. set isEnabled(value: boolean);
  51938. get isEnabled(): boolean;
  51939. private _getBonePosition;
  51940. private _getLinesForBonesWithLength;
  51941. private _getLinesForBonesNoLength;
  51942. /** Update the viewer to sync with current skeleton state */
  51943. update(): void;
  51944. /** Release associated resources */
  51945. dispose(): void;
  51946. }
  51947. }
  51948. declare module "babylonjs/Debug/index" {
  51949. export * from "babylonjs/Debug/axesViewer";
  51950. export * from "babylonjs/Debug/boneAxesViewer";
  51951. export * from "babylonjs/Debug/debugLayer";
  51952. export * from "babylonjs/Debug/physicsViewer";
  51953. export * from "babylonjs/Debug/rayHelper";
  51954. export * from "babylonjs/Debug/skeletonViewer";
  51955. }
  51956. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  51957. /**
  51958. * Enum for Device Types
  51959. */
  51960. export enum DeviceType {
  51961. /** Generic */
  51962. Generic = 0,
  51963. /** Keyboard */
  51964. Keyboard = 1,
  51965. /** Mouse */
  51966. Mouse = 2,
  51967. /** Touch Pointers */
  51968. Touch = 3,
  51969. /** PS4 Dual Shock */
  51970. DualShock = 4,
  51971. /** Xbox */
  51972. Xbox = 5,
  51973. /** Switch Controller */
  51974. Switch = 6
  51975. }
  51976. /**
  51977. * Enum for All Pointers (Touch/Mouse)
  51978. */
  51979. export enum PointerInput {
  51980. /** Horizontal Axis */
  51981. Horizontal = 0,
  51982. /** Vertical Axis */
  51983. Vertical = 1,
  51984. /** Left Click or Touch */
  51985. LeftClick = 2,
  51986. /** Middle Click */
  51987. MiddleClick = 3,
  51988. /** Right Click */
  51989. RightClick = 4,
  51990. /** Browser Back */
  51991. BrowserBack = 5,
  51992. /** Browser Forward */
  51993. BrowserForward = 6
  51994. }
  51995. /**
  51996. * Enum for Dual Shock Gamepad
  51997. */
  51998. export enum DualShockInput {
  51999. /** Cross */
  52000. Cross = 0,
  52001. /** Circle */
  52002. Circle = 1,
  52003. /** Square */
  52004. Square = 2,
  52005. /** Triangle */
  52006. Triangle = 3,
  52007. /** L1 */
  52008. L1 = 4,
  52009. /** R1 */
  52010. R1 = 5,
  52011. /** L2 */
  52012. L2 = 6,
  52013. /** R2 */
  52014. R2 = 7,
  52015. /** Share */
  52016. Share = 8,
  52017. /** Options */
  52018. Options = 9,
  52019. /** L3 */
  52020. L3 = 10,
  52021. /** R3 */
  52022. R3 = 11,
  52023. /** DPadUp */
  52024. DPadUp = 12,
  52025. /** DPadDown */
  52026. DPadDown = 13,
  52027. /** DPadLeft */
  52028. DPadLeft = 14,
  52029. /** DRight */
  52030. DPadRight = 15,
  52031. /** Home */
  52032. Home = 16,
  52033. /** TouchPad */
  52034. TouchPad = 17,
  52035. /** LStickXAxis */
  52036. LStickXAxis = 18,
  52037. /** LStickYAxis */
  52038. LStickYAxis = 19,
  52039. /** RStickXAxis */
  52040. RStickXAxis = 20,
  52041. /** RStickYAxis */
  52042. RStickYAxis = 21
  52043. }
  52044. /**
  52045. * Enum for Xbox Gamepad
  52046. */
  52047. export enum XboxInput {
  52048. /** A */
  52049. A = 0,
  52050. /** B */
  52051. B = 1,
  52052. /** X */
  52053. X = 2,
  52054. /** Y */
  52055. Y = 3,
  52056. /** LB */
  52057. LB = 4,
  52058. /** RB */
  52059. RB = 5,
  52060. /** LT */
  52061. LT = 6,
  52062. /** RT */
  52063. RT = 7,
  52064. /** Back */
  52065. Back = 8,
  52066. /** Start */
  52067. Start = 9,
  52068. /** LS */
  52069. LS = 10,
  52070. /** RS */
  52071. RS = 11,
  52072. /** DPadUp */
  52073. DPadUp = 12,
  52074. /** DPadDown */
  52075. DPadDown = 13,
  52076. /** DPadLeft */
  52077. DPadLeft = 14,
  52078. /** DRight */
  52079. DPadRight = 15,
  52080. /** Home */
  52081. Home = 16,
  52082. /** LStickXAxis */
  52083. LStickXAxis = 17,
  52084. /** LStickYAxis */
  52085. LStickYAxis = 18,
  52086. /** RStickXAxis */
  52087. RStickXAxis = 19,
  52088. /** RStickYAxis */
  52089. RStickYAxis = 20
  52090. }
  52091. /**
  52092. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  52093. */
  52094. export enum SwitchInput {
  52095. /** B */
  52096. B = 0,
  52097. /** A */
  52098. A = 1,
  52099. /** Y */
  52100. Y = 2,
  52101. /** X */
  52102. X = 3,
  52103. /** L */
  52104. L = 4,
  52105. /** R */
  52106. R = 5,
  52107. /** ZL */
  52108. ZL = 6,
  52109. /** ZR */
  52110. ZR = 7,
  52111. /** Minus */
  52112. Minus = 8,
  52113. /** Plus */
  52114. Plus = 9,
  52115. /** LS */
  52116. LS = 10,
  52117. /** RS */
  52118. RS = 11,
  52119. /** DPadUp */
  52120. DPadUp = 12,
  52121. /** DPadDown */
  52122. DPadDown = 13,
  52123. /** DPadLeft */
  52124. DPadLeft = 14,
  52125. /** DRight */
  52126. DPadRight = 15,
  52127. /** Home */
  52128. Home = 16,
  52129. /** Capture */
  52130. Capture = 17,
  52131. /** LStickXAxis */
  52132. LStickXAxis = 18,
  52133. /** LStickYAxis */
  52134. LStickYAxis = 19,
  52135. /** RStickXAxis */
  52136. RStickXAxis = 20,
  52137. /** RStickYAxis */
  52138. RStickYAxis = 21
  52139. }
  52140. }
  52141. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  52142. import { Engine } from "babylonjs/Engines/engine";
  52143. import { IDisposable } from "babylonjs/scene";
  52144. import { Nullable } from "babylonjs/types";
  52145. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52146. /**
  52147. * This class will take all inputs from Keyboard, Pointer, and
  52148. * any Gamepads and provide a polling system that all devices
  52149. * will use. This class assumes that there will only be one
  52150. * pointer device and one keyboard.
  52151. */
  52152. export class DeviceInputSystem implements IDisposable {
  52153. /**
  52154. * Callback to be triggered when a device is connected
  52155. */
  52156. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52157. /**
  52158. * Callback to be triggered when a device is disconnected
  52159. */
  52160. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52161. /**
  52162. * Callback to be triggered when event driven input is updated
  52163. */
  52164. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  52165. private _inputs;
  52166. private _gamepads;
  52167. private _keyboardActive;
  52168. private _pointerActive;
  52169. private _elementToAttachTo;
  52170. private _keyboardDownEvent;
  52171. private _keyboardUpEvent;
  52172. private _pointerMoveEvent;
  52173. private _pointerDownEvent;
  52174. private _pointerUpEvent;
  52175. private _gamepadConnectedEvent;
  52176. private _gamepadDisconnectedEvent;
  52177. private static _MAX_KEYCODES;
  52178. private static _MAX_POINTER_INPUTS;
  52179. private constructor();
  52180. /**
  52181. * Creates a new DeviceInputSystem instance
  52182. * @param engine Engine to pull input element from
  52183. * @returns The new instance
  52184. */
  52185. static Create(engine: Engine): DeviceInputSystem;
  52186. /**
  52187. * Checks for current device input value, given an id and input index
  52188. * @param deviceName Id of connected device
  52189. * @param inputIndex Index of device input
  52190. * @returns Current value of input
  52191. */
  52192. /**
  52193. * Checks for current device input value, given an id and input index
  52194. * @param deviceType Enum specifiying device type
  52195. * @param deviceSlot "Slot" or index that device is referenced in
  52196. * @param inputIndex Id of input to be checked
  52197. * @returns Current value of input
  52198. */
  52199. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  52200. /**
  52201. * Dispose of all the eventlisteners
  52202. */
  52203. dispose(): void;
  52204. /**
  52205. * Add device and inputs to device array
  52206. * @param deviceType Enum specifiying device type
  52207. * @param deviceSlot "Slot" or index that device is referenced in
  52208. * @param numberOfInputs Number of input entries to create for given device
  52209. */
  52210. private _registerDevice;
  52211. /**
  52212. * Given a specific device name, remove that device from the device map
  52213. * @param deviceType Enum specifiying device type
  52214. * @param deviceSlot "Slot" or index that device is referenced in
  52215. */
  52216. private _unregisterDevice;
  52217. /**
  52218. * Handle all actions that come from keyboard interaction
  52219. */
  52220. private _handleKeyActions;
  52221. /**
  52222. * Handle all actions that come from pointer interaction
  52223. */
  52224. private _handlePointerActions;
  52225. /**
  52226. * Handle all actions that come from gamepad interaction
  52227. */
  52228. private _handleGamepadActions;
  52229. /**
  52230. * Update all non-event based devices with each frame
  52231. * @param deviceType Enum specifiying device type
  52232. * @param deviceSlot "Slot" or index that device is referenced in
  52233. * @param inputIndex Id of input to be checked
  52234. */
  52235. private _updateDevice;
  52236. /**
  52237. * Gets DeviceType from the device name
  52238. * @param deviceName Name of Device from DeviceInputSystem
  52239. * @returns DeviceType enum value
  52240. */
  52241. private _getGamepadDeviceType;
  52242. }
  52243. }
  52244. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  52245. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52246. /**
  52247. * Type to handle enforcement of inputs
  52248. */
  52249. 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;
  52250. }
  52251. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  52252. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  52253. import { Engine } from "babylonjs/Engines/engine";
  52254. import { IDisposable } from "babylonjs/scene";
  52255. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52256. import { Nullable } from "babylonjs/types";
  52257. import { Observable } from "babylonjs/Misc/observable";
  52258. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52259. /**
  52260. * Class that handles all input for a specific device
  52261. */
  52262. export class DeviceSource<T extends DeviceType> {
  52263. /** Type of device */
  52264. readonly deviceType: DeviceType;
  52265. /** "Slot" or index that device is referenced in */
  52266. readonly deviceSlot: number;
  52267. /**
  52268. * Observable to handle device input changes per device
  52269. */
  52270. readonly onInputChangedObservable: Observable<{
  52271. inputIndex: DeviceInput<T>;
  52272. previousState: Nullable<number>;
  52273. currentState: Nullable<number>;
  52274. }>;
  52275. private readonly _deviceInputSystem;
  52276. /**
  52277. * Default Constructor
  52278. * @param deviceInputSystem Reference to DeviceInputSystem
  52279. * @param deviceType Type of device
  52280. * @param deviceSlot "Slot" or index that device is referenced in
  52281. */
  52282. constructor(deviceInputSystem: DeviceInputSystem,
  52283. /** Type of device */
  52284. deviceType: DeviceType,
  52285. /** "Slot" or index that device is referenced in */
  52286. deviceSlot?: number);
  52287. /**
  52288. * Get input for specific input
  52289. * @param inputIndex index of specific input on device
  52290. * @returns Input value from DeviceInputSystem
  52291. */
  52292. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  52293. }
  52294. /**
  52295. * Class to keep track of devices
  52296. */
  52297. export class DeviceSourceManager implements IDisposable {
  52298. /**
  52299. * Observable to be triggered when before a device is connected
  52300. */
  52301. readonly onBeforeDeviceConnectedObservable: Observable<{
  52302. deviceType: DeviceType;
  52303. deviceSlot: number;
  52304. }>;
  52305. /**
  52306. * Observable to be triggered when before a device is disconnected
  52307. */
  52308. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  52309. deviceType: DeviceType;
  52310. deviceSlot: number;
  52311. }>;
  52312. /**
  52313. * Observable to be triggered when after a device is connected
  52314. */
  52315. readonly onAfterDeviceConnectedObservable: Observable<{
  52316. deviceType: DeviceType;
  52317. deviceSlot: number;
  52318. }>;
  52319. /**
  52320. * Observable to be triggered when after a device is disconnected
  52321. */
  52322. readonly onAfterDeviceDisconnectedObservable: Observable<{
  52323. deviceType: DeviceType;
  52324. deviceSlot: number;
  52325. }>;
  52326. private readonly _devices;
  52327. private readonly _firstDevice;
  52328. private readonly _deviceInputSystem;
  52329. /**
  52330. * Default Constructor
  52331. * @param engine engine to pull input element from
  52332. */
  52333. constructor(engine: Engine);
  52334. /**
  52335. * Gets a DeviceSource, given a type and slot
  52336. * @param deviceType Enum specifying device type
  52337. * @param deviceSlot "Slot" or index that device is referenced in
  52338. * @returns DeviceSource object
  52339. */
  52340. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  52341. /**
  52342. * Gets an array of DeviceSource objects for a given device type
  52343. * @param deviceType Enum specifying device type
  52344. * @returns Array of DeviceSource objects
  52345. */
  52346. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  52347. /**
  52348. * Dispose of DeviceInputSystem and other parts
  52349. */
  52350. dispose(): void;
  52351. /**
  52352. * Function to add device name to device list
  52353. * @param deviceType Enum specifying device type
  52354. * @param deviceSlot "Slot" or index that device is referenced in
  52355. */
  52356. private _addDevice;
  52357. /**
  52358. * Function to remove device name to device list
  52359. * @param deviceType Enum specifying device type
  52360. * @param deviceSlot "Slot" or index that device is referenced in
  52361. */
  52362. private _removeDevice;
  52363. /**
  52364. * Updates array storing first connected device of each type
  52365. * @param type Type of Device
  52366. */
  52367. private _updateFirstDevices;
  52368. }
  52369. }
  52370. declare module "babylonjs/DeviceInput/index" {
  52371. export * from "babylonjs/DeviceInput/deviceInputSystem";
  52372. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52373. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52374. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52375. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52376. }
  52377. declare module "babylonjs/Engines/nullEngine" {
  52378. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  52379. import { Engine } from "babylonjs/Engines/engine";
  52380. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  52381. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  52382. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52383. import { Effect } from "babylonjs/Materials/effect";
  52384. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  52385. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  52386. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  52387. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  52388. /**
  52389. * Options to create the null engine
  52390. */
  52391. export class NullEngineOptions {
  52392. /**
  52393. * Render width (Default: 512)
  52394. */
  52395. renderWidth: number;
  52396. /**
  52397. * Render height (Default: 256)
  52398. */
  52399. renderHeight: number;
  52400. /**
  52401. * Texture size (Default: 512)
  52402. */
  52403. textureSize: number;
  52404. /**
  52405. * If delta time between frames should be constant
  52406. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52407. */
  52408. deterministicLockstep: boolean;
  52409. /**
  52410. * Maximum about of steps between frames (Default: 4)
  52411. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52412. */
  52413. lockstepMaxSteps: number;
  52414. }
  52415. /**
  52416. * The null engine class provides support for headless version of babylon.js.
  52417. * This can be used in server side scenario or for testing purposes
  52418. */
  52419. export class NullEngine extends Engine {
  52420. private _options;
  52421. /**
  52422. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  52423. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52424. * @returns true if engine is in deterministic lock step mode
  52425. */
  52426. isDeterministicLockStep(): boolean;
  52427. /**
  52428. * Gets the max steps when engine is running in deterministic lock step
  52429. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52430. * @returns the max steps
  52431. */
  52432. getLockstepMaxSteps(): number;
  52433. /**
  52434. * Gets the current hardware scaling level.
  52435. * By default the hardware scaling level is computed from the window device ratio.
  52436. * 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.
  52437. * @returns a number indicating the current hardware scaling level
  52438. */
  52439. getHardwareScalingLevel(): number;
  52440. constructor(options?: NullEngineOptions);
  52441. /**
  52442. * Creates a vertex buffer
  52443. * @param vertices the data for the vertex buffer
  52444. * @returns the new WebGL static buffer
  52445. */
  52446. createVertexBuffer(vertices: FloatArray): DataBuffer;
  52447. /**
  52448. * Creates a new index buffer
  52449. * @param indices defines the content of the index buffer
  52450. * @param updatable defines if the index buffer must be updatable
  52451. * @returns a new webGL buffer
  52452. */
  52453. createIndexBuffer(indices: IndicesArray): DataBuffer;
  52454. /**
  52455. * Clear the current render buffer or the current render target (if any is set up)
  52456. * @param color defines the color to use
  52457. * @param backBuffer defines if the back buffer must be cleared
  52458. * @param depth defines if the depth buffer must be cleared
  52459. * @param stencil defines if the stencil buffer must be cleared
  52460. */
  52461. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52462. /**
  52463. * Gets the current render width
  52464. * @param useScreen defines if screen size must be used (or the current render target if any)
  52465. * @returns a number defining the current render width
  52466. */
  52467. getRenderWidth(useScreen?: boolean): number;
  52468. /**
  52469. * Gets the current render height
  52470. * @param useScreen defines if screen size must be used (or the current render target if any)
  52471. * @returns a number defining the current render height
  52472. */
  52473. getRenderHeight(useScreen?: boolean): number;
  52474. /**
  52475. * Set the WebGL's viewport
  52476. * @param viewport defines the viewport element to be used
  52477. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  52478. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  52479. */
  52480. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  52481. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  52482. /**
  52483. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  52484. * @param pipelineContext defines the pipeline context to use
  52485. * @param uniformsNames defines the list of uniform names
  52486. * @returns an array of webGL uniform locations
  52487. */
  52488. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  52489. /**
  52490. * Gets the lsit of active attributes for a given webGL program
  52491. * @param pipelineContext defines the pipeline context to use
  52492. * @param attributesNames defines the list of attribute names to get
  52493. * @returns an array of indices indicating the offset of each attribute
  52494. */
  52495. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52496. /**
  52497. * Binds an effect to the webGL context
  52498. * @param effect defines the effect to bind
  52499. */
  52500. bindSamplers(effect: Effect): void;
  52501. /**
  52502. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  52503. * @param effect defines the effect to activate
  52504. */
  52505. enableEffect(effect: Effect): void;
  52506. /**
  52507. * Set various states to the webGL context
  52508. * @param culling defines backface culling state
  52509. * @param zOffset defines the value to apply to zOffset (0 by default)
  52510. * @param force defines if states must be applied even if cache is up to date
  52511. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52512. */
  52513. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52514. /**
  52515. * Set the value of an uniform to an array of int32
  52516. * @param uniform defines the webGL uniform location where to store the value
  52517. * @param array defines the array of int32 to store
  52518. */
  52519. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52520. /**
  52521. * Set the value of an uniform to an array of int32 (stored as vec2)
  52522. * @param uniform defines the webGL uniform location where to store the value
  52523. * @param array defines the array of int32 to store
  52524. */
  52525. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52526. /**
  52527. * Set the value of an uniform to an array of int32 (stored as vec3)
  52528. * @param uniform defines the webGL uniform location where to store the value
  52529. * @param array defines the array of int32 to store
  52530. */
  52531. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52532. /**
  52533. * Set the value of an uniform to an array of int32 (stored as vec4)
  52534. * @param uniform defines the webGL uniform location where to store the value
  52535. * @param array defines the array of int32 to store
  52536. */
  52537. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52538. /**
  52539. * Set the value of an uniform to an array of float32
  52540. * @param uniform defines the webGL uniform location where to store the value
  52541. * @param array defines the array of float32 to store
  52542. */
  52543. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52544. /**
  52545. * Set the value of an uniform to an array of float32 (stored as vec2)
  52546. * @param uniform defines the webGL uniform location where to store the value
  52547. * @param array defines the array of float32 to store
  52548. */
  52549. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52550. /**
  52551. * Set the value of an uniform to an array of float32 (stored as vec3)
  52552. * @param uniform defines the webGL uniform location where to store the value
  52553. * @param array defines the array of float32 to store
  52554. */
  52555. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52556. /**
  52557. * Set the value of an uniform to an array of float32 (stored as vec4)
  52558. * @param uniform defines the webGL uniform location where to store the value
  52559. * @param array defines the array of float32 to store
  52560. */
  52561. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52562. /**
  52563. * Set the value of an uniform to an array of number
  52564. * @param uniform defines the webGL uniform location where to store the value
  52565. * @param array defines the array of number to store
  52566. */
  52567. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52568. /**
  52569. * Set the value of an uniform to an array of number (stored as vec2)
  52570. * @param uniform defines the webGL uniform location where to store the value
  52571. * @param array defines the array of number to store
  52572. */
  52573. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52574. /**
  52575. * Set the value of an uniform to an array of number (stored as vec3)
  52576. * @param uniform defines the webGL uniform location where to store the value
  52577. * @param array defines the array of number to store
  52578. */
  52579. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52580. /**
  52581. * Set the value of an uniform to an array of number (stored as vec4)
  52582. * @param uniform defines the webGL uniform location where to store the value
  52583. * @param array defines the array of number to store
  52584. */
  52585. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52586. /**
  52587. * Set the value of an uniform to an array of float32 (stored as matrices)
  52588. * @param uniform defines the webGL uniform location where to store the value
  52589. * @param matrices defines the array of float32 to store
  52590. */
  52591. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52592. /**
  52593. * Set the value of an uniform to a matrix (3x3)
  52594. * @param uniform defines the webGL uniform location where to store the value
  52595. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52596. */
  52597. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52598. /**
  52599. * Set the value of an uniform to a matrix (2x2)
  52600. * @param uniform defines the webGL uniform location where to store the value
  52601. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52602. */
  52603. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52604. /**
  52605. * Set the value of an uniform to a number (float)
  52606. * @param uniform defines the webGL uniform location where to store the value
  52607. * @param value defines the float number to store
  52608. */
  52609. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52610. /**
  52611. * Set the value of an uniform to a vec2
  52612. * @param uniform defines the webGL uniform location where to store the value
  52613. * @param x defines the 1st component of the value
  52614. * @param y defines the 2nd component of the value
  52615. */
  52616. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52617. /**
  52618. * Set the value of an uniform to a vec3
  52619. * @param uniform defines the webGL uniform location where to store the value
  52620. * @param x defines the 1st component of the value
  52621. * @param y defines the 2nd component of the value
  52622. * @param z defines the 3rd component of the value
  52623. */
  52624. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52625. /**
  52626. * Set the value of an uniform to a boolean
  52627. * @param uniform defines the webGL uniform location where to store the value
  52628. * @param bool defines the boolean to store
  52629. */
  52630. setBool(uniform: WebGLUniformLocation, bool: number): void;
  52631. /**
  52632. * Set the value of an uniform to a vec4
  52633. * @param uniform defines the webGL uniform location where to store the value
  52634. * @param x defines the 1st component of the value
  52635. * @param y defines the 2nd component of the value
  52636. * @param z defines the 3rd component of the value
  52637. * @param w defines the 4th component of the value
  52638. */
  52639. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52640. /**
  52641. * Sets the current alpha mode
  52642. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52643. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52644. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52645. */
  52646. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52647. /**
  52648. * Bind webGl buffers directly to the webGL context
  52649. * @param vertexBuffers defines the vertex buffer to bind
  52650. * @param indexBuffer defines the index buffer to bind
  52651. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52652. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52653. * @param effect defines the effect associated with the vertex buffer
  52654. */
  52655. bindBuffers(vertexBuffers: {
  52656. [key: string]: VertexBuffer;
  52657. }, indexBuffer: DataBuffer, effect: Effect): void;
  52658. /**
  52659. * Force the entire cache to be cleared
  52660. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52661. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52662. */
  52663. wipeCaches(bruteForce?: boolean): void;
  52664. /**
  52665. * Send a draw order
  52666. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52667. * @param indexStart defines the starting index
  52668. * @param indexCount defines the number of index to draw
  52669. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52670. */
  52671. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52672. /**
  52673. * Draw a list of indexed primitives
  52674. * @param fillMode defines the primitive to use
  52675. * @param indexStart defines the starting index
  52676. * @param indexCount defines the number of index to draw
  52677. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52678. */
  52679. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52680. /**
  52681. * Draw a list of unindexed primitives
  52682. * @param fillMode defines the primitive to use
  52683. * @param verticesStart defines the index of first vertex to draw
  52684. * @param verticesCount defines the count of vertices to draw
  52685. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52686. */
  52687. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52688. /** @hidden */
  52689. _createTexture(): WebGLTexture;
  52690. /** @hidden */
  52691. _releaseTexture(texture: InternalTexture): void;
  52692. /**
  52693. * Usually called from Texture.ts.
  52694. * Passed information to create a WebGLTexture
  52695. * @param urlArg defines a value which contains one of the following:
  52696. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52697. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52698. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52699. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52700. * @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)
  52701. * @param scene needed for loading to the correct scene
  52702. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52703. * @param onLoad optional callback to be called upon successful completion
  52704. * @param onError optional callback to be called upon failure
  52705. * @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
  52706. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52707. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52708. * @param forcedExtension defines the extension to use to pick the right loader
  52709. * @param mimeType defines an optional mime type
  52710. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52711. */
  52712. 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;
  52713. /**
  52714. * Creates a new render target texture
  52715. * @param size defines the size of the texture
  52716. * @param options defines the options used to create the texture
  52717. * @returns a new render target texture stored in an InternalTexture
  52718. */
  52719. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52720. /**
  52721. * Update the sampling mode of a given texture
  52722. * @param samplingMode defines the required sampling mode
  52723. * @param texture defines the texture to update
  52724. */
  52725. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52726. /**
  52727. * Binds the frame buffer to the specified texture.
  52728. * @param texture The texture to render to or null for the default canvas
  52729. * @param faceIndex The face of the texture to render to in case of cube texture
  52730. * @param requiredWidth The width of the target to render to
  52731. * @param requiredHeight The height of the target to render to
  52732. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52733. * @param lodLevel defines le lod level to bind to the frame buffer
  52734. */
  52735. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52736. /**
  52737. * Unbind the current render target texture from the webGL context
  52738. * @param texture defines the render target texture to unbind
  52739. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52740. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52741. */
  52742. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52743. /**
  52744. * Creates a dynamic vertex buffer
  52745. * @param vertices the data for the dynamic vertex buffer
  52746. * @returns the new WebGL dynamic buffer
  52747. */
  52748. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52749. /**
  52750. * Update the content of a dynamic texture
  52751. * @param texture defines the texture to update
  52752. * @param canvas defines the canvas containing the source
  52753. * @param invertY defines if data must be stored with Y axis inverted
  52754. * @param premulAlpha defines if alpha is stored as premultiplied
  52755. * @param format defines the format of the data
  52756. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52757. */
  52758. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52759. /**
  52760. * Gets a boolean indicating if all created effects are ready
  52761. * @returns true if all effects are ready
  52762. */
  52763. areAllEffectsReady(): boolean;
  52764. /**
  52765. * @hidden
  52766. * Get the current error code of the webGL context
  52767. * @returns the error code
  52768. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52769. */
  52770. getError(): number;
  52771. /** @hidden */
  52772. _getUnpackAlignement(): number;
  52773. /** @hidden */
  52774. _unpackFlipY(value: boolean): void;
  52775. /**
  52776. * Update a dynamic index buffer
  52777. * @param indexBuffer defines the target index buffer
  52778. * @param indices defines the data to update
  52779. * @param offset defines the offset in the target index buffer where update should start
  52780. */
  52781. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52782. /**
  52783. * Updates a dynamic vertex buffer.
  52784. * @param vertexBuffer the vertex buffer to update
  52785. * @param vertices the data used to update the vertex buffer
  52786. * @param byteOffset the byte offset of the data (optional)
  52787. * @param byteLength the byte length of the data (optional)
  52788. */
  52789. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52790. /** @hidden */
  52791. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52792. /** @hidden */
  52793. _bindTexture(channel: number, texture: InternalTexture): void;
  52794. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52795. /**
  52796. * 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
  52797. */
  52798. releaseEffects(): void;
  52799. displayLoadingUI(): void;
  52800. hideLoadingUI(): void;
  52801. /** @hidden */
  52802. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52803. /** @hidden */
  52804. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52805. /** @hidden */
  52806. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52807. /** @hidden */
  52808. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52809. }
  52810. }
  52811. declare module "babylonjs/Instrumentation/timeToken" {
  52812. import { Nullable } from "babylonjs/types";
  52813. /**
  52814. * @hidden
  52815. **/
  52816. export class _TimeToken {
  52817. _startTimeQuery: Nullable<WebGLQuery>;
  52818. _endTimeQuery: Nullable<WebGLQuery>;
  52819. _timeElapsedQuery: Nullable<WebGLQuery>;
  52820. _timeElapsedQueryEnded: boolean;
  52821. }
  52822. }
  52823. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  52824. import { Nullable, int } from "babylonjs/types";
  52825. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  52826. /** @hidden */
  52827. export class _OcclusionDataStorage {
  52828. /** @hidden */
  52829. occlusionInternalRetryCounter: number;
  52830. /** @hidden */
  52831. isOcclusionQueryInProgress: boolean;
  52832. /** @hidden */
  52833. isOccluded: boolean;
  52834. /** @hidden */
  52835. occlusionRetryCount: number;
  52836. /** @hidden */
  52837. occlusionType: number;
  52838. /** @hidden */
  52839. occlusionQueryAlgorithmType: number;
  52840. }
  52841. module "babylonjs/Engines/engine" {
  52842. interface Engine {
  52843. /**
  52844. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52845. * @return the new query
  52846. */
  52847. createQuery(): WebGLQuery;
  52848. /**
  52849. * Delete and release a webGL query
  52850. * @param query defines the query to delete
  52851. * @return the current engine
  52852. */
  52853. deleteQuery(query: WebGLQuery): Engine;
  52854. /**
  52855. * Check if a given query has resolved and got its value
  52856. * @param query defines the query to check
  52857. * @returns true if the query got its value
  52858. */
  52859. isQueryResultAvailable(query: WebGLQuery): boolean;
  52860. /**
  52861. * Gets the value of a given query
  52862. * @param query defines the query to check
  52863. * @returns the value of the query
  52864. */
  52865. getQueryResult(query: WebGLQuery): number;
  52866. /**
  52867. * Initiates an occlusion query
  52868. * @param algorithmType defines the algorithm to use
  52869. * @param query defines the query to use
  52870. * @returns the current engine
  52871. * @see http://doc.babylonjs.com/features/occlusionquery
  52872. */
  52873. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52874. /**
  52875. * Ends an occlusion query
  52876. * @see http://doc.babylonjs.com/features/occlusionquery
  52877. * @param algorithmType defines the algorithm to use
  52878. * @returns the current engine
  52879. */
  52880. endOcclusionQuery(algorithmType: number): Engine;
  52881. /**
  52882. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52883. * Please note that only one query can be issued at a time
  52884. * @returns a time token used to track the time span
  52885. */
  52886. startTimeQuery(): Nullable<_TimeToken>;
  52887. /**
  52888. * Ends a time query
  52889. * @param token defines the token used to measure the time span
  52890. * @returns the time spent (in ns)
  52891. */
  52892. endTimeQuery(token: _TimeToken): int;
  52893. /** @hidden */
  52894. _currentNonTimestampToken: Nullable<_TimeToken>;
  52895. /** @hidden */
  52896. _createTimeQuery(): WebGLQuery;
  52897. /** @hidden */
  52898. _deleteTimeQuery(query: WebGLQuery): void;
  52899. /** @hidden */
  52900. _getGlAlgorithmType(algorithmType: number): number;
  52901. /** @hidden */
  52902. _getTimeQueryResult(query: WebGLQuery): any;
  52903. /** @hidden */
  52904. _getTimeQueryAvailability(query: WebGLQuery): any;
  52905. }
  52906. }
  52907. module "babylonjs/Meshes/abstractMesh" {
  52908. interface AbstractMesh {
  52909. /**
  52910. * Backing filed
  52911. * @hidden
  52912. */
  52913. __occlusionDataStorage: _OcclusionDataStorage;
  52914. /**
  52915. * Access property
  52916. * @hidden
  52917. */
  52918. _occlusionDataStorage: _OcclusionDataStorage;
  52919. /**
  52920. * 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.
  52921. * The default value is -1 which means don't break the query and wait till the result
  52922. * @see http://doc.babylonjs.com/features/occlusionquery
  52923. */
  52924. occlusionRetryCount: number;
  52925. /**
  52926. * 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:
  52927. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52928. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52929. * * 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.
  52930. * @see http://doc.babylonjs.com/features/occlusionquery
  52931. */
  52932. occlusionType: number;
  52933. /**
  52934. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52935. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52936. * * 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.
  52937. * @see http://doc.babylonjs.com/features/occlusionquery
  52938. */
  52939. occlusionQueryAlgorithmType: number;
  52940. /**
  52941. * 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
  52942. * @see http://doc.babylonjs.com/features/occlusionquery
  52943. */
  52944. isOccluded: boolean;
  52945. /**
  52946. * Flag to check the progress status of the query
  52947. * @see http://doc.babylonjs.com/features/occlusionquery
  52948. */
  52949. isOcclusionQueryInProgress: boolean;
  52950. }
  52951. }
  52952. }
  52953. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  52954. import { Nullable } from "babylonjs/types";
  52955. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  52956. /** @hidden */
  52957. export var _forceTransformFeedbackToBundle: boolean;
  52958. module "babylonjs/Engines/engine" {
  52959. interface Engine {
  52960. /**
  52961. * Creates a webGL transform feedback object
  52962. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52963. * @returns the webGL transform feedback object
  52964. */
  52965. createTransformFeedback(): WebGLTransformFeedback;
  52966. /**
  52967. * Delete a webGL transform feedback object
  52968. * @param value defines the webGL transform feedback object to delete
  52969. */
  52970. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52971. /**
  52972. * Bind a webGL transform feedback object to the webgl context
  52973. * @param value defines the webGL transform feedback object to bind
  52974. */
  52975. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52976. /**
  52977. * Begins a transform feedback operation
  52978. * @param usePoints defines if points or triangles must be used
  52979. */
  52980. beginTransformFeedback(usePoints: boolean): void;
  52981. /**
  52982. * Ends a transform feedback operation
  52983. */
  52984. endTransformFeedback(): void;
  52985. /**
  52986. * Specify the varyings to use with transform feedback
  52987. * @param program defines the associated webGL program
  52988. * @param value defines the list of strings representing the varying names
  52989. */
  52990. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52991. /**
  52992. * Bind a webGL buffer for a transform feedback operation
  52993. * @param value defines the webGL buffer to bind
  52994. */
  52995. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52996. }
  52997. }
  52998. }
  52999. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  53000. import { Scene } from "babylonjs/scene";
  53001. import { Engine } from "babylonjs/Engines/engine";
  53002. import { Texture } from "babylonjs/Materials/Textures/texture";
  53003. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53004. import "babylonjs/Engines/Extensions/engine.multiRender";
  53005. /**
  53006. * Creation options of the multi render target texture.
  53007. */
  53008. export interface IMultiRenderTargetOptions {
  53009. /**
  53010. * Define if the texture needs to create mip maps after render.
  53011. */
  53012. generateMipMaps?: boolean;
  53013. /**
  53014. * Define the types of all the draw buffers we want to create
  53015. */
  53016. types?: number[];
  53017. /**
  53018. * Define the sampling modes of all the draw buffers we want to create
  53019. */
  53020. samplingModes?: number[];
  53021. /**
  53022. * Define if a depth buffer is required
  53023. */
  53024. generateDepthBuffer?: boolean;
  53025. /**
  53026. * Define if a stencil buffer is required
  53027. */
  53028. generateStencilBuffer?: boolean;
  53029. /**
  53030. * Define if a depth texture is required instead of a depth buffer
  53031. */
  53032. generateDepthTexture?: boolean;
  53033. /**
  53034. * Define the number of desired draw buffers
  53035. */
  53036. textureCount?: number;
  53037. /**
  53038. * Define if aspect ratio should be adapted to the texture or stay the scene one
  53039. */
  53040. doNotChangeAspectRatio?: boolean;
  53041. /**
  53042. * Define the default type of the buffers we are creating
  53043. */
  53044. defaultType?: number;
  53045. }
  53046. /**
  53047. * A multi render target, like a render target provides the ability to render to a texture.
  53048. * Unlike the render target, it can render to several draw buffers in one draw.
  53049. * This is specially interesting in deferred rendering or for any effects requiring more than
  53050. * just one color from a single pass.
  53051. */
  53052. export class MultiRenderTarget extends RenderTargetTexture {
  53053. private _internalTextures;
  53054. private _textures;
  53055. private _multiRenderTargetOptions;
  53056. /**
  53057. * Get if draw buffers are currently supported by the used hardware and browser.
  53058. */
  53059. get isSupported(): boolean;
  53060. /**
  53061. * Get the list of textures generated by the multi render target.
  53062. */
  53063. get textures(): Texture[];
  53064. /**
  53065. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  53066. */
  53067. get depthTexture(): Texture;
  53068. /**
  53069. * Set the wrapping mode on U of all the textures we are rendering to.
  53070. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  53071. */
  53072. set wrapU(wrap: number);
  53073. /**
  53074. * Set the wrapping mode on V of all the textures we are rendering to.
  53075. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  53076. */
  53077. set wrapV(wrap: number);
  53078. /**
  53079. * Instantiate a new multi render target texture.
  53080. * A multi render target, like a render target provides the ability to render to a texture.
  53081. * Unlike the render target, it can render to several draw buffers in one draw.
  53082. * This is specially interesting in deferred rendering or for any effects requiring more than
  53083. * just one color from a single pass.
  53084. * @param name Define the name of the texture
  53085. * @param size Define the size of the buffers to render to
  53086. * @param count Define the number of target we are rendering into
  53087. * @param scene Define the scene the texture belongs to
  53088. * @param options Define the options used to create the multi render target
  53089. */
  53090. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  53091. /** @hidden */
  53092. _rebuild(): void;
  53093. private _createInternalTextures;
  53094. private _createTextures;
  53095. /**
  53096. * Define the number of samples used if MSAA is enabled.
  53097. */
  53098. get samples(): number;
  53099. set samples(value: number);
  53100. /**
  53101. * Resize all the textures in the multi render target.
  53102. * Be carrefull as it will recreate all the data in the new texture.
  53103. * @param size Define the new size
  53104. */
  53105. resize(size: any): void;
  53106. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  53107. /**
  53108. * Dispose the render targets and their associated resources
  53109. */
  53110. dispose(): void;
  53111. /**
  53112. * Release all the underlying texture used as draw buffers.
  53113. */
  53114. releaseInternalTextures(): void;
  53115. }
  53116. }
  53117. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  53118. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53119. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  53120. import { Nullable } from "babylonjs/types";
  53121. module "babylonjs/Engines/thinEngine" {
  53122. interface ThinEngine {
  53123. /**
  53124. * Unbind a list of render target textures from the webGL context
  53125. * This is used only when drawBuffer extension or webGL2 are active
  53126. * @param textures defines the render target textures to unbind
  53127. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  53128. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  53129. */
  53130. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  53131. /**
  53132. * Create a multi render target texture
  53133. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  53134. * @param size defines the size of the texture
  53135. * @param options defines the creation options
  53136. * @returns the cube texture as an InternalTexture
  53137. */
  53138. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  53139. /**
  53140. * Update the sample count for a given multiple render target texture
  53141. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  53142. * @param textures defines the textures to update
  53143. * @param samples defines the sample count to set
  53144. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  53145. */
  53146. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  53147. }
  53148. }
  53149. }
  53150. declare module "babylonjs/Engines/Extensions/engine.views" {
  53151. import { Camera } from "babylonjs/Cameras/camera";
  53152. import { Nullable } from "babylonjs/types";
  53153. /**
  53154. * Class used to define an additional view for the engine
  53155. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53156. */
  53157. export class EngineView {
  53158. /** Defines the canvas where to render the view */
  53159. target: HTMLCanvasElement;
  53160. /** Defines an optional camera used to render the view (will use active camera else) */
  53161. camera?: Camera;
  53162. }
  53163. module "babylonjs/Engines/engine" {
  53164. interface Engine {
  53165. /**
  53166. * Gets or sets the HTML element to use for attaching events
  53167. */
  53168. inputElement: Nullable<HTMLElement>;
  53169. /**
  53170. * Gets the current engine view
  53171. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53172. */
  53173. activeView: Nullable<EngineView>;
  53174. /** Gets or sets the list of views */
  53175. views: EngineView[];
  53176. /**
  53177. * Register a new child canvas
  53178. * @param canvas defines the canvas to register
  53179. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  53180. * @returns the associated view
  53181. */
  53182. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  53183. /**
  53184. * Remove a registered child canvas
  53185. * @param canvas defines the canvas to remove
  53186. * @returns the current engine
  53187. */
  53188. unRegisterView(canvas: HTMLCanvasElement): Engine;
  53189. }
  53190. }
  53191. }
  53192. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  53193. import { Nullable } from "babylonjs/types";
  53194. module "babylonjs/Engines/engine" {
  53195. interface Engine {
  53196. /** @hidden */
  53197. _excludedCompressedTextures: string[];
  53198. /** @hidden */
  53199. _textureFormatInUse: string;
  53200. /**
  53201. * Gets the list of texture formats supported
  53202. */
  53203. readonly texturesSupported: Array<string>;
  53204. /**
  53205. * Gets the texture format in use
  53206. */
  53207. readonly textureFormatInUse: Nullable<string>;
  53208. /**
  53209. * Set the compressed texture extensions or file names to skip.
  53210. *
  53211. * @param skippedFiles defines the list of those texture files you want to skip
  53212. * Example: [".dds", ".env", "myfile.png"]
  53213. */
  53214. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  53215. /**
  53216. * Set the compressed texture format to use, based on the formats you have, and the formats
  53217. * supported by the hardware / browser.
  53218. *
  53219. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  53220. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  53221. * to API arguments needed to compressed textures. This puts the burden on the container
  53222. * generator to house the arcane code for determining these for current & future formats.
  53223. *
  53224. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53225. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53226. *
  53227. * Note: The result of this call is not taken into account when a texture is base64.
  53228. *
  53229. * @param formatsAvailable defines the list of those format families you have created
  53230. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  53231. *
  53232. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  53233. * @returns The extension selected.
  53234. */
  53235. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  53236. }
  53237. }
  53238. }
  53239. declare module "babylonjs/Engines/Extensions/index" {
  53240. export * from "babylonjs/Engines/Extensions/engine.alpha";
  53241. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  53242. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  53243. export * from "babylonjs/Engines/Extensions/engine.multiview";
  53244. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  53245. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  53246. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  53247. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  53248. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  53249. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  53250. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53251. export * from "babylonjs/Engines/Extensions/engine.webVR";
  53252. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  53253. export * from "babylonjs/Engines/Extensions/engine.views";
  53254. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  53255. import "babylonjs/Engines/Extensions/engine.textureSelector";
  53256. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  53257. }
  53258. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  53259. import { Nullable } from "babylonjs/types";
  53260. /**
  53261. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  53262. */
  53263. export interface CubeMapInfo {
  53264. /**
  53265. * The pixel array for the front face.
  53266. * This is stored in format, left to right, up to down format.
  53267. */
  53268. front: Nullable<ArrayBufferView>;
  53269. /**
  53270. * The pixel array for the back face.
  53271. * This is stored in format, left to right, up to down format.
  53272. */
  53273. back: Nullable<ArrayBufferView>;
  53274. /**
  53275. * The pixel array for the left face.
  53276. * This is stored in format, left to right, up to down format.
  53277. */
  53278. left: Nullable<ArrayBufferView>;
  53279. /**
  53280. * The pixel array for the right face.
  53281. * This is stored in format, left to right, up to down format.
  53282. */
  53283. right: Nullable<ArrayBufferView>;
  53284. /**
  53285. * The pixel array for the up face.
  53286. * This is stored in format, left to right, up to down format.
  53287. */
  53288. up: Nullable<ArrayBufferView>;
  53289. /**
  53290. * The pixel array for the down face.
  53291. * This is stored in format, left to right, up to down format.
  53292. */
  53293. down: Nullable<ArrayBufferView>;
  53294. /**
  53295. * The size of the cubemap stored.
  53296. *
  53297. * Each faces will be size * size pixels.
  53298. */
  53299. size: number;
  53300. /**
  53301. * The format of the texture.
  53302. *
  53303. * RGBA, RGB.
  53304. */
  53305. format: number;
  53306. /**
  53307. * The type of the texture data.
  53308. *
  53309. * UNSIGNED_INT, FLOAT.
  53310. */
  53311. type: number;
  53312. /**
  53313. * Specifies whether the texture is in gamma space.
  53314. */
  53315. gammaSpace: boolean;
  53316. }
  53317. /**
  53318. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  53319. */
  53320. export class PanoramaToCubeMapTools {
  53321. private static FACE_LEFT;
  53322. private static FACE_RIGHT;
  53323. private static FACE_FRONT;
  53324. private static FACE_BACK;
  53325. private static FACE_DOWN;
  53326. private static FACE_UP;
  53327. /**
  53328. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  53329. *
  53330. * @param float32Array The source data.
  53331. * @param inputWidth The width of the input panorama.
  53332. * @param inputHeight The height of the input panorama.
  53333. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  53334. * @return The cubemap data
  53335. */
  53336. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  53337. private static CreateCubemapTexture;
  53338. private static CalcProjectionSpherical;
  53339. }
  53340. }
  53341. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  53342. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53343. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53344. import { Nullable } from "babylonjs/types";
  53345. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53346. /**
  53347. * Helper class dealing with the extraction of spherical polynomial dataArray
  53348. * from a cube map.
  53349. */
  53350. export class CubeMapToSphericalPolynomialTools {
  53351. private static FileFaces;
  53352. /**
  53353. * Converts a texture to the according Spherical Polynomial data.
  53354. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53355. *
  53356. * @param texture The texture to extract the information from.
  53357. * @return The Spherical Polynomial data.
  53358. */
  53359. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  53360. /**
  53361. * Converts a cubemap to the according Spherical Polynomial data.
  53362. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53363. *
  53364. * @param cubeInfo The Cube map to extract the information from.
  53365. * @return The Spherical Polynomial data.
  53366. */
  53367. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  53368. }
  53369. }
  53370. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  53371. import { Nullable } from "babylonjs/types";
  53372. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53373. module "babylonjs/Materials/Textures/baseTexture" {
  53374. interface BaseTexture {
  53375. /**
  53376. * Get the polynomial representation of the texture data.
  53377. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  53378. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  53379. */
  53380. sphericalPolynomial: Nullable<SphericalPolynomial>;
  53381. }
  53382. }
  53383. }
  53384. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  53385. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53386. /** @hidden */
  53387. export var rgbdEncodePixelShader: {
  53388. name: string;
  53389. shader: string;
  53390. };
  53391. }
  53392. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  53393. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53394. /** @hidden */
  53395. export var rgbdDecodePixelShader: {
  53396. name: string;
  53397. shader: string;
  53398. };
  53399. }
  53400. declare module "babylonjs/Misc/environmentTextureTools" {
  53401. import { Nullable } from "babylonjs/types";
  53402. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53403. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53404. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53405. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53406. import "babylonjs/Engines/Extensions/engine.readTexture";
  53407. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53408. import "babylonjs/Shaders/rgbdEncode.fragment";
  53409. import "babylonjs/Shaders/rgbdDecode.fragment";
  53410. /**
  53411. * Raw texture data and descriptor sufficient for WebGL texture upload
  53412. */
  53413. export interface EnvironmentTextureInfo {
  53414. /**
  53415. * Version of the environment map
  53416. */
  53417. version: number;
  53418. /**
  53419. * Width of image
  53420. */
  53421. width: number;
  53422. /**
  53423. * Irradiance information stored in the file.
  53424. */
  53425. irradiance: any;
  53426. /**
  53427. * Specular information stored in the file.
  53428. */
  53429. specular: any;
  53430. }
  53431. /**
  53432. * Defines One Image in the file. It requires only the position in the file
  53433. * as well as the length.
  53434. */
  53435. interface BufferImageData {
  53436. /**
  53437. * Length of the image data.
  53438. */
  53439. length: number;
  53440. /**
  53441. * Position of the data from the null terminator delimiting the end of the JSON.
  53442. */
  53443. position: number;
  53444. }
  53445. /**
  53446. * Defines the specular data enclosed in the file.
  53447. * This corresponds to the version 1 of the data.
  53448. */
  53449. export interface EnvironmentTextureSpecularInfoV1 {
  53450. /**
  53451. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  53452. */
  53453. specularDataPosition?: number;
  53454. /**
  53455. * This contains all the images data needed to reconstruct the cubemap.
  53456. */
  53457. mipmaps: Array<BufferImageData>;
  53458. /**
  53459. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  53460. */
  53461. lodGenerationScale: number;
  53462. }
  53463. /**
  53464. * Sets of helpers addressing the serialization and deserialization of environment texture
  53465. * stored in a BabylonJS env file.
  53466. * Those files are usually stored as .env files.
  53467. */
  53468. export class EnvironmentTextureTools {
  53469. /**
  53470. * Magic number identifying the env file.
  53471. */
  53472. private static _MagicBytes;
  53473. /**
  53474. * Gets the environment info from an env file.
  53475. * @param data The array buffer containing the .env bytes.
  53476. * @returns the environment file info (the json header) if successfully parsed.
  53477. */
  53478. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  53479. /**
  53480. * Creates an environment texture from a loaded cube texture.
  53481. * @param texture defines the cube texture to convert in env file
  53482. * @return a promise containing the environment data if succesfull.
  53483. */
  53484. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  53485. /**
  53486. * Creates a JSON representation of the spherical data.
  53487. * @param texture defines the texture containing the polynomials
  53488. * @return the JSON representation of the spherical info
  53489. */
  53490. private static _CreateEnvTextureIrradiance;
  53491. /**
  53492. * Creates the ArrayBufferViews used for initializing environment texture image data.
  53493. * @param data the image data
  53494. * @param info parameters that determine what views will be created for accessing the underlying buffer
  53495. * @return the views described by info providing access to the underlying buffer
  53496. */
  53497. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  53498. /**
  53499. * Uploads the texture info contained in the env file to the GPU.
  53500. * @param texture defines the internal texture to upload to
  53501. * @param data defines the data to load
  53502. * @param info defines the texture info retrieved through the GetEnvInfo method
  53503. * @returns a promise
  53504. */
  53505. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  53506. private static _OnImageReadyAsync;
  53507. /**
  53508. * Uploads the levels of image data to the GPU.
  53509. * @param texture defines the internal texture to upload to
  53510. * @param imageData defines the array buffer views of image data [mipmap][face]
  53511. * @returns a promise
  53512. */
  53513. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  53514. /**
  53515. * Uploads spherical polynomials information to the texture.
  53516. * @param texture defines the texture we are trying to upload the information to
  53517. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  53518. */
  53519. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  53520. /** @hidden */
  53521. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53522. }
  53523. }
  53524. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  53525. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  53526. /** @hidden */
  53527. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  53528. private _genericAttributeLocation;
  53529. private _varyingLocationCount;
  53530. private _varyingLocationMap;
  53531. private _replacements;
  53532. private _textureCount;
  53533. private _uniforms;
  53534. lineProcessor(line: string): string;
  53535. attributeProcessor(attribute: string): string;
  53536. varyingProcessor(varying: string, isFragment: boolean): string;
  53537. uniformProcessor(uniform: string): string;
  53538. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  53539. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  53540. }
  53541. }
  53542. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  53543. /**
  53544. * Class used to inline functions in shader code
  53545. */
  53546. export class ShaderCodeInliner {
  53547. private static readonly _RegexpFindFunctionNameAndType;
  53548. private _sourceCode;
  53549. private _functionDescr;
  53550. private _numMaxIterations;
  53551. /** Gets or sets the token used to mark the functions to inline */
  53552. inlineToken: string;
  53553. /** Gets or sets the debug mode */
  53554. debug: boolean;
  53555. /** Gets the code after the inlining process */
  53556. get code(): string;
  53557. /**
  53558. * Initializes the inliner
  53559. * @param sourceCode shader code source to inline
  53560. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  53561. */
  53562. constructor(sourceCode: string, numMaxIterations?: number);
  53563. /**
  53564. * Start the processing of the shader code
  53565. */
  53566. processCode(): void;
  53567. private _collectFunctions;
  53568. private _processInlining;
  53569. private _extractBetweenMarkers;
  53570. private _skipWhitespaces;
  53571. private _removeComments;
  53572. private _replaceFunctionCallsByCode;
  53573. private _findBackward;
  53574. private _escapeRegExp;
  53575. private _replaceNames;
  53576. }
  53577. }
  53578. declare module "babylonjs/Engines/nativeEngine" {
  53579. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  53580. import { Engine } from "babylonjs/Engines/engine";
  53581. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53582. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53583. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53584. import { Effect } from "babylonjs/Materials/effect";
  53585. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53586. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  53587. import { IColor4Like } from "babylonjs/Maths/math.like";
  53588. import { Scene } from "babylonjs/scene";
  53589. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53590. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53591. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53592. /**
  53593. * Container for accessors for natively-stored mesh data buffers.
  53594. */
  53595. class NativeDataBuffer extends DataBuffer {
  53596. /**
  53597. * Accessor value used to identify/retrieve a natively-stored index buffer.
  53598. */
  53599. nativeIndexBuffer?: any;
  53600. /**
  53601. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  53602. */
  53603. nativeVertexBuffer?: any;
  53604. }
  53605. /** @hidden */
  53606. class NativeTexture extends InternalTexture {
  53607. getInternalTexture(): InternalTexture;
  53608. getViewCount(): number;
  53609. }
  53610. /** @hidden */
  53611. export class NativeEngine extends Engine {
  53612. private readonly _native;
  53613. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  53614. private readonly INVALID_HANDLE;
  53615. getHardwareScalingLevel(): number;
  53616. constructor();
  53617. dispose(): void;
  53618. /**
  53619. * Can be used to override the current requestAnimationFrame requester.
  53620. * @hidden
  53621. */
  53622. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  53623. /**
  53624. * Override default engine behavior.
  53625. * @param color
  53626. * @param backBuffer
  53627. * @param depth
  53628. * @param stencil
  53629. */
  53630. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  53631. /**
  53632. * Gets host document
  53633. * @returns the host document object
  53634. */
  53635. getHostDocument(): Nullable<Document>;
  53636. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53637. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  53638. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  53639. recordVertexArrayObject(vertexBuffers: {
  53640. [key: string]: VertexBuffer;
  53641. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  53642. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53643. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53644. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53645. /**
  53646. * Draw a list of indexed primitives
  53647. * @param fillMode defines the primitive to use
  53648. * @param indexStart defines the starting index
  53649. * @param indexCount defines the number of index to draw
  53650. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53651. */
  53652. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53653. /**
  53654. * Draw a list of unindexed primitives
  53655. * @param fillMode defines the primitive to use
  53656. * @param verticesStart defines the index of first vertex to draw
  53657. * @param verticesCount defines the count of vertices to draw
  53658. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53659. */
  53660. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53661. createPipelineContext(): IPipelineContext;
  53662. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  53663. /** @hidden */
  53664. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  53665. /** @hidden */
  53666. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  53667. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53668. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53669. protected _setProgram(program: WebGLProgram): void;
  53670. _releaseEffect(effect: Effect): void;
  53671. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  53672. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  53673. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  53674. bindSamplers(effect: Effect): void;
  53675. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  53676. getRenderWidth(useScreen?: boolean): number;
  53677. getRenderHeight(useScreen?: boolean): number;
  53678. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  53679. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53680. /**
  53681. * Set the z offset to apply to current rendering
  53682. * @param value defines the offset to apply
  53683. */
  53684. setZOffset(value: number): void;
  53685. /**
  53686. * Gets the current value of the zOffset
  53687. * @returns the current zOffset state
  53688. */
  53689. getZOffset(): number;
  53690. /**
  53691. * Enable or disable depth buffering
  53692. * @param enable defines the state to set
  53693. */
  53694. setDepthBuffer(enable: boolean): void;
  53695. /**
  53696. * Gets a boolean indicating if depth writing is enabled
  53697. * @returns the current depth writing state
  53698. */
  53699. getDepthWrite(): boolean;
  53700. /**
  53701. * Enable or disable depth writing
  53702. * @param enable defines the state to set
  53703. */
  53704. setDepthWrite(enable: boolean): void;
  53705. /**
  53706. * Enable or disable color writing
  53707. * @param enable defines the state to set
  53708. */
  53709. setColorWrite(enable: boolean): void;
  53710. /**
  53711. * Gets a boolean indicating if color writing is enabled
  53712. * @returns the current color writing state
  53713. */
  53714. getColorWrite(): boolean;
  53715. /**
  53716. * Sets alpha constants used by some alpha blending modes
  53717. * @param r defines the red component
  53718. * @param g defines the green component
  53719. * @param b defines the blue component
  53720. * @param a defines the alpha component
  53721. */
  53722. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53723. /**
  53724. * Sets the current alpha mode
  53725. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53726. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53727. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53728. */
  53729. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53730. /**
  53731. * Gets the current alpha mode
  53732. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53733. * @returns the current alpha mode
  53734. */
  53735. getAlphaMode(): number;
  53736. setInt(uniform: WebGLUniformLocation, int: number): void;
  53737. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53738. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53739. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53740. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53741. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53742. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53743. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53744. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53745. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53746. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53747. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53748. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53749. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53750. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53751. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53752. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53753. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53754. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53755. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53756. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  53757. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  53758. wipeCaches(bruteForce?: boolean): void;
  53759. _createTexture(): WebGLTexture;
  53760. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53761. /**
  53762. * Usually called from Texture.ts.
  53763. * Passed information to create a WebGLTexture
  53764. * @param url defines a value which contains one of the following:
  53765. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53766. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53767. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53768. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53769. * @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)
  53770. * @param scene needed for loading to the correct scene
  53771. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53772. * @param onLoad optional callback to be called upon successful completion
  53773. * @param onError optional callback to be called upon failure
  53774. * @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
  53775. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53776. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53777. * @param forcedExtension defines the extension to use to pick the right loader
  53778. * @param mimeType defines an optional mime type
  53779. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53780. */
  53781. 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;
  53782. /**
  53783. * Creates a cube texture
  53784. * @param rootUrl defines the url where the files to load is located
  53785. * @param scene defines the current scene
  53786. * @param files defines the list of files to load (1 per face)
  53787. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53788. * @param onLoad defines an optional callback raised when the texture is loaded
  53789. * @param onError defines an optional callback raised if there is an issue to load the texture
  53790. * @param format defines the format of the data
  53791. * @param forcedExtension defines the extension to use to pick the right loader
  53792. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53793. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53794. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53795. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53796. * @returns the cube texture as an InternalTexture
  53797. */
  53798. 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;
  53799. private _getSamplingFilter;
  53800. private static _GetNativeTextureFormat;
  53801. createRenderTargetTexture(size: number | {
  53802. width: number;
  53803. height: number;
  53804. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53805. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53806. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53807. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53808. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53809. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53810. /**
  53811. * Updates a dynamic vertex buffer.
  53812. * @param vertexBuffer the vertex buffer to update
  53813. * @param data the data used to update the vertex buffer
  53814. * @param byteOffset the byte offset of the data (optional)
  53815. * @param byteLength the byte length of the data (optional)
  53816. */
  53817. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53818. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53819. private _updateAnisotropicLevel;
  53820. private _getAddressMode;
  53821. /** @hidden */
  53822. _bindTexture(channel: number, texture: InternalTexture): void;
  53823. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53824. releaseEffects(): void;
  53825. /** @hidden */
  53826. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53827. /** @hidden */
  53828. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53829. /** @hidden */
  53830. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53831. /** @hidden */
  53832. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53833. }
  53834. }
  53835. declare module "babylonjs/Engines/index" {
  53836. export * from "babylonjs/Engines/constants";
  53837. export * from "babylonjs/Engines/engineCapabilities";
  53838. export * from "babylonjs/Engines/instancingAttributeInfo";
  53839. export * from "babylonjs/Engines/thinEngine";
  53840. export * from "babylonjs/Engines/engine";
  53841. export * from "babylonjs/Engines/engineStore";
  53842. export * from "babylonjs/Engines/nullEngine";
  53843. export * from "babylonjs/Engines/Extensions/index";
  53844. export * from "babylonjs/Engines/IPipelineContext";
  53845. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  53846. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  53847. export * from "babylonjs/Engines/nativeEngine";
  53848. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  53849. }
  53850. declare module "babylonjs/Events/clipboardEvents" {
  53851. /**
  53852. * Gather the list of clipboard event types as constants.
  53853. */
  53854. export class ClipboardEventTypes {
  53855. /**
  53856. * The clipboard event is fired when a copy command is active (pressed).
  53857. */
  53858. static readonly COPY: number;
  53859. /**
  53860. * The clipboard event is fired when a cut command is active (pressed).
  53861. */
  53862. static readonly CUT: number;
  53863. /**
  53864. * The clipboard event is fired when a paste command is active (pressed).
  53865. */
  53866. static readonly PASTE: number;
  53867. }
  53868. /**
  53869. * This class is used to store clipboard related info for the onClipboardObservable event.
  53870. */
  53871. export class ClipboardInfo {
  53872. /**
  53873. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53874. */
  53875. type: number;
  53876. /**
  53877. * Defines the related dom event
  53878. */
  53879. event: ClipboardEvent;
  53880. /**
  53881. *Creates an instance of ClipboardInfo.
  53882. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  53883. * @param event Defines the related dom event
  53884. */
  53885. constructor(
  53886. /**
  53887. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53888. */
  53889. type: number,
  53890. /**
  53891. * Defines the related dom event
  53892. */
  53893. event: ClipboardEvent);
  53894. /**
  53895. * Get the clipboard event's type from the keycode.
  53896. * @param keyCode Defines the keyCode for the current keyboard event.
  53897. * @return {number}
  53898. */
  53899. static GetTypeFromCharacter(keyCode: number): number;
  53900. }
  53901. }
  53902. declare module "babylonjs/Events/index" {
  53903. export * from "babylonjs/Events/keyboardEvents";
  53904. export * from "babylonjs/Events/pointerEvents";
  53905. export * from "babylonjs/Events/clipboardEvents";
  53906. }
  53907. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  53908. import { Scene } from "babylonjs/scene";
  53909. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53910. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53911. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53912. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53913. /**
  53914. * Google Daydream controller
  53915. */
  53916. export class DaydreamController extends WebVRController {
  53917. /**
  53918. * Base Url for the controller model.
  53919. */
  53920. static MODEL_BASE_URL: string;
  53921. /**
  53922. * File name for the controller model.
  53923. */
  53924. static MODEL_FILENAME: string;
  53925. /**
  53926. * Gamepad Id prefix used to identify Daydream Controller.
  53927. */
  53928. static readonly GAMEPAD_ID_PREFIX: string;
  53929. /**
  53930. * Creates a new DaydreamController from a gamepad
  53931. * @param vrGamepad the gamepad that the controller should be created from
  53932. */
  53933. constructor(vrGamepad: any);
  53934. /**
  53935. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53936. * @param scene scene in which to add meshes
  53937. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53938. */
  53939. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53940. /**
  53941. * Called once for each button that changed state since the last frame
  53942. * @param buttonIdx Which button index changed
  53943. * @param state New state of the button
  53944. * @param changes Which properties on the state changed since last frame
  53945. */
  53946. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53947. }
  53948. }
  53949. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  53950. import { Scene } from "babylonjs/scene";
  53951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53952. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53953. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53954. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53955. /**
  53956. * Gear VR Controller
  53957. */
  53958. export class GearVRController extends WebVRController {
  53959. /**
  53960. * Base Url for the controller model.
  53961. */
  53962. static MODEL_BASE_URL: string;
  53963. /**
  53964. * File name for the controller model.
  53965. */
  53966. static MODEL_FILENAME: string;
  53967. /**
  53968. * Gamepad Id prefix used to identify this controller.
  53969. */
  53970. static readonly GAMEPAD_ID_PREFIX: string;
  53971. private readonly _buttonIndexToObservableNameMap;
  53972. /**
  53973. * Creates a new GearVRController from a gamepad
  53974. * @param vrGamepad the gamepad that the controller should be created from
  53975. */
  53976. constructor(vrGamepad: any);
  53977. /**
  53978. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53979. * @param scene scene in which to add meshes
  53980. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53981. */
  53982. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53983. /**
  53984. * Called once for each button that changed state since the last frame
  53985. * @param buttonIdx Which button index changed
  53986. * @param state New state of the button
  53987. * @param changes Which properties on the state changed since last frame
  53988. */
  53989. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53990. }
  53991. }
  53992. declare module "babylonjs/Gamepads/Controllers/genericController" {
  53993. import { Scene } from "babylonjs/scene";
  53994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53995. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53996. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53997. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53998. /**
  53999. * Generic Controller
  54000. */
  54001. export class GenericController extends WebVRController {
  54002. /**
  54003. * Base Url for the controller model.
  54004. */
  54005. static readonly MODEL_BASE_URL: string;
  54006. /**
  54007. * File name for the controller model.
  54008. */
  54009. static readonly MODEL_FILENAME: string;
  54010. /**
  54011. * Creates a new GenericController from a gamepad
  54012. * @param vrGamepad the gamepad that the controller should be created from
  54013. */
  54014. constructor(vrGamepad: any);
  54015. /**
  54016. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54017. * @param scene scene in which to add meshes
  54018. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54019. */
  54020. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54021. /**
  54022. * Called once for each button that changed state since the last frame
  54023. * @param buttonIdx Which button index changed
  54024. * @param state New state of the button
  54025. * @param changes Which properties on the state changed since last frame
  54026. */
  54027. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54028. }
  54029. }
  54030. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  54031. import { Observable } from "babylonjs/Misc/observable";
  54032. import { Scene } from "babylonjs/scene";
  54033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54034. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54035. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54036. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54037. /**
  54038. * Oculus Touch Controller
  54039. */
  54040. export class OculusTouchController extends WebVRController {
  54041. /**
  54042. * Base Url for the controller model.
  54043. */
  54044. static MODEL_BASE_URL: string;
  54045. /**
  54046. * File name for the left controller model.
  54047. */
  54048. static MODEL_LEFT_FILENAME: string;
  54049. /**
  54050. * File name for the right controller model.
  54051. */
  54052. static MODEL_RIGHT_FILENAME: string;
  54053. /**
  54054. * Base Url for the Quest controller model.
  54055. */
  54056. static QUEST_MODEL_BASE_URL: string;
  54057. /**
  54058. * @hidden
  54059. * If the controllers are running on a device that needs the updated Quest controller models
  54060. */
  54061. static _IsQuest: boolean;
  54062. /**
  54063. * Fired when the secondary trigger on this controller is modified
  54064. */
  54065. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  54066. /**
  54067. * Fired when the thumb rest on this controller is modified
  54068. */
  54069. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  54070. /**
  54071. * Creates a new OculusTouchController from a gamepad
  54072. * @param vrGamepad the gamepad that the controller should be created from
  54073. */
  54074. constructor(vrGamepad: any);
  54075. /**
  54076. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54077. * @param scene scene in which to add meshes
  54078. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54079. */
  54080. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54081. /**
  54082. * Fired when the A button on this controller is modified
  54083. */
  54084. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54085. /**
  54086. * Fired when the B button on this controller is modified
  54087. */
  54088. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54089. /**
  54090. * Fired when the X button on this controller is modified
  54091. */
  54092. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54093. /**
  54094. * Fired when the Y button on this controller is modified
  54095. */
  54096. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54097. /**
  54098. * Called once for each button that changed state since the last frame
  54099. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  54100. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  54101. * 2) secondary trigger (same)
  54102. * 3) A (right) X (left), touch, pressed = value
  54103. * 4) B / Y
  54104. * 5) thumb rest
  54105. * @param buttonIdx Which button index changed
  54106. * @param state New state of the button
  54107. * @param changes Which properties on the state changed since last frame
  54108. */
  54109. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54110. }
  54111. }
  54112. declare module "babylonjs/Gamepads/Controllers/viveController" {
  54113. import { Scene } from "babylonjs/scene";
  54114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54115. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54116. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54117. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54118. import { Observable } from "babylonjs/Misc/observable";
  54119. /**
  54120. * Vive Controller
  54121. */
  54122. export class ViveController extends WebVRController {
  54123. /**
  54124. * Base Url for the controller model.
  54125. */
  54126. static MODEL_BASE_URL: string;
  54127. /**
  54128. * File name for the controller model.
  54129. */
  54130. static MODEL_FILENAME: string;
  54131. /**
  54132. * Creates a new ViveController from a gamepad
  54133. * @param vrGamepad the gamepad that the controller should be created from
  54134. */
  54135. constructor(vrGamepad: any);
  54136. /**
  54137. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54138. * @param scene scene in which to add meshes
  54139. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54140. */
  54141. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54142. /**
  54143. * Fired when the left button on this controller is modified
  54144. */
  54145. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54146. /**
  54147. * Fired when the right button on this controller is modified
  54148. */
  54149. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54150. /**
  54151. * Fired when the menu button on this controller is modified
  54152. */
  54153. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54154. /**
  54155. * Called once for each button that changed state since the last frame
  54156. * Vive mapping:
  54157. * 0: touchpad
  54158. * 1: trigger
  54159. * 2: left AND right buttons
  54160. * 3: menu button
  54161. * @param buttonIdx Which button index changed
  54162. * @param state New state of the button
  54163. * @param changes Which properties on the state changed since last frame
  54164. */
  54165. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54166. }
  54167. }
  54168. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  54169. import { Observable } from "babylonjs/Misc/observable";
  54170. import { Scene } from "babylonjs/scene";
  54171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54172. import { Ray } from "babylonjs/Culling/ray";
  54173. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54174. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54175. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54176. /**
  54177. * Defines the WindowsMotionController object that the state of the windows motion controller
  54178. */
  54179. export class WindowsMotionController extends WebVRController {
  54180. /**
  54181. * The base url used to load the left and right controller models
  54182. */
  54183. static MODEL_BASE_URL: string;
  54184. /**
  54185. * The name of the left controller model file
  54186. */
  54187. static MODEL_LEFT_FILENAME: string;
  54188. /**
  54189. * The name of the right controller model file
  54190. */
  54191. static MODEL_RIGHT_FILENAME: string;
  54192. /**
  54193. * The controller name prefix for this controller type
  54194. */
  54195. static readonly GAMEPAD_ID_PREFIX: string;
  54196. /**
  54197. * The controller id pattern for this controller type
  54198. */
  54199. private static readonly GAMEPAD_ID_PATTERN;
  54200. private _loadedMeshInfo;
  54201. protected readonly _mapping: {
  54202. buttons: string[];
  54203. buttonMeshNames: {
  54204. trigger: string;
  54205. menu: string;
  54206. grip: string;
  54207. thumbstick: string;
  54208. trackpad: string;
  54209. };
  54210. buttonObservableNames: {
  54211. trigger: string;
  54212. menu: string;
  54213. grip: string;
  54214. thumbstick: string;
  54215. trackpad: string;
  54216. };
  54217. axisMeshNames: string[];
  54218. pointingPoseMeshName: string;
  54219. };
  54220. /**
  54221. * Fired when the trackpad on this controller is clicked
  54222. */
  54223. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54224. /**
  54225. * Fired when the trackpad on this controller is modified
  54226. */
  54227. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54228. /**
  54229. * The current x and y values of this controller's trackpad
  54230. */
  54231. trackpad: StickValues;
  54232. /**
  54233. * Creates a new WindowsMotionController from a gamepad
  54234. * @param vrGamepad the gamepad that the controller should be created from
  54235. */
  54236. constructor(vrGamepad: any);
  54237. /**
  54238. * Fired when the trigger on this controller is modified
  54239. */
  54240. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54241. /**
  54242. * Fired when the menu button on this controller is modified
  54243. */
  54244. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54245. /**
  54246. * Fired when the grip button on this controller is modified
  54247. */
  54248. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54249. /**
  54250. * Fired when the thumbstick button on this controller is modified
  54251. */
  54252. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54253. /**
  54254. * Fired when the touchpad button on this controller is modified
  54255. */
  54256. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54257. /**
  54258. * Fired when the touchpad values on this controller are modified
  54259. */
  54260. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  54261. protected _updateTrackpad(): void;
  54262. /**
  54263. * Called once per frame by the engine.
  54264. */
  54265. update(): void;
  54266. /**
  54267. * Called once for each button that changed state since the last frame
  54268. * @param buttonIdx Which button index changed
  54269. * @param state New state of the button
  54270. * @param changes Which properties on the state changed since last frame
  54271. */
  54272. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54273. /**
  54274. * Moves the buttons on the controller mesh based on their current state
  54275. * @param buttonName the name of the button to move
  54276. * @param buttonValue the value of the button which determines the buttons new position
  54277. */
  54278. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  54279. /**
  54280. * Moves the axis on the controller mesh based on its current state
  54281. * @param axis the index of the axis
  54282. * @param axisValue the value of the axis which determines the meshes new position
  54283. * @hidden
  54284. */
  54285. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  54286. /**
  54287. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54288. * @param scene scene in which to add meshes
  54289. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54290. */
  54291. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  54292. /**
  54293. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  54294. * can be transformed by button presses and axes values, based on this._mapping.
  54295. *
  54296. * @param scene scene in which the meshes exist
  54297. * @param meshes list of meshes that make up the controller model to process
  54298. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  54299. */
  54300. private processModel;
  54301. private createMeshInfo;
  54302. /**
  54303. * Gets the ray of the controller in the direction the controller is pointing
  54304. * @param length the length the resulting ray should be
  54305. * @returns a ray in the direction the controller is pointing
  54306. */
  54307. getForwardRay(length?: number): Ray;
  54308. /**
  54309. * Disposes of the controller
  54310. */
  54311. dispose(): void;
  54312. }
  54313. /**
  54314. * This class represents a new windows motion controller in XR.
  54315. */
  54316. export class XRWindowsMotionController extends WindowsMotionController {
  54317. /**
  54318. * Changing the original WIndowsMotionController mapping to fir the new mapping
  54319. */
  54320. protected readonly _mapping: {
  54321. buttons: string[];
  54322. buttonMeshNames: {
  54323. trigger: string;
  54324. menu: string;
  54325. grip: string;
  54326. thumbstick: string;
  54327. trackpad: string;
  54328. };
  54329. buttonObservableNames: {
  54330. trigger: string;
  54331. menu: string;
  54332. grip: string;
  54333. thumbstick: string;
  54334. trackpad: string;
  54335. };
  54336. axisMeshNames: string[];
  54337. pointingPoseMeshName: string;
  54338. };
  54339. /**
  54340. * Construct a new XR-Based windows motion controller
  54341. *
  54342. * @param gamepadInfo the gamepad object from the browser
  54343. */
  54344. constructor(gamepadInfo: any);
  54345. /**
  54346. * holds the thumbstick values (X,Y)
  54347. */
  54348. thumbstickValues: StickValues;
  54349. /**
  54350. * Fired when the thumbstick on this controller is clicked
  54351. */
  54352. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  54353. /**
  54354. * Fired when the thumbstick on this controller is modified
  54355. */
  54356. onThumbstickValuesChangedObservable: Observable<StickValues>;
  54357. /**
  54358. * Fired when the touchpad button on this controller is modified
  54359. */
  54360. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54361. /**
  54362. * Fired when the touchpad values on this controller are modified
  54363. */
  54364. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54365. /**
  54366. * Fired when the thumbstick button on this controller is modified
  54367. * here to prevent breaking changes
  54368. */
  54369. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54370. /**
  54371. * updating the thumbstick(!) and not the trackpad.
  54372. * This is named this way due to the difference between WebVR and XR and to avoid
  54373. * changing the parent class.
  54374. */
  54375. protected _updateTrackpad(): void;
  54376. /**
  54377. * Disposes the class with joy
  54378. */
  54379. dispose(): void;
  54380. }
  54381. }
  54382. declare module "babylonjs/Gamepads/Controllers/index" {
  54383. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  54384. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  54385. export * from "babylonjs/Gamepads/Controllers/genericController";
  54386. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  54387. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54388. export * from "babylonjs/Gamepads/Controllers/viveController";
  54389. export * from "babylonjs/Gamepads/Controllers/webVRController";
  54390. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  54391. }
  54392. declare module "babylonjs/Gamepads/index" {
  54393. export * from "babylonjs/Gamepads/Controllers/index";
  54394. export * from "babylonjs/Gamepads/gamepad";
  54395. export * from "babylonjs/Gamepads/gamepadManager";
  54396. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  54397. export * from "babylonjs/Gamepads/xboxGamepad";
  54398. export * from "babylonjs/Gamepads/dualShockGamepad";
  54399. }
  54400. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  54401. import { Scene } from "babylonjs/scene";
  54402. import { Vector4 } from "babylonjs/Maths/math.vector";
  54403. import { Color4 } from "babylonjs/Maths/math.color";
  54404. import { Mesh } from "babylonjs/Meshes/mesh";
  54405. import { Nullable } from "babylonjs/types";
  54406. /**
  54407. * Class containing static functions to help procedurally build meshes
  54408. */
  54409. export class PolyhedronBuilder {
  54410. /**
  54411. * Creates a polyhedron mesh
  54412. * * 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
  54413. * * The parameter `size` (positive float, default 1) sets the polygon size
  54414. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54415. * * 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`
  54416. * * 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
  54417. * * 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)`)
  54418. * * 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
  54419. * * 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
  54420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54421. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54423. * @param name defines the name of the mesh
  54424. * @param options defines the options used to create the mesh
  54425. * @param scene defines the hosting scene
  54426. * @returns the polyhedron mesh
  54427. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54428. */
  54429. static CreatePolyhedron(name: string, options: {
  54430. type?: number;
  54431. size?: number;
  54432. sizeX?: number;
  54433. sizeY?: number;
  54434. sizeZ?: number;
  54435. custom?: any;
  54436. faceUV?: Vector4[];
  54437. faceColors?: Color4[];
  54438. flat?: boolean;
  54439. updatable?: boolean;
  54440. sideOrientation?: number;
  54441. frontUVs?: Vector4;
  54442. backUVs?: Vector4;
  54443. }, scene?: Nullable<Scene>): Mesh;
  54444. }
  54445. }
  54446. declare module "babylonjs/Gizmos/scaleGizmo" {
  54447. import { Observable } from "babylonjs/Misc/observable";
  54448. import { Nullable } from "babylonjs/types";
  54449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54450. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54451. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  54452. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54453. /**
  54454. * Gizmo that enables scaling a mesh along 3 axis
  54455. */
  54456. export class ScaleGizmo extends Gizmo {
  54457. /**
  54458. * Internal gizmo used for interactions on the x axis
  54459. */
  54460. xGizmo: AxisScaleGizmo;
  54461. /**
  54462. * Internal gizmo used for interactions on the y axis
  54463. */
  54464. yGizmo: AxisScaleGizmo;
  54465. /**
  54466. * Internal gizmo used for interactions on the z axis
  54467. */
  54468. zGizmo: AxisScaleGizmo;
  54469. /**
  54470. * Internal gizmo used to scale all axis equally
  54471. */
  54472. uniformScaleGizmo: AxisScaleGizmo;
  54473. private _meshAttached;
  54474. private _updateGizmoRotationToMatchAttachedMesh;
  54475. private _snapDistance;
  54476. private _scaleRatio;
  54477. private _uniformScalingMesh;
  54478. private _octahedron;
  54479. private _sensitivity;
  54480. /** Fires an event when any of it's sub gizmos are dragged */
  54481. onDragStartObservable: Observable<unknown>;
  54482. /** Fires an event when any of it's sub gizmos are released from dragging */
  54483. onDragEndObservable: Observable<unknown>;
  54484. get attachedMesh(): Nullable<AbstractMesh>;
  54485. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54486. /**
  54487. * Creates a ScaleGizmo
  54488. * @param gizmoLayer The utility layer the gizmo will be added to
  54489. */
  54490. constructor(gizmoLayer?: UtilityLayerRenderer);
  54491. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54492. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54493. /**
  54494. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54495. */
  54496. set snapDistance(value: number);
  54497. get snapDistance(): number;
  54498. /**
  54499. * Ratio for the scale of the gizmo (Default: 1)
  54500. */
  54501. set scaleRatio(value: number);
  54502. get scaleRatio(): number;
  54503. /**
  54504. * Sensitivity factor for dragging (Default: 1)
  54505. */
  54506. set sensitivity(value: number);
  54507. get sensitivity(): number;
  54508. /**
  54509. * Disposes of the gizmo
  54510. */
  54511. dispose(): void;
  54512. }
  54513. }
  54514. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  54515. import { Observable } from "babylonjs/Misc/observable";
  54516. import { Nullable } from "babylonjs/types";
  54517. import { Vector3 } from "babylonjs/Maths/math.vector";
  54518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54519. import { Mesh } from "babylonjs/Meshes/mesh";
  54520. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54521. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54522. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54523. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54524. import { Color3 } from "babylonjs/Maths/math.color";
  54525. /**
  54526. * Single axis scale gizmo
  54527. */
  54528. export class AxisScaleGizmo extends Gizmo {
  54529. /**
  54530. * Drag behavior responsible for the gizmos dragging interactions
  54531. */
  54532. dragBehavior: PointerDragBehavior;
  54533. private _pointerObserver;
  54534. /**
  54535. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54536. */
  54537. snapDistance: number;
  54538. /**
  54539. * Event that fires each time the gizmo snaps to a new location.
  54540. * * snapDistance is the the change in distance
  54541. */
  54542. onSnapObservable: Observable<{
  54543. snapDistance: number;
  54544. }>;
  54545. /**
  54546. * If the scaling operation should be done on all axis (default: false)
  54547. */
  54548. uniformScaling: boolean;
  54549. /**
  54550. * Custom sensitivity value for the drag strength
  54551. */
  54552. sensitivity: number;
  54553. private _isEnabled;
  54554. private _parent;
  54555. private _arrow;
  54556. private _coloredMaterial;
  54557. private _hoverMaterial;
  54558. /**
  54559. * Creates an AxisScaleGizmo
  54560. * @param gizmoLayer The utility layer the gizmo will be added to
  54561. * @param dragAxis The axis which the gizmo will be able to scale on
  54562. * @param color The color of the gizmo
  54563. */
  54564. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  54565. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54566. /**
  54567. * If the gizmo is enabled
  54568. */
  54569. set isEnabled(value: boolean);
  54570. get isEnabled(): boolean;
  54571. /**
  54572. * Disposes of the gizmo
  54573. */
  54574. dispose(): void;
  54575. /**
  54576. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54577. * @param mesh The mesh to replace the default mesh of the gizmo
  54578. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54579. */
  54580. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54581. }
  54582. }
  54583. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  54584. import { Observable } from "babylonjs/Misc/observable";
  54585. import { Nullable } from "babylonjs/types";
  54586. import { Vector3 } from "babylonjs/Maths/math.vector";
  54587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54588. import { Mesh } from "babylonjs/Meshes/mesh";
  54589. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54590. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54591. import { Color3 } from "babylonjs/Maths/math.color";
  54592. import "babylonjs/Meshes/Builders/boxBuilder";
  54593. /**
  54594. * Bounding box gizmo
  54595. */
  54596. export class BoundingBoxGizmo extends Gizmo {
  54597. private _lineBoundingBox;
  54598. private _rotateSpheresParent;
  54599. private _scaleBoxesParent;
  54600. private _boundingDimensions;
  54601. private _renderObserver;
  54602. private _pointerObserver;
  54603. private _scaleDragSpeed;
  54604. private _tmpQuaternion;
  54605. private _tmpVector;
  54606. private _tmpRotationMatrix;
  54607. /**
  54608. * 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)
  54609. */
  54610. ignoreChildren: boolean;
  54611. /**
  54612. * 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)
  54613. */
  54614. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54615. /**
  54616. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54617. */
  54618. rotationSphereSize: number;
  54619. /**
  54620. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54621. */
  54622. scaleBoxSize: number;
  54623. /**
  54624. * 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)
  54625. */
  54626. fixedDragMeshScreenSize: boolean;
  54627. /**
  54628. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54629. */
  54630. fixedDragMeshScreenSizeDistanceFactor: number;
  54631. /**
  54632. * Fired when a rotation sphere or scale box is dragged
  54633. */
  54634. onDragStartObservable: Observable<{}>;
  54635. /**
  54636. * Fired when a scale box is dragged
  54637. */
  54638. onScaleBoxDragObservable: Observable<{}>;
  54639. /**
  54640. * Fired when a scale box drag is ended
  54641. */
  54642. onScaleBoxDragEndObservable: Observable<{}>;
  54643. /**
  54644. * Fired when a rotation sphere is dragged
  54645. */
  54646. onRotationSphereDragObservable: Observable<{}>;
  54647. /**
  54648. * Fired when a rotation sphere drag is ended
  54649. */
  54650. onRotationSphereDragEndObservable: Observable<{}>;
  54651. /**
  54652. * 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)
  54653. */
  54654. scalePivot: Nullable<Vector3>;
  54655. /**
  54656. * Mesh used as a pivot to rotate the attached mesh
  54657. */
  54658. private _anchorMesh;
  54659. private _existingMeshScale;
  54660. private _dragMesh;
  54661. private pointerDragBehavior;
  54662. private coloredMaterial;
  54663. private hoverColoredMaterial;
  54664. /**
  54665. * Sets the color of the bounding box gizmo
  54666. * @param color the color to set
  54667. */
  54668. setColor(color: Color3): void;
  54669. /**
  54670. * Creates an BoundingBoxGizmo
  54671. * @param gizmoLayer The utility layer the gizmo will be added to
  54672. * @param color The color of the gizmo
  54673. */
  54674. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54675. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54676. private _selectNode;
  54677. /**
  54678. * Updates the bounding box information for the Gizmo
  54679. */
  54680. updateBoundingBox(): void;
  54681. private _updateRotationSpheres;
  54682. private _updateScaleBoxes;
  54683. /**
  54684. * Enables rotation on the specified axis and disables rotation on the others
  54685. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54686. */
  54687. setEnabledRotationAxis(axis: string): void;
  54688. /**
  54689. * Enables/disables scaling
  54690. * @param enable if scaling should be enabled
  54691. * @param homogeneousScaling defines if scaling should only be homogeneous
  54692. */
  54693. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54694. private _updateDummy;
  54695. /**
  54696. * Enables a pointer drag behavior on the bounding box of the gizmo
  54697. */
  54698. enableDragBehavior(): void;
  54699. /**
  54700. * Disposes of the gizmo
  54701. */
  54702. dispose(): void;
  54703. /**
  54704. * 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)
  54705. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54706. * @returns the bounding box mesh with the passed in mesh as a child
  54707. */
  54708. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54709. /**
  54710. * CustomMeshes are not supported by this gizmo
  54711. * @param mesh The mesh to replace the default mesh of the gizmo
  54712. */
  54713. setCustomMesh(mesh: Mesh): void;
  54714. }
  54715. }
  54716. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  54717. import { Observable } from "babylonjs/Misc/observable";
  54718. import { Nullable } from "babylonjs/types";
  54719. import { Vector3 } from "babylonjs/Maths/math.vector";
  54720. import { Color3 } from "babylonjs/Maths/math.color";
  54721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54722. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54723. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54724. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54725. import "babylonjs/Meshes/Builders/linesBuilder";
  54726. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54727. /**
  54728. * Single plane rotation gizmo
  54729. */
  54730. export class PlaneRotationGizmo extends Gizmo {
  54731. /**
  54732. * Drag behavior responsible for the gizmos dragging interactions
  54733. */
  54734. dragBehavior: PointerDragBehavior;
  54735. private _pointerObserver;
  54736. /**
  54737. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54738. */
  54739. snapDistance: number;
  54740. /**
  54741. * Event that fires each time the gizmo snaps to a new location.
  54742. * * snapDistance is the the change in distance
  54743. */
  54744. onSnapObservable: Observable<{
  54745. snapDistance: number;
  54746. }>;
  54747. private _isEnabled;
  54748. private _parent;
  54749. /**
  54750. * Creates a PlaneRotationGizmo
  54751. * @param gizmoLayer The utility layer the gizmo will be added to
  54752. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54753. * @param color The color of the gizmo
  54754. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54755. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54756. */
  54757. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  54758. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54759. /**
  54760. * If the gizmo is enabled
  54761. */
  54762. set isEnabled(value: boolean);
  54763. get isEnabled(): boolean;
  54764. /**
  54765. * Disposes of the gizmo
  54766. */
  54767. dispose(): void;
  54768. }
  54769. }
  54770. declare module "babylonjs/Gizmos/rotationGizmo" {
  54771. import { Observable } from "babylonjs/Misc/observable";
  54772. import { Nullable } from "babylonjs/types";
  54773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54774. import { Mesh } from "babylonjs/Meshes/mesh";
  54775. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54776. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  54777. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54778. /**
  54779. * Gizmo that enables rotating a mesh along 3 axis
  54780. */
  54781. export class RotationGizmo extends Gizmo {
  54782. /**
  54783. * Internal gizmo used for interactions on the x axis
  54784. */
  54785. xGizmo: PlaneRotationGizmo;
  54786. /**
  54787. * Internal gizmo used for interactions on the y axis
  54788. */
  54789. yGizmo: PlaneRotationGizmo;
  54790. /**
  54791. * Internal gizmo used for interactions on the z axis
  54792. */
  54793. zGizmo: PlaneRotationGizmo;
  54794. /** Fires an event when any of it's sub gizmos are dragged */
  54795. onDragStartObservable: Observable<unknown>;
  54796. /** Fires an event when any of it's sub gizmos are released from dragging */
  54797. onDragEndObservable: Observable<unknown>;
  54798. private _meshAttached;
  54799. get attachedMesh(): Nullable<AbstractMesh>;
  54800. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54801. /**
  54802. * Creates a RotationGizmo
  54803. * @param gizmoLayer The utility layer the gizmo will be added to
  54804. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54805. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54806. */
  54807. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  54808. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54809. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54810. /**
  54811. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54812. */
  54813. set snapDistance(value: number);
  54814. get snapDistance(): number;
  54815. /**
  54816. * Ratio for the scale of the gizmo (Default: 1)
  54817. */
  54818. set scaleRatio(value: number);
  54819. get scaleRatio(): number;
  54820. /**
  54821. * Disposes of the gizmo
  54822. */
  54823. dispose(): void;
  54824. /**
  54825. * CustomMeshes are not supported by this gizmo
  54826. * @param mesh The mesh to replace the default mesh of the gizmo
  54827. */
  54828. setCustomMesh(mesh: Mesh): void;
  54829. }
  54830. }
  54831. declare module "babylonjs/Gizmos/gizmoManager" {
  54832. import { Observable } from "babylonjs/Misc/observable";
  54833. import { Nullable } from "babylonjs/types";
  54834. import { Scene, IDisposable } from "babylonjs/scene";
  54835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54836. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54837. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  54838. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54839. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  54840. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54841. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  54842. /**
  54843. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  54844. */
  54845. export class GizmoManager implements IDisposable {
  54846. private scene;
  54847. /**
  54848. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54849. */
  54850. gizmos: {
  54851. positionGizmo: Nullable<PositionGizmo>;
  54852. rotationGizmo: Nullable<RotationGizmo>;
  54853. scaleGizmo: Nullable<ScaleGizmo>;
  54854. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54855. };
  54856. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54857. clearGizmoOnEmptyPointerEvent: boolean;
  54858. /** Fires an event when the manager is attached to a mesh */
  54859. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54860. private _gizmosEnabled;
  54861. private _pointerObserver;
  54862. private _attachedMesh;
  54863. private _boundingBoxColor;
  54864. private _defaultUtilityLayer;
  54865. private _defaultKeepDepthUtilityLayer;
  54866. /**
  54867. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54868. */
  54869. boundingBoxDragBehavior: SixDofDragBehavior;
  54870. /**
  54871. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54872. */
  54873. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54874. /**
  54875. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  54876. */
  54877. usePointerToAttachGizmos: boolean;
  54878. /**
  54879. * Utility layer that the bounding box gizmo belongs to
  54880. */
  54881. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54882. /**
  54883. * Utility layer that all gizmos besides bounding box belong to
  54884. */
  54885. get utilityLayer(): UtilityLayerRenderer;
  54886. /**
  54887. * Instatiates a gizmo manager
  54888. * @param scene the scene to overlay the gizmos on top of
  54889. */
  54890. constructor(scene: Scene);
  54891. /**
  54892. * Attaches a set of gizmos to the specified mesh
  54893. * @param mesh The mesh the gizmo's should be attached to
  54894. */
  54895. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54896. /**
  54897. * If the position gizmo is enabled
  54898. */
  54899. set positionGizmoEnabled(value: boolean);
  54900. get positionGizmoEnabled(): boolean;
  54901. /**
  54902. * If the rotation gizmo is enabled
  54903. */
  54904. set rotationGizmoEnabled(value: boolean);
  54905. get rotationGizmoEnabled(): boolean;
  54906. /**
  54907. * If the scale gizmo is enabled
  54908. */
  54909. set scaleGizmoEnabled(value: boolean);
  54910. get scaleGizmoEnabled(): boolean;
  54911. /**
  54912. * If the boundingBox gizmo is enabled
  54913. */
  54914. set boundingBoxGizmoEnabled(value: boolean);
  54915. get boundingBoxGizmoEnabled(): boolean;
  54916. /**
  54917. * Disposes of the gizmo manager
  54918. */
  54919. dispose(): void;
  54920. }
  54921. }
  54922. declare module "babylonjs/Lights/directionalLight" {
  54923. import { Camera } from "babylonjs/Cameras/camera";
  54924. import { Scene } from "babylonjs/scene";
  54925. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54927. import { Light } from "babylonjs/Lights/light";
  54928. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54929. import { Effect } from "babylonjs/Materials/effect";
  54930. /**
  54931. * A directional light is defined by a direction (what a surprise!).
  54932. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  54933. * 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.
  54934. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54935. */
  54936. export class DirectionalLight extends ShadowLight {
  54937. private _shadowFrustumSize;
  54938. /**
  54939. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  54940. */
  54941. get shadowFrustumSize(): number;
  54942. /**
  54943. * Specifies a fix frustum size for the shadow generation.
  54944. */
  54945. set shadowFrustumSize(value: number);
  54946. private _shadowOrthoScale;
  54947. /**
  54948. * Gets the shadow projection scale against the optimal computed one.
  54949. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54950. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54951. */
  54952. get shadowOrthoScale(): number;
  54953. /**
  54954. * Sets the shadow projection scale against the optimal computed one.
  54955. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54956. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54957. */
  54958. set shadowOrthoScale(value: number);
  54959. /**
  54960. * Automatically compute the projection matrix to best fit (including all the casters)
  54961. * on each frame.
  54962. */
  54963. autoUpdateExtends: boolean;
  54964. /**
  54965. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  54966. * on each frame. autoUpdateExtends must be set to true for this to work
  54967. */
  54968. autoCalcShadowZBounds: boolean;
  54969. private _orthoLeft;
  54970. private _orthoRight;
  54971. private _orthoTop;
  54972. private _orthoBottom;
  54973. /**
  54974. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  54975. * The directional light is emitted from everywhere in the given direction.
  54976. * It can cast shadows.
  54977. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54978. * @param name The friendly name of the light
  54979. * @param direction The direction of the light
  54980. * @param scene The scene the light belongs to
  54981. */
  54982. constructor(name: string, direction: Vector3, scene: Scene);
  54983. /**
  54984. * Returns the string "DirectionalLight".
  54985. * @return The class name
  54986. */
  54987. getClassName(): string;
  54988. /**
  54989. * Returns the integer 1.
  54990. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54991. */
  54992. getTypeID(): number;
  54993. /**
  54994. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  54995. * Returns the DirectionalLight Shadow projection matrix.
  54996. */
  54997. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54998. /**
  54999. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  55000. * Returns the DirectionalLight Shadow projection matrix.
  55001. */
  55002. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  55003. /**
  55004. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  55005. * Returns the DirectionalLight Shadow projection matrix.
  55006. */
  55007. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55008. protected _buildUniformLayout(): void;
  55009. /**
  55010. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  55011. * @param effect The effect to update
  55012. * @param lightIndex The index of the light in the effect to update
  55013. * @returns The directional light
  55014. */
  55015. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  55016. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  55017. /**
  55018. * Gets the minZ used for shadow according to both the scene and the light.
  55019. *
  55020. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55021. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55022. * @param activeCamera The camera we are returning the min for
  55023. * @returns the depth min z
  55024. */
  55025. getDepthMinZ(activeCamera: Camera): number;
  55026. /**
  55027. * Gets the maxZ used for shadow according to both the scene and the light.
  55028. *
  55029. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55030. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55031. * @param activeCamera The camera we are returning the max for
  55032. * @returns the depth max z
  55033. */
  55034. getDepthMaxZ(activeCamera: Camera): number;
  55035. /**
  55036. * Prepares the list of defines specific to the light type.
  55037. * @param defines the list of defines
  55038. * @param lightIndex defines the index of the light for the effect
  55039. */
  55040. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55041. }
  55042. }
  55043. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  55044. import { Mesh } from "babylonjs/Meshes/mesh";
  55045. /**
  55046. * Class containing static functions to help procedurally build meshes
  55047. */
  55048. export class HemisphereBuilder {
  55049. /**
  55050. * Creates a hemisphere mesh
  55051. * @param name defines the name of the mesh
  55052. * @param options defines the options used to create the mesh
  55053. * @param scene defines the hosting scene
  55054. * @returns the hemisphere mesh
  55055. */
  55056. static CreateHemisphere(name: string, options: {
  55057. segments?: number;
  55058. diameter?: number;
  55059. sideOrientation?: number;
  55060. }, scene: any): Mesh;
  55061. }
  55062. }
  55063. declare module "babylonjs/Lights/spotLight" {
  55064. import { Nullable } from "babylonjs/types";
  55065. import { Scene } from "babylonjs/scene";
  55066. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55067. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55068. import { Effect } from "babylonjs/Materials/effect";
  55069. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55070. import { Light } from "babylonjs/Lights/light";
  55071. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55072. /**
  55073. * A spot light is defined by a position, a direction, an angle, and an exponent.
  55074. * These values define a cone of light starting from the position, emitting toward the direction.
  55075. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  55076. * and the exponent defines the speed of the decay of the light with distance (reach).
  55077. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55078. */
  55079. export class SpotLight extends ShadowLight {
  55080. private _angle;
  55081. private _innerAngle;
  55082. private _cosHalfAngle;
  55083. private _lightAngleScale;
  55084. private _lightAngleOffset;
  55085. /**
  55086. * Gets the cone angle of the spot light in Radians.
  55087. */
  55088. get angle(): number;
  55089. /**
  55090. * Sets the cone angle of the spot light in Radians.
  55091. */
  55092. set angle(value: number);
  55093. /**
  55094. * Only used in gltf falloff mode, this defines the angle where
  55095. * the directional falloff will start before cutting at angle which could be seen
  55096. * as outer angle.
  55097. */
  55098. get innerAngle(): number;
  55099. /**
  55100. * Only used in gltf falloff mode, this defines the angle where
  55101. * the directional falloff will start before cutting at angle which could be seen
  55102. * as outer angle.
  55103. */
  55104. set innerAngle(value: number);
  55105. private _shadowAngleScale;
  55106. /**
  55107. * Allows scaling the angle of the light for shadow generation only.
  55108. */
  55109. get shadowAngleScale(): number;
  55110. /**
  55111. * Allows scaling the angle of the light for shadow generation only.
  55112. */
  55113. set shadowAngleScale(value: number);
  55114. /**
  55115. * The light decay speed with the distance from the emission spot.
  55116. */
  55117. exponent: number;
  55118. private _projectionTextureMatrix;
  55119. /**
  55120. * Allows reading the projecton texture
  55121. */
  55122. get projectionTextureMatrix(): Matrix;
  55123. protected _projectionTextureLightNear: number;
  55124. /**
  55125. * Gets the near clip of the Spotlight for texture projection.
  55126. */
  55127. get projectionTextureLightNear(): number;
  55128. /**
  55129. * Sets the near clip of the Spotlight for texture projection.
  55130. */
  55131. set projectionTextureLightNear(value: number);
  55132. protected _projectionTextureLightFar: number;
  55133. /**
  55134. * Gets the far clip of the Spotlight for texture projection.
  55135. */
  55136. get projectionTextureLightFar(): number;
  55137. /**
  55138. * Sets the far clip of the Spotlight for texture projection.
  55139. */
  55140. set projectionTextureLightFar(value: number);
  55141. protected _projectionTextureUpDirection: Vector3;
  55142. /**
  55143. * Gets the Up vector of the Spotlight for texture projection.
  55144. */
  55145. get projectionTextureUpDirection(): Vector3;
  55146. /**
  55147. * Sets the Up vector of the Spotlight for texture projection.
  55148. */
  55149. set projectionTextureUpDirection(value: Vector3);
  55150. private _projectionTexture;
  55151. /**
  55152. * Gets the projection texture of the light.
  55153. */
  55154. get projectionTexture(): Nullable<BaseTexture>;
  55155. /**
  55156. * Sets the projection texture of the light.
  55157. */
  55158. set projectionTexture(value: Nullable<BaseTexture>);
  55159. private _projectionTextureViewLightDirty;
  55160. private _projectionTextureProjectionLightDirty;
  55161. private _projectionTextureDirty;
  55162. private _projectionTextureViewTargetVector;
  55163. private _projectionTextureViewLightMatrix;
  55164. private _projectionTextureProjectionLightMatrix;
  55165. private _projectionTextureScalingMatrix;
  55166. /**
  55167. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  55168. * It can cast shadows.
  55169. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55170. * @param name The light friendly name
  55171. * @param position The position of the spot light in the scene
  55172. * @param direction The direction of the light in the scene
  55173. * @param angle The cone angle of the light in Radians
  55174. * @param exponent The light decay speed with the distance from the emission spot
  55175. * @param scene The scene the lights belongs to
  55176. */
  55177. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  55178. /**
  55179. * Returns the string "SpotLight".
  55180. * @returns the class name
  55181. */
  55182. getClassName(): string;
  55183. /**
  55184. * Returns the integer 2.
  55185. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55186. */
  55187. getTypeID(): number;
  55188. /**
  55189. * Overrides the direction setter to recompute the projection texture view light Matrix.
  55190. */
  55191. protected _setDirection(value: Vector3): void;
  55192. /**
  55193. * Overrides the position setter to recompute the projection texture view light Matrix.
  55194. */
  55195. protected _setPosition(value: Vector3): void;
  55196. /**
  55197. * 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.
  55198. * Returns the SpotLight.
  55199. */
  55200. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55201. protected _computeProjectionTextureViewLightMatrix(): void;
  55202. protected _computeProjectionTextureProjectionLightMatrix(): void;
  55203. /**
  55204. * Main function for light texture projection matrix computing.
  55205. */
  55206. protected _computeProjectionTextureMatrix(): void;
  55207. protected _buildUniformLayout(): void;
  55208. private _computeAngleValues;
  55209. /**
  55210. * Sets the passed Effect "effect" with the Light textures.
  55211. * @param effect The effect to update
  55212. * @param lightIndex The index of the light in the effect to update
  55213. * @returns The light
  55214. */
  55215. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  55216. /**
  55217. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  55218. * @param effect The effect to update
  55219. * @param lightIndex The index of the light in the effect to update
  55220. * @returns The spot light
  55221. */
  55222. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  55223. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55224. /**
  55225. * Disposes the light and the associated resources.
  55226. */
  55227. dispose(): void;
  55228. /**
  55229. * Prepares the list of defines specific to the light type.
  55230. * @param defines the list of defines
  55231. * @param lightIndex defines the index of the light for the effect
  55232. */
  55233. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55234. }
  55235. }
  55236. declare module "babylonjs/Gizmos/lightGizmo" {
  55237. import { Nullable } from "babylonjs/types";
  55238. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55239. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55240. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55241. import { Light } from "babylonjs/Lights/light";
  55242. /**
  55243. * Gizmo that enables viewing a light
  55244. */
  55245. export class LightGizmo extends Gizmo {
  55246. private _lightMesh;
  55247. private _material;
  55248. private _cachedPosition;
  55249. private _cachedForward;
  55250. private _attachedMeshParent;
  55251. /**
  55252. * Creates a LightGizmo
  55253. * @param gizmoLayer The utility layer the gizmo will be added to
  55254. */
  55255. constructor(gizmoLayer?: UtilityLayerRenderer);
  55256. private _light;
  55257. /**
  55258. * The light that the gizmo is attached to
  55259. */
  55260. set light(light: Nullable<Light>);
  55261. get light(): Nullable<Light>;
  55262. /**
  55263. * Gets the material used to render the light gizmo
  55264. */
  55265. get material(): StandardMaterial;
  55266. /**
  55267. * @hidden
  55268. * Updates the gizmo to match the attached mesh's position/rotation
  55269. */
  55270. protected _update(): void;
  55271. private static _Scale;
  55272. /**
  55273. * Creates the lines for a light mesh
  55274. */
  55275. private static _CreateLightLines;
  55276. /**
  55277. * Disposes of the light gizmo
  55278. */
  55279. dispose(): void;
  55280. private static _CreateHemisphericLightMesh;
  55281. private static _CreatePointLightMesh;
  55282. private static _CreateSpotLightMesh;
  55283. private static _CreateDirectionalLightMesh;
  55284. }
  55285. }
  55286. declare module "babylonjs/Gizmos/index" {
  55287. export * from "babylonjs/Gizmos/axisDragGizmo";
  55288. export * from "babylonjs/Gizmos/axisScaleGizmo";
  55289. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  55290. export * from "babylonjs/Gizmos/gizmo";
  55291. export * from "babylonjs/Gizmos/gizmoManager";
  55292. export * from "babylonjs/Gizmos/planeRotationGizmo";
  55293. export * from "babylonjs/Gizmos/positionGizmo";
  55294. export * from "babylonjs/Gizmos/rotationGizmo";
  55295. export * from "babylonjs/Gizmos/scaleGizmo";
  55296. export * from "babylonjs/Gizmos/lightGizmo";
  55297. export * from "babylonjs/Gizmos/planeDragGizmo";
  55298. }
  55299. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  55300. /** @hidden */
  55301. export var backgroundFragmentDeclaration: {
  55302. name: string;
  55303. shader: string;
  55304. };
  55305. }
  55306. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  55307. /** @hidden */
  55308. export var backgroundUboDeclaration: {
  55309. name: string;
  55310. shader: string;
  55311. };
  55312. }
  55313. declare module "babylonjs/Shaders/background.fragment" {
  55314. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  55315. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55316. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55317. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  55318. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55319. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55320. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55321. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  55322. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  55323. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  55324. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  55325. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  55326. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  55327. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  55328. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  55329. /** @hidden */
  55330. export var backgroundPixelShader: {
  55331. name: string;
  55332. shader: string;
  55333. };
  55334. }
  55335. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  55336. /** @hidden */
  55337. export var backgroundVertexDeclaration: {
  55338. name: string;
  55339. shader: string;
  55340. };
  55341. }
  55342. declare module "babylonjs/Shaders/background.vertex" {
  55343. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  55344. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55345. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55346. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55347. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55348. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  55349. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  55350. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55351. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55352. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55353. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55354. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  55355. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  55356. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  55357. /** @hidden */
  55358. export var backgroundVertexShader: {
  55359. name: string;
  55360. shader: string;
  55361. };
  55362. }
  55363. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  55364. import { Nullable, int, float } from "babylonjs/types";
  55365. import { Scene } from "babylonjs/scene";
  55366. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55367. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55369. import { Mesh } from "babylonjs/Meshes/mesh";
  55370. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55371. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  55372. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  55373. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55374. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  55375. import { Color3 } from "babylonjs/Maths/math.color";
  55376. import "babylonjs/Shaders/background.fragment";
  55377. import "babylonjs/Shaders/background.vertex";
  55378. /**
  55379. * Background material used to create an efficient environement around your scene.
  55380. */
  55381. export class BackgroundMaterial extends PushMaterial {
  55382. /**
  55383. * Standard reflectance value at parallel view angle.
  55384. */
  55385. static StandardReflectance0: number;
  55386. /**
  55387. * Standard reflectance value at grazing angle.
  55388. */
  55389. static StandardReflectance90: number;
  55390. protected _primaryColor: Color3;
  55391. /**
  55392. * Key light Color (multiply against the environement texture)
  55393. */
  55394. primaryColor: Color3;
  55395. protected __perceptualColor: Nullable<Color3>;
  55396. /**
  55397. * Experimental Internal Use Only.
  55398. *
  55399. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  55400. * This acts as a helper to set the primary color to a more "human friendly" value.
  55401. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  55402. * output color as close as possible from the chosen value.
  55403. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  55404. * part of lighting setup.)
  55405. */
  55406. get _perceptualColor(): Nullable<Color3>;
  55407. set _perceptualColor(value: Nullable<Color3>);
  55408. protected _primaryColorShadowLevel: float;
  55409. /**
  55410. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  55411. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  55412. */
  55413. get primaryColorShadowLevel(): float;
  55414. set primaryColorShadowLevel(value: float);
  55415. protected _primaryColorHighlightLevel: float;
  55416. /**
  55417. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  55418. * The primary color is used at the level chosen to define what the white area would look.
  55419. */
  55420. get primaryColorHighlightLevel(): float;
  55421. set primaryColorHighlightLevel(value: float);
  55422. protected _reflectionTexture: Nullable<BaseTexture>;
  55423. /**
  55424. * Reflection Texture used in the material.
  55425. * Should be author in a specific way for the best result (refer to the documentation).
  55426. */
  55427. reflectionTexture: Nullable<BaseTexture>;
  55428. protected _reflectionBlur: float;
  55429. /**
  55430. * Reflection Texture level of blur.
  55431. *
  55432. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  55433. * texture twice.
  55434. */
  55435. reflectionBlur: float;
  55436. protected _diffuseTexture: Nullable<BaseTexture>;
  55437. /**
  55438. * Diffuse Texture used in the material.
  55439. * Should be author in a specific way for the best result (refer to the documentation).
  55440. */
  55441. diffuseTexture: Nullable<BaseTexture>;
  55442. protected _shadowLights: Nullable<IShadowLight[]>;
  55443. /**
  55444. * Specify the list of lights casting shadow on the material.
  55445. * All scene shadow lights will be included if null.
  55446. */
  55447. shadowLights: Nullable<IShadowLight[]>;
  55448. protected _shadowLevel: float;
  55449. /**
  55450. * Helps adjusting the shadow to a softer level if required.
  55451. * 0 means black shadows and 1 means no shadows.
  55452. */
  55453. shadowLevel: float;
  55454. protected _sceneCenter: Vector3;
  55455. /**
  55456. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  55457. * It is usually zero but might be interesting to modify according to your setup.
  55458. */
  55459. sceneCenter: Vector3;
  55460. protected _opacityFresnel: boolean;
  55461. /**
  55462. * This helps specifying that the material is falling off to the sky box at grazing angle.
  55463. * This helps ensuring a nice transition when the camera goes under the ground.
  55464. */
  55465. opacityFresnel: boolean;
  55466. protected _reflectionFresnel: boolean;
  55467. /**
  55468. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  55469. * This helps adding a mirror texture on the ground.
  55470. */
  55471. reflectionFresnel: boolean;
  55472. protected _reflectionFalloffDistance: number;
  55473. /**
  55474. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  55475. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  55476. */
  55477. reflectionFalloffDistance: number;
  55478. protected _reflectionAmount: number;
  55479. /**
  55480. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  55481. */
  55482. reflectionAmount: number;
  55483. protected _reflectionReflectance0: number;
  55484. /**
  55485. * This specifies the weight of the reflection at grazing angle.
  55486. */
  55487. reflectionReflectance0: number;
  55488. protected _reflectionReflectance90: number;
  55489. /**
  55490. * This specifies the weight of the reflection at a perpendicular point of view.
  55491. */
  55492. reflectionReflectance90: number;
  55493. /**
  55494. * Sets the reflection reflectance fresnel values according to the default standard
  55495. * empirically know to work well :-)
  55496. */
  55497. set reflectionStandardFresnelWeight(value: number);
  55498. protected _useRGBColor: boolean;
  55499. /**
  55500. * Helps to directly use the maps channels instead of their level.
  55501. */
  55502. useRGBColor: boolean;
  55503. protected _enableNoise: boolean;
  55504. /**
  55505. * This helps reducing the banding effect that could occur on the background.
  55506. */
  55507. enableNoise: boolean;
  55508. /**
  55509. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55510. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  55511. * Recommended to be keep at 1.0 except for special cases.
  55512. */
  55513. get fovMultiplier(): number;
  55514. set fovMultiplier(value: number);
  55515. private _fovMultiplier;
  55516. /**
  55517. * Enable the FOV adjustment feature controlled by fovMultiplier.
  55518. */
  55519. useEquirectangularFOV: boolean;
  55520. private _maxSimultaneousLights;
  55521. /**
  55522. * Number of Simultaneous lights allowed on the material.
  55523. */
  55524. maxSimultaneousLights: int;
  55525. /**
  55526. * Default configuration related to image processing available in the Background Material.
  55527. */
  55528. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55529. /**
  55530. * Keep track of the image processing observer to allow dispose and replace.
  55531. */
  55532. private _imageProcessingObserver;
  55533. /**
  55534. * Attaches a new image processing configuration to the PBR Material.
  55535. * @param configuration (if null the scene configuration will be use)
  55536. */
  55537. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55538. /**
  55539. * Gets the image processing configuration used either in this material.
  55540. */
  55541. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  55542. /**
  55543. * Sets the Default image processing configuration used either in the this material.
  55544. *
  55545. * If sets to null, the scene one is in use.
  55546. */
  55547. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  55548. /**
  55549. * Gets wether the color curves effect is enabled.
  55550. */
  55551. get cameraColorCurvesEnabled(): boolean;
  55552. /**
  55553. * Sets wether the color curves effect is enabled.
  55554. */
  55555. set cameraColorCurvesEnabled(value: boolean);
  55556. /**
  55557. * Gets wether the color grading effect is enabled.
  55558. */
  55559. get cameraColorGradingEnabled(): boolean;
  55560. /**
  55561. * Gets wether the color grading effect is enabled.
  55562. */
  55563. set cameraColorGradingEnabled(value: boolean);
  55564. /**
  55565. * Gets wether tonemapping is enabled or not.
  55566. */
  55567. get cameraToneMappingEnabled(): boolean;
  55568. /**
  55569. * Sets wether tonemapping is enabled or not
  55570. */
  55571. set cameraToneMappingEnabled(value: boolean);
  55572. /**
  55573. * The camera exposure used on this material.
  55574. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55575. * This corresponds to a photographic exposure.
  55576. */
  55577. get cameraExposure(): float;
  55578. /**
  55579. * The camera exposure used on this material.
  55580. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55581. * This corresponds to a photographic exposure.
  55582. */
  55583. set cameraExposure(value: float);
  55584. /**
  55585. * Gets The camera contrast used on this material.
  55586. */
  55587. get cameraContrast(): float;
  55588. /**
  55589. * Sets The camera contrast used on this material.
  55590. */
  55591. set cameraContrast(value: float);
  55592. /**
  55593. * Gets the Color Grading 2D Lookup Texture.
  55594. */
  55595. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55596. /**
  55597. * Sets the Color Grading 2D Lookup Texture.
  55598. */
  55599. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55600. /**
  55601. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55602. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55603. * 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;
  55604. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55605. */
  55606. get cameraColorCurves(): Nullable<ColorCurves>;
  55607. /**
  55608. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55609. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55610. * 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;
  55611. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55612. */
  55613. set cameraColorCurves(value: Nullable<ColorCurves>);
  55614. /**
  55615. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  55616. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  55617. */
  55618. switchToBGR: boolean;
  55619. private _renderTargets;
  55620. private _reflectionControls;
  55621. private _white;
  55622. private _primaryShadowColor;
  55623. private _primaryHighlightColor;
  55624. /**
  55625. * Instantiates a Background Material in the given scene
  55626. * @param name The friendly name of the material
  55627. * @param scene The scene to add the material to
  55628. */
  55629. constructor(name: string, scene: Scene);
  55630. /**
  55631. * Gets a boolean indicating that current material needs to register RTT
  55632. */
  55633. get hasRenderTargetTextures(): boolean;
  55634. /**
  55635. * The entire material has been created in order to prevent overdraw.
  55636. * @returns false
  55637. */
  55638. needAlphaTesting(): boolean;
  55639. /**
  55640. * The entire material has been created in order to prevent overdraw.
  55641. * @returns true if blending is enable
  55642. */
  55643. needAlphaBlending(): boolean;
  55644. /**
  55645. * Checks wether the material is ready to be rendered for a given mesh.
  55646. * @param mesh The mesh to render
  55647. * @param subMesh The submesh to check against
  55648. * @param useInstances Specify wether or not the material is used with instances
  55649. * @returns true if all the dependencies are ready (Textures, Effects...)
  55650. */
  55651. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55652. /**
  55653. * Compute the primary color according to the chosen perceptual color.
  55654. */
  55655. private _computePrimaryColorFromPerceptualColor;
  55656. /**
  55657. * Compute the highlights and shadow colors according to their chosen levels.
  55658. */
  55659. private _computePrimaryColors;
  55660. /**
  55661. * Build the uniform buffer used in the material.
  55662. */
  55663. buildUniformLayout(): void;
  55664. /**
  55665. * Unbind the material.
  55666. */
  55667. unbind(): void;
  55668. /**
  55669. * Bind only the world matrix to the material.
  55670. * @param world The world matrix to bind.
  55671. */
  55672. bindOnlyWorldMatrix(world: Matrix): void;
  55673. /**
  55674. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  55675. * @param world The world matrix to bind.
  55676. * @param subMesh The submesh to bind for.
  55677. */
  55678. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55679. /**
  55680. * Checks to see if a texture is used in the material.
  55681. * @param texture - Base texture to use.
  55682. * @returns - Boolean specifying if a texture is used in the material.
  55683. */
  55684. hasTexture(texture: BaseTexture): boolean;
  55685. /**
  55686. * Dispose the material.
  55687. * @param forceDisposeEffect Force disposal of the associated effect.
  55688. * @param forceDisposeTextures Force disposal of the associated textures.
  55689. */
  55690. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55691. /**
  55692. * Clones the material.
  55693. * @param name The cloned name.
  55694. * @returns The cloned material.
  55695. */
  55696. clone(name: string): BackgroundMaterial;
  55697. /**
  55698. * Serializes the current material to its JSON representation.
  55699. * @returns The JSON representation.
  55700. */
  55701. serialize(): any;
  55702. /**
  55703. * Gets the class name of the material
  55704. * @returns "BackgroundMaterial"
  55705. */
  55706. getClassName(): string;
  55707. /**
  55708. * Parse a JSON input to create back a background material.
  55709. * @param source The JSON data to parse
  55710. * @param scene The scene to create the parsed material in
  55711. * @param rootUrl The root url of the assets the material depends upon
  55712. * @returns the instantiated BackgroundMaterial.
  55713. */
  55714. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  55715. }
  55716. }
  55717. declare module "babylonjs/Helpers/environmentHelper" {
  55718. import { Observable } from "babylonjs/Misc/observable";
  55719. import { Nullable } from "babylonjs/types";
  55720. import { Scene } from "babylonjs/scene";
  55721. import { Vector3 } from "babylonjs/Maths/math.vector";
  55722. import { Color3 } from "babylonjs/Maths/math.color";
  55723. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55724. import { Mesh } from "babylonjs/Meshes/mesh";
  55725. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55726. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  55727. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55728. import "babylonjs/Meshes/Builders/planeBuilder";
  55729. import "babylonjs/Meshes/Builders/boxBuilder";
  55730. /**
  55731. * Represents the different options available during the creation of
  55732. * a Environment helper.
  55733. *
  55734. * This can control the default ground, skybox and image processing setup of your scene.
  55735. */
  55736. export interface IEnvironmentHelperOptions {
  55737. /**
  55738. * Specifies whether or not to create a ground.
  55739. * True by default.
  55740. */
  55741. createGround: boolean;
  55742. /**
  55743. * Specifies the ground size.
  55744. * 15 by default.
  55745. */
  55746. groundSize: number;
  55747. /**
  55748. * The texture used on the ground for the main color.
  55749. * Comes from the BabylonJS CDN by default.
  55750. *
  55751. * Remarks: Can be either a texture or a url.
  55752. */
  55753. groundTexture: string | BaseTexture;
  55754. /**
  55755. * The color mixed in the ground texture by default.
  55756. * BabylonJS clearColor by default.
  55757. */
  55758. groundColor: Color3;
  55759. /**
  55760. * Specifies the ground opacity.
  55761. * 1 by default.
  55762. */
  55763. groundOpacity: number;
  55764. /**
  55765. * Enables the ground to receive shadows.
  55766. * True by default.
  55767. */
  55768. enableGroundShadow: boolean;
  55769. /**
  55770. * Helps preventing the shadow to be fully black on the ground.
  55771. * 0.5 by default.
  55772. */
  55773. groundShadowLevel: number;
  55774. /**
  55775. * Creates a mirror texture attach to the ground.
  55776. * false by default.
  55777. */
  55778. enableGroundMirror: boolean;
  55779. /**
  55780. * Specifies the ground mirror size ratio.
  55781. * 0.3 by default as the default kernel is 64.
  55782. */
  55783. groundMirrorSizeRatio: number;
  55784. /**
  55785. * Specifies the ground mirror blur kernel size.
  55786. * 64 by default.
  55787. */
  55788. groundMirrorBlurKernel: number;
  55789. /**
  55790. * Specifies the ground mirror visibility amount.
  55791. * 1 by default
  55792. */
  55793. groundMirrorAmount: number;
  55794. /**
  55795. * Specifies the ground mirror reflectance weight.
  55796. * This uses the standard weight of the background material to setup the fresnel effect
  55797. * of the mirror.
  55798. * 1 by default.
  55799. */
  55800. groundMirrorFresnelWeight: number;
  55801. /**
  55802. * Specifies the ground mirror Falloff distance.
  55803. * This can helps reducing the size of the reflection.
  55804. * 0 by Default.
  55805. */
  55806. groundMirrorFallOffDistance: number;
  55807. /**
  55808. * Specifies the ground mirror texture type.
  55809. * Unsigned Int by Default.
  55810. */
  55811. groundMirrorTextureType: number;
  55812. /**
  55813. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  55814. * the shown objects.
  55815. */
  55816. groundYBias: number;
  55817. /**
  55818. * Specifies whether or not to create a skybox.
  55819. * True by default.
  55820. */
  55821. createSkybox: boolean;
  55822. /**
  55823. * Specifies the skybox size.
  55824. * 20 by default.
  55825. */
  55826. skyboxSize: number;
  55827. /**
  55828. * The texture used on the skybox for the main color.
  55829. * Comes from the BabylonJS CDN by default.
  55830. *
  55831. * Remarks: Can be either a texture or a url.
  55832. */
  55833. skyboxTexture: string | BaseTexture;
  55834. /**
  55835. * The color mixed in the skybox texture by default.
  55836. * BabylonJS clearColor by default.
  55837. */
  55838. skyboxColor: Color3;
  55839. /**
  55840. * The background rotation around the Y axis of the scene.
  55841. * This helps aligning the key lights of your scene with the background.
  55842. * 0 by default.
  55843. */
  55844. backgroundYRotation: number;
  55845. /**
  55846. * Compute automatically the size of the elements to best fit with the scene.
  55847. */
  55848. sizeAuto: boolean;
  55849. /**
  55850. * Default position of the rootMesh if autoSize is not true.
  55851. */
  55852. rootPosition: Vector3;
  55853. /**
  55854. * Sets up the image processing in the scene.
  55855. * true by default.
  55856. */
  55857. setupImageProcessing: boolean;
  55858. /**
  55859. * The texture used as your environment texture in the scene.
  55860. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  55861. *
  55862. * Remarks: Can be either a texture or a url.
  55863. */
  55864. environmentTexture: string | BaseTexture;
  55865. /**
  55866. * The value of the exposure to apply to the scene.
  55867. * 0.6 by default if setupImageProcessing is true.
  55868. */
  55869. cameraExposure: number;
  55870. /**
  55871. * The value of the contrast to apply to the scene.
  55872. * 1.6 by default if setupImageProcessing is true.
  55873. */
  55874. cameraContrast: number;
  55875. /**
  55876. * Specifies whether or not tonemapping should be enabled in the scene.
  55877. * true by default if setupImageProcessing is true.
  55878. */
  55879. toneMappingEnabled: boolean;
  55880. }
  55881. /**
  55882. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  55883. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  55884. * It also helps with the default setup of your imageProcessing configuration.
  55885. */
  55886. export class EnvironmentHelper {
  55887. /**
  55888. * Default ground texture URL.
  55889. */
  55890. private static _groundTextureCDNUrl;
  55891. /**
  55892. * Default skybox texture URL.
  55893. */
  55894. private static _skyboxTextureCDNUrl;
  55895. /**
  55896. * Default environment texture URL.
  55897. */
  55898. private static _environmentTextureCDNUrl;
  55899. /**
  55900. * Creates the default options for the helper.
  55901. */
  55902. private static _getDefaultOptions;
  55903. private _rootMesh;
  55904. /**
  55905. * Gets the root mesh created by the helper.
  55906. */
  55907. get rootMesh(): Mesh;
  55908. private _skybox;
  55909. /**
  55910. * Gets the skybox created by the helper.
  55911. */
  55912. get skybox(): Nullable<Mesh>;
  55913. private _skyboxTexture;
  55914. /**
  55915. * Gets the skybox texture created by the helper.
  55916. */
  55917. get skyboxTexture(): Nullable<BaseTexture>;
  55918. private _skyboxMaterial;
  55919. /**
  55920. * Gets the skybox material created by the helper.
  55921. */
  55922. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  55923. private _ground;
  55924. /**
  55925. * Gets the ground mesh created by the helper.
  55926. */
  55927. get ground(): Nullable<Mesh>;
  55928. private _groundTexture;
  55929. /**
  55930. * Gets the ground texture created by the helper.
  55931. */
  55932. get groundTexture(): Nullable<BaseTexture>;
  55933. private _groundMirror;
  55934. /**
  55935. * Gets the ground mirror created by the helper.
  55936. */
  55937. get groundMirror(): Nullable<MirrorTexture>;
  55938. /**
  55939. * Gets the ground mirror render list to helps pushing the meshes
  55940. * you wish in the ground reflection.
  55941. */
  55942. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  55943. private _groundMaterial;
  55944. /**
  55945. * Gets the ground material created by the helper.
  55946. */
  55947. get groundMaterial(): Nullable<BackgroundMaterial>;
  55948. /**
  55949. * Stores the creation options.
  55950. */
  55951. private readonly _scene;
  55952. private _options;
  55953. /**
  55954. * This observable will be notified with any error during the creation of the environment,
  55955. * mainly texture creation errors.
  55956. */
  55957. onErrorObservable: Observable<{
  55958. message?: string;
  55959. exception?: any;
  55960. }>;
  55961. /**
  55962. * constructor
  55963. * @param options Defines the options we want to customize the helper
  55964. * @param scene The scene to add the material to
  55965. */
  55966. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  55967. /**
  55968. * Updates the background according to the new options
  55969. * @param options
  55970. */
  55971. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  55972. /**
  55973. * Sets the primary color of all the available elements.
  55974. * @param color the main color to affect to the ground and the background
  55975. */
  55976. setMainColor(color: Color3): void;
  55977. /**
  55978. * Setup the image processing according to the specified options.
  55979. */
  55980. private _setupImageProcessing;
  55981. /**
  55982. * Setup the environment texture according to the specified options.
  55983. */
  55984. private _setupEnvironmentTexture;
  55985. /**
  55986. * Setup the background according to the specified options.
  55987. */
  55988. private _setupBackground;
  55989. /**
  55990. * Get the scene sizes according to the setup.
  55991. */
  55992. private _getSceneSize;
  55993. /**
  55994. * Setup the ground according to the specified options.
  55995. */
  55996. private _setupGround;
  55997. /**
  55998. * Setup the ground material according to the specified options.
  55999. */
  56000. private _setupGroundMaterial;
  56001. /**
  56002. * Setup the ground diffuse texture according to the specified options.
  56003. */
  56004. private _setupGroundDiffuseTexture;
  56005. /**
  56006. * Setup the ground mirror texture according to the specified options.
  56007. */
  56008. private _setupGroundMirrorTexture;
  56009. /**
  56010. * Setup the ground to receive the mirror texture.
  56011. */
  56012. private _setupMirrorInGroundMaterial;
  56013. /**
  56014. * Setup the skybox according to the specified options.
  56015. */
  56016. private _setupSkybox;
  56017. /**
  56018. * Setup the skybox material according to the specified options.
  56019. */
  56020. private _setupSkyboxMaterial;
  56021. /**
  56022. * Setup the skybox reflection texture according to the specified options.
  56023. */
  56024. private _setupSkyboxReflectionTexture;
  56025. private _errorHandler;
  56026. /**
  56027. * Dispose all the elements created by the Helper.
  56028. */
  56029. dispose(): void;
  56030. }
  56031. }
  56032. declare module "babylonjs/Helpers/photoDome" {
  56033. import { Observable } from "babylonjs/Misc/observable";
  56034. import { Nullable } from "babylonjs/types";
  56035. import { Scene } from "babylonjs/scene";
  56036. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56037. import { Mesh } from "babylonjs/Meshes/mesh";
  56038. import { Texture } from "babylonjs/Materials/Textures/texture";
  56039. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56040. import "babylonjs/Meshes/Builders/sphereBuilder";
  56041. /**
  56042. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  56043. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  56044. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  56045. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56046. */
  56047. export class PhotoDome extends TransformNode {
  56048. /**
  56049. * Define the image as a Monoscopic panoramic 360 image.
  56050. */
  56051. static readonly MODE_MONOSCOPIC: number;
  56052. /**
  56053. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56054. */
  56055. static readonly MODE_TOPBOTTOM: number;
  56056. /**
  56057. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56058. */
  56059. static readonly MODE_SIDEBYSIDE: number;
  56060. private _useDirectMapping;
  56061. /**
  56062. * The texture being displayed on the sphere
  56063. */
  56064. protected _photoTexture: Texture;
  56065. /**
  56066. * Gets or sets the texture being displayed on the sphere
  56067. */
  56068. get photoTexture(): Texture;
  56069. set photoTexture(value: Texture);
  56070. /**
  56071. * Observable raised when an error occured while loading the 360 image
  56072. */
  56073. onLoadErrorObservable: Observable<string>;
  56074. /**
  56075. * The skybox material
  56076. */
  56077. protected _material: BackgroundMaterial;
  56078. /**
  56079. * The surface used for the skybox
  56080. */
  56081. protected _mesh: Mesh;
  56082. /**
  56083. * Gets the mesh used for the skybox.
  56084. */
  56085. get mesh(): Mesh;
  56086. /**
  56087. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56088. * Also see the options.resolution property.
  56089. */
  56090. get fovMultiplier(): number;
  56091. set fovMultiplier(value: number);
  56092. private _imageMode;
  56093. /**
  56094. * Gets or set the current video mode for the video. It can be:
  56095. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  56096. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56097. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56098. */
  56099. get imageMode(): number;
  56100. set imageMode(value: number);
  56101. /**
  56102. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  56103. * @param name Element's name, child elements will append suffixes for their own names.
  56104. * @param urlsOfPhoto defines the url of the photo to display
  56105. * @param options defines an object containing optional or exposed sub element properties
  56106. * @param onError defines a callback called when an error occured while loading the texture
  56107. */
  56108. constructor(name: string, urlOfPhoto: string, options: {
  56109. resolution?: number;
  56110. size?: number;
  56111. useDirectMapping?: boolean;
  56112. faceForward?: boolean;
  56113. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  56114. private _onBeforeCameraRenderObserver;
  56115. private _changeImageMode;
  56116. /**
  56117. * Releases resources associated with this node.
  56118. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56119. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56120. */
  56121. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56122. }
  56123. }
  56124. declare module "babylonjs/Misc/rgbdTextureTools" {
  56125. import "babylonjs/Shaders/rgbdDecode.fragment";
  56126. import "babylonjs/Engines/Extensions/engine.renderTarget";
  56127. import { Texture } from "babylonjs/Materials/Textures/texture";
  56128. /**
  56129. * Class used to host RGBD texture specific utilities
  56130. */
  56131. export class RGBDTextureTools {
  56132. /**
  56133. * Expand the RGBD Texture from RGBD to Half Float if possible.
  56134. * @param texture the texture to expand.
  56135. */
  56136. static ExpandRGBDTexture(texture: Texture): void;
  56137. }
  56138. }
  56139. declare module "babylonjs/Misc/brdfTextureTools" {
  56140. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56141. import { Scene } from "babylonjs/scene";
  56142. /**
  56143. * Class used to host texture specific utilities
  56144. */
  56145. export class BRDFTextureTools {
  56146. /**
  56147. * Prevents texture cache collision
  56148. */
  56149. private static _instanceNumber;
  56150. /**
  56151. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  56152. * @param scene defines the hosting scene
  56153. * @returns the environment BRDF texture
  56154. */
  56155. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  56156. private static _environmentBRDFBase64Texture;
  56157. }
  56158. }
  56159. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  56160. import { Nullable } from "babylonjs/types";
  56161. import { Color3 } from "babylonjs/Maths/math.color";
  56162. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56163. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56164. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56165. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56166. import { Engine } from "babylonjs/Engines/engine";
  56167. import { Scene } from "babylonjs/scene";
  56168. /**
  56169. * @hidden
  56170. */
  56171. export interface IMaterialClearCoatDefines {
  56172. CLEARCOAT: boolean;
  56173. CLEARCOAT_DEFAULTIOR: boolean;
  56174. CLEARCOAT_TEXTURE: boolean;
  56175. CLEARCOAT_TEXTUREDIRECTUV: number;
  56176. CLEARCOAT_BUMP: boolean;
  56177. CLEARCOAT_BUMPDIRECTUV: number;
  56178. CLEARCOAT_TINT: boolean;
  56179. CLEARCOAT_TINT_TEXTURE: boolean;
  56180. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56181. /** @hidden */
  56182. _areTexturesDirty: boolean;
  56183. }
  56184. /**
  56185. * Define the code related to the clear coat parameters of the pbr material.
  56186. */
  56187. export class PBRClearCoatConfiguration {
  56188. /**
  56189. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56190. * The default fits with a polyurethane material.
  56191. */
  56192. private static readonly _DefaultIndexOfRefraction;
  56193. private _isEnabled;
  56194. /**
  56195. * Defines if the clear coat is enabled in the material.
  56196. */
  56197. isEnabled: boolean;
  56198. /**
  56199. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  56200. */
  56201. intensity: number;
  56202. /**
  56203. * Defines the clear coat layer roughness.
  56204. */
  56205. roughness: number;
  56206. private _indexOfRefraction;
  56207. /**
  56208. * Defines the index of refraction of the clear coat.
  56209. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56210. * The default fits with a polyurethane material.
  56211. * Changing the default value is more performance intensive.
  56212. */
  56213. indexOfRefraction: number;
  56214. private _texture;
  56215. /**
  56216. * Stores the clear coat values in a texture.
  56217. */
  56218. texture: Nullable<BaseTexture>;
  56219. private _bumpTexture;
  56220. /**
  56221. * Define the clear coat specific bump texture.
  56222. */
  56223. bumpTexture: Nullable<BaseTexture>;
  56224. private _isTintEnabled;
  56225. /**
  56226. * Defines if the clear coat tint is enabled in the material.
  56227. */
  56228. isTintEnabled: boolean;
  56229. /**
  56230. * Defines the clear coat tint of the material.
  56231. * This is only use if tint is enabled
  56232. */
  56233. tintColor: Color3;
  56234. /**
  56235. * Defines the distance at which the tint color should be found in the
  56236. * clear coat media.
  56237. * This is only use if tint is enabled
  56238. */
  56239. tintColorAtDistance: number;
  56240. /**
  56241. * Defines the clear coat layer thickness.
  56242. * This is only use if tint is enabled
  56243. */
  56244. tintThickness: number;
  56245. private _tintTexture;
  56246. /**
  56247. * Stores the clear tint values in a texture.
  56248. * rgb is tint
  56249. * a is a thickness factor
  56250. */
  56251. tintTexture: Nullable<BaseTexture>;
  56252. /** @hidden */
  56253. private _internalMarkAllSubMeshesAsTexturesDirty;
  56254. /** @hidden */
  56255. _markAllSubMeshesAsTexturesDirty(): void;
  56256. /**
  56257. * Instantiate a new istance of clear coat configuration.
  56258. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56259. */
  56260. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56261. /**
  56262. * Gets wehter the submesh is ready to be used or not.
  56263. * @param defines the list of "defines" to update.
  56264. * @param scene defines the scene the material belongs to.
  56265. * @param engine defines the engine the material belongs to.
  56266. * @param disableBumpMap defines wether the material disables bump or not.
  56267. * @returns - boolean indicating that the submesh is ready or not.
  56268. */
  56269. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  56270. /**
  56271. * Checks to see if a texture is used in the material.
  56272. * @param defines the list of "defines" to update.
  56273. * @param scene defines the scene to the material belongs to.
  56274. */
  56275. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  56276. /**
  56277. * Binds the material data.
  56278. * @param uniformBuffer defines the Uniform buffer to fill in.
  56279. * @param scene defines the scene the material belongs to.
  56280. * @param engine defines the engine the material belongs to.
  56281. * @param disableBumpMap defines wether the material disables bump or not.
  56282. * @param isFrozen defines wether the material is frozen or not.
  56283. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56284. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56285. */
  56286. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  56287. /**
  56288. * Checks to see if a texture is used in the material.
  56289. * @param texture - Base texture to use.
  56290. * @returns - Boolean specifying if a texture is used in the material.
  56291. */
  56292. hasTexture(texture: BaseTexture): boolean;
  56293. /**
  56294. * Returns an array of the actively used textures.
  56295. * @param activeTextures Array of BaseTextures
  56296. */
  56297. getActiveTextures(activeTextures: BaseTexture[]): void;
  56298. /**
  56299. * Returns the animatable textures.
  56300. * @param animatables Array of animatable textures.
  56301. */
  56302. getAnimatables(animatables: IAnimatable[]): void;
  56303. /**
  56304. * Disposes the resources of the material.
  56305. * @param forceDisposeTextures - Forces the disposal of all textures.
  56306. */
  56307. dispose(forceDisposeTextures?: boolean): void;
  56308. /**
  56309. * Get the current class name of the texture useful for serialization or dynamic coding.
  56310. * @returns "PBRClearCoatConfiguration"
  56311. */
  56312. getClassName(): string;
  56313. /**
  56314. * Add fallbacks to the effect fallbacks list.
  56315. * @param defines defines the Base texture to use.
  56316. * @param fallbacks defines the current fallback list.
  56317. * @param currentRank defines the current fallback rank.
  56318. * @returns the new fallback rank.
  56319. */
  56320. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56321. /**
  56322. * Add the required uniforms to the current list.
  56323. * @param uniforms defines the current uniform list.
  56324. */
  56325. static AddUniforms(uniforms: string[]): void;
  56326. /**
  56327. * Add the required samplers to the current list.
  56328. * @param samplers defines the current sampler list.
  56329. */
  56330. static AddSamplers(samplers: string[]): void;
  56331. /**
  56332. * Add the required uniforms to the current buffer.
  56333. * @param uniformBuffer defines the current uniform buffer.
  56334. */
  56335. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56336. /**
  56337. * Makes a duplicate of the current configuration into another one.
  56338. * @param clearCoatConfiguration define the config where to copy the info
  56339. */
  56340. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  56341. /**
  56342. * Serializes this clear coat configuration.
  56343. * @returns - An object with the serialized config.
  56344. */
  56345. serialize(): any;
  56346. /**
  56347. * Parses a anisotropy Configuration from a serialized object.
  56348. * @param source - Serialized object.
  56349. * @param scene Defines the scene we are parsing for
  56350. * @param rootUrl Defines the rootUrl to load from
  56351. */
  56352. parse(source: any, scene: Scene, rootUrl: string): void;
  56353. }
  56354. }
  56355. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  56356. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56358. import { Vector2 } from "babylonjs/Maths/math.vector";
  56359. import { Scene } from "babylonjs/scene";
  56360. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56361. import { Nullable } from "babylonjs/types";
  56362. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56363. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56364. /**
  56365. * @hidden
  56366. */
  56367. export interface IMaterialAnisotropicDefines {
  56368. ANISOTROPIC: boolean;
  56369. ANISOTROPIC_TEXTURE: boolean;
  56370. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56371. MAINUV1: boolean;
  56372. _areTexturesDirty: boolean;
  56373. _needUVs: boolean;
  56374. }
  56375. /**
  56376. * Define the code related to the anisotropic parameters of the pbr material.
  56377. */
  56378. export class PBRAnisotropicConfiguration {
  56379. private _isEnabled;
  56380. /**
  56381. * Defines if the anisotropy is enabled in the material.
  56382. */
  56383. isEnabled: boolean;
  56384. /**
  56385. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  56386. */
  56387. intensity: number;
  56388. /**
  56389. * Defines if the effect is along the tangents, bitangents or in between.
  56390. * By default, the effect is "strectching" the highlights along the tangents.
  56391. */
  56392. direction: Vector2;
  56393. private _texture;
  56394. /**
  56395. * Stores the anisotropy values in a texture.
  56396. * rg is direction (like normal from -1 to 1)
  56397. * b is a intensity
  56398. */
  56399. texture: Nullable<BaseTexture>;
  56400. /** @hidden */
  56401. private _internalMarkAllSubMeshesAsTexturesDirty;
  56402. /** @hidden */
  56403. _markAllSubMeshesAsTexturesDirty(): void;
  56404. /**
  56405. * Instantiate a new istance of anisotropy configuration.
  56406. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56407. */
  56408. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56409. /**
  56410. * Specifies that the submesh is ready to be used.
  56411. * @param defines the list of "defines" to update.
  56412. * @param scene defines the scene the material belongs to.
  56413. * @returns - boolean indicating that the submesh is ready or not.
  56414. */
  56415. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  56416. /**
  56417. * Checks to see if a texture is used in the material.
  56418. * @param defines the list of "defines" to update.
  56419. * @param mesh the mesh we are preparing the defines for.
  56420. * @param scene defines the scene the material belongs to.
  56421. */
  56422. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  56423. /**
  56424. * Binds the material data.
  56425. * @param uniformBuffer defines the Uniform buffer to fill in.
  56426. * @param scene defines the scene the material belongs to.
  56427. * @param isFrozen defines wether the material is frozen or not.
  56428. */
  56429. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56430. /**
  56431. * Checks to see if a texture is used in the material.
  56432. * @param texture - Base texture to use.
  56433. * @returns - Boolean specifying if a texture is used in the material.
  56434. */
  56435. hasTexture(texture: BaseTexture): boolean;
  56436. /**
  56437. * Returns an array of the actively used textures.
  56438. * @param activeTextures Array of BaseTextures
  56439. */
  56440. getActiveTextures(activeTextures: BaseTexture[]): void;
  56441. /**
  56442. * Returns the animatable textures.
  56443. * @param animatables Array of animatable textures.
  56444. */
  56445. getAnimatables(animatables: IAnimatable[]): void;
  56446. /**
  56447. * Disposes the resources of the material.
  56448. * @param forceDisposeTextures - Forces the disposal of all textures.
  56449. */
  56450. dispose(forceDisposeTextures?: boolean): void;
  56451. /**
  56452. * Get the current class name of the texture useful for serialization or dynamic coding.
  56453. * @returns "PBRAnisotropicConfiguration"
  56454. */
  56455. getClassName(): string;
  56456. /**
  56457. * Add fallbacks to the effect fallbacks list.
  56458. * @param defines defines the Base texture to use.
  56459. * @param fallbacks defines the current fallback list.
  56460. * @param currentRank defines the current fallback rank.
  56461. * @returns the new fallback rank.
  56462. */
  56463. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56464. /**
  56465. * Add the required uniforms to the current list.
  56466. * @param uniforms defines the current uniform list.
  56467. */
  56468. static AddUniforms(uniforms: string[]): void;
  56469. /**
  56470. * Add the required uniforms to the current buffer.
  56471. * @param uniformBuffer defines the current uniform buffer.
  56472. */
  56473. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56474. /**
  56475. * Add the required samplers to the current list.
  56476. * @param samplers defines the current sampler list.
  56477. */
  56478. static AddSamplers(samplers: string[]): void;
  56479. /**
  56480. * Makes a duplicate of the current configuration into another one.
  56481. * @param anisotropicConfiguration define the config where to copy the info
  56482. */
  56483. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  56484. /**
  56485. * Serializes this anisotropy configuration.
  56486. * @returns - An object with the serialized config.
  56487. */
  56488. serialize(): any;
  56489. /**
  56490. * Parses a anisotropy Configuration from a serialized object.
  56491. * @param source - Serialized object.
  56492. * @param scene Defines the scene we are parsing for
  56493. * @param rootUrl Defines the rootUrl to load from
  56494. */
  56495. parse(source: any, scene: Scene, rootUrl: string): void;
  56496. }
  56497. }
  56498. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  56499. import { Scene } from "babylonjs/scene";
  56500. /**
  56501. * @hidden
  56502. */
  56503. export interface IMaterialBRDFDefines {
  56504. BRDF_V_HEIGHT_CORRELATED: boolean;
  56505. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56506. SPHERICAL_HARMONICS: boolean;
  56507. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56508. /** @hidden */
  56509. _areMiscDirty: boolean;
  56510. }
  56511. /**
  56512. * Define the code related to the BRDF parameters of the pbr material.
  56513. */
  56514. export class PBRBRDFConfiguration {
  56515. /**
  56516. * Default value used for the energy conservation.
  56517. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56518. */
  56519. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  56520. /**
  56521. * Default value used for the Smith Visibility Height Correlated mode.
  56522. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56523. */
  56524. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  56525. /**
  56526. * Default value used for the IBL diffuse part.
  56527. * This can help switching back to the polynomials mode globally which is a tiny bit
  56528. * less GPU intensive at the drawback of a lower quality.
  56529. */
  56530. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  56531. /**
  56532. * Default value used for activating energy conservation for the specular workflow.
  56533. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56534. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56535. */
  56536. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  56537. private _useEnergyConservation;
  56538. /**
  56539. * Defines if the material uses energy conservation.
  56540. */
  56541. useEnergyConservation: boolean;
  56542. private _useSmithVisibilityHeightCorrelated;
  56543. /**
  56544. * LEGACY Mode set to false
  56545. * Defines if the material uses height smith correlated visibility term.
  56546. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  56547. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  56548. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  56549. * Not relying on height correlated will also disable energy conservation.
  56550. */
  56551. useSmithVisibilityHeightCorrelated: boolean;
  56552. private _useSphericalHarmonics;
  56553. /**
  56554. * LEGACY Mode set to false
  56555. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  56556. * diffuse part of the IBL.
  56557. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  56558. * to the ground truth.
  56559. */
  56560. useSphericalHarmonics: boolean;
  56561. private _useSpecularGlossinessInputEnergyConservation;
  56562. /**
  56563. * Defines if the material uses energy conservation, when the specular workflow is active.
  56564. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56565. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56566. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  56567. */
  56568. useSpecularGlossinessInputEnergyConservation: boolean;
  56569. /** @hidden */
  56570. private _internalMarkAllSubMeshesAsMiscDirty;
  56571. /** @hidden */
  56572. _markAllSubMeshesAsMiscDirty(): void;
  56573. /**
  56574. * Instantiate a new istance of clear coat configuration.
  56575. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  56576. */
  56577. constructor(markAllSubMeshesAsMiscDirty: () => void);
  56578. /**
  56579. * Checks to see if a texture is used in the material.
  56580. * @param defines the list of "defines" to update.
  56581. */
  56582. prepareDefines(defines: IMaterialBRDFDefines): void;
  56583. /**
  56584. * Get the current class name of the texture useful for serialization or dynamic coding.
  56585. * @returns "PBRClearCoatConfiguration"
  56586. */
  56587. getClassName(): string;
  56588. /**
  56589. * Makes a duplicate of the current configuration into another one.
  56590. * @param brdfConfiguration define the config where to copy the info
  56591. */
  56592. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  56593. /**
  56594. * Serializes this BRDF configuration.
  56595. * @returns - An object with the serialized config.
  56596. */
  56597. serialize(): any;
  56598. /**
  56599. * Parses a anisotropy Configuration from a serialized object.
  56600. * @param source - Serialized object.
  56601. * @param scene Defines the scene we are parsing for
  56602. * @param rootUrl Defines the rootUrl to load from
  56603. */
  56604. parse(source: any, scene: Scene, rootUrl: string): void;
  56605. }
  56606. }
  56607. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  56608. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56609. import { Color3 } from "babylonjs/Maths/math.color";
  56610. import { Scene } from "babylonjs/scene";
  56611. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56612. import { Nullable } from "babylonjs/types";
  56613. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56614. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56615. /**
  56616. * @hidden
  56617. */
  56618. export interface IMaterialSheenDefines {
  56619. SHEEN: boolean;
  56620. SHEEN_TEXTURE: boolean;
  56621. SHEEN_TEXTUREDIRECTUV: number;
  56622. SHEEN_LINKWITHALBEDO: boolean;
  56623. SHEEN_ROUGHNESS: boolean;
  56624. SHEEN_ALBEDOSCALING: boolean;
  56625. /** @hidden */
  56626. _areTexturesDirty: boolean;
  56627. }
  56628. /**
  56629. * Define the code related to the Sheen parameters of the pbr material.
  56630. */
  56631. export class PBRSheenConfiguration {
  56632. private _isEnabled;
  56633. /**
  56634. * Defines if the material uses sheen.
  56635. */
  56636. isEnabled: boolean;
  56637. private _linkSheenWithAlbedo;
  56638. /**
  56639. * Defines if the sheen is linked to the sheen color.
  56640. */
  56641. linkSheenWithAlbedo: boolean;
  56642. /**
  56643. * Defines the sheen intensity.
  56644. */
  56645. intensity: number;
  56646. /**
  56647. * Defines the sheen color.
  56648. */
  56649. color: Color3;
  56650. private _texture;
  56651. /**
  56652. * Stores the sheen tint values in a texture.
  56653. * rgb is tint
  56654. * a is a intensity
  56655. */
  56656. texture: Nullable<BaseTexture>;
  56657. private _roughness;
  56658. /**
  56659. * Defines the sheen roughness.
  56660. * It is not taken into account if linkSheenWithAlbedo is true.
  56661. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  56662. */
  56663. roughness: Nullable<number>;
  56664. private _albedoScaling;
  56665. /**
  56666. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  56667. * It allows the strength of the sheen effect to not depend on the base color of the material,
  56668. * making it easier to setup and tweak the effect
  56669. */
  56670. albedoScaling: boolean;
  56671. /** @hidden */
  56672. private _internalMarkAllSubMeshesAsTexturesDirty;
  56673. /** @hidden */
  56674. _markAllSubMeshesAsTexturesDirty(): void;
  56675. /**
  56676. * Instantiate a new istance of clear coat configuration.
  56677. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56678. */
  56679. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56680. /**
  56681. * Specifies that the submesh is ready to be used.
  56682. * @param defines the list of "defines" to update.
  56683. * @param scene defines the scene the material belongs to.
  56684. * @returns - boolean indicating that the submesh is ready or not.
  56685. */
  56686. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  56687. /**
  56688. * Checks to see if a texture is used in the material.
  56689. * @param defines the list of "defines" to update.
  56690. * @param scene defines the scene the material belongs to.
  56691. */
  56692. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  56693. /**
  56694. * Binds the material data.
  56695. * @param uniformBuffer defines the Uniform buffer to fill in.
  56696. * @param scene defines the scene the material belongs to.
  56697. * @param isFrozen defines wether the material is frozen or not.
  56698. */
  56699. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56700. /**
  56701. * Checks to see if a texture is used in the material.
  56702. * @param texture - Base texture to use.
  56703. * @returns - Boolean specifying if a texture is used in the material.
  56704. */
  56705. hasTexture(texture: BaseTexture): boolean;
  56706. /**
  56707. * Returns an array of the actively used textures.
  56708. * @param activeTextures Array of BaseTextures
  56709. */
  56710. getActiveTextures(activeTextures: BaseTexture[]): void;
  56711. /**
  56712. * Returns the animatable textures.
  56713. * @param animatables Array of animatable textures.
  56714. */
  56715. getAnimatables(animatables: IAnimatable[]): void;
  56716. /**
  56717. * Disposes the resources of the material.
  56718. * @param forceDisposeTextures - Forces the disposal of all textures.
  56719. */
  56720. dispose(forceDisposeTextures?: boolean): void;
  56721. /**
  56722. * Get the current class name of the texture useful for serialization or dynamic coding.
  56723. * @returns "PBRSheenConfiguration"
  56724. */
  56725. getClassName(): string;
  56726. /**
  56727. * Add fallbacks to the effect fallbacks list.
  56728. * @param defines defines the Base texture to use.
  56729. * @param fallbacks defines the current fallback list.
  56730. * @param currentRank defines the current fallback rank.
  56731. * @returns the new fallback rank.
  56732. */
  56733. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56734. /**
  56735. * Add the required uniforms to the current list.
  56736. * @param uniforms defines the current uniform list.
  56737. */
  56738. static AddUniforms(uniforms: string[]): void;
  56739. /**
  56740. * Add the required uniforms to the current buffer.
  56741. * @param uniformBuffer defines the current uniform buffer.
  56742. */
  56743. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56744. /**
  56745. * Add the required samplers to the current list.
  56746. * @param samplers defines the current sampler list.
  56747. */
  56748. static AddSamplers(samplers: string[]): void;
  56749. /**
  56750. * Makes a duplicate of the current configuration into another one.
  56751. * @param sheenConfiguration define the config where to copy the info
  56752. */
  56753. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  56754. /**
  56755. * Serializes this BRDF configuration.
  56756. * @returns - An object with the serialized config.
  56757. */
  56758. serialize(): any;
  56759. /**
  56760. * Parses a anisotropy Configuration from a serialized object.
  56761. * @param source - Serialized object.
  56762. * @param scene Defines the scene we are parsing for
  56763. * @param rootUrl Defines the rootUrl to load from
  56764. */
  56765. parse(source: any, scene: Scene, rootUrl: string): void;
  56766. }
  56767. }
  56768. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  56769. import { Nullable } from "babylonjs/types";
  56770. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56771. import { Color3 } from "babylonjs/Maths/math.color";
  56772. import { SmartArray } from "babylonjs/Misc/smartArray";
  56773. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56774. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56775. import { Effect } from "babylonjs/Materials/effect";
  56776. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56777. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56778. import { Engine } from "babylonjs/Engines/engine";
  56779. import { Scene } from "babylonjs/scene";
  56780. /**
  56781. * @hidden
  56782. */
  56783. export interface IMaterialSubSurfaceDefines {
  56784. SUBSURFACE: boolean;
  56785. SS_REFRACTION: boolean;
  56786. SS_TRANSLUCENCY: boolean;
  56787. SS_SCATTERING: boolean;
  56788. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56789. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56790. SS_REFRACTIONMAP_3D: boolean;
  56791. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56792. SS_LODINREFRACTIONALPHA: boolean;
  56793. SS_GAMMAREFRACTION: boolean;
  56794. SS_RGBDREFRACTION: boolean;
  56795. SS_LINEARSPECULARREFRACTION: boolean;
  56796. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56797. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56798. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56799. /** @hidden */
  56800. _areTexturesDirty: boolean;
  56801. }
  56802. /**
  56803. * Define the code related to the sub surface parameters of the pbr material.
  56804. */
  56805. export class PBRSubSurfaceConfiguration {
  56806. private _isRefractionEnabled;
  56807. /**
  56808. * Defines if the refraction is enabled in the material.
  56809. */
  56810. isRefractionEnabled: boolean;
  56811. private _isTranslucencyEnabled;
  56812. /**
  56813. * Defines if the translucency is enabled in the material.
  56814. */
  56815. isTranslucencyEnabled: boolean;
  56816. private _isScatteringEnabled;
  56817. /**
  56818. * Defines the refraction intensity of the material.
  56819. * The refraction when enabled replaces the Diffuse part of the material.
  56820. * The intensity helps transitionning between diffuse and refraction.
  56821. */
  56822. refractionIntensity: number;
  56823. /**
  56824. * Defines the translucency intensity of the material.
  56825. * When translucency has been enabled, this defines how much of the "translucency"
  56826. * is addded to the diffuse part of the material.
  56827. */
  56828. translucencyIntensity: number;
  56829. /**
  56830. * Defines the scattering intensity of the material.
  56831. * When scattering has been enabled, this defines how much of the "scattered light"
  56832. * is addded to the diffuse part of the material.
  56833. */
  56834. scatteringIntensity: number;
  56835. /**
  56836. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  56837. */
  56838. useAlbedoToTintRefraction: boolean;
  56839. private _thicknessTexture;
  56840. /**
  56841. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  56842. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  56843. * 0 would mean minimumThickness
  56844. * 1 would mean maximumThickness
  56845. * The other channels might be use as a mask to vary the different effects intensity.
  56846. */
  56847. thicknessTexture: Nullable<BaseTexture>;
  56848. private _refractionTexture;
  56849. /**
  56850. * Defines the texture to use for refraction.
  56851. */
  56852. refractionTexture: Nullable<BaseTexture>;
  56853. private _indexOfRefraction;
  56854. /**
  56855. * Index of refraction of the material base layer.
  56856. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56857. *
  56858. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56859. *
  56860. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56861. */
  56862. indexOfRefraction: number;
  56863. private _volumeIndexOfRefraction;
  56864. /**
  56865. * Index of refraction of the material's volume.
  56866. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56867. *
  56868. * This ONLY impacts refraction. If not provided or given a non-valid value,
  56869. * the volume will use the same IOR as the surface.
  56870. */
  56871. get volumeIndexOfRefraction(): number;
  56872. set volumeIndexOfRefraction(value: number);
  56873. private _invertRefractionY;
  56874. /**
  56875. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56876. */
  56877. invertRefractionY: boolean;
  56878. private _linkRefractionWithTransparency;
  56879. /**
  56880. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56881. * Materials half opaque for instance using refraction could benefit from this control.
  56882. */
  56883. linkRefractionWithTransparency: boolean;
  56884. /**
  56885. * Defines the minimum thickness stored in the thickness map.
  56886. * If no thickness map is defined, this value will be used to simulate thickness.
  56887. */
  56888. minimumThickness: number;
  56889. /**
  56890. * Defines the maximum thickness stored in the thickness map.
  56891. */
  56892. maximumThickness: number;
  56893. /**
  56894. * Defines the volume tint of the material.
  56895. * This is used for both translucency and scattering.
  56896. */
  56897. tintColor: Color3;
  56898. /**
  56899. * Defines the distance at which the tint color should be found in the media.
  56900. * This is used for refraction only.
  56901. */
  56902. tintColorAtDistance: number;
  56903. /**
  56904. * Defines how far each channel transmit through the media.
  56905. * It is defined as a color to simplify it selection.
  56906. */
  56907. diffusionDistance: Color3;
  56908. private _useMaskFromThicknessTexture;
  56909. /**
  56910. * Stores the intensity of the different subsurface effects in the thickness texture.
  56911. * * the green channel is the translucency intensity.
  56912. * * the blue channel is the scattering intensity.
  56913. * * the alpha channel is the refraction intensity.
  56914. */
  56915. useMaskFromThicknessTexture: boolean;
  56916. /** @hidden */
  56917. private _internalMarkAllSubMeshesAsTexturesDirty;
  56918. /** @hidden */
  56919. _markAllSubMeshesAsTexturesDirty(): void;
  56920. /**
  56921. * Instantiate a new istance of sub surface configuration.
  56922. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56923. */
  56924. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56925. /**
  56926. * Gets wehter the submesh is ready to be used or not.
  56927. * @param defines the list of "defines" to update.
  56928. * @param scene defines the scene the material belongs to.
  56929. * @returns - boolean indicating that the submesh is ready or not.
  56930. */
  56931. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  56932. /**
  56933. * Checks to see if a texture is used in the material.
  56934. * @param defines the list of "defines" to update.
  56935. * @param scene defines the scene to the material belongs to.
  56936. */
  56937. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  56938. /**
  56939. * Binds the material data.
  56940. * @param uniformBuffer defines the Uniform buffer to fill in.
  56941. * @param scene defines the scene the material belongs to.
  56942. * @param engine defines the engine the material belongs to.
  56943. * @param isFrozen defines whether the material is frozen or not.
  56944. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  56945. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  56946. */
  56947. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  56948. /**
  56949. * Unbinds the material from the mesh.
  56950. * @param activeEffect defines the effect that should be unbound from.
  56951. * @returns true if unbound, otherwise false
  56952. */
  56953. unbind(activeEffect: Effect): boolean;
  56954. /**
  56955. * Returns the texture used for refraction or null if none is used.
  56956. * @param scene defines the scene the material belongs to.
  56957. * @returns - Refraction texture if present. If no refraction texture and refraction
  56958. * is linked with transparency, returns environment texture. Otherwise, returns null.
  56959. */
  56960. private _getRefractionTexture;
  56961. /**
  56962. * Returns true if alpha blending should be disabled.
  56963. */
  56964. get disableAlphaBlending(): boolean;
  56965. /**
  56966. * Fills the list of render target textures.
  56967. * @param renderTargets the list of render targets to update
  56968. */
  56969. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  56970. /**
  56971. * Checks to see if a texture is used in the material.
  56972. * @param texture - Base texture to use.
  56973. * @returns - Boolean specifying if a texture is used in the material.
  56974. */
  56975. hasTexture(texture: BaseTexture): boolean;
  56976. /**
  56977. * Gets a boolean indicating that current material needs to register RTT
  56978. * @returns true if this uses a render target otherwise false.
  56979. */
  56980. hasRenderTargetTextures(): boolean;
  56981. /**
  56982. * Returns an array of the actively used textures.
  56983. * @param activeTextures Array of BaseTextures
  56984. */
  56985. getActiveTextures(activeTextures: BaseTexture[]): void;
  56986. /**
  56987. * Returns the animatable textures.
  56988. * @param animatables Array of animatable textures.
  56989. */
  56990. getAnimatables(animatables: IAnimatable[]): void;
  56991. /**
  56992. * Disposes the resources of the material.
  56993. * @param forceDisposeTextures - Forces the disposal of all textures.
  56994. */
  56995. dispose(forceDisposeTextures?: boolean): void;
  56996. /**
  56997. * Get the current class name of the texture useful for serialization or dynamic coding.
  56998. * @returns "PBRSubSurfaceConfiguration"
  56999. */
  57000. getClassName(): string;
  57001. /**
  57002. * Add fallbacks to the effect fallbacks list.
  57003. * @param defines defines the Base texture to use.
  57004. * @param fallbacks defines the current fallback list.
  57005. * @param currentRank defines the current fallback rank.
  57006. * @returns the new fallback rank.
  57007. */
  57008. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57009. /**
  57010. * Add the required uniforms to the current list.
  57011. * @param uniforms defines the current uniform list.
  57012. */
  57013. static AddUniforms(uniforms: string[]): void;
  57014. /**
  57015. * Add the required samplers to the current list.
  57016. * @param samplers defines the current sampler list.
  57017. */
  57018. static AddSamplers(samplers: string[]): void;
  57019. /**
  57020. * Add the required uniforms to the current buffer.
  57021. * @param uniformBuffer defines the current uniform buffer.
  57022. */
  57023. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57024. /**
  57025. * Makes a duplicate of the current configuration into another one.
  57026. * @param configuration define the config where to copy the info
  57027. */
  57028. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  57029. /**
  57030. * Serializes this Sub Surface configuration.
  57031. * @returns - An object with the serialized config.
  57032. */
  57033. serialize(): any;
  57034. /**
  57035. * Parses a anisotropy Configuration from a serialized object.
  57036. * @param source - Serialized object.
  57037. * @param scene Defines the scene we are parsing for
  57038. * @param rootUrl Defines the rootUrl to load from
  57039. */
  57040. parse(source: any, scene: Scene, rootUrl: string): void;
  57041. }
  57042. }
  57043. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  57044. /** @hidden */
  57045. export var pbrFragmentDeclaration: {
  57046. name: string;
  57047. shader: string;
  57048. };
  57049. }
  57050. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  57051. /** @hidden */
  57052. export var pbrUboDeclaration: {
  57053. name: string;
  57054. shader: string;
  57055. };
  57056. }
  57057. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  57058. /** @hidden */
  57059. export var pbrFragmentExtraDeclaration: {
  57060. name: string;
  57061. shader: string;
  57062. };
  57063. }
  57064. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  57065. /** @hidden */
  57066. export var pbrFragmentSamplersDeclaration: {
  57067. name: string;
  57068. shader: string;
  57069. };
  57070. }
  57071. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  57072. /** @hidden */
  57073. export var importanceSampling: {
  57074. name: string;
  57075. shader: string;
  57076. };
  57077. }
  57078. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  57079. /** @hidden */
  57080. export var pbrHelperFunctions: {
  57081. name: string;
  57082. shader: string;
  57083. };
  57084. }
  57085. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  57086. /** @hidden */
  57087. export var harmonicsFunctions: {
  57088. name: string;
  57089. shader: string;
  57090. };
  57091. }
  57092. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  57093. /** @hidden */
  57094. export var pbrDirectLightingSetupFunctions: {
  57095. name: string;
  57096. shader: string;
  57097. };
  57098. }
  57099. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  57100. /** @hidden */
  57101. export var pbrDirectLightingFalloffFunctions: {
  57102. name: string;
  57103. shader: string;
  57104. };
  57105. }
  57106. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  57107. /** @hidden */
  57108. export var pbrBRDFFunctions: {
  57109. name: string;
  57110. shader: string;
  57111. };
  57112. }
  57113. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  57114. /** @hidden */
  57115. export var hdrFilteringFunctions: {
  57116. name: string;
  57117. shader: string;
  57118. };
  57119. }
  57120. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  57121. /** @hidden */
  57122. export var pbrDirectLightingFunctions: {
  57123. name: string;
  57124. shader: string;
  57125. };
  57126. }
  57127. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  57128. /** @hidden */
  57129. export var pbrIBLFunctions: {
  57130. name: string;
  57131. shader: string;
  57132. };
  57133. }
  57134. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  57135. /** @hidden */
  57136. export var pbrBlockAlbedoOpacity: {
  57137. name: string;
  57138. shader: string;
  57139. };
  57140. }
  57141. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  57142. /** @hidden */
  57143. export var pbrBlockReflectivity: {
  57144. name: string;
  57145. shader: string;
  57146. };
  57147. }
  57148. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  57149. /** @hidden */
  57150. export var pbrBlockAmbientOcclusion: {
  57151. name: string;
  57152. shader: string;
  57153. };
  57154. }
  57155. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  57156. /** @hidden */
  57157. export var pbrBlockAlphaFresnel: {
  57158. name: string;
  57159. shader: string;
  57160. };
  57161. }
  57162. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  57163. /** @hidden */
  57164. export var pbrBlockAnisotropic: {
  57165. name: string;
  57166. shader: string;
  57167. };
  57168. }
  57169. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  57170. /** @hidden */
  57171. export var pbrBlockReflection: {
  57172. name: string;
  57173. shader: string;
  57174. };
  57175. }
  57176. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  57177. /** @hidden */
  57178. export var pbrBlockSheen: {
  57179. name: string;
  57180. shader: string;
  57181. };
  57182. }
  57183. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  57184. /** @hidden */
  57185. export var pbrBlockClearcoat: {
  57186. name: string;
  57187. shader: string;
  57188. };
  57189. }
  57190. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  57191. /** @hidden */
  57192. export var pbrBlockSubSurface: {
  57193. name: string;
  57194. shader: string;
  57195. };
  57196. }
  57197. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  57198. /** @hidden */
  57199. export var pbrBlockNormalGeometric: {
  57200. name: string;
  57201. shader: string;
  57202. };
  57203. }
  57204. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  57205. /** @hidden */
  57206. export var pbrBlockNormalFinal: {
  57207. name: string;
  57208. shader: string;
  57209. };
  57210. }
  57211. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  57212. /** @hidden */
  57213. export var pbrBlockGeometryInfo: {
  57214. name: string;
  57215. shader: string;
  57216. };
  57217. }
  57218. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  57219. /** @hidden */
  57220. export var pbrBlockReflectance0: {
  57221. name: string;
  57222. shader: string;
  57223. };
  57224. }
  57225. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  57226. /** @hidden */
  57227. export var pbrBlockReflectance: {
  57228. name: string;
  57229. shader: string;
  57230. };
  57231. }
  57232. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  57233. /** @hidden */
  57234. export var pbrBlockDirectLighting: {
  57235. name: string;
  57236. shader: string;
  57237. };
  57238. }
  57239. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  57240. /** @hidden */
  57241. export var pbrBlockFinalLitComponents: {
  57242. name: string;
  57243. shader: string;
  57244. };
  57245. }
  57246. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  57247. /** @hidden */
  57248. export var pbrBlockFinalUnlitComponents: {
  57249. name: string;
  57250. shader: string;
  57251. };
  57252. }
  57253. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  57254. /** @hidden */
  57255. export var pbrBlockFinalColorComposition: {
  57256. name: string;
  57257. shader: string;
  57258. };
  57259. }
  57260. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  57261. /** @hidden */
  57262. export var pbrBlockImageProcessing: {
  57263. name: string;
  57264. shader: string;
  57265. };
  57266. }
  57267. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  57268. /** @hidden */
  57269. export var pbrDebug: {
  57270. name: string;
  57271. shader: string;
  57272. };
  57273. }
  57274. declare module "babylonjs/Shaders/pbr.fragment" {
  57275. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  57276. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57277. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  57278. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57279. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57280. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  57281. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57282. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  57283. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57284. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57285. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57286. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  57287. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  57288. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57289. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57290. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57291. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  57292. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  57293. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  57294. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  57295. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  57296. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  57297. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  57298. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57299. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  57300. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  57301. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  57302. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  57303. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  57304. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  57305. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  57306. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  57307. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  57308. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  57309. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  57310. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  57311. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57312. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  57313. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  57314. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  57315. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  57316. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  57317. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  57318. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57319. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  57320. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  57321. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  57322. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57323. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  57324. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  57325. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  57326. /** @hidden */
  57327. export var pbrPixelShader: {
  57328. name: string;
  57329. shader: string;
  57330. };
  57331. }
  57332. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  57333. /** @hidden */
  57334. export var pbrVertexDeclaration: {
  57335. name: string;
  57336. shader: string;
  57337. };
  57338. }
  57339. declare module "babylonjs/Shaders/pbr.vertex" {
  57340. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  57341. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57342. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57343. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57344. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57345. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57346. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  57347. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  57348. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  57349. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57350. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57351. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57352. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57353. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57354. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  57355. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57356. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57357. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  57358. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  57359. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  57360. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57361. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57362. /** @hidden */
  57363. export var pbrVertexShader: {
  57364. name: string;
  57365. shader: string;
  57366. };
  57367. }
  57368. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  57369. import { Nullable } from "babylonjs/types";
  57370. import { Scene } from "babylonjs/scene";
  57371. import { Matrix } from "babylonjs/Maths/math.vector";
  57372. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57373. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57374. import { Mesh } from "babylonjs/Meshes/mesh";
  57375. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  57376. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  57377. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  57378. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  57379. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  57380. import { Color3 } from "babylonjs/Maths/math.color";
  57381. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  57382. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  57383. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  57384. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57385. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57386. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57387. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57388. import "babylonjs/Shaders/pbr.fragment";
  57389. import "babylonjs/Shaders/pbr.vertex";
  57390. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  57391. /**
  57392. * Manages the defines for the PBR Material.
  57393. * @hidden
  57394. */
  57395. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  57396. PBR: boolean;
  57397. NUM_SAMPLES: string;
  57398. REALTIME_FILTERING: boolean;
  57399. MAINUV1: boolean;
  57400. MAINUV2: boolean;
  57401. UV1: boolean;
  57402. UV2: boolean;
  57403. ALBEDO: boolean;
  57404. GAMMAALBEDO: boolean;
  57405. ALBEDODIRECTUV: number;
  57406. VERTEXCOLOR: boolean;
  57407. DETAIL: boolean;
  57408. DETAILDIRECTUV: number;
  57409. DETAIL_NORMALBLENDMETHOD: number;
  57410. AMBIENT: boolean;
  57411. AMBIENTDIRECTUV: number;
  57412. AMBIENTINGRAYSCALE: boolean;
  57413. OPACITY: boolean;
  57414. VERTEXALPHA: boolean;
  57415. OPACITYDIRECTUV: number;
  57416. OPACITYRGB: boolean;
  57417. ALPHATEST: boolean;
  57418. DEPTHPREPASS: boolean;
  57419. ALPHABLEND: boolean;
  57420. ALPHAFROMALBEDO: boolean;
  57421. ALPHATESTVALUE: string;
  57422. SPECULAROVERALPHA: boolean;
  57423. RADIANCEOVERALPHA: boolean;
  57424. ALPHAFRESNEL: boolean;
  57425. LINEARALPHAFRESNEL: boolean;
  57426. PREMULTIPLYALPHA: boolean;
  57427. EMISSIVE: boolean;
  57428. EMISSIVEDIRECTUV: number;
  57429. REFLECTIVITY: boolean;
  57430. REFLECTIVITYDIRECTUV: number;
  57431. SPECULARTERM: boolean;
  57432. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  57433. MICROSURFACEAUTOMATIC: boolean;
  57434. LODBASEDMICROSFURACE: boolean;
  57435. MICROSURFACEMAP: boolean;
  57436. MICROSURFACEMAPDIRECTUV: number;
  57437. METALLICWORKFLOW: boolean;
  57438. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  57439. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  57440. METALLNESSSTOREINMETALMAPBLUE: boolean;
  57441. AOSTOREINMETALMAPRED: boolean;
  57442. METALLIC_REFLECTANCE: boolean;
  57443. METALLIC_REFLECTANCEDIRECTUV: number;
  57444. ENVIRONMENTBRDF: boolean;
  57445. ENVIRONMENTBRDF_RGBD: boolean;
  57446. NORMAL: boolean;
  57447. TANGENT: boolean;
  57448. BUMP: boolean;
  57449. BUMPDIRECTUV: number;
  57450. OBJECTSPACE_NORMALMAP: boolean;
  57451. PARALLAX: boolean;
  57452. PARALLAXOCCLUSION: boolean;
  57453. NORMALXYSCALE: boolean;
  57454. LIGHTMAP: boolean;
  57455. LIGHTMAPDIRECTUV: number;
  57456. USELIGHTMAPASSHADOWMAP: boolean;
  57457. GAMMALIGHTMAP: boolean;
  57458. RGBDLIGHTMAP: boolean;
  57459. REFLECTION: boolean;
  57460. REFLECTIONMAP_3D: boolean;
  57461. REFLECTIONMAP_SPHERICAL: boolean;
  57462. REFLECTIONMAP_PLANAR: boolean;
  57463. REFLECTIONMAP_CUBIC: boolean;
  57464. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  57465. REFLECTIONMAP_PROJECTION: boolean;
  57466. REFLECTIONMAP_SKYBOX: boolean;
  57467. REFLECTIONMAP_EXPLICIT: boolean;
  57468. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  57469. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  57470. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  57471. INVERTCUBICMAP: boolean;
  57472. USESPHERICALFROMREFLECTIONMAP: boolean;
  57473. USEIRRADIANCEMAP: boolean;
  57474. SPHERICAL_HARMONICS: boolean;
  57475. USESPHERICALINVERTEX: boolean;
  57476. REFLECTIONMAP_OPPOSITEZ: boolean;
  57477. LODINREFLECTIONALPHA: boolean;
  57478. GAMMAREFLECTION: boolean;
  57479. RGBDREFLECTION: boolean;
  57480. LINEARSPECULARREFLECTION: boolean;
  57481. RADIANCEOCCLUSION: boolean;
  57482. HORIZONOCCLUSION: boolean;
  57483. INSTANCES: boolean;
  57484. THIN_INSTANCES: boolean;
  57485. NUM_BONE_INFLUENCERS: number;
  57486. BonesPerMesh: number;
  57487. BONETEXTURE: boolean;
  57488. NONUNIFORMSCALING: boolean;
  57489. MORPHTARGETS: boolean;
  57490. MORPHTARGETS_NORMAL: boolean;
  57491. MORPHTARGETS_TANGENT: boolean;
  57492. MORPHTARGETS_UV: boolean;
  57493. NUM_MORPH_INFLUENCERS: number;
  57494. IMAGEPROCESSING: boolean;
  57495. VIGNETTE: boolean;
  57496. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57497. VIGNETTEBLENDMODEOPAQUE: boolean;
  57498. TONEMAPPING: boolean;
  57499. TONEMAPPING_ACES: boolean;
  57500. CONTRAST: boolean;
  57501. COLORCURVES: boolean;
  57502. COLORGRADING: boolean;
  57503. COLORGRADING3D: boolean;
  57504. SAMPLER3DGREENDEPTH: boolean;
  57505. SAMPLER3DBGRMAP: boolean;
  57506. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57507. EXPOSURE: boolean;
  57508. MULTIVIEW: boolean;
  57509. USEPHYSICALLIGHTFALLOFF: boolean;
  57510. USEGLTFLIGHTFALLOFF: boolean;
  57511. TWOSIDEDLIGHTING: boolean;
  57512. SHADOWFLOAT: boolean;
  57513. CLIPPLANE: boolean;
  57514. CLIPPLANE2: boolean;
  57515. CLIPPLANE3: boolean;
  57516. CLIPPLANE4: boolean;
  57517. CLIPPLANE5: boolean;
  57518. CLIPPLANE6: boolean;
  57519. POINTSIZE: boolean;
  57520. FOG: boolean;
  57521. LOGARITHMICDEPTH: boolean;
  57522. FORCENORMALFORWARD: boolean;
  57523. SPECULARAA: boolean;
  57524. CLEARCOAT: boolean;
  57525. CLEARCOAT_DEFAULTIOR: boolean;
  57526. CLEARCOAT_TEXTURE: boolean;
  57527. CLEARCOAT_TEXTUREDIRECTUV: number;
  57528. CLEARCOAT_BUMP: boolean;
  57529. CLEARCOAT_BUMPDIRECTUV: number;
  57530. CLEARCOAT_TINT: boolean;
  57531. CLEARCOAT_TINT_TEXTURE: boolean;
  57532. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57533. ANISOTROPIC: boolean;
  57534. ANISOTROPIC_TEXTURE: boolean;
  57535. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57536. BRDF_V_HEIGHT_CORRELATED: boolean;
  57537. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57538. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57539. SHEEN: boolean;
  57540. SHEEN_TEXTURE: boolean;
  57541. SHEEN_TEXTUREDIRECTUV: number;
  57542. SHEEN_LINKWITHALBEDO: boolean;
  57543. SHEEN_ROUGHNESS: boolean;
  57544. SHEEN_ALBEDOSCALING: boolean;
  57545. SUBSURFACE: boolean;
  57546. SS_REFRACTION: boolean;
  57547. SS_TRANSLUCENCY: boolean;
  57548. SS_SCATTERING: boolean;
  57549. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57550. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57551. SS_REFRACTIONMAP_3D: boolean;
  57552. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57553. SS_LODINREFRACTIONALPHA: boolean;
  57554. SS_GAMMAREFRACTION: boolean;
  57555. SS_RGBDREFRACTION: boolean;
  57556. SS_LINEARSPECULARREFRACTION: boolean;
  57557. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57558. SS_ALBEDOFORREFRACTIONTINT: boolean;
  57559. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57560. UNLIT: boolean;
  57561. DEBUGMODE: number;
  57562. /**
  57563. * Initializes the PBR Material defines.
  57564. */
  57565. constructor();
  57566. /**
  57567. * Resets the PBR Material defines.
  57568. */
  57569. reset(): void;
  57570. }
  57571. /**
  57572. * The Physically based material base class of BJS.
  57573. *
  57574. * This offers the main features of a standard PBR material.
  57575. * For more information, please refer to the documentation :
  57576. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57577. */
  57578. export abstract class PBRBaseMaterial extends PushMaterial {
  57579. /**
  57580. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57581. */
  57582. static readonly PBRMATERIAL_OPAQUE: number;
  57583. /**
  57584. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57585. */
  57586. static readonly PBRMATERIAL_ALPHATEST: number;
  57587. /**
  57588. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57589. */
  57590. static readonly PBRMATERIAL_ALPHABLEND: number;
  57591. /**
  57592. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57593. * They are also discarded below the alpha cutoff threshold to improve performances.
  57594. */
  57595. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57596. /**
  57597. * Defines the default value of how much AO map is occluding the analytical lights
  57598. * (point spot...).
  57599. */
  57600. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57601. /**
  57602. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  57603. */
  57604. static readonly LIGHTFALLOFF_PHYSICAL: number;
  57605. /**
  57606. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  57607. * to enhance interoperability with other engines.
  57608. */
  57609. static readonly LIGHTFALLOFF_GLTF: number;
  57610. /**
  57611. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  57612. * to enhance interoperability with other materials.
  57613. */
  57614. static readonly LIGHTFALLOFF_STANDARD: number;
  57615. /**
  57616. * Intensity of the direct lights e.g. the four lights available in your scene.
  57617. * This impacts both the direct diffuse and specular highlights.
  57618. */
  57619. protected _directIntensity: number;
  57620. /**
  57621. * Intensity of the emissive part of the material.
  57622. * This helps controlling the emissive effect without modifying the emissive color.
  57623. */
  57624. protected _emissiveIntensity: number;
  57625. /**
  57626. * Intensity of the environment e.g. how much the environment will light the object
  57627. * either through harmonics for rough material or through the refelction for shiny ones.
  57628. */
  57629. protected _environmentIntensity: number;
  57630. /**
  57631. * This is a special control allowing the reduction of the specular highlights coming from the
  57632. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57633. */
  57634. protected _specularIntensity: number;
  57635. /**
  57636. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  57637. */
  57638. private _lightingInfos;
  57639. /**
  57640. * Debug Control allowing disabling the bump map on this material.
  57641. */
  57642. protected _disableBumpMap: boolean;
  57643. /**
  57644. * AKA Diffuse Texture in standard nomenclature.
  57645. */
  57646. protected _albedoTexture: Nullable<BaseTexture>;
  57647. /**
  57648. * AKA Occlusion Texture in other nomenclature.
  57649. */
  57650. protected _ambientTexture: Nullable<BaseTexture>;
  57651. /**
  57652. * AKA Occlusion Texture Intensity in other nomenclature.
  57653. */
  57654. protected _ambientTextureStrength: number;
  57655. /**
  57656. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57657. * 1 means it completely occludes it
  57658. * 0 mean it has no impact
  57659. */
  57660. protected _ambientTextureImpactOnAnalyticalLights: number;
  57661. /**
  57662. * Stores the alpha values in a texture.
  57663. */
  57664. protected _opacityTexture: Nullable<BaseTexture>;
  57665. /**
  57666. * Stores the reflection values in a texture.
  57667. */
  57668. protected _reflectionTexture: Nullable<BaseTexture>;
  57669. /**
  57670. * Stores the emissive values in a texture.
  57671. */
  57672. protected _emissiveTexture: Nullable<BaseTexture>;
  57673. /**
  57674. * AKA Specular texture in other nomenclature.
  57675. */
  57676. protected _reflectivityTexture: Nullable<BaseTexture>;
  57677. /**
  57678. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57679. */
  57680. protected _metallicTexture: Nullable<BaseTexture>;
  57681. /**
  57682. * Specifies the metallic scalar of the metallic/roughness workflow.
  57683. * Can also be used to scale the metalness values of the metallic texture.
  57684. */
  57685. protected _metallic: Nullable<number>;
  57686. /**
  57687. * Specifies the roughness scalar of the metallic/roughness workflow.
  57688. * Can also be used to scale the roughness values of the metallic texture.
  57689. */
  57690. protected _roughness: Nullable<number>;
  57691. /**
  57692. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57693. * By default the indexOfrefraction is used to compute F0;
  57694. *
  57695. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57696. *
  57697. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57698. * F90 = metallicReflectanceColor;
  57699. */
  57700. protected _metallicF0Factor: number;
  57701. /**
  57702. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57703. * By default the F90 is always 1;
  57704. *
  57705. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57706. *
  57707. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57708. * F90 = metallicReflectanceColor;
  57709. */
  57710. protected _metallicReflectanceColor: Color3;
  57711. /**
  57712. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57713. * This is multiply against the scalar values defined in the material.
  57714. */
  57715. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  57716. /**
  57717. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57718. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57719. */
  57720. protected _microSurfaceTexture: Nullable<BaseTexture>;
  57721. /**
  57722. * Stores surface normal data used to displace a mesh in a texture.
  57723. */
  57724. protected _bumpTexture: Nullable<BaseTexture>;
  57725. /**
  57726. * Stores the pre-calculated light information of a mesh in a texture.
  57727. */
  57728. protected _lightmapTexture: Nullable<BaseTexture>;
  57729. /**
  57730. * The color of a material in ambient lighting.
  57731. */
  57732. protected _ambientColor: Color3;
  57733. /**
  57734. * AKA Diffuse Color in other nomenclature.
  57735. */
  57736. protected _albedoColor: Color3;
  57737. /**
  57738. * AKA Specular Color in other nomenclature.
  57739. */
  57740. protected _reflectivityColor: Color3;
  57741. /**
  57742. * The color applied when light is reflected from a material.
  57743. */
  57744. protected _reflectionColor: Color3;
  57745. /**
  57746. * The color applied when light is emitted from a material.
  57747. */
  57748. protected _emissiveColor: Color3;
  57749. /**
  57750. * AKA Glossiness in other nomenclature.
  57751. */
  57752. protected _microSurface: number;
  57753. /**
  57754. * Specifies that the material will use the light map as a show map.
  57755. */
  57756. protected _useLightmapAsShadowmap: boolean;
  57757. /**
  57758. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57759. * makes the reflect vector face the model (under horizon).
  57760. */
  57761. protected _useHorizonOcclusion: boolean;
  57762. /**
  57763. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57764. * too much the area relying on ambient texture to define their ambient occlusion.
  57765. */
  57766. protected _useRadianceOcclusion: boolean;
  57767. /**
  57768. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57769. */
  57770. protected _useAlphaFromAlbedoTexture: boolean;
  57771. /**
  57772. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  57773. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57774. */
  57775. protected _useSpecularOverAlpha: boolean;
  57776. /**
  57777. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57778. */
  57779. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57780. /**
  57781. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57782. */
  57783. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  57784. /**
  57785. * Specifies if the metallic texture contains the roughness information in its green channel.
  57786. */
  57787. protected _useRoughnessFromMetallicTextureGreen: boolean;
  57788. /**
  57789. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57790. */
  57791. protected _useMetallnessFromMetallicTextureBlue: boolean;
  57792. /**
  57793. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57794. */
  57795. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  57796. /**
  57797. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57798. */
  57799. protected _useAmbientInGrayScale: boolean;
  57800. /**
  57801. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57802. * The material will try to infer what glossiness each pixel should be.
  57803. */
  57804. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  57805. /**
  57806. * Defines the falloff type used in this material.
  57807. * It by default is Physical.
  57808. */
  57809. protected _lightFalloff: number;
  57810. /**
  57811. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57812. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57813. */
  57814. protected _useRadianceOverAlpha: boolean;
  57815. /**
  57816. * Allows using an object space normal map (instead of tangent space).
  57817. */
  57818. protected _useObjectSpaceNormalMap: boolean;
  57819. /**
  57820. * Allows using the bump map in parallax mode.
  57821. */
  57822. protected _useParallax: boolean;
  57823. /**
  57824. * Allows using the bump map in parallax occlusion mode.
  57825. */
  57826. protected _useParallaxOcclusion: boolean;
  57827. /**
  57828. * Controls the scale bias of the parallax mode.
  57829. */
  57830. protected _parallaxScaleBias: number;
  57831. /**
  57832. * If sets to true, disables all the lights affecting the material.
  57833. */
  57834. protected _disableLighting: boolean;
  57835. /**
  57836. * Number of Simultaneous lights allowed on the material.
  57837. */
  57838. protected _maxSimultaneousLights: number;
  57839. /**
  57840. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57841. */
  57842. protected _invertNormalMapX: boolean;
  57843. /**
  57844. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57845. */
  57846. protected _invertNormalMapY: boolean;
  57847. /**
  57848. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57849. */
  57850. protected _twoSidedLighting: boolean;
  57851. /**
  57852. * Defines the alpha limits in alpha test mode.
  57853. */
  57854. protected _alphaCutOff: number;
  57855. /**
  57856. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57857. */
  57858. protected _forceAlphaTest: boolean;
  57859. /**
  57860. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57861. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57862. */
  57863. protected _useAlphaFresnel: boolean;
  57864. /**
  57865. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57866. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57867. */
  57868. protected _useLinearAlphaFresnel: boolean;
  57869. /**
  57870. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  57871. * from cos thetav and roughness:
  57872. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  57873. */
  57874. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  57875. /**
  57876. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57877. */
  57878. protected _forceIrradianceInFragment: boolean;
  57879. private _realTimeFiltering;
  57880. /**
  57881. * Enables realtime filtering on the texture.
  57882. */
  57883. get realTimeFiltering(): boolean;
  57884. set realTimeFiltering(b: boolean);
  57885. private _realTimeFilteringQuality;
  57886. /**
  57887. * Quality switch for realtime filtering
  57888. */
  57889. get realTimeFilteringQuality(): number;
  57890. set realTimeFilteringQuality(n: number);
  57891. /**
  57892. * Force normal to face away from face.
  57893. */
  57894. protected _forceNormalForward: boolean;
  57895. /**
  57896. * Enables specular anti aliasing in the PBR shader.
  57897. * It will both interacts on the Geometry for analytical and IBL lighting.
  57898. * It also prefilter the roughness map based on the bump values.
  57899. */
  57900. protected _enableSpecularAntiAliasing: boolean;
  57901. /**
  57902. * Default configuration related to image processing available in the PBR Material.
  57903. */
  57904. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57905. /**
  57906. * Keep track of the image processing observer to allow dispose and replace.
  57907. */
  57908. private _imageProcessingObserver;
  57909. /**
  57910. * Attaches a new image processing configuration to the PBR Material.
  57911. * @param configuration
  57912. */
  57913. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57914. /**
  57915. * Stores the available render targets.
  57916. */
  57917. private _renderTargets;
  57918. /**
  57919. * Sets the global ambient color for the material used in lighting calculations.
  57920. */
  57921. private _globalAmbientColor;
  57922. /**
  57923. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  57924. */
  57925. private _useLogarithmicDepth;
  57926. /**
  57927. * If set to true, no lighting calculations will be applied.
  57928. */
  57929. private _unlit;
  57930. private _debugMode;
  57931. /**
  57932. * @hidden
  57933. * This is reserved for the inspector.
  57934. * Defines the material debug mode.
  57935. * It helps seeing only some components of the material while troubleshooting.
  57936. */
  57937. debugMode: number;
  57938. /**
  57939. * @hidden
  57940. * This is reserved for the inspector.
  57941. * Specify from where on screen the debug mode should start.
  57942. * The value goes from -1 (full screen) to 1 (not visible)
  57943. * It helps with side by side comparison against the final render
  57944. * This defaults to -1
  57945. */
  57946. private debugLimit;
  57947. /**
  57948. * @hidden
  57949. * This is reserved for the inspector.
  57950. * As the default viewing range might not be enough (if the ambient is really small for instance)
  57951. * You can use the factor to better multiply the final value.
  57952. */
  57953. private debugFactor;
  57954. /**
  57955. * Defines the clear coat layer parameters for the material.
  57956. */
  57957. readonly clearCoat: PBRClearCoatConfiguration;
  57958. /**
  57959. * Defines the anisotropic parameters for the material.
  57960. */
  57961. readonly anisotropy: PBRAnisotropicConfiguration;
  57962. /**
  57963. * Defines the BRDF parameters for the material.
  57964. */
  57965. readonly brdf: PBRBRDFConfiguration;
  57966. /**
  57967. * Defines the Sheen parameters for the material.
  57968. */
  57969. readonly sheen: PBRSheenConfiguration;
  57970. /**
  57971. * Defines the SubSurface parameters for the material.
  57972. */
  57973. readonly subSurface: PBRSubSurfaceConfiguration;
  57974. /**
  57975. * Defines the detail map parameters for the material.
  57976. */
  57977. readonly detailMap: DetailMapConfiguration;
  57978. protected _rebuildInParallel: boolean;
  57979. /**
  57980. * Instantiates a new PBRMaterial instance.
  57981. *
  57982. * @param name The material name
  57983. * @param scene The scene the material will be use in.
  57984. */
  57985. constructor(name: string, scene: Scene);
  57986. /**
  57987. * Gets a boolean indicating that current material needs to register RTT
  57988. */
  57989. get hasRenderTargetTextures(): boolean;
  57990. /**
  57991. * Gets the name of the material class.
  57992. */
  57993. getClassName(): string;
  57994. /**
  57995. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57996. */
  57997. get useLogarithmicDepth(): boolean;
  57998. /**
  57999. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58000. */
  58001. set useLogarithmicDepth(value: boolean);
  58002. /**
  58003. * Returns true if alpha blending should be disabled.
  58004. */
  58005. protected get _disableAlphaBlending(): boolean;
  58006. /**
  58007. * Specifies whether or not this material should be rendered in alpha blend mode.
  58008. */
  58009. needAlphaBlending(): boolean;
  58010. /**
  58011. * Specifies whether or not this material should be rendered in alpha test mode.
  58012. */
  58013. needAlphaTesting(): boolean;
  58014. /**
  58015. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  58016. */
  58017. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  58018. /**
  58019. * Gets the texture used for the alpha test.
  58020. */
  58021. getAlphaTestTexture(): Nullable<BaseTexture>;
  58022. /**
  58023. * Specifies that the submesh is ready to be used.
  58024. * @param mesh - BJS mesh.
  58025. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  58026. * @param useInstances - Specifies that instances should be used.
  58027. * @returns - boolean indicating that the submesh is ready or not.
  58028. */
  58029. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58030. /**
  58031. * Specifies if the material uses metallic roughness workflow.
  58032. * @returns boolean specifiying if the material uses metallic roughness workflow.
  58033. */
  58034. isMetallicWorkflow(): boolean;
  58035. private _prepareEffect;
  58036. private _prepareDefines;
  58037. /**
  58038. * Force shader compilation
  58039. */
  58040. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  58041. /**
  58042. * Initializes the uniform buffer layout for the shader.
  58043. */
  58044. buildUniformLayout(): void;
  58045. /**
  58046. * Unbinds the material from the mesh
  58047. */
  58048. unbind(): void;
  58049. /**
  58050. * Binds the submesh data.
  58051. * @param world - The world matrix.
  58052. * @param mesh - The BJS mesh.
  58053. * @param subMesh - A submesh of the BJS mesh.
  58054. */
  58055. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58056. /**
  58057. * Returns the animatable textures.
  58058. * @returns - Array of animatable textures.
  58059. */
  58060. getAnimatables(): IAnimatable[];
  58061. /**
  58062. * Returns the texture used for reflections.
  58063. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  58064. */
  58065. private _getReflectionTexture;
  58066. /**
  58067. * Returns an array of the actively used textures.
  58068. * @returns - Array of BaseTextures
  58069. */
  58070. getActiveTextures(): BaseTexture[];
  58071. /**
  58072. * Checks to see if a texture is used in the material.
  58073. * @param texture - Base texture to use.
  58074. * @returns - Boolean specifying if a texture is used in the material.
  58075. */
  58076. hasTexture(texture: BaseTexture): boolean;
  58077. /**
  58078. * Disposes the resources of the material.
  58079. * @param forceDisposeEffect - Forces the disposal of effects.
  58080. * @param forceDisposeTextures - Forces the disposal of all textures.
  58081. */
  58082. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58083. }
  58084. }
  58085. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  58086. import { Nullable } from "babylonjs/types";
  58087. import { Scene } from "babylonjs/scene";
  58088. import { Color3 } from "babylonjs/Maths/math.color";
  58089. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  58090. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  58091. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58092. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58093. /**
  58094. * The Physically based material of BJS.
  58095. *
  58096. * This offers the main features of a standard PBR material.
  58097. * For more information, please refer to the documentation :
  58098. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58099. */
  58100. export class PBRMaterial extends PBRBaseMaterial {
  58101. /**
  58102. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58103. */
  58104. static readonly PBRMATERIAL_OPAQUE: number;
  58105. /**
  58106. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58107. */
  58108. static readonly PBRMATERIAL_ALPHATEST: number;
  58109. /**
  58110. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58111. */
  58112. static readonly PBRMATERIAL_ALPHABLEND: number;
  58113. /**
  58114. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58115. * They are also discarded below the alpha cutoff threshold to improve performances.
  58116. */
  58117. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58118. /**
  58119. * Defines the default value of how much AO map is occluding the analytical lights
  58120. * (point spot...).
  58121. */
  58122. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58123. /**
  58124. * Intensity of the direct lights e.g. the four lights available in your scene.
  58125. * This impacts both the direct diffuse and specular highlights.
  58126. */
  58127. directIntensity: number;
  58128. /**
  58129. * Intensity of the emissive part of the material.
  58130. * This helps controlling the emissive effect without modifying the emissive color.
  58131. */
  58132. emissiveIntensity: number;
  58133. /**
  58134. * Intensity of the environment e.g. how much the environment will light the object
  58135. * either through harmonics for rough material or through the refelction for shiny ones.
  58136. */
  58137. environmentIntensity: number;
  58138. /**
  58139. * This is a special control allowing the reduction of the specular highlights coming from the
  58140. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58141. */
  58142. specularIntensity: number;
  58143. /**
  58144. * Debug Control allowing disabling the bump map on this material.
  58145. */
  58146. disableBumpMap: boolean;
  58147. /**
  58148. * AKA Diffuse Texture in standard nomenclature.
  58149. */
  58150. albedoTexture: BaseTexture;
  58151. /**
  58152. * AKA Occlusion Texture in other nomenclature.
  58153. */
  58154. ambientTexture: BaseTexture;
  58155. /**
  58156. * AKA Occlusion Texture Intensity in other nomenclature.
  58157. */
  58158. ambientTextureStrength: number;
  58159. /**
  58160. * Defines how much the AO map is occluding the analytical lights (point spot...).
  58161. * 1 means it completely occludes it
  58162. * 0 mean it has no impact
  58163. */
  58164. ambientTextureImpactOnAnalyticalLights: number;
  58165. /**
  58166. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  58167. */
  58168. opacityTexture: BaseTexture;
  58169. /**
  58170. * Stores the reflection values in a texture.
  58171. */
  58172. reflectionTexture: Nullable<BaseTexture>;
  58173. /**
  58174. * Stores the emissive values in a texture.
  58175. */
  58176. emissiveTexture: BaseTexture;
  58177. /**
  58178. * AKA Specular texture in other nomenclature.
  58179. */
  58180. reflectivityTexture: BaseTexture;
  58181. /**
  58182. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58183. */
  58184. metallicTexture: BaseTexture;
  58185. /**
  58186. * Specifies the metallic scalar of the metallic/roughness workflow.
  58187. * Can also be used to scale the metalness values of the metallic texture.
  58188. */
  58189. metallic: Nullable<number>;
  58190. /**
  58191. * Specifies the roughness scalar of the metallic/roughness workflow.
  58192. * Can also be used to scale the roughness values of the metallic texture.
  58193. */
  58194. roughness: Nullable<number>;
  58195. /**
  58196. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58197. * By default the indexOfrefraction is used to compute F0;
  58198. *
  58199. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58200. *
  58201. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58202. * F90 = metallicReflectanceColor;
  58203. */
  58204. metallicF0Factor: number;
  58205. /**
  58206. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58207. * By default the F90 is always 1;
  58208. *
  58209. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58210. *
  58211. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58212. * F90 = metallicReflectanceColor;
  58213. */
  58214. metallicReflectanceColor: Color3;
  58215. /**
  58216. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58217. * This is multiply against the scalar values defined in the material.
  58218. */
  58219. metallicReflectanceTexture: Nullable<BaseTexture>;
  58220. /**
  58221. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58222. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58223. */
  58224. microSurfaceTexture: BaseTexture;
  58225. /**
  58226. * Stores surface normal data used to displace a mesh in a texture.
  58227. */
  58228. bumpTexture: BaseTexture;
  58229. /**
  58230. * Stores the pre-calculated light information of a mesh in a texture.
  58231. */
  58232. lightmapTexture: BaseTexture;
  58233. /**
  58234. * Stores the refracted light information in a texture.
  58235. */
  58236. get refractionTexture(): Nullable<BaseTexture>;
  58237. set refractionTexture(value: Nullable<BaseTexture>);
  58238. /**
  58239. * The color of a material in ambient lighting.
  58240. */
  58241. ambientColor: Color3;
  58242. /**
  58243. * AKA Diffuse Color in other nomenclature.
  58244. */
  58245. albedoColor: Color3;
  58246. /**
  58247. * AKA Specular Color in other nomenclature.
  58248. */
  58249. reflectivityColor: Color3;
  58250. /**
  58251. * The color reflected from the material.
  58252. */
  58253. reflectionColor: Color3;
  58254. /**
  58255. * The color emitted from the material.
  58256. */
  58257. emissiveColor: Color3;
  58258. /**
  58259. * AKA Glossiness in other nomenclature.
  58260. */
  58261. microSurface: number;
  58262. /**
  58263. * Index of refraction of the material base layer.
  58264. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58265. *
  58266. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58267. *
  58268. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58269. */
  58270. get indexOfRefraction(): number;
  58271. set indexOfRefraction(value: number);
  58272. /**
  58273. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58274. */
  58275. get invertRefractionY(): boolean;
  58276. set invertRefractionY(value: boolean);
  58277. /**
  58278. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58279. * Materials half opaque for instance using refraction could benefit from this control.
  58280. */
  58281. get linkRefractionWithTransparency(): boolean;
  58282. set linkRefractionWithTransparency(value: boolean);
  58283. /**
  58284. * If true, the light map contains occlusion information instead of lighting info.
  58285. */
  58286. useLightmapAsShadowmap: boolean;
  58287. /**
  58288. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58289. */
  58290. useAlphaFromAlbedoTexture: boolean;
  58291. /**
  58292. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58293. */
  58294. forceAlphaTest: boolean;
  58295. /**
  58296. * Defines the alpha limits in alpha test mode.
  58297. */
  58298. alphaCutOff: number;
  58299. /**
  58300. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  58301. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58302. */
  58303. useSpecularOverAlpha: boolean;
  58304. /**
  58305. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  58306. */
  58307. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  58308. /**
  58309. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  58310. */
  58311. useRoughnessFromMetallicTextureAlpha: boolean;
  58312. /**
  58313. * Specifies if the metallic texture contains the roughness information in its green channel.
  58314. */
  58315. useRoughnessFromMetallicTextureGreen: boolean;
  58316. /**
  58317. * Specifies if the metallic texture contains the metallness information in its blue channel.
  58318. */
  58319. useMetallnessFromMetallicTextureBlue: boolean;
  58320. /**
  58321. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  58322. */
  58323. useAmbientOcclusionFromMetallicTextureRed: boolean;
  58324. /**
  58325. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  58326. */
  58327. useAmbientInGrayScale: boolean;
  58328. /**
  58329. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58330. * The material will try to infer what glossiness each pixel should be.
  58331. */
  58332. useAutoMicroSurfaceFromReflectivityMap: boolean;
  58333. /**
  58334. * BJS is using an harcoded light falloff based on a manually sets up range.
  58335. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58336. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58337. */
  58338. get usePhysicalLightFalloff(): boolean;
  58339. /**
  58340. * BJS is using an harcoded light falloff based on a manually sets up range.
  58341. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58342. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58343. */
  58344. set usePhysicalLightFalloff(value: boolean);
  58345. /**
  58346. * In order to support the falloff compatibility with gltf, a special mode has been added
  58347. * to reproduce the gltf light falloff.
  58348. */
  58349. get useGLTFLightFalloff(): boolean;
  58350. /**
  58351. * In order to support the falloff compatibility with gltf, a special mode has been added
  58352. * to reproduce the gltf light falloff.
  58353. */
  58354. set useGLTFLightFalloff(value: boolean);
  58355. /**
  58356. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58357. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58358. */
  58359. useRadianceOverAlpha: boolean;
  58360. /**
  58361. * Allows using an object space normal map (instead of tangent space).
  58362. */
  58363. useObjectSpaceNormalMap: boolean;
  58364. /**
  58365. * Allows using the bump map in parallax mode.
  58366. */
  58367. useParallax: boolean;
  58368. /**
  58369. * Allows using the bump map in parallax occlusion mode.
  58370. */
  58371. useParallaxOcclusion: boolean;
  58372. /**
  58373. * Controls the scale bias of the parallax mode.
  58374. */
  58375. parallaxScaleBias: number;
  58376. /**
  58377. * If sets to true, disables all the lights affecting the material.
  58378. */
  58379. disableLighting: boolean;
  58380. /**
  58381. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58382. */
  58383. forceIrradianceInFragment: boolean;
  58384. /**
  58385. * Number of Simultaneous lights allowed on the material.
  58386. */
  58387. maxSimultaneousLights: number;
  58388. /**
  58389. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58390. */
  58391. invertNormalMapX: boolean;
  58392. /**
  58393. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58394. */
  58395. invertNormalMapY: boolean;
  58396. /**
  58397. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58398. */
  58399. twoSidedLighting: boolean;
  58400. /**
  58401. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58402. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58403. */
  58404. useAlphaFresnel: boolean;
  58405. /**
  58406. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58407. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58408. */
  58409. useLinearAlphaFresnel: boolean;
  58410. /**
  58411. * Let user defines the brdf lookup texture used for IBL.
  58412. * A default 8bit version is embedded but you could point at :
  58413. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  58414. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  58415. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  58416. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  58417. */
  58418. environmentBRDFTexture: Nullable<BaseTexture>;
  58419. /**
  58420. * Force normal to face away from face.
  58421. */
  58422. forceNormalForward: boolean;
  58423. /**
  58424. * Enables specular anti aliasing in the PBR shader.
  58425. * It will both interacts on the Geometry for analytical and IBL lighting.
  58426. * It also prefilter the roughness map based on the bump values.
  58427. */
  58428. enableSpecularAntiAliasing: boolean;
  58429. /**
  58430. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58431. * makes the reflect vector face the model (under horizon).
  58432. */
  58433. useHorizonOcclusion: boolean;
  58434. /**
  58435. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58436. * too much the area relying on ambient texture to define their ambient occlusion.
  58437. */
  58438. useRadianceOcclusion: boolean;
  58439. /**
  58440. * If set to true, no lighting calculations will be applied.
  58441. */
  58442. unlit: boolean;
  58443. /**
  58444. * Gets the image processing configuration used either in this material.
  58445. */
  58446. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58447. /**
  58448. * Sets the Default image processing configuration used either in the this material.
  58449. *
  58450. * If sets to null, the scene one is in use.
  58451. */
  58452. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58453. /**
  58454. * Gets wether the color curves effect is enabled.
  58455. */
  58456. get cameraColorCurvesEnabled(): boolean;
  58457. /**
  58458. * Sets wether the color curves effect is enabled.
  58459. */
  58460. set cameraColorCurvesEnabled(value: boolean);
  58461. /**
  58462. * Gets wether the color grading effect is enabled.
  58463. */
  58464. get cameraColorGradingEnabled(): boolean;
  58465. /**
  58466. * Gets wether the color grading effect is enabled.
  58467. */
  58468. set cameraColorGradingEnabled(value: boolean);
  58469. /**
  58470. * Gets wether tonemapping is enabled or not.
  58471. */
  58472. get cameraToneMappingEnabled(): boolean;
  58473. /**
  58474. * Sets wether tonemapping is enabled or not
  58475. */
  58476. set cameraToneMappingEnabled(value: boolean);
  58477. /**
  58478. * The camera exposure used on this material.
  58479. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58480. * This corresponds to a photographic exposure.
  58481. */
  58482. get cameraExposure(): number;
  58483. /**
  58484. * The camera exposure used on this material.
  58485. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58486. * This corresponds to a photographic exposure.
  58487. */
  58488. set cameraExposure(value: number);
  58489. /**
  58490. * Gets The camera contrast used on this material.
  58491. */
  58492. get cameraContrast(): number;
  58493. /**
  58494. * Sets The camera contrast used on this material.
  58495. */
  58496. set cameraContrast(value: number);
  58497. /**
  58498. * Gets the Color Grading 2D Lookup Texture.
  58499. */
  58500. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58501. /**
  58502. * Sets the Color Grading 2D Lookup Texture.
  58503. */
  58504. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58505. /**
  58506. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58507. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58508. * 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;
  58509. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58510. */
  58511. get cameraColorCurves(): Nullable<ColorCurves>;
  58512. /**
  58513. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58514. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58515. * 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;
  58516. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58517. */
  58518. set cameraColorCurves(value: Nullable<ColorCurves>);
  58519. /**
  58520. * Instantiates a new PBRMaterial instance.
  58521. *
  58522. * @param name The material name
  58523. * @param scene The scene the material will be use in.
  58524. */
  58525. constructor(name: string, scene: Scene);
  58526. /**
  58527. * Returns the name of this material class.
  58528. */
  58529. getClassName(): string;
  58530. /**
  58531. * Makes a duplicate of the current material.
  58532. * @param name - name to use for the new material.
  58533. */
  58534. clone(name: string): PBRMaterial;
  58535. /**
  58536. * Serializes this PBR Material.
  58537. * @returns - An object with the serialized material.
  58538. */
  58539. serialize(): any;
  58540. /**
  58541. * Parses a PBR Material from a serialized object.
  58542. * @param source - Serialized object.
  58543. * @param scene - BJS scene instance.
  58544. * @param rootUrl - url for the scene object
  58545. * @returns - PBRMaterial
  58546. */
  58547. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  58548. }
  58549. }
  58550. declare module "babylonjs/Misc/dds" {
  58551. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58552. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58553. import { Nullable } from "babylonjs/types";
  58554. import { Scene } from "babylonjs/scene";
  58555. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  58556. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58557. /**
  58558. * Direct draw surface info
  58559. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58560. */
  58561. export interface DDSInfo {
  58562. /**
  58563. * Width of the texture
  58564. */
  58565. width: number;
  58566. /**
  58567. * Width of the texture
  58568. */
  58569. height: number;
  58570. /**
  58571. * Number of Mipmaps for the texture
  58572. * @see https://en.wikipedia.org/wiki/Mipmap
  58573. */
  58574. mipmapCount: number;
  58575. /**
  58576. * If the textures format is a known fourCC format
  58577. * @see https://www.fourcc.org/
  58578. */
  58579. isFourCC: boolean;
  58580. /**
  58581. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58582. */
  58583. isRGB: boolean;
  58584. /**
  58585. * If the texture is a lumincance format
  58586. */
  58587. isLuminance: boolean;
  58588. /**
  58589. * If this is a cube texture
  58590. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58591. */
  58592. isCube: boolean;
  58593. /**
  58594. * If the texture is a compressed format eg. FOURCC_DXT1
  58595. */
  58596. isCompressed: boolean;
  58597. /**
  58598. * The dxgiFormat of the texture
  58599. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58600. */
  58601. dxgiFormat: number;
  58602. /**
  58603. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58604. */
  58605. textureType: number;
  58606. /**
  58607. * Sphericle polynomial created for the dds texture
  58608. */
  58609. sphericalPolynomial?: SphericalPolynomial;
  58610. }
  58611. /**
  58612. * Class used to provide DDS decompression tools
  58613. */
  58614. export class DDSTools {
  58615. /**
  58616. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58617. */
  58618. static StoreLODInAlphaChannel: boolean;
  58619. /**
  58620. * Gets DDS information from an array buffer
  58621. * @param data defines the array buffer view to read data from
  58622. * @returns the DDS information
  58623. */
  58624. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58625. private static _FloatView;
  58626. private static _Int32View;
  58627. private static _ToHalfFloat;
  58628. private static _FromHalfFloat;
  58629. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58630. private static _GetHalfFloatRGBAArrayBuffer;
  58631. private static _GetFloatRGBAArrayBuffer;
  58632. private static _GetFloatAsUIntRGBAArrayBuffer;
  58633. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58634. private static _GetRGBAArrayBuffer;
  58635. private static _ExtractLongWordOrder;
  58636. private static _GetRGBArrayBuffer;
  58637. private static _GetLuminanceArrayBuffer;
  58638. /**
  58639. * Uploads DDS Levels to a Babylon Texture
  58640. * @hidden
  58641. */
  58642. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58643. }
  58644. module "babylonjs/Engines/thinEngine" {
  58645. interface ThinEngine {
  58646. /**
  58647. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58648. * @param rootUrl defines the url where the file to load is located
  58649. * @param scene defines the current scene
  58650. * @param lodScale defines scale to apply to the mip map selection
  58651. * @param lodOffset defines offset to apply to the mip map selection
  58652. * @param onLoad defines an optional callback raised when the texture is loaded
  58653. * @param onError defines an optional callback raised if there is an issue to load the texture
  58654. * @param format defines the format of the data
  58655. * @param forcedExtension defines the extension to use to pick the right loader
  58656. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58657. * @returns the cube texture as an InternalTexture
  58658. */
  58659. 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;
  58660. }
  58661. }
  58662. }
  58663. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  58664. import { Nullable } from "babylonjs/types";
  58665. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58666. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58667. /**
  58668. * Implementation of the DDS Texture Loader.
  58669. * @hidden
  58670. */
  58671. export class _DDSTextureLoader implements IInternalTextureLoader {
  58672. /**
  58673. * Defines wether the loader supports cascade loading the different faces.
  58674. */
  58675. readonly supportCascades: boolean;
  58676. /**
  58677. * This returns if the loader support the current file information.
  58678. * @param extension defines the file extension of the file being loaded
  58679. * @returns true if the loader can load the specified file
  58680. */
  58681. canLoad(extension: string): boolean;
  58682. /**
  58683. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58684. * @param data contains the texture data
  58685. * @param texture defines the BabylonJS internal texture
  58686. * @param createPolynomials will be true if polynomials have been requested
  58687. * @param onLoad defines the callback to trigger once the texture is ready
  58688. * @param onError defines the callback to trigger in case of error
  58689. */
  58690. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58691. /**
  58692. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58693. * @param data contains the texture data
  58694. * @param texture defines the BabylonJS internal texture
  58695. * @param callback defines the method to call once ready to upload
  58696. */
  58697. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58698. }
  58699. }
  58700. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  58701. import { Nullable } from "babylonjs/types";
  58702. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58703. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58704. /**
  58705. * Implementation of the ENV Texture Loader.
  58706. * @hidden
  58707. */
  58708. export class _ENVTextureLoader implements IInternalTextureLoader {
  58709. /**
  58710. * Defines wether the loader supports cascade loading the different faces.
  58711. */
  58712. readonly supportCascades: boolean;
  58713. /**
  58714. * This returns if the loader support the current file information.
  58715. * @param extension defines the file extension of the file being loaded
  58716. * @returns true if the loader can load the specified file
  58717. */
  58718. canLoad(extension: string): boolean;
  58719. /**
  58720. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58721. * @param data contains the texture data
  58722. * @param texture defines the BabylonJS internal texture
  58723. * @param createPolynomials will be true if polynomials have been requested
  58724. * @param onLoad defines the callback to trigger once the texture is ready
  58725. * @param onError defines the callback to trigger in case of error
  58726. */
  58727. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58728. /**
  58729. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58730. * @param data contains the texture data
  58731. * @param texture defines the BabylonJS internal texture
  58732. * @param callback defines the method to call once ready to upload
  58733. */
  58734. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58735. }
  58736. }
  58737. declare module "babylonjs/Misc/khronosTextureContainer" {
  58738. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58739. /**
  58740. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58741. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58742. */
  58743. export class KhronosTextureContainer {
  58744. /** contents of the KTX container file */
  58745. data: ArrayBufferView;
  58746. private static HEADER_LEN;
  58747. private static COMPRESSED_2D;
  58748. private static COMPRESSED_3D;
  58749. private static TEX_2D;
  58750. private static TEX_3D;
  58751. /**
  58752. * Gets the openGL type
  58753. */
  58754. glType: number;
  58755. /**
  58756. * Gets the openGL type size
  58757. */
  58758. glTypeSize: number;
  58759. /**
  58760. * Gets the openGL format
  58761. */
  58762. glFormat: number;
  58763. /**
  58764. * Gets the openGL internal format
  58765. */
  58766. glInternalFormat: number;
  58767. /**
  58768. * Gets the base internal format
  58769. */
  58770. glBaseInternalFormat: number;
  58771. /**
  58772. * Gets image width in pixel
  58773. */
  58774. pixelWidth: number;
  58775. /**
  58776. * Gets image height in pixel
  58777. */
  58778. pixelHeight: number;
  58779. /**
  58780. * Gets image depth in pixels
  58781. */
  58782. pixelDepth: number;
  58783. /**
  58784. * Gets the number of array elements
  58785. */
  58786. numberOfArrayElements: number;
  58787. /**
  58788. * Gets the number of faces
  58789. */
  58790. numberOfFaces: number;
  58791. /**
  58792. * Gets the number of mipmap levels
  58793. */
  58794. numberOfMipmapLevels: number;
  58795. /**
  58796. * Gets the bytes of key value data
  58797. */
  58798. bytesOfKeyValueData: number;
  58799. /**
  58800. * Gets the load type
  58801. */
  58802. loadType: number;
  58803. /**
  58804. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58805. */
  58806. isInvalid: boolean;
  58807. /**
  58808. * Creates a new KhronosTextureContainer
  58809. * @param data contents of the KTX container file
  58810. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58811. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58812. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58813. */
  58814. constructor(
  58815. /** contents of the KTX container file */
  58816. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58817. /**
  58818. * Uploads KTX content to a Babylon Texture.
  58819. * It is assumed that the texture has already been created & is currently bound
  58820. * @hidden
  58821. */
  58822. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58823. private _upload2DCompressedLevels;
  58824. /**
  58825. * Checks if the given data starts with a KTX file identifier.
  58826. * @param data the data to check
  58827. * @returns true if the data is a KTX file or false otherwise
  58828. */
  58829. static IsValid(data: ArrayBufferView): boolean;
  58830. }
  58831. }
  58832. declare module "babylonjs/Misc/khronosTextureContainer2" {
  58833. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58834. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58835. /**
  58836. * Class for loading KTX2 files
  58837. * !!! Experimental Extension Subject to Changes !!!
  58838. * @hidden
  58839. */
  58840. export class KhronosTextureContainer2 {
  58841. private static _ModulePromise;
  58842. private static _TranscodeFormat;
  58843. constructor(engine: ThinEngine);
  58844. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  58845. private _determineTranscodeFormat;
  58846. /**
  58847. * Checks if the given data starts with a KTX2 file identifier.
  58848. * @param data the data to check
  58849. * @returns true if the data is a KTX2 file or false otherwise
  58850. */
  58851. static IsValid(data: ArrayBufferView): boolean;
  58852. }
  58853. }
  58854. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  58855. import { Nullable } from "babylonjs/types";
  58856. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58857. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58858. /**
  58859. * Implementation of the KTX Texture Loader.
  58860. * @hidden
  58861. */
  58862. export class _KTXTextureLoader implements IInternalTextureLoader {
  58863. /**
  58864. * Defines wether the loader supports cascade loading the different faces.
  58865. */
  58866. readonly supportCascades: boolean;
  58867. /**
  58868. * This returns if the loader support the current file information.
  58869. * @param extension defines the file extension of the file being loaded
  58870. * @returns true if the loader can load the specified file
  58871. */
  58872. canLoad(extension: string): boolean;
  58873. /**
  58874. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58875. * @param data contains the texture data
  58876. * @param texture defines the BabylonJS internal texture
  58877. * @param createPolynomials will be true if polynomials have been requested
  58878. * @param onLoad defines the callback to trigger once the texture is ready
  58879. * @param onError defines the callback to trigger in case of error
  58880. */
  58881. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58882. /**
  58883. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58884. * @param data contains the texture data
  58885. * @param texture defines the BabylonJS internal texture
  58886. * @param callback defines the method to call once ready to upload
  58887. */
  58888. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  58889. }
  58890. }
  58891. declare module "babylonjs/Helpers/sceneHelpers" {
  58892. import { Nullable } from "babylonjs/types";
  58893. import { Mesh } from "babylonjs/Meshes/mesh";
  58894. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58895. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  58896. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  58897. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58898. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58899. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58900. import "babylonjs/Meshes/Builders/boxBuilder";
  58901. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  58902. /** @hidden */
  58903. export var _forceSceneHelpersToBundle: boolean;
  58904. module "babylonjs/scene" {
  58905. interface Scene {
  58906. /**
  58907. * Creates a default light for the scene.
  58908. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58909. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58910. */
  58911. createDefaultLight(replace?: boolean): void;
  58912. /**
  58913. * Creates a default camera for the scene.
  58914. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58915. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58916. * @param replace has default false, when true replaces the active camera in the scene
  58917. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58918. */
  58919. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58920. /**
  58921. * Creates a default camera and a default light.
  58922. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58923. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58924. * @param replace has the default false, when true replaces the active camera/light in the scene
  58925. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58926. */
  58927. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58928. /**
  58929. * Creates a new sky box
  58930. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58931. * @param environmentTexture defines the texture to use as environment texture
  58932. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58933. * @param scale defines the overall scale of the skybox
  58934. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58935. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58936. * @returns a new mesh holding the sky box
  58937. */
  58938. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58939. /**
  58940. * Creates a new environment
  58941. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58942. * @param options defines the options you can use to configure the environment
  58943. * @returns the new EnvironmentHelper
  58944. */
  58945. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58946. /**
  58947. * Creates a new VREXperienceHelper
  58948. * @see http://doc.babylonjs.com/how_to/webvr_helper
  58949. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58950. * @returns a new VREXperienceHelper
  58951. */
  58952. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58953. /**
  58954. * Creates a new WebXRDefaultExperience
  58955. * @see http://doc.babylonjs.com/how_to/webxr
  58956. * @param options experience options
  58957. * @returns a promise for a new WebXRDefaultExperience
  58958. */
  58959. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58960. }
  58961. }
  58962. }
  58963. declare module "babylonjs/Helpers/videoDome" {
  58964. import { Scene } from "babylonjs/scene";
  58965. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58966. import { Mesh } from "babylonjs/Meshes/mesh";
  58967. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  58968. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  58969. import "babylonjs/Meshes/Builders/sphereBuilder";
  58970. /**
  58971. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58972. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58973. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58974. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58975. */
  58976. export class VideoDome extends TransformNode {
  58977. /**
  58978. * Define the video source as a Monoscopic panoramic 360 video.
  58979. */
  58980. static readonly MODE_MONOSCOPIC: number;
  58981. /**
  58982. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58983. */
  58984. static readonly MODE_TOPBOTTOM: number;
  58985. /**
  58986. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58987. */
  58988. static readonly MODE_SIDEBYSIDE: number;
  58989. private _halfDome;
  58990. private _useDirectMapping;
  58991. /**
  58992. * The video texture being displayed on the sphere
  58993. */
  58994. protected _videoTexture: VideoTexture;
  58995. /**
  58996. * Gets the video texture being displayed on the sphere
  58997. */
  58998. get videoTexture(): VideoTexture;
  58999. /**
  59000. * The skybox material
  59001. */
  59002. protected _material: BackgroundMaterial;
  59003. /**
  59004. * The surface used for the skybox
  59005. */
  59006. protected _mesh: Mesh;
  59007. /**
  59008. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  59009. */
  59010. private _halfDomeMask;
  59011. /**
  59012. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  59013. * Also see the options.resolution property.
  59014. */
  59015. get fovMultiplier(): number;
  59016. set fovMultiplier(value: number);
  59017. private _videoMode;
  59018. /**
  59019. * Gets or set the current video mode for the video. It can be:
  59020. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  59021. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59022. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59023. */
  59024. get videoMode(): number;
  59025. set videoMode(value: number);
  59026. /**
  59027. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  59028. *
  59029. */
  59030. get halfDome(): boolean;
  59031. /**
  59032. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  59033. */
  59034. set halfDome(enabled: boolean);
  59035. /**
  59036. * Oberserver used in Stereoscopic VR Mode.
  59037. */
  59038. private _onBeforeCameraRenderObserver;
  59039. /**
  59040. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  59041. * @param name Element's name, child elements will append suffixes for their own names.
  59042. * @param urlsOrVideo defines the url(s) or the video element to use
  59043. * @param options An object containing optional or exposed sub element properties
  59044. */
  59045. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  59046. resolution?: number;
  59047. clickToPlay?: boolean;
  59048. autoPlay?: boolean;
  59049. loop?: boolean;
  59050. size?: number;
  59051. poster?: string;
  59052. faceForward?: boolean;
  59053. useDirectMapping?: boolean;
  59054. halfDomeMode?: boolean;
  59055. }, scene: Scene);
  59056. private _changeVideoMode;
  59057. /**
  59058. * Releases resources associated with this node.
  59059. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  59060. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  59061. */
  59062. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  59063. }
  59064. }
  59065. declare module "babylonjs/Helpers/index" {
  59066. export * from "babylonjs/Helpers/environmentHelper";
  59067. export * from "babylonjs/Helpers/photoDome";
  59068. export * from "babylonjs/Helpers/sceneHelpers";
  59069. export * from "babylonjs/Helpers/videoDome";
  59070. }
  59071. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  59072. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59073. import { IDisposable } from "babylonjs/scene";
  59074. import { Engine } from "babylonjs/Engines/engine";
  59075. /**
  59076. * This class can be used to get instrumentation data from a Babylon engine
  59077. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59078. */
  59079. export class EngineInstrumentation implements IDisposable {
  59080. /**
  59081. * Define the instrumented engine.
  59082. */
  59083. engine: Engine;
  59084. private _captureGPUFrameTime;
  59085. private _gpuFrameTimeToken;
  59086. private _gpuFrameTime;
  59087. private _captureShaderCompilationTime;
  59088. private _shaderCompilationTime;
  59089. private _onBeginFrameObserver;
  59090. private _onEndFrameObserver;
  59091. private _onBeforeShaderCompilationObserver;
  59092. private _onAfterShaderCompilationObserver;
  59093. /**
  59094. * Gets the perf counter used for GPU frame time
  59095. */
  59096. get gpuFrameTimeCounter(): PerfCounter;
  59097. /**
  59098. * Gets the GPU frame time capture status
  59099. */
  59100. get captureGPUFrameTime(): boolean;
  59101. /**
  59102. * Enable or disable the GPU frame time capture
  59103. */
  59104. set captureGPUFrameTime(value: boolean);
  59105. /**
  59106. * Gets the perf counter used for shader compilation time
  59107. */
  59108. get shaderCompilationTimeCounter(): PerfCounter;
  59109. /**
  59110. * Gets the shader compilation time capture status
  59111. */
  59112. get captureShaderCompilationTime(): boolean;
  59113. /**
  59114. * Enable or disable the shader compilation time capture
  59115. */
  59116. set captureShaderCompilationTime(value: boolean);
  59117. /**
  59118. * Instantiates a new engine instrumentation.
  59119. * This class can be used to get instrumentation data from a Babylon engine
  59120. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59121. * @param engine Defines the engine to instrument
  59122. */
  59123. constructor(
  59124. /**
  59125. * Define the instrumented engine.
  59126. */
  59127. engine: Engine);
  59128. /**
  59129. * Dispose and release associated resources.
  59130. */
  59131. dispose(): void;
  59132. }
  59133. }
  59134. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  59135. import { Scene, IDisposable } from "babylonjs/scene";
  59136. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59137. /**
  59138. * This class can be used to get instrumentation data from a Babylon engine
  59139. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59140. */
  59141. export class SceneInstrumentation implements IDisposable {
  59142. /**
  59143. * Defines the scene to instrument
  59144. */
  59145. scene: Scene;
  59146. private _captureActiveMeshesEvaluationTime;
  59147. private _activeMeshesEvaluationTime;
  59148. private _captureRenderTargetsRenderTime;
  59149. private _renderTargetsRenderTime;
  59150. private _captureFrameTime;
  59151. private _frameTime;
  59152. private _captureRenderTime;
  59153. private _renderTime;
  59154. private _captureInterFrameTime;
  59155. private _interFrameTime;
  59156. private _captureParticlesRenderTime;
  59157. private _particlesRenderTime;
  59158. private _captureSpritesRenderTime;
  59159. private _spritesRenderTime;
  59160. private _capturePhysicsTime;
  59161. private _physicsTime;
  59162. private _captureAnimationsTime;
  59163. private _animationsTime;
  59164. private _captureCameraRenderTime;
  59165. private _cameraRenderTime;
  59166. private _onBeforeActiveMeshesEvaluationObserver;
  59167. private _onAfterActiveMeshesEvaluationObserver;
  59168. private _onBeforeRenderTargetsRenderObserver;
  59169. private _onAfterRenderTargetsRenderObserver;
  59170. private _onAfterRenderObserver;
  59171. private _onBeforeDrawPhaseObserver;
  59172. private _onAfterDrawPhaseObserver;
  59173. private _onBeforeAnimationsObserver;
  59174. private _onBeforeParticlesRenderingObserver;
  59175. private _onAfterParticlesRenderingObserver;
  59176. private _onBeforeSpritesRenderingObserver;
  59177. private _onAfterSpritesRenderingObserver;
  59178. private _onBeforePhysicsObserver;
  59179. private _onAfterPhysicsObserver;
  59180. private _onAfterAnimationsObserver;
  59181. private _onBeforeCameraRenderObserver;
  59182. private _onAfterCameraRenderObserver;
  59183. /**
  59184. * Gets the perf counter used for active meshes evaluation time
  59185. */
  59186. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59187. /**
  59188. * Gets the active meshes evaluation time capture status
  59189. */
  59190. get captureActiveMeshesEvaluationTime(): boolean;
  59191. /**
  59192. * Enable or disable the active meshes evaluation time capture
  59193. */
  59194. set captureActiveMeshesEvaluationTime(value: boolean);
  59195. /**
  59196. * Gets the perf counter used for render targets render time
  59197. */
  59198. get renderTargetsRenderTimeCounter(): PerfCounter;
  59199. /**
  59200. * Gets the render targets render time capture status
  59201. */
  59202. get captureRenderTargetsRenderTime(): boolean;
  59203. /**
  59204. * Enable or disable the render targets render time capture
  59205. */
  59206. set captureRenderTargetsRenderTime(value: boolean);
  59207. /**
  59208. * Gets the perf counter used for particles render time
  59209. */
  59210. get particlesRenderTimeCounter(): PerfCounter;
  59211. /**
  59212. * Gets the particles render time capture status
  59213. */
  59214. get captureParticlesRenderTime(): boolean;
  59215. /**
  59216. * Enable or disable the particles render time capture
  59217. */
  59218. set captureParticlesRenderTime(value: boolean);
  59219. /**
  59220. * Gets the perf counter used for sprites render time
  59221. */
  59222. get spritesRenderTimeCounter(): PerfCounter;
  59223. /**
  59224. * Gets the sprites render time capture status
  59225. */
  59226. get captureSpritesRenderTime(): boolean;
  59227. /**
  59228. * Enable or disable the sprites render time capture
  59229. */
  59230. set captureSpritesRenderTime(value: boolean);
  59231. /**
  59232. * Gets the perf counter used for physics time
  59233. */
  59234. get physicsTimeCounter(): PerfCounter;
  59235. /**
  59236. * Gets the physics time capture status
  59237. */
  59238. get capturePhysicsTime(): boolean;
  59239. /**
  59240. * Enable or disable the physics time capture
  59241. */
  59242. set capturePhysicsTime(value: boolean);
  59243. /**
  59244. * Gets the perf counter used for animations time
  59245. */
  59246. get animationsTimeCounter(): PerfCounter;
  59247. /**
  59248. * Gets the animations time capture status
  59249. */
  59250. get captureAnimationsTime(): boolean;
  59251. /**
  59252. * Enable or disable the animations time capture
  59253. */
  59254. set captureAnimationsTime(value: boolean);
  59255. /**
  59256. * Gets the perf counter used for frame time capture
  59257. */
  59258. get frameTimeCounter(): PerfCounter;
  59259. /**
  59260. * Gets the frame time capture status
  59261. */
  59262. get captureFrameTime(): boolean;
  59263. /**
  59264. * Enable or disable the frame time capture
  59265. */
  59266. set captureFrameTime(value: boolean);
  59267. /**
  59268. * Gets the perf counter used for inter-frames time capture
  59269. */
  59270. get interFrameTimeCounter(): PerfCounter;
  59271. /**
  59272. * Gets the inter-frames time capture status
  59273. */
  59274. get captureInterFrameTime(): boolean;
  59275. /**
  59276. * Enable or disable the inter-frames time capture
  59277. */
  59278. set captureInterFrameTime(value: boolean);
  59279. /**
  59280. * Gets the perf counter used for render time capture
  59281. */
  59282. get renderTimeCounter(): PerfCounter;
  59283. /**
  59284. * Gets the render time capture status
  59285. */
  59286. get captureRenderTime(): boolean;
  59287. /**
  59288. * Enable or disable the render time capture
  59289. */
  59290. set captureRenderTime(value: boolean);
  59291. /**
  59292. * Gets the perf counter used for camera render time capture
  59293. */
  59294. get cameraRenderTimeCounter(): PerfCounter;
  59295. /**
  59296. * Gets the camera render time capture status
  59297. */
  59298. get captureCameraRenderTime(): boolean;
  59299. /**
  59300. * Enable or disable the camera render time capture
  59301. */
  59302. set captureCameraRenderTime(value: boolean);
  59303. /**
  59304. * Gets the perf counter used for draw calls
  59305. */
  59306. get drawCallsCounter(): PerfCounter;
  59307. /**
  59308. * Instantiates a new scene instrumentation.
  59309. * This class can be used to get instrumentation data from a Babylon engine
  59310. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59311. * @param scene Defines the scene to instrument
  59312. */
  59313. constructor(
  59314. /**
  59315. * Defines the scene to instrument
  59316. */
  59317. scene: Scene);
  59318. /**
  59319. * Dispose and release associated resources.
  59320. */
  59321. dispose(): void;
  59322. }
  59323. }
  59324. declare module "babylonjs/Instrumentation/index" {
  59325. export * from "babylonjs/Instrumentation/engineInstrumentation";
  59326. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  59327. export * from "babylonjs/Instrumentation/timeToken";
  59328. }
  59329. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  59330. /** @hidden */
  59331. export var glowMapGenerationPixelShader: {
  59332. name: string;
  59333. shader: string;
  59334. };
  59335. }
  59336. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  59337. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59338. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59339. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59340. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59341. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59342. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59343. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59344. /** @hidden */
  59345. export var glowMapGenerationVertexShader: {
  59346. name: string;
  59347. shader: string;
  59348. };
  59349. }
  59350. declare module "babylonjs/Layers/effectLayer" {
  59351. import { Observable } from "babylonjs/Misc/observable";
  59352. import { Nullable } from "babylonjs/types";
  59353. import { Camera } from "babylonjs/Cameras/camera";
  59354. import { Scene } from "babylonjs/scene";
  59355. import { ISize } from "babylonjs/Maths/math.size";
  59356. import { Color4 } from "babylonjs/Maths/math.color";
  59357. import { Engine } from "babylonjs/Engines/engine";
  59358. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59360. import { Mesh } from "babylonjs/Meshes/mesh";
  59361. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59362. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59363. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59364. import { Effect } from "babylonjs/Materials/effect";
  59365. import { Material } from "babylonjs/Materials/material";
  59366. import "babylonjs/Shaders/glowMapGeneration.fragment";
  59367. import "babylonjs/Shaders/glowMapGeneration.vertex";
  59368. /**
  59369. * Effect layer options. This helps customizing the behaviour
  59370. * of the effect layer.
  59371. */
  59372. export interface IEffectLayerOptions {
  59373. /**
  59374. * Multiplication factor apply to the canvas size to compute the render target size
  59375. * used to generated the objects (the smaller the faster).
  59376. */
  59377. mainTextureRatio: number;
  59378. /**
  59379. * Enforces a fixed size texture to ensure effect stability across devices.
  59380. */
  59381. mainTextureFixedSize?: number;
  59382. /**
  59383. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59384. */
  59385. alphaBlendingMode: number;
  59386. /**
  59387. * The camera attached to the layer.
  59388. */
  59389. camera: Nullable<Camera>;
  59390. /**
  59391. * The rendering group to draw the layer in.
  59392. */
  59393. renderingGroupId: number;
  59394. }
  59395. /**
  59396. * The effect layer Helps adding post process effect blended with the main pass.
  59397. *
  59398. * This can be for instance use to generate glow or higlight effects on the scene.
  59399. *
  59400. * The effect layer class can not be used directly and is intented to inherited from to be
  59401. * customized per effects.
  59402. */
  59403. export abstract class EffectLayer {
  59404. private _vertexBuffers;
  59405. private _indexBuffer;
  59406. private _cachedDefines;
  59407. private _effectLayerMapGenerationEffect;
  59408. private _effectLayerOptions;
  59409. private _mergeEffect;
  59410. protected _scene: Scene;
  59411. protected _engine: Engine;
  59412. protected _maxSize: number;
  59413. protected _mainTextureDesiredSize: ISize;
  59414. protected _mainTexture: RenderTargetTexture;
  59415. protected _shouldRender: boolean;
  59416. protected _postProcesses: PostProcess[];
  59417. protected _textures: BaseTexture[];
  59418. protected _emissiveTextureAndColor: {
  59419. texture: Nullable<BaseTexture>;
  59420. color: Color4;
  59421. };
  59422. /**
  59423. * The name of the layer
  59424. */
  59425. name: string;
  59426. /**
  59427. * The clear color of the texture used to generate the glow map.
  59428. */
  59429. neutralColor: Color4;
  59430. /**
  59431. * Specifies whether the highlight layer is enabled or not.
  59432. */
  59433. isEnabled: boolean;
  59434. /**
  59435. * Gets the camera attached to the layer.
  59436. */
  59437. get camera(): Nullable<Camera>;
  59438. /**
  59439. * Gets the rendering group id the layer should render in.
  59440. */
  59441. get renderingGroupId(): number;
  59442. set renderingGroupId(renderingGroupId: number);
  59443. /**
  59444. * An event triggered when the effect layer has been disposed.
  59445. */
  59446. onDisposeObservable: Observable<EffectLayer>;
  59447. /**
  59448. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59449. */
  59450. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59451. /**
  59452. * An event triggered when the generated texture is being merged in the scene.
  59453. */
  59454. onBeforeComposeObservable: Observable<EffectLayer>;
  59455. /**
  59456. * An event triggered when the mesh is rendered into the effect render target.
  59457. */
  59458. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59459. /**
  59460. * An event triggered after the mesh has been rendered into the effect render target.
  59461. */
  59462. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59463. /**
  59464. * An event triggered when the generated texture has been merged in the scene.
  59465. */
  59466. onAfterComposeObservable: Observable<EffectLayer>;
  59467. /**
  59468. * An event triggered when the efffect layer changes its size.
  59469. */
  59470. onSizeChangedObservable: Observable<EffectLayer>;
  59471. /** @hidden */
  59472. static _SceneComponentInitialization: (scene: Scene) => void;
  59473. /**
  59474. * Instantiates a new effect Layer and references it in the scene.
  59475. * @param name The name of the layer
  59476. * @param scene The scene to use the layer in
  59477. */
  59478. constructor(
  59479. /** The Friendly of the effect in the scene */
  59480. name: string, scene: Scene);
  59481. /**
  59482. * Get the effect name of the layer.
  59483. * @return The effect name
  59484. */
  59485. abstract getEffectName(): string;
  59486. /**
  59487. * Checks for the readiness of the element composing the layer.
  59488. * @param subMesh the mesh to check for
  59489. * @param useInstances specify whether or not to use instances to render the mesh
  59490. * @return true if ready otherwise, false
  59491. */
  59492. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59493. /**
  59494. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59495. * @returns true if the effect requires stencil during the main canvas render pass.
  59496. */
  59497. abstract needStencil(): boolean;
  59498. /**
  59499. * Create the merge effect. This is the shader use to blit the information back
  59500. * to the main canvas at the end of the scene rendering.
  59501. * @returns The effect containing the shader used to merge the effect on the main canvas
  59502. */
  59503. protected abstract _createMergeEffect(): Effect;
  59504. /**
  59505. * Creates the render target textures and post processes used in the effect layer.
  59506. */
  59507. protected abstract _createTextureAndPostProcesses(): void;
  59508. /**
  59509. * Implementation specific of rendering the generating effect on the main canvas.
  59510. * @param effect The effect used to render through
  59511. */
  59512. protected abstract _internalRender(effect: Effect): void;
  59513. /**
  59514. * Sets the required values for both the emissive texture and and the main color.
  59515. */
  59516. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59517. /**
  59518. * Free any resources and references associated to a mesh.
  59519. * Internal use
  59520. * @param mesh The mesh to free.
  59521. */
  59522. abstract _disposeMesh(mesh: Mesh): void;
  59523. /**
  59524. * Serializes this layer (Glow or Highlight for example)
  59525. * @returns a serialized layer object
  59526. */
  59527. abstract serialize?(): any;
  59528. /**
  59529. * Initializes the effect layer with the required options.
  59530. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59531. */
  59532. protected _init(options: Partial<IEffectLayerOptions>): void;
  59533. /**
  59534. * Generates the index buffer of the full screen quad blending to the main canvas.
  59535. */
  59536. private _generateIndexBuffer;
  59537. /**
  59538. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59539. */
  59540. private _generateVertexBuffer;
  59541. /**
  59542. * Sets the main texture desired size which is the closest power of two
  59543. * of the engine canvas size.
  59544. */
  59545. private _setMainTextureSize;
  59546. /**
  59547. * Creates the main texture for the effect layer.
  59548. */
  59549. protected _createMainTexture(): void;
  59550. /**
  59551. * Adds specific effects defines.
  59552. * @param defines The defines to add specifics to.
  59553. */
  59554. protected _addCustomEffectDefines(defines: string[]): void;
  59555. /**
  59556. * Checks for the readiness of the element composing the layer.
  59557. * @param subMesh the mesh to check for
  59558. * @param useInstances specify whether or not to use instances to render the mesh
  59559. * @param emissiveTexture the associated emissive texture used to generate the glow
  59560. * @return true if ready otherwise, false
  59561. */
  59562. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59563. /**
  59564. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59565. */
  59566. render(): void;
  59567. /**
  59568. * Determine if a given mesh will be used in the current effect.
  59569. * @param mesh mesh to test
  59570. * @returns true if the mesh will be used
  59571. */
  59572. hasMesh(mesh: AbstractMesh): boolean;
  59573. /**
  59574. * Returns true if the layer contains information to display, otherwise false.
  59575. * @returns true if the glow layer should be rendered
  59576. */
  59577. shouldRender(): boolean;
  59578. /**
  59579. * Returns true if the mesh should render, otherwise false.
  59580. * @param mesh The mesh to render
  59581. * @returns true if it should render otherwise false
  59582. */
  59583. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59584. /**
  59585. * Returns true if the mesh can be rendered, otherwise false.
  59586. * @param mesh The mesh to render
  59587. * @param material The material used on the mesh
  59588. * @returns true if it can be rendered otherwise false
  59589. */
  59590. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59591. /**
  59592. * Returns true if the mesh should render, otherwise false.
  59593. * @param mesh The mesh to render
  59594. * @returns true if it should render otherwise false
  59595. */
  59596. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59597. /**
  59598. * Renders the submesh passed in parameter to the generation map.
  59599. */
  59600. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59601. /**
  59602. * Defines whether the current material of the mesh should be use to render the effect.
  59603. * @param mesh defines the current mesh to render
  59604. */
  59605. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59606. /**
  59607. * Rebuild the required buffers.
  59608. * @hidden Internal use only.
  59609. */
  59610. _rebuild(): void;
  59611. /**
  59612. * Dispose only the render target textures and post process.
  59613. */
  59614. private _disposeTextureAndPostProcesses;
  59615. /**
  59616. * Dispose the highlight layer and free resources.
  59617. */
  59618. dispose(): void;
  59619. /**
  59620. * Gets the class name of the effect layer
  59621. * @returns the string with the class name of the effect layer
  59622. */
  59623. getClassName(): string;
  59624. /**
  59625. * Creates an effect layer from parsed effect layer data
  59626. * @param parsedEffectLayer defines effect layer data
  59627. * @param scene defines the current scene
  59628. * @param rootUrl defines the root URL containing the effect layer information
  59629. * @returns a parsed effect Layer
  59630. */
  59631. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59632. }
  59633. }
  59634. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  59635. import { Scene } from "babylonjs/scene";
  59636. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  59637. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59638. import { AbstractScene } from "babylonjs/abstractScene";
  59639. module "babylonjs/abstractScene" {
  59640. interface AbstractScene {
  59641. /**
  59642. * The list of effect layers (highlights/glow) added to the scene
  59643. * @see http://doc.babylonjs.com/how_to/highlight_layer
  59644. * @see http://doc.babylonjs.com/how_to/glow_layer
  59645. */
  59646. effectLayers: Array<EffectLayer>;
  59647. /**
  59648. * Removes the given effect layer from this scene.
  59649. * @param toRemove defines the effect layer to remove
  59650. * @returns the index of the removed effect layer
  59651. */
  59652. removeEffectLayer(toRemove: EffectLayer): number;
  59653. /**
  59654. * Adds the given effect layer to this scene
  59655. * @param newEffectLayer defines the effect layer to add
  59656. */
  59657. addEffectLayer(newEffectLayer: EffectLayer): void;
  59658. }
  59659. }
  59660. /**
  59661. * Defines the layer scene component responsible to manage any effect layers
  59662. * in a given scene.
  59663. */
  59664. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59665. /**
  59666. * The component name helpfull to identify the component in the list of scene components.
  59667. */
  59668. readonly name: string;
  59669. /**
  59670. * The scene the component belongs to.
  59671. */
  59672. scene: Scene;
  59673. private _engine;
  59674. private _renderEffects;
  59675. private _needStencil;
  59676. private _previousStencilState;
  59677. /**
  59678. * Creates a new instance of the component for the given scene
  59679. * @param scene Defines the scene to register the component in
  59680. */
  59681. constructor(scene: Scene);
  59682. /**
  59683. * Registers the component in a given scene
  59684. */
  59685. register(): void;
  59686. /**
  59687. * Rebuilds the elements related to this component in case of
  59688. * context lost for instance.
  59689. */
  59690. rebuild(): void;
  59691. /**
  59692. * Serializes the component data to the specified json object
  59693. * @param serializationObject The object to serialize to
  59694. */
  59695. serialize(serializationObject: any): void;
  59696. /**
  59697. * Adds all the elements from the container to the scene
  59698. * @param container the container holding the elements
  59699. */
  59700. addFromContainer(container: AbstractScene): void;
  59701. /**
  59702. * Removes all the elements in the container from the scene
  59703. * @param container contains the elements to remove
  59704. * @param dispose if the removed element should be disposed (default: false)
  59705. */
  59706. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59707. /**
  59708. * Disposes the component and the associated ressources.
  59709. */
  59710. dispose(): void;
  59711. private _isReadyForMesh;
  59712. private _renderMainTexture;
  59713. private _setStencil;
  59714. private _setStencilBack;
  59715. private _draw;
  59716. private _drawCamera;
  59717. private _drawRenderingGroup;
  59718. }
  59719. }
  59720. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  59721. /** @hidden */
  59722. export var glowMapMergePixelShader: {
  59723. name: string;
  59724. shader: string;
  59725. };
  59726. }
  59727. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  59728. /** @hidden */
  59729. export var glowMapMergeVertexShader: {
  59730. name: string;
  59731. shader: string;
  59732. };
  59733. }
  59734. declare module "babylonjs/Layers/glowLayer" {
  59735. import { Nullable } from "babylonjs/types";
  59736. import { Camera } from "babylonjs/Cameras/camera";
  59737. import { Scene } from "babylonjs/scene";
  59738. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59739. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59740. import { Mesh } from "babylonjs/Meshes/mesh";
  59741. import { Texture } from "babylonjs/Materials/Textures/texture";
  59742. import { Effect } from "babylonjs/Materials/effect";
  59743. import { Material } from "babylonjs/Materials/material";
  59744. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59745. import { Color4 } from "babylonjs/Maths/math.color";
  59746. import "babylonjs/Shaders/glowMapMerge.fragment";
  59747. import "babylonjs/Shaders/glowMapMerge.vertex";
  59748. import "babylonjs/Layers/effectLayerSceneComponent";
  59749. module "babylonjs/abstractScene" {
  59750. interface AbstractScene {
  59751. /**
  59752. * Return a the first highlight layer of the scene with a given name.
  59753. * @param name The name of the highlight layer to look for.
  59754. * @return The highlight layer if found otherwise null.
  59755. */
  59756. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59757. }
  59758. }
  59759. /**
  59760. * Glow layer options. This helps customizing the behaviour
  59761. * of the glow layer.
  59762. */
  59763. export interface IGlowLayerOptions {
  59764. /**
  59765. * Multiplication factor apply to the canvas size to compute the render target size
  59766. * used to generated the glowing objects (the smaller the faster).
  59767. */
  59768. mainTextureRatio: number;
  59769. /**
  59770. * Enforces a fixed size texture to ensure resize independant blur.
  59771. */
  59772. mainTextureFixedSize?: number;
  59773. /**
  59774. * How big is the kernel of the blur texture.
  59775. */
  59776. blurKernelSize: number;
  59777. /**
  59778. * The camera attached to the layer.
  59779. */
  59780. camera: Nullable<Camera>;
  59781. /**
  59782. * Enable MSAA by chosing the number of samples.
  59783. */
  59784. mainTextureSamples?: number;
  59785. /**
  59786. * The rendering group to draw the layer in.
  59787. */
  59788. renderingGroupId: number;
  59789. }
  59790. /**
  59791. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59792. *
  59793. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59794. *
  59795. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59796. */
  59797. export class GlowLayer extends EffectLayer {
  59798. /**
  59799. * Effect Name of the layer.
  59800. */
  59801. static readonly EffectName: string;
  59802. /**
  59803. * The default blur kernel size used for the glow.
  59804. */
  59805. static DefaultBlurKernelSize: number;
  59806. /**
  59807. * The default texture size ratio used for the glow.
  59808. */
  59809. static DefaultTextureRatio: number;
  59810. /**
  59811. * Sets the kernel size of the blur.
  59812. */
  59813. set blurKernelSize(value: number);
  59814. /**
  59815. * Gets the kernel size of the blur.
  59816. */
  59817. get blurKernelSize(): number;
  59818. /**
  59819. * Sets the glow intensity.
  59820. */
  59821. set intensity(value: number);
  59822. /**
  59823. * Gets the glow intensity.
  59824. */
  59825. get intensity(): number;
  59826. private _options;
  59827. private _intensity;
  59828. private _horizontalBlurPostprocess1;
  59829. private _verticalBlurPostprocess1;
  59830. private _horizontalBlurPostprocess2;
  59831. private _verticalBlurPostprocess2;
  59832. private _blurTexture1;
  59833. private _blurTexture2;
  59834. private _postProcesses1;
  59835. private _postProcesses2;
  59836. private _includedOnlyMeshes;
  59837. private _excludedMeshes;
  59838. private _meshesUsingTheirOwnMaterials;
  59839. /**
  59840. * Callback used to let the user override the color selection on a per mesh basis
  59841. */
  59842. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59843. /**
  59844. * Callback used to let the user override the texture selection on a per mesh basis
  59845. */
  59846. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59847. /**
  59848. * Instantiates a new glow Layer and references it to the scene.
  59849. * @param name The name of the layer
  59850. * @param scene The scene to use the layer in
  59851. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59852. */
  59853. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59854. /**
  59855. * Get the effect name of the layer.
  59856. * @return The effect name
  59857. */
  59858. getEffectName(): string;
  59859. /**
  59860. * Create the merge effect. This is the shader use to blit the information back
  59861. * to the main canvas at the end of the scene rendering.
  59862. */
  59863. protected _createMergeEffect(): Effect;
  59864. /**
  59865. * Creates the render target textures and post processes used in the glow layer.
  59866. */
  59867. protected _createTextureAndPostProcesses(): void;
  59868. /**
  59869. * Checks for the readiness of the element composing the layer.
  59870. * @param subMesh the mesh to check for
  59871. * @param useInstances specify wether or not to use instances to render the mesh
  59872. * @param emissiveTexture the associated emissive texture used to generate the glow
  59873. * @return true if ready otherwise, false
  59874. */
  59875. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59876. /**
  59877. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59878. */
  59879. needStencil(): boolean;
  59880. /**
  59881. * Returns true if the mesh can be rendered, otherwise false.
  59882. * @param mesh The mesh to render
  59883. * @param material The material used on the mesh
  59884. * @returns true if it can be rendered otherwise false
  59885. */
  59886. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59887. /**
  59888. * Implementation specific of rendering the generating effect on the main canvas.
  59889. * @param effect The effect used to render through
  59890. */
  59891. protected _internalRender(effect: Effect): void;
  59892. /**
  59893. * Sets the required values for both the emissive texture and and the main color.
  59894. */
  59895. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59896. /**
  59897. * Returns true if the mesh should render, otherwise false.
  59898. * @param mesh The mesh to render
  59899. * @returns true if it should render otherwise false
  59900. */
  59901. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59902. /**
  59903. * Adds specific effects defines.
  59904. * @param defines The defines to add specifics to.
  59905. */
  59906. protected _addCustomEffectDefines(defines: string[]): void;
  59907. /**
  59908. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59909. * @param mesh The mesh to exclude from the glow layer
  59910. */
  59911. addExcludedMesh(mesh: Mesh): void;
  59912. /**
  59913. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59914. * @param mesh The mesh to remove
  59915. */
  59916. removeExcludedMesh(mesh: Mesh): void;
  59917. /**
  59918. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59919. * @param mesh The mesh to include in the glow layer
  59920. */
  59921. addIncludedOnlyMesh(mesh: Mesh): void;
  59922. /**
  59923. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59924. * @param mesh The mesh to remove
  59925. */
  59926. removeIncludedOnlyMesh(mesh: Mesh): void;
  59927. /**
  59928. * Determine if a given mesh will be used in the glow layer
  59929. * @param mesh The mesh to test
  59930. * @returns true if the mesh will be highlighted by the current glow layer
  59931. */
  59932. hasMesh(mesh: AbstractMesh): boolean;
  59933. /**
  59934. * Defines whether the current material of the mesh should be use to render the effect.
  59935. * @param mesh defines the current mesh to render
  59936. */
  59937. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59938. /**
  59939. * Add a mesh to be rendered through its own material and not with emissive only.
  59940. * @param mesh The mesh for which we need to use its material
  59941. */
  59942. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59943. /**
  59944. * Remove a mesh from being rendered through its own material and not with emissive only.
  59945. * @param mesh The mesh for which we need to not use its material
  59946. */
  59947. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59948. /**
  59949. * Free any resources and references associated to a mesh.
  59950. * Internal use
  59951. * @param mesh The mesh to free.
  59952. * @hidden
  59953. */
  59954. _disposeMesh(mesh: Mesh): void;
  59955. /**
  59956. * Gets the class name of the effect layer
  59957. * @returns the string with the class name of the effect layer
  59958. */
  59959. getClassName(): string;
  59960. /**
  59961. * Serializes this glow layer
  59962. * @returns a serialized glow layer object
  59963. */
  59964. serialize(): any;
  59965. /**
  59966. * Creates a Glow Layer from parsed glow layer data
  59967. * @param parsedGlowLayer defines glow layer data
  59968. * @param scene defines the current scene
  59969. * @param rootUrl defines the root URL containing the glow layer information
  59970. * @returns a parsed Glow Layer
  59971. */
  59972. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59973. }
  59974. }
  59975. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  59976. /** @hidden */
  59977. export var glowBlurPostProcessPixelShader: {
  59978. name: string;
  59979. shader: string;
  59980. };
  59981. }
  59982. declare module "babylonjs/Layers/highlightLayer" {
  59983. import { Observable } from "babylonjs/Misc/observable";
  59984. import { Nullable } from "babylonjs/types";
  59985. import { Camera } from "babylonjs/Cameras/camera";
  59986. import { Scene } from "babylonjs/scene";
  59987. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59989. import { Mesh } from "babylonjs/Meshes/mesh";
  59990. import { Effect } from "babylonjs/Materials/effect";
  59991. import { Material } from "babylonjs/Materials/material";
  59992. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59993. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59994. import "babylonjs/Shaders/glowMapMerge.fragment";
  59995. import "babylonjs/Shaders/glowMapMerge.vertex";
  59996. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  59997. module "babylonjs/abstractScene" {
  59998. interface AbstractScene {
  59999. /**
  60000. * Return a the first highlight layer of the scene with a given name.
  60001. * @param name The name of the highlight layer to look for.
  60002. * @return The highlight layer if found otherwise null.
  60003. */
  60004. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60005. }
  60006. }
  60007. /**
  60008. * Highlight layer options. This helps customizing the behaviour
  60009. * of the highlight layer.
  60010. */
  60011. export interface IHighlightLayerOptions {
  60012. /**
  60013. * Multiplication factor apply to the canvas size to compute the render target size
  60014. * used to generated the glowing objects (the smaller the faster).
  60015. */
  60016. mainTextureRatio: number;
  60017. /**
  60018. * Enforces a fixed size texture to ensure resize independant blur.
  60019. */
  60020. mainTextureFixedSize?: number;
  60021. /**
  60022. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60023. * of the picture to blur (the smaller the faster).
  60024. */
  60025. blurTextureSizeRatio: number;
  60026. /**
  60027. * How big in texel of the blur texture is the vertical blur.
  60028. */
  60029. blurVerticalSize: number;
  60030. /**
  60031. * How big in texel of the blur texture is the horizontal blur.
  60032. */
  60033. blurHorizontalSize: number;
  60034. /**
  60035. * Alpha blending mode used to apply the blur. Default is combine.
  60036. */
  60037. alphaBlendingMode: number;
  60038. /**
  60039. * The camera attached to the layer.
  60040. */
  60041. camera: Nullable<Camera>;
  60042. /**
  60043. * Should we display highlight as a solid stroke?
  60044. */
  60045. isStroke?: boolean;
  60046. /**
  60047. * The rendering group to draw the layer in.
  60048. */
  60049. renderingGroupId: number;
  60050. }
  60051. /**
  60052. * The highlight layer Helps adding a glow effect around a mesh.
  60053. *
  60054. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60055. * glowy meshes to your scene.
  60056. *
  60057. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60058. */
  60059. export class HighlightLayer extends EffectLayer {
  60060. name: string;
  60061. /**
  60062. * Effect Name of the highlight layer.
  60063. */
  60064. static readonly EffectName: string;
  60065. /**
  60066. * The neutral color used during the preparation of the glow effect.
  60067. * This is black by default as the blend operation is a blend operation.
  60068. */
  60069. static NeutralColor: Color4;
  60070. /**
  60071. * Stencil value used for glowing meshes.
  60072. */
  60073. static GlowingMeshStencilReference: number;
  60074. /**
  60075. * Stencil value used for the other meshes in the scene.
  60076. */
  60077. static NormalMeshStencilReference: number;
  60078. /**
  60079. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60080. */
  60081. innerGlow: boolean;
  60082. /**
  60083. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60084. */
  60085. outerGlow: boolean;
  60086. /**
  60087. * Specifies the horizontal size of the blur.
  60088. */
  60089. set blurHorizontalSize(value: number);
  60090. /**
  60091. * Specifies the vertical size of the blur.
  60092. */
  60093. set blurVerticalSize(value: number);
  60094. /**
  60095. * Gets the horizontal size of the blur.
  60096. */
  60097. get blurHorizontalSize(): number;
  60098. /**
  60099. * Gets the vertical size of the blur.
  60100. */
  60101. get blurVerticalSize(): number;
  60102. /**
  60103. * An event triggered when the highlight layer is being blurred.
  60104. */
  60105. onBeforeBlurObservable: Observable<HighlightLayer>;
  60106. /**
  60107. * An event triggered when the highlight layer has been blurred.
  60108. */
  60109. onAfterBlurObservable: Observable<HighlightLayer>;
  60110. private _instanceGlowingMeshStencilReference;
  60111. private _options;
  60112. private _downSamplePostprocess;
  60113. private _horizontalBlurPostprocess;
  60114. private _verticalBlurPostprocess;
  60115. private _blurTexture;
  60116. private _meshes;
  60117. private _excludedMeshes;
  60118. /**
  60119. * Instantiates a new highlight Layer and references it to the scene..
  60120. * @param name The name of the layer
  60121. * @param scene The scene to use the layer in
  60122. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60123. */
  60124. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60125. /**
  60126. * Get the effect name of the layer.
  60127. * @return The effect name
  60128. */
  60129. getEffectName(): string;
  60130. /**
  60131. * Create the merge effect. This is the shader use to blit the information back
  60132. * to the main canvas at the end of the scene rendering.
  60133. */
  60134. protected _createMergeEffect(): Effect;
  60135. /**
  60136. * Creates the render target textures and post processes used in the highlight layer.
  60137. */
  60138. protected _createTextureAndPostProcesses(): void;
  60139. /**
  60140. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60141. */
  60142. needStencil(): boolean;
  60143. /**
  60144. * Checks for the readiness of the element composing the layer.
  60145. * @param subMesh the mesh to check for
  60146. * @param useInstances specify wether or not to use instances to render the mesh
  60147. * @param emissiveTexture the associated emissive texture used to generate the glow
  60148. * @return true if ready otherwise, false
  60149. */
  60150. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60151. /**
  60152. * Implementation specific of rendering the generating effect on the main canvas.
  60153. * @param effect The effect used to render through
  60154. */
  60155. protected _internalRender(effect: Effect): void;
  60156. /**
  60157. * Returns true if the layer contains information to display, otherwise false.
  60158. */
  60159. shouldRender(): boolean;
  60160. /**
  60161. * Returns true if the mesh should render, otherwise false.
  60162. * @param mesh The mesh to render
  60163. * @returns true if it should render otherwise false
  60164. */
  60165. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60166. /**
  60167. * Adds specific effects defines.
  60168. * @param defines The defines to add specifics to.
  60169. */
  60170. protected _addCustomEffectDefines(defines: string[]): void;
  60171. /**
  60172. * Sets the required values for both the emissive texture and and the main color.
  60173. */
  60174. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60175. /**
  60176. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60177. * @param mesh The mesh to exclude from the highlight layer
  60178. */
  60179. addExcludedMesh(mesh: Mesh): void;
  60180. /**
  60181. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60182. * @param mesh The mesh to highlight
  60183. */
  60184. removeExcludedMesh(mesh: Mesh): void;
  60185. /**
  60186. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60187. * @param mesh mesh to test
  60188. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60189. */
  60190. hasMesh(mesh: AbstractMesh): boolean;
  60191. /**
  60192. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60193. * @param mesh The mesh to highlight
  60194. * @param color The color of the highlight
  60195. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60196. */
  60197. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60198. /**
  60199. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60200. * @param mesh The mesh to highlight
  60201. */
  60202. removeMesh(mesh: Mesh): void;
  60203. /**
  60204. * Remove all the meshes currently referenced in the highlight layer
  60205. */
  60206. removeAllMeshes(): void;
  60207. /**
  60208. * Force the stencil to the normal expected value for none glowing parts
  60209. */
  60210. private _defaultStencilReference;
  60211. /**
  60212. * Free any resources and references associated to a mesh.
  60213. * Internal use
  60214. * @param mesh The mesh to free.
  60215. * @hidden
  60216. */
  60217. _disposeMesh(mesh: Mesh): void;
  60218. /**
  60219. * Dispose the highlight layer and free resources.
  60220. */
  60221. dispose(): void;
  60222. /**
  60223. * Gets the class name of the effect layer
  60224. * @returns the string with the class name of the effect layer
  60225. */
  60226. getClassName(): string;
  60227. /**
  60228. * Serializes this Highlight layer
  60229. * @returns a serialized Highlight layer object
  60230. */
  60231. serialize(): any;
  60232. /**
  60233. * Creates a Highlight layer from parsed Highlight layer data
  60234. * @param parsedHightlightLayer defines the Highlight layer data
  60235. * @param scene defines the current scene
  60236. * @param rootUrl defines the root URL containing the Highlight layer information
  60237. * @returns a parsed Highlight layer
  60238. */
  60239. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60240. }
  60241. }
  60242. declare module "babylonjs/Layers/layerSceneComponent" {
  60243. import { Scene } from "babylonjs/scene";
  60244. import { ISceneComponent } from "babylonjs/sceneComponent";
  60245. import { Layer } from "babylonjs/Layers/layer";
  60246. import { AbstractScene } from "babylonjs/abstractScene";
  60247. module "babylonjs/abstractScene" {
  60248. interface AbstractScene {
  60249. /**
  60250. * The list of layers (background and foreground) of the scene
  60251. */
  60252. layers: Array<Layer>;
  60253. }
  60254. }
  60255. /**
  60256. * Defines the layer scene component responsible to manage any layers
  60257. * in a given scene.
  60258. */
  60259. export class LayerSceneComponent implements ISceneComponent {
  60260. /**
  60261. * The component name helpfull to identify the component in the list of scene components.
  60262. */
  60263. readonly name: string;
  60264. /**
  60265. * The scene the component belongs to.
  60266. */
  60267. scene: Scene;
  60268. private _engine;
  60269. /**
  60270. * Creates a new instance of the component for the given scene
  60271. * @param scene Defines the scene to register the component in
  60272. */
  60273. constructor(scene: Scene);
  60274. /**
  60275. * Registers the component in a given scene
  60276. */
  60277. register(): void;
  60278. /**
  60279. * Rebuilds the elements related to this component in case of
  60280. * context lost for instance.
  60281. */
  60282. rebuild(): void;
  60283. /**
  60284. * Disposes the component and the associated ressources.
  60285. */
  60286. dispose(): void;
  60287. private _draw;
  60288. private _drawCameraPredicate;
  60289. private _drawCameraBackground;
  60290. private _drawCameraForeground;
  60291. private _drawRenderTargetPredicate;
  60292. private _drawRenderTargetBackground;
  60293. private _drawRenderTargetForeground;
  60294. /**
  60295. * Adds all the elements from the container to the scene
  60296. * @param container the container holding the elements
  60297. */
  60298. addFromContainer(container: AbstractScene): void;
  60299. /**
  60300. * Removes all the elements in the container from the scene
  60301. * @param container contains the elements to remove
  60302. * @param dispose if the removed element should be disposed (default: false)
  60303. */
  60304. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60305. }
  60306. }
  60307. declare module "babylonjs/Shaders/layer.fragment" {
  60308. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60309. /** @hidden */
  60310. export var layerPixelShader: {
  60311. name: string;
  60312. shader: string;
  60313. };
  60314. }
  60315. declare module "babylonjs/Shaders/layer.vertex" {
  60316. /** @hidden */
  60317. export var layerVertexShader: {
  60318. name: string;
  60319. shader: string;
  60320. };
  60321. }
  60322. declare module "babylonjs/Layers/layer" {
  60323. import { Observable } from "babylonjs/Misc/observable";
  60324. import { Nullable } from "babylonjs/types";
  60325. import { Scene } from "babylonjs/scene";
  60326. import { Vector2 } from "babylonjs/Maths/math.vector";
  60327. import { Color4 } from "babylonjs/Maths/math.color";
  60328. import { Texture } from "babylonjs/Materials/Textures/texture";
  60329. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60330. import "babylonjs/Shaders/layer.fragment";
  60331. import "babylonjs/Shaders/layer.vertex";
  60332. /**
  60333. * This represents a full screen 2d layer.
  60334. * This can be useful to display a picture in the background of your scene for instance.
  60335. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60336. */
  60337. export class Layer {
  60338. /**
  60339. * Define the name of the layer.
  60340. */
  60341. name: string;
  60342. /**
  60343. * Define the texture the layer should display.
  60344. */
  60345. texture: Nullable<Texture>;
  60346. /**
  60347. * Is the layer in background or foreground.
  60348. */
  60349. isBackground: boolean;
  60350. /**
  60351. * Define the color of the layer (instead of texture).
  60352. */
  60353. color: Color4;
  60354. /**
  60355. * Define the scale of the layer in order to zoom in out of the texture.
  60356. */
  60357. scale: Vector2;
  60358. /**
  60359. * Define an offset for the layer in order to shift the texture.
  60360. */
  60361. offset: Vector2;
  60362. /**
  60363. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60364. */
  60365. alphaBlendingMode: number;
  60366. /**
  60367. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60368. * Alpha test will not mix with the background color in case of transparency.
  60369. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60370. */
  60371. alphaTest: boolean;
  60372. /**
  60373. * Define a mask to restrict the layer to only some of the scene cameras.
  60374. */
  60375. layerMask: number;
  60376. /**
  60377. * Define the list of render target the layer is visible into.
  60378. */
  60379. renderTargetTextures: RenderTargetTexture[];
  60380. /**
  60381. * Define if the layer is only used in renderTarget or if it also
  60382. * renders in the main frame buffer of the canvas.
  60383. */
  60384. renderOnlyInRenderTargetTextures: boolean;
  60385. private _scene;
  60386. private _vertexBuffers;
  60387. private _indexBuffer;
  60388. private _effect;
  60389. private _previousDefines;
  60390. /**
  60391. * An event triggered when the layer is disposed.
  60392. */
  60393. onDisposeObservable: Observable<Layer>;
  60394. private _onDisposeObserver;
  60395. /**
  60396. * Back compatibility with callback before the onDisposeObservable existed.
  60397. * The set callback will be triggered when the layer has been disposed.
  60398. */
  60399. set onDispose(callback: () => void);
  60400. /**
  60401. * An event triggered before rendering the scene
  60402. */
  60403. onBeforeRenderObservable: Observable<Layer>;
  60404. private _onBeforeRenderObserver;
  60405. /**
  60406. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60407. * The set callback will be triggered just before rendering the layer.
  60408. */
  60409. set onBeforeRender(callback: () => void);
  60410. /**
  60411. * An event triggered after rendering the scene
  60412. */
  60413. onAfterRenderObservable: Observable<Layer>;
  60414. private _onAfterRenderObserver;
  60415. /**
  60416. * Back compatibility with callback before the onAfterRenderObservable existed.
  60417. * The set callback will be triggered just after rendering the layer.
  60418. */
  60419. set onAfterRender(callback: () => void);
  60420. /**
  60421. * Instantiates a new layer.
  60422. * This represents a full screen 2d layer.
  60423. * This can be useful to display a picture in the background of your scene for instance.
  60424. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60425. * @param name Define the name of the layer in the scene
  60426. * @param imgUrl Define the url of the texture to display in the layer
  60427. * @param scene Define the scene the layer belongs to
  60428. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60429. * @param color Defines a color for the layer
  60430. */
  60431. constructor(
  60432. /**
  60433. * Define the name of the layer.
  60434. */
  60435. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60436. private _createIndexBuffer;
  60437. /** @hidden */
  60438. _rebuild(): void;
  60439. /**
  60440. * Renders the layer in the scene.
  60441. */
  60442. render(): void;
  60443. /**
  60444. * Disposes and releases the associated ressources.
  60445. */
  60446. dispose(): void;
  60447. }
  60448. }
  60449. declare module "babylonjs/Layers/index" {
  60450. export * from "babylonjs/Layers/effectLayer";
  60451. export * from "babylonjs/Layers/effectLayerSceneComponent";
  60452. export * from "babylonjs/Layers/glowLayer";
  60453. export * from "babylonjs/Layers/highlightLayer";
  60454. export * from "babylonjs/Layers/layer";
  60455. export * from "babylonjs/Layers/layerSceneComponent";
  60456. }
  60457. declare module "babylonjs/Shaders/lensFlare.fragment" {
  60458. /** @hidden */
  60459. export var lensFlarePixelShader: {
  60460. name: string;
  60461. shader: string;
  60462. };
  60463. }
  60464. declare module "babylonjs/Shaders/lensFlare.vertex" {
  60465. /** @hidden */
  60466. export var lensFlareVertexShader: {
  60467. name: string;
  60468. shader: string;
  60469. };
  60470. }
  60471. declare module "babylonjs/LensFlares/lensFlareSystem" {
  60472. import { Scene } from "babylonjs/scene";
  60473. import { Vector3 } from "babylonjs/Maths/math.vector";
  60474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60475. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  60476. import "babylonjs/Shaders/lensFlare.fragment";
  60477. import "babylonjs/Shaders/lensFlare.vertex";
  60478. import { Viewport } from "babylonjs/Maths/math.viewport";
  60479. /**
  60480. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60481. * It is usually composed of several `lensFlare`.
  60482. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60483. */
  60484. export class LensFlareSystem {
  60485. /**
  60486. * Define the name of the lens flare system
  60487. */
  60488. name: string;
  60489. /**
  60490. * List of lens flares used in this system.
  60491. */
  60492. lensFlares: LensFlare[];
  60493. /**
  60494. * Define a limit from the border the lens flare can be visible.
  60495. */
  60496. borderLimit: number;
  60497. /**
  60498. * Define a viewport border we do not want to see the lens flare in.
  60499. */
  60500. viewportBorder: number;
  60501. /**
  60502. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60503. */
  60504. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60505. /**
  60506. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60507. */
  60508. layerMask: number;
  60509. /**
  60510. * Define the id of the lens flare system in the scene.
  60511. * (equal to name by default)
  60512. */
  60513. id: string;
  60514. private _scene;
  60515. private _emitter;
  60516. private _vertexBuffers;
  60517. private _indexBuffer;
  60518. private _effect;
  60519. private _positionX;
  60520. private _positionY;
  60521. private _isEnabled;
  60522. /** @hidden */
  60523. static _SceneComponentInitialization: (scene: Scene) => void;
  60524. /**
  60525. * Instantiates a lens flare system.
  60526. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60527. * It is usually composed of several `lensFlare`.
  60528. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60529. * @param name Define the name of the lens flare system in the scene
  60530. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60531. * @param scene Define the scene the lens flare system belongs to
  60532. */
  60533. constructor(
  60534. /**
  60535. * Define the name of the lens flare system
  60536. */
  60537. name: string, emitter: any, scene: Scene);
  60538. /**
  60539. * Define if the lens flare system is enabled.
  60540. */
  60541. get isEnabled(): boolean;
  60542. set isEnabled(value: boolean);
  60543. /**
  60544. * Get the scene the effects belongs to.
  60545. * @returns the scene holding the lens flare system
  60546. */
  60547. getScene(): Scene;
  60548. /**
  60549. * Get the emitter of the lens flare system.
  60550. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60551. * @returns the emitter of the lens flare system
  60552. */
  60553. getEmitter(): any;
  60554. /**
  60555. * Set the emitter of the lens flare system.
  60556. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60557. * @param newEmitter Define the new emitter of the system
  60558. */
  60559. setEmitter(newEmitter: any): void;
  60560. /**
  60561. * Get the lens flare system emitter position.
  60562. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60563. * @returns the position
  60564. */
  60565. getEmitterPosition(): Vector3;
  60566. /**
  60567. * @hidden
  60568. */
  60569. computeEffectivePosition(globalViewport: Viewport): boolean;
  60570. /** @hidden */
  60571. _isVisible(): boolean;
  60572. /**
  60573. * @hidden
  60574. */
  60575. render(): boolean;
  60576. /**
  60577. * Dispose and release the lens flare with its associated resources.
  60578. */
  60579. dispose(): void;
  60580. /**
  60581. * Parse a lens flare system from a JSON repressentation
  60582. * @param parsedLensFlareSystem Define the JSON to parse
  60583. * @param scene Define the scene the parsed system should be instantiated in
  60584. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60585. * @returns the parsed system
  60586. */
  60587. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60588. /**
  60589. * Serialize the current Lens Flare System into a JSON representation.
  60590. * @returns the serialized JSON
  60591. */
  60592. serialize(): any;
  60593. }
  60594. }
  60595. declare module "babylonjs/LensFlares/lensFlare" {
  60596. import { Nullable } from "babylonjs/types";
  60597. import { Color3 } from "babylonjs/Maths/math.color";
  60598. import { Texture } from "babylonjs/Materials/Textures/texture";
  60599. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60600. /**
  60601. * This represents one of the lens effect in a `lensFlareSystem`.
  60602. * It controls one of the indiviual texture used in the effect.
  60603. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60604. */
  60605. export class LensFlare {
  60606. /**
  60607. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60608. */
  60609. size: number;
  60610. /**
  60611. * 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.
  60612. */
  60613. position: number;
  60614. /**
  60615. * Define the lens color.
  60616. */
  60617. color: Color3;
  60618. /**
  60619. * Define the lens texture.
  60620. */
  60621. texture: Nullable<Texture>;
  60622. /**
  60623. * Define the alpha mode to render this particular lens.
  60624. */
  60625. alphaMode: number;
  60626. private _system;
  60627. /**
  60628. * Creates a new Lens Flare.
  60629. * This represents one of the lens effect in a `lensFlareSystem`.
  60630. * It controls one of the indiviual texture used in the effect.
  60631. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60632. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60633. * @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.
  60634. * @param color Define the lens color
  60635. * @param imgUrl Define the lens texture url
  60636. * @param system Define the `lensFlareSystem` this flare is part of
  60637. * @returns The newly created Lens Flare
  60638. */
  60639. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60640. /**
  60641. * Instantiates a new Lens Flare.
  60642. * This represents one of the lens effect in a `lensFlareSystem`.
  60643. * It controls one of the indiviual texture used in the effect.
  60644. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60645. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60646. * @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.
  60647. * @param color Define the lens color
  60648. * @param imgUrl Define the lens texture url
  60649. * @param system Define the `lensFlareSystem` this flare is part of
  60650. */
  60651. constructor(
  60652. /**
  60653. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60654. */
  60655. size: number,
  60656. /**
  60657. * 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.
  60658. */
  60659. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60660. /**
  60661. * Dispose and release the lens flare with its associated resources.
  60662. */
  60663. dispose(): void;
  60664. }
  60665. }
  60666. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  60667. import { Nullable } from "babylonjs/types";
  60668. import { Scene } from "babylonjs/scene";
  60669. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60670. import { AbstractScene } from "babylonjs/abstractScene";
  60671. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60672. module "babylonjs/abstractScene" {
  60673. interface AbstractScene {
  60674. /**
  60675. * The list of lens flare system added to the scene
  60676. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60677. */
  60678. lensFlareSystems: Array<LensFlareSystem>;
  60679. /**
  60680. * Removes the given lens flare system from this scene.
  60681. * @param toRemove The lens flare system to remove
  60682. * @returns The index of the removed lens flare system
  60683. */
  60684. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60685. /**
  60686. * Adds the given lens flare system to this scene
  60687. * @param newLensFlareSystem The lens flare system to add
  60688. */
  60689. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60690. /**
  60691. * Gets a lens flare system using its name
  60692. * @param name defines the name to look for
  60693. * @returns the lens flare system or null if not found
  60694. */
  60695. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60696. /**
  60697. * Gets a lens flare system using its id
  60698. * @param id defines the id to look for
  60699. * @returns the lens flare system or null if not found
  60700. */
  60701. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60702. }
  60703. }
  60704. /**
  60705. * Defines the lens flare scene component responsible to manage any lens flares
  60706. * in a given scene.
  60707. */
  60708. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60709. /**
  60710. * The component name helpfull to identify the component in the list of scene components.
  60711. */
  60712. readonly name: string;
  60713. /**
  60714. * The scene the component belongs to.
  60715. */
  60716. scene: Scene;
  60717. /**
  60718. * Creates a new instance of the component for the given scene
  60719. * @param scene Defines the scene to register the component in
  60720. */
  60721. constructor(scene: Scene);
  60722. /**
  60723. * Registers the component in a given scene
  60724. */
  60725. register(): void;
  60726. /**
  60727. * Rebuilds the elements related to this component in case of
  60728. * context lost for instance.
  60729. */
  60730. rebuild(): void;
  60731. /**
  60732. * Adds all the elements from the container to the scene
  60733. * @param container the container holding the elements
  60734. */
  60735. addFromContainer(container: AbstractScene): void;
  60736. /**
  60737. * Removes all the elements in the container from the scene
  60738. * @param container contains the elements to remove
  60739. * @param dispose if the removed element should be disposed (default: false)
  60740. */
  60741. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60742. /**
  60743. * Serializes the component data to the specified json object
  60744. * @param serializationObject The object to serialize to
  60745. */
  60746. serialize(serializationObject: any): void;
  60747. /**
  60748. * Disposes the component and the associated ressources.
  60749. */
  60750. dispose(): void;
  60751. private _draw;
  60752. }
  60753. }
  60754. declare module "babylonjs/LensFlares/index" {
  60755. export * from "babylonjs/LensFlares/lensFlare";
  60756. export * from "babylonjs/LensFlares/lensFlareSystem";
  60757. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  60758. }
  60759. declare module "babylonjs/Shaders/depth.fragment" {
  60760. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  60761. /** @hidden */
  60762. export var depthPixelShader: {
  60763. name: string;
  60764. shader: string;
  60765. };
  60766. }
  60767. declare module "babylonjs/Shaders/depth.vertex" {
  60768. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60769. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60770. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60771. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60772. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60773. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60774. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60775. /** @hidden */
  60776. export var depthVertexShader: {
  60777. name: string;
  60778. shader: string;
  60779. };
  60780. }
  60781. declare module "babylonjs/Rendering/depthRenderer" {
  60782. import { Nullable } from "babylonjs/types";
  60783. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60784. import { Scene } from "babylonjs/scene";
  60785. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60786. import { Camera } from "babylonjs/Cameras/camera";
  60787. import "babylonjs/Shaders/depth.fragment";
  60788. import "babylonjs/Shaders/depth.vertex";
  60789. /**
  60790. * This represents a depth renderer in Babylon.
  60791. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60792. */
  60793. export class DepthRenderer {
  60794. private _scene;
  60795. private _depthMap;
  60796. private _effect;
  60797. private readonly _storeNonLinearDepth;
  60798. private readonly _clearColor;
  60799. /** Get if the depth renderer is using packed depth or not */
  60800. readonly isPacked: boolean;
  60801. private _cachedDefines;
  60802. private _camera;
  60803. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60804. enabled: boolean;
  60805. /**
  60806. * Specifiess that the depth renderer will only be used within
  60807. * the camera it is created for.
  60808. * This can help forcing its rendering during the camera processing.
  60809. */
  60810. useOnlyInActiveCamera: boolean;
  60811. /** @hidden */
  60812. static _SceneComponentInitialization: (scene: Scene) => void;
  60813. /**
  60814. * Instantiates a depth renderer
  60815. * @param scene The scene the renderer belongs to
  60816. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60817. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60818. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60819. */
  60820. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60821. /**
  60822. * Creates the depth rendering effect and checks if the effect is ready.
  60823. * @param subMesh The submesh to be used to render the depth map of
  60824. * @param useInstances If multiple world instances should be used
  60825. * @returns if the depth renderer is ready to render the depth map
  60826. */
  60827. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60828. /**
  60829. * Gets the texture which the depth map will be written to.
  60830. * @returns The depth map texture
  60831. */
  60832. getDepthMap(): RenderTargetTexture;
  60833. /**
  60834. * Disposes of the depth renderer.
  60835. */
  60836. dispose(): void;
  60837. }
  60838. }
  60839. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  60840. /** @hidden */
  60841. export var minmaxReduxPixelShader: {
  60842. name: string;
  60843. shader: string;
  60844. };
  60845. }
  60846. declare module "babylonjs/Misc/minMaxReducer" {
  60847. import { Nullable } from "babylonjs/types";
  60848. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60849. import { Camera } from "babylonjs/Cameras/camera";
  60850. import { Observer } from "babylonjs/Misc/observable";
  60851. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60852. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  60853. import { Observable } from "babylonjs/Misc/observable";
  60854. import "babylonjs/Shaders/minmaxRedux.fragment";
  60855. /**
  60856. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60857. * and maximum values from all values of the texture.
  60858. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60859. * The source values are read from the red channel of the texture.
  60860. */
  60861. export class MinMaxReducer {
  60862. /**
  60863. * Observable triggered when the computation has been performed
  60864. */
  60865. onAfterReductionPerformed: Observable<{
  60866. min: number;
  60867. max: number;
  60868. }>;
  60869. protected _camera: Camera;
  60870. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60871. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60872. protected _postProcessManager: PostProcessManager;
  60873. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60874. protected _forceFullscreenViewport: boolean;
  60875. /**
  60876. * Creates a min/max reducer
  60877. * @param camera The camera to use for the post processes
  60878. */
  60879. constructor(camera: Camera);
  60880. /**
  60881. * Gets the texture used to read the values from.
  60882. */
  60883. get sourceTexture(): Nullable<RenderTargetTexture>;
  60884. /**
  60885. * Sets the source texture to read the values from.
  60886. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60887. * because in such textures '1' value must not be taken into account to compute the maximum
  60888. * as this value is used to clear the texture.
  60889. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60890. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60891. * @param depthRedux Indicates if the texture is a depth texture or not
  60892. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60893. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60894. */
  60895. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60896. /**
  60897. * Defines the refresh rate of the computation.
  60898. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60899. */
  60900. get refreshRate(): number;
  60901. set refreshRate(value: number);
  60902. protected _activated: boolean;
  60903. /**
  60904. * Gets the activation status of the reducer
  60905. */
  60906. get activated(): boolean;
  60907. /**
  60908. * Activates the reduction computation.
  60909. * When activated, the observers registered in onAfterReductionPerformed are
  60910. * called after the compuation is performed
  60911. */
  60912. activate(): void;
  60913. /**
  60914. * Deactivates the reduction computation.
  60915. */
  60916. deactivate(): void;
  60917. /**
  60918. * Disposes the min/max reducer
  60919. * @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.
  60920. */
  60921. dispose(disposeAll?: boolean): void;
  60922. }
  60923. }
  60924. declare module "babylonjs/Misc/depthReducer" {
  60925. import { Nullable } from "babylonjs/types";
  60926. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60927. import { Camera } from "babylonjs/Cameras/camera";
  60928. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60929. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  60930. /**
  60931. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60932. */
  60933. export class DepthReducer extends MinMaxReducer {
  60934. private _depthRenderer;
  60935. private _depthRendererId;
  60936. /**
  60937. * Gets the depth renderer used for the computation.
  60938. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60939. */
  60940. get depthRenderer(): Nullable<DepthRenderer>;
  60941. /**
  60942. * Creates a depth reducer
  60943. * @param camera The camera used to render the depth texture
  60944. */
  60945. constructor(camera: Camera);
  60946. /**
  60947. * Sets the depth renderer to use to generate the depth map
  60948. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60949. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60950. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60951. */
  60952. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60953. /** @hidden */
  60954. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60955. /**
  60956. * Activates the reduction computation.
  60957. * When activated, the observers registered in onAfterReductionPerformed are
  60958. * called after the compuation is performed
  60959. */
  60960. activate(): void;
  60961. /**
  60962. * Deactivates the reduction computation.
  60963. */
  60964. deactivate(): void;
  60965. /**
  60966. * Disposes the depth reducer
  60967. * @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.
  60968. */
  60969. dispose(disposeAll?: boolean): void;
  60970. }
  60971. }
  60972. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  60973. import { Nullable } from "babylonjs/types";
  60974. import { Scene } from "babylonjs/scene";
  60975. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60976. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60978. import { Effect } from "babylonjs/Materials/effect";
  60979. import "babylonjs/Shaders/shadowMap.fragment";
  60980. import "babylonjs/Shaders/shadowMap.vertex";
  60981. import "babylonjs/Shaders/depthBoxBlur.fragment";
  60982. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  60983. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  60984. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  60985. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60986. /**
  60987. * A CSM implementation allowing casting shadows on large scenes.
  60988. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60989. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60990. */
  60991. export class CascadedShadowGenerator extends ShadowGenerator {
  60992. private static readonly frustumCornersNDCSpace;
  60993. /**
  60994. * Name of the CSM class
  60995. */
  60996. static CLASSNAME: string;
  60997. /**
  60998. * Defines the default number of cascades used by the CSM.
  60999. */
  61000. static readonly DEFAULT_CASCADES_COUNT: number;
  61001. /**
  61002. * Defines the minimum number of cascades used by the CSM.
  61003. */
  61004. static readonly MIN_CASCADES_COUNT: number;
  61005. /**
  61006. * Defines the maximum number of cascades used by the CSM.
  61007. */
  61008. static readonly MAX_CASCADES_COUNT: number;
  61009. protected _validateFilter(filter: number): number;
  61010. /**
  61011. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61012. */
  61013. penumbraDarkness: number;
  61014. private _numCascades;
  61015. /**
  61016. * Gets or set the number of cascades used by the CSM.
  61017. */
  61018. get numCascades(): number;
  61019. set numCascades(value: number);
  61020. /**
  61021. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61022. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61023. */
  61024. stabilizeCascades: boolean;
  61025. private _freezeShadowCastersBoundingInfo;
  61026. private _freezeShadowCastersBoundingInfoObservable;
  61027. /**
  61028. * Enables or disables the shadow casters bounding info computation.
  61029. * If your shadow casters don't move, you can disable this feature.
  61030. * If it is enabled, the bounding box computation is done every frame.
  61031. */
  61032. get freezeShadowCastersBoundingInfo(): boolean;
  61033. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61034. private _scbiMin;
  61035. private _scbiMax;
  61036. protected _computeShadowCastersBoundingInfo(): void;
  61037. protected _shadowCastersBoundingInfo: BoundingInfo;
  61038. /**
  61039. * Gets or sets the shadow casters bounding info.
  61040. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61041. * so that the system won't overwrite the bounds you provide
  61042. */
  61043. get shadowCastersBoundingInfo(): BoundingInfo;
  61044. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61045. protected _breaksAreDirty: boolean;
  61046. protected _minDistance: number;
  61047. protected _maxDistance: number;
  61048. /**
  61049. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61050. *
  61051. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61052. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61053. * @param min minimal distance for the breaks (default to 0.)
  61054. * @param max maximal distance for the breaks (default to 1.)
  61055. */
  61056. setMinMaxDistance(min: number, max: number): void;
  61057. /** Gets the minimal distance used in the cascade break computation */
  61058. get minDistance(): number;
  61059. /** Gets the maximal distance used in the cascade break computation */
  61060. get maxDistance(): number;
  61061. /**
  61062. * Gets the class name of that object
  61063. * @returns "CascadedShadowGenerator"
  61064. */
  61065. getClassName(): string;
  61066. private _cascadeMinExtents;
  61067. private _cascadeMaxExtents;
  61068. /**
  61069. * Gets a cascade minimum extents
  61070. * @param cascadeIndex index of the cascade
  61071. * @returns the minimum cascade extents
  61072. */
  61073. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61074. /**
  61075. * Gets a cascade maximum extents
  61076. * @param cascadeIndex index of the cascade
  61077. * @returns the maximum cascade extents
  61078. */
  61079. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61080. private _cascades;
  61081. private _currentLayer;
  61082. private _viewSpaceFrustumsZ;
  61083. private _viewMatrices;
  61084. private _projectionMatrices;
  61085. private _transformMatrices;
  61086. private _transformMatricesAsArray;
  61087. private _frustumLengths;
  61088. private _lightSizeUVCorrection;
  61089. private _depthCorrection;
  61090. private _frustumCornersWorldSpace;
  61091. private _frustumCenter;
  61092. private _shadowCameraPos;
  61093. private _shadowMaxZ;
  61094. /**
  61095. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61096. * It defaults to camera.maxZ
  61097. */
  61098. get shadowMaxZ(): number;
  61099. /**
  61100. * Sets the shadow max z distance.
  61101. */
  61102. set shadowMaxZ(value: number);
  61103. protected _debug: boolean;
  61104. /**
  61105. * Gets or sets the debug flag.
  61106. * When enabled, the cascades are materialized by different colors on the screen.
  61107. */
  61108. get debug(): boolean;
  61109. set debug(dbg: boolean);
  61110. private _depthClamp;
  61111. /**
  61112. * Gets or sets the depth clamping value.
  61113. *
  61114. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61115. * to account for the shadow casters far away.
  61116. *
  61117. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61118. */
  61119. get depthClamp(): boolean;
  61120. set depthClamp(value: boolean);
  61121. private _cascadeBlendPercentage;
  61122. /**
  61123. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61124. * It defaults to 0.1 (10% blending).
  61125. */
  61126. get cascadeBlendPercentage(): number;
  61127. set cascadeBlendPercentage(value: number);
  61128. private _lambda;
  61129. /**
  61130. * Gets or set the lambda parameter.
  61131. * This parameter is used to split the camera frustum and create the cascades.
  61132. * 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.
  61133. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61134. */
  61135. get lambda(): number;
  61136. set lambda(value: number);
  61137. /**
  61138. * Gets the view matrix corresponding to a given cascade
  61139. * @param cascadeNum cascade to retrieve the view matrix from
  61140. * @returns the cascade view matrix
  61141. */
  61142. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61143. /**
  61144. * Gets the projection matrix corresponding to a given cascade
  61145. * @param cascadeNum cascade to retrieve the projection matrix from
  61146. * @returns the cascade projection matrix
  61147. */
  61148. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61149. /**
  61150. * Gets the transformation matrix corresponding to a given cascade
  61151. * @param cascadeNum cascade to retrieve the transformation matrix from
  61152. * @returns the cascade transformation matrix
  61153. */
  61154. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61155. private _depthRenderer;
  61156. /**
  61157. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61158. *
  61159. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61160. *
  61161. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61162. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61163. * @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
  61164. */
  61165. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61166. private _depthReducer;
  61167. private _autoCalcDepthBounds;
  61168. /**
  61169. * Gets or sets the autoCalcDepthBounds property.
  61170. *
  61171. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61172. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61173. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61174. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61175. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61176. */
  61177. get autoCalcDepthBounds(): boolean;
  61178. set autoCalcDepthBounds(value: boolean);
  61179. /**
  61180. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61181. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61182. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61183. * for setting the refresh rate on the renderer yourself!
  61184. */
  61185. get autoCalcDepthBoundsRefreshRate(): number;
  61186. set autoCalcDepthBoundsRefreshRate(value: number);
  61187. /**
  61188. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61189. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61190. * you change the camera near/far planes!
  61191. */
  61192. splitFrustum(): void;
  61193. private _splitFrustum;
  61194. private _computeMatrices;
  61195. private _computeFrustumInWorldSpace;
  61196. private _computeCascadeFrustum;
  61197. /**
  61198. * Support test.
  61199. */
  61200. static get IsSupported(): boolean;
  61201. /** @hidden */
  61202. static _SceneComponentInitialization: (scene: Scene) => void;
  61203. /**
  61204. * Creates a Cascaded Shadow Generator object.
  61205. * A ShadowGenerator is the required tool to use the shadows.
  61206. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61207. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61208. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61209. * @param light The directional light object generating the shadows.
  61210. * @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.
  61211. */
  61212. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61213. protected _initializeGenerator(): void;
  61214. protected _createTargetRenderTexture(): void;
  61215. protected _initializeShadowMap(): void;
  61216. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61217. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61218. /**
  61219. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61220. * @param defines Defines of the material we want to update
  61221. * @param lightIndex Index of the light in the enabled light list of the material
  61222. */
  61223. prepareDefines(defines: any, lightIndex: number): void;
  61224. /**
  61225. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61226. * defined in the generator but impacting the effect).
  61227. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61228. * @param effect The effect we are binfing the information for
  61229. */
  61230. bindShadowLight(lightIndex: string, effect: Effect): void;
  61231. /**
  61232. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61233. * (eq to view projection * shadow projection matrices)
  61234. * @returns The transform matrix used to create the shadow map
  61235. */
  61236. getTransformMatrix(): Matrix;
  61237. /**
  61238. * Disposes the ShadowGenerator.
  61239. * Returns nothing.
  61240. */
  61241. dispose(): void;
  61242. /**
  61243. * Serializes the shadow generator setup to a json object.
  61244. * @returns The serialized JSON object
  61245. */
  61246. serialize(): any;
  61247. /**
  61248. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61249. * @param parsedShadowGenerator The JSON object to parse
  61250. * @param scene The scene to create the shadow map for
  61251. * @returns The parsed shadow generator
  61252. */
  61253. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61254. }
  61255. }
  61256. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  61257. import { Scene } from "babylonjs/scene";
  61258. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61259. import { AbstractScene } from "babylonjs/abstractScene";
  61260. /**
  61261. * Defines the shadow generator component responsible to manage any shadow generators
  61262. * in a given scene.
  61263. */
  61264. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61265. /**
  61266. * The component name helpfull to identify the component in the list of scene components.
  61267. */
  61268. readonly name: string;
  61269. /**
  61270. * The scene the component belongs to.
  61271. */
  61272. scene: Scene;
  61273. /**
  61274. * Creates a new instance of the component for the given scene
  61275. * @param scene Defines the scene to register the component in
  61276. */
  61277. constructor(scene: Scene);
  61278. /**
  61279. * Registers the component in a given scene
  61280. */
  61281. register(): void;
  61282. /**
  61283. * Rebuilds the elements related to this component in case of
  61284. * context lost for instance.
  61285. */
  61286. rebuild(): void;
  61287. /**
  61288. * Serializes the component data to the specified json object
  61289. * @param serializationObject The object to serialize to
  61290. */
  61291. serialize(serializationObject: any): void;
  61292. /**
  61293. * Adds all the elements from the container to the scene
  61294. * @param container the container holding the elements
  61295. */
  61296. addFromContainer(container: AbstractScene): void;
  61297. /**
  61298. * Removes all the elements in the container from the scene
  61299. * @param container contains the elements to remove
  61300. * @param dispose if the removed element should be disposed (default: false)
  61301. */
  61302. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61303. /**
  61304. * Rebuilds the elements related to this component in case of
  61305. * context lost for instance.
  61306. */
  61307. dispose(): void;
  61308. private _gatherRenderTargets;
  61309. }
  61310. }
  61311. declare module "babylonjs/Lights/Shadows/index" {
  61312. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  61313. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  61314. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  61315. }
  61316. declare module "babylonjs/Lights/pointLight" {
  61317. import { Scene } from "babylonjs/scene";
  61318. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61320. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  61321. import { Effect } from "babylonjs/Materials/effect";
  61322. /**
  61323. * A point light is a light defined by an unique point in world space.
  61324. * The light is emitted in every direction from this point.
  61325. * A good example of a point light is a standard light bulb.
  61326. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61327. */
  61328. export class PointLight extends ShadowLight {
  61329. private _shadowAngle;
  61330. /**
  61331. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61332. * This specifies what angle the shadow will use to be created.
  61333. *
  61334. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61335. */
  61336. get shadowAngle(): number;
  61337. /**
  61338. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61339. * This specifies what angle the shadow will use to be created.
  61340. *
  61341. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61342. */
  61343. set shadowAngle(value: number);
  61344. /**
  61345. * Gets the direction if it has been set.
  61346. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61347. */
  61348. get direction(): Vector3;
  61349. /**
  61350. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61351. */
  61352. set direction(value: Vector3);
  61353. /**
  61354. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61355. * A PointLight emits the light in every direction.
  61356. * It can cast shadows.
  61357. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61358. * ```javascript
  61359. * var pointLight = new PointLight("pl", camera.position, scene);
  61360. * ```
  61361. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61362. * @param name The light friendly name
  61363. * @param position The position of the point light in the scene
  61364. * @param scene The scene the lights belongs to
  61365. */
  61366. constructor(name: string, position: Vector3, scene: Scene);
  61367. /**
  61368. * Returns the string "PointLight"
  61369. * @returns the class name
  61370. */
  61371. getClassName(): string;
  61372. /**
  61373. * Returns the integer 0.
  61374. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61375. */
  61376. getTypeID(): number;
  61377. /**
  61378. * Specifies wether or not the shadowmap should be a cube texture.
  61379. * @returns true if the shadowmap needs to be a cube texture.
  61380. */
  61381. needCube(): boolean;
  61382. /**
  61383. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61384. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61385. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61386. */
  61387. getShadowDirection(faceIndex?: number): Vector3;
  61388. /**
  61389. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61390. * - fov = PI / 2
  61391. * - aspect ratio : 1.0
  61392. * - z-near and far equal to the active camera minZ and maxZ.
  61393. * Returns the PointLight.
  61394. */
  61395. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61396. protected _buildUniformLayout(): void;
  61397. /**
  61398. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61399. * @param effect The effect to update
  61400. * @param lightIndex The index of the light in the effect to update
  61401. * @returns The point light
  61402. */
  61403. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61404. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61405. /**
  61406. * Prepares the list of defines specific to the light type.
  61407. * @param defines the list of defines
  61408. * @param lightIndex defines the index of the light for the effect
  61409. */
  61410. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61411. }
  61412. }
  61413. declare module "babylonjs/Lights/index" {
  61414. export * from "babylonjs/Lights/light";
  61415. export * from "babylonjs/Lights/shadowLight";
  61416. export * from "babylonjs/Lights/Shadows/index";
  61417. export * from "babylonjs/Lights/directionalLight";
  61418. export * from "babylonjs/Lights/hemisphericLight";
  61419. export * from "babylonjs/Lights/pointLight";
  61420. export * from "babylonjs/Lights/spotLight";
  61421. }
  61422. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  61423. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61424. /**
  61425. * Header information of HDR texture files.
  61426. */
  61427. export interface HDRInfo {
  61428. /**
  61429. * The height of the texture in pixels.
  61430. */
  61431. height: number;
  61432. /**
  61433. * The width of the texture in pixels.
  61434. */
  61435. width: number;
  61436. /**
  61437. * The index of the beginning of the data in the binary file.
  61438. */
  61439. dataPosition: number;
  61440. }
  61441. /**
  61442. * This groups tools to convert HDR texture to native colors array.
  61443. */
  61444. export class HDRTools {
  61445. private static Ldexp;
  61446. private static Rgbe2float;
  61447. private static readStringLine;
  61448. /**
  61449. * Reads header information from an RGBE texture stored in a native array.
  61450. * More information on this format are available here:
  61451. * https://en.wikipedia.org/wiki/RGBE_image_format
  61452. *
  61453. * @param uint8array The binary file stored in native array.
  61454. * @return The header information.
  61455. */
  61456. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61457. /**
  61458. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61459. * This RGBE texture needs to store the information as a panorama.
  61460. *
  61461. * More information on this format are available here:
  61462. * https://en.wikipedia.org/wiki/RGBE_image_format
  61463. *
  61464. * @param buffer The binary file stored in an array buffer.
  61465. * @param size The expected size of the extracted cubemap.
  61466. * @return The Cube Map information.
  61467. */
  61468. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61469. /**
  61470. * Returns the pixels data extracted from an RGBE texture.
  61471. * This pixels will be stored left to right up to down in the R G B order in one array.
  61472. *
  61473. * More information on this format are available here:
  61474. * https://en.wikipedia.org/wiki/RGBE_image_format
  61475. *
  61476. * @param uint8array The binary file stored in an array buffer.
  61477. * @param hdrInfo The header information of the file.
  61478. * @return The pixels data in RGB right to left up to down order.
  61479. */
  61480. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61481. private static RGBE_ReadPixels_RLE;
  61482. }
  61483. }
  61484. declare module "babylonjs/Materials/effectRenderer" {
  61485. import { Nullable } from "babylonjs/types";
  61486. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61487. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61488. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61489. import { Viewport } from "babylonjs/Maths/math.viewport";
  61490. import { Observable } from "babylonjs/Misc/observable";
  61491. import { Effect } from "babylonjs/Materials/effect";
  61492. import "babylonjs/Shaders/postprocess.vertex";
  61493. /**
  61494. * Effect Render Options
  61495. */
  61496. export interface IEffectRendererOptions {
  61497. /**
  61498. * Defines the vertices positions.
  61499. */
  61500. positions?: number[];
  61501. /**
  61502. * Defines the indices.
  61503. */
  61504. indices?: number[];
  61505. }
  61506. /**
  61507. * Helper class to render one or more effects.
  61508. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61509. */
  61510. export class EffectRenderer {
  61511. private engine;
  61512. private static _DefaultOptions;
  61513. private _vertexBuffers;
  61514. private _indexBuffer;
  61515. private _fullscreenViewport;
  61516. /**
  61517. * Creates an effect renderer
  61518. * @param engine the engine to use for rendering
  61519. * @param options defines the options of the effect renderer
  61520. */
  61521. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61522. /**
  61523. * Sets the current viewport in normalized coordinates 0-1
  61524. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61525. */
  61526. setViewport(viewport?: Viewport): void;
  61527. /**
  61528. * Binds the embedded attributes buffer to the effect.
  61529. * @param effect Defines the effect to bind the attributes for
  61530. */
  61531. bindBuffers(effect: Effect): void;
  61532. /**
  61533. * Sets the current effect wrapper to use during draw.
  61534. * The effect needs to be ready before calling this api.
  61535. * This also sets the default full screen position attribute.
  61536. * @param effectWrapper Defines the effect to draw with
  61537. */
  61538. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61539. /**
  61540. * Restores engine states
  61541. */
  61542. restoreStates(): void;
  61543. /**
  61544. * Draws a full screen quad.
  61545. */
  61546. draw(): void;
  61547. private isRenderTargetTexture;
  61548. /**
  61549. * renders one or more effects to a specified texture
  61550. * @param effectWrapper the effect to renderer
  61551. * @param outputTexture texture to draw to, if null it will render to the screen.
  61552. */
  61553. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61554. /**
  61555. * Disposes of the effect renderer
  61556. */
  61557. dispose(): void;
  61558. }
  61559. /**
  61560. * Options to create an EffectWrapper
  61561. */
  61562. interface EffectWrapperCreationOptions {
  61563. /**
  61564. * Engine to use to create the effect
  61565. */
  61566. engine: ThinEngine;
  61567. /**
  61568. * Fragment shader for the effect
  61569. */
  61570. fragmentShader: string;
  61571. /**
  61572. * Use the shader store instead of direct source code
  61573. */
  61574. useShaderStore?: boolean;
  61575. /**
  61576. * Vertex shader for the effect
  61577. */
  61578. vertexShader?: string;
  61579. /**
  61580. * Attributes to use in the shader
  61581. */
  61582. attributeNames?: Array<string>;
  61583. /**
  61584. * Uniforms to use in the shader
  61585. */
  61586. uniformNames?: Array<string>;
  61587. /**
  61588. * Texture sampler names to use in the shader
  61589. */
  61590. samplerNames?: Array<string>;
  61591. /**
  61592. * Defines to use in the shader
  61593. */
  61594. defines?: Array<string>;
  61595. /**
  61596. * Callback when effect is compiled
  61597. */
  61598. onCompiled?: Nullable<(effect: Effect) => void>;
  61599. /**
  61600. * The friendly name of the effect displayed in Spector.
  61601. */
  61602. name?: string;
  61603. }
  61604. /**
  61605. * Wraps an effect to be used for rendering
  61606. */
  61607. export class EffectWrapper {
  61608. /**
  61609. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61610. */
  61611. onApplyObservable: Observable<{}>;
  61612. /**
  61613. * The underlying effect
  61614. */
  61615. effect: Effect;
  61616. /**
  61617. * Creates an effect to be renderer
  61618. * @param creationOptions options to create the effect
  61619. */
  61620. constructor(creationOptions: EffectWrapperCreationOptions);
  61621. /**
  61622. * Disposes of the effect wrapper
  61623. */
  61624. dispose(): void;
  61625. }
  61626. }
  61627. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  61628. /** @hidden */
  61629. export var hdrFilteringVertexShader: {
  61630. name: string;
  61631. shader: string;
  61632. };
  61633. }
  61634. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  61635. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61636. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  61637. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  61638. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  61639. /** @hidden */
  61640. export var hdrFilteringPixelShader: {
  61641. name: string;
  61642. shader: string;
  61643. };
  61644. }
  61645. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  61646. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61647. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61648. import { Nullable } from "babylonjs/types";
  61649. import "babylonjs/Shaders/hdrFiltering.vertex";
  61650. import "babylonjs/Shaders/hdrFiltering.fragment";
  61651. /**
  61652. * Options for texture filtering
  61653. */
  61654. interface IHDRFilteringOptions {
  61655. /**
  61656. * Scales pixel intensity for the input HDR map.
  61657. */
  61658. hdrScale?: number;
  61659. /**
  61660. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61661. */
  61662. quality?: number;
  61663. }
  61664. /**
  61665. * Filters HDR maps to get correct renderings of PBR reflections
  61666. */
  61667. export class HDRFiltering {
  61668. private _engine;
  61669. private _effectRenderer;
  61670. private _effectWrapper;
  61671. private _lodGenerationOffset;
  61672. private _lodGenerationScale;
  61673. /**
  61674. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61675. * you care about baking speed.
  61676. */
  61677. quality: number;
  61678. /**
  61679. * Scales pixel intensity for the input HDR map.
  61680. */
  61681. hdrScale: number;
  61682. /**
  61683. * Instantiates HDR filter for reflection maps
  61684. *
  61685. * @param engine Thin engine
  61686. * @param options Options
  61687. */
  61688. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61689. private _createRenderTarget;
  61690. private _prefilterInternal;
  61691. private _createEffect;
  61692. /**
  61693. * Get a value indicating if the filter is ready to be used
  61694. * @param texture Texture to filter
  61695. * @returns true if the filter is ready
  61696. */
  61697. isReady(texture: BaseTexture): boolean;
  61698. /**
  61699. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61700. * Prefiltering will be invoked at the end of next rendering pass.
  61701. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61702. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61703. * @param texture Texture to filter
  61704. * @param onFinished Callback when filtering is done
  61705. * @return Promise called when prefiltering is done
  61706. */
  61707. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61708. }
  61709. }
  61710. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  61711. import { Nullable } from "babylonjs/types";
  61712. import { Scene } from "babylonjs/scene";
  61713. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61714. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61715. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61716. import "babylonjs/Engines/Extensions/engine.rawTexture";
  61717. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  61718. /**
  61719. * This represents a texture coming from an HDR input.
  61720. *
  61721. * The only supported format is currently panorama picture stored in RGBE format.
  61722. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61723. */
  61724. export class HDRCubeTexture extends BaseTexture {
  61725. private static _facesMapping;
  61726. private _generateHarmonics;
  61727. private _noMipmap;
  61728. private _prefilterOnLoad;
  61729. private _textureMatrix;
  61730. private _size;
  61731. private _onLoad;
  61732. private _onError;
  61733. /**
  61734. * The texture URL.
  61735. */
  61736. url: string;
  61737. /**
  61738. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  61739. */
  61740. coordinatesMode: number;
  61741. protected _isBlocking: boolean;
  61742. /**
  61743. * Sets wether or not the texture is blocking during loading.
  61744. */
  61745. set isBlocking(value: boolean);
  61746. /**
  61747. * Gets wether or not the texture is blocking during loading.
  61748. */
  61749. get isBlocking(): boolean;
  61750. protected _rotationY: number;
  61751. /**
  61752. * Sets texture matrix rotation angle around Y axis in radians.
  61753. */
  61754. set rotationY(value: number);
  61755. /**
  61756. * Gets texture matrix rotation angle around Y axis radians.
  61757. */
  61758. get rotationY(): number;
  61759. /**
  61760. * Gets or sets the center of the bounding box associated with the cube texture
  61761. * It must define where the camera used to render the texture was set
  61762. */
  61763. boundingBoxPosition: Vector3;
  61764. private _boundingBoxSize;
  61765. /**
  61766. * Gets or sets the size of the bounding box associated with the cube texture
  61767. * When defined, the cubemap will switch to local mode
  61768. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61769. * @example https://www.babylonjs-playground.com/#RNASML
  61770. */
  61771. set boundingBoxSize(value: Vector3);
  61772. get boundingBoxSize(): Vector3;
  61773. /**
  61774. * Instantiates an HDRTexture from the following parameters.
  61775. *
  61776. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61777. * @param sceneOrEngine The scene or engine the texture will be used in
  61778. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61779. * @param noMipmap Forces to not generate the mipmap if true
  61780. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61781. * @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)
  61782. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61783. */
  61784. 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>);
  61785. /**
  61786. * Get the current class name of the texture useful for serialization or dynamic coding.
  61787. * @returns "HDRCubeTexture"
  61788. */
  61789. getClassName(): string;
  61790. /**
  61791. * Occurs when the file is raw .hdr file.
  61792. */
  61793. private loadTexture;
  61794. clone(): HDRCubeTexture;
  61795. delayLoad(): void;
  61796. /**
  61797. * Get the texture reflection matrix used to rotate/transform the reflection.
  61798. * @returns the reflection matrix
  61799. */
  61800. getReflectionTextureMatrix(): Matrix;
  61801. /**
  61802. * Set the texture reflection matrix used to rotate/transform the reflection.
  61803. * @param value Define the reflection matrix to set
  61804. */
  61805. setReflectionTextureMatrix(value: Matrix): void;
  61806. /**
  61807. * Parses a JSON representation of an HDR Texture in order to create the texture
  61808. * @param parsedTexture Define the JSON representation
  61809. * @param scene Define the scene the texture should be created in
  61810. * @param rootUrl Define the root url in case we need to load relative dependencies
  61811. * @returns the newly created texture after parsing
  61812. */
  61813. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61814. serialize(): any;
  61815. }
  61816. }
  61817. declare module "babylonjs/Physics/physicsEngine" {
  61818. import { Nullable } from "babylonjs/types";
  61819. import { Vector3 } from "babylonjs/Maths/math.vector";
  61820. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61821. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  61822. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  61823. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61824. /**
  61825. * Class used to control physics engine
  61826. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61827. */
  61828. export class PhysicsEngine implements IPhysicsEngine {
  61829. private _physicsPlugin;
  61830. /**
  61831. * Global value used to control the smallest number supported by the simulation
  61832. */
  61833. static Epsilon: number;
  61834. private _impostors;
  61835. private _joints;
  61836. private _subTimeStep;
  61837. /**
  61838. * Gets the gravity vector used by the simulation
  61839. */
  61840. gravity: Vector3;
  61841. /**
  61842. * Factory used to create the default physics plugin.
  61843. * @returns The default physics plugin
  61844. */
  61845. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61846. /**
  61847. * Creates a new Physics Engine
  61848. * @param gravity defines the gravity vector used by the simulation
  61849. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61850. */
  61851. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61852. /**
  61853. * Sets the gravity vector used by the simulation
  61854. * @param gravity defines the gravity vector to use
  61855. */
  61856. setGravity(gravity: Vector3): void;
  61857. /**
  61858. * Set the time step of the physics engine.
  61859. * Default is 1/60.
  61860. * To slow it down, enter 1/600 for example.
  61861. * To speed it up, 1/30
  61862. * @param newTimeStep defines the new timestep to apply to this world.
  61863. */
  61864. setTimeStep(newTimeStep?: number): void;
  61865. /**
  61866. * Get the time step of the physics engine.
  61867. * @returns the current time step
  61868. */
  61869. getTimeStep(): number;
  61870. /**
  61871. * Set the sub time step of the physics engine.
  61872. * Default is 0 meaning there is no sub steps
  61873. * To increase physics resolution precision, set a small value (like 1 ms)
  61874. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61875. */
  61876. setSubTimeStep(subTimeStep?: number): void;
  61877. /**
  61878. * Get the sub time step of the physics engine.
  61879. * @returns the current sub time step
  61880. */
  61881. getSubTimeStep(): number;
  61882. /**
  61883. * Release all resources
  61884. */
  61885. dispose(): void;
  61886. /**
  61887. * Gets the name of the current physics plugin
  61888. * @returns the name of the plugin
  61889. */
  61890. getPhysicsPluginName(): string;
  61891. /**
  61892. * Adding a new impostor for the impostor tracking.
  61893. * This will be done by the impostor itself.
  61894. * @param impostor the impostor to add
  61895. */
  61896. addImpostor(impostor: PhysicsImpostor): void;
  61897. /**
  61898. * Remove an impostor from the engine.
  61899. * This impostor and its mesh will not longer be updated by the physics engine.
  61900. * @param impostor the impostor to remove
  61901. */
  61902. removeImpostor(impostor: PhysicsImpostor): void;
  61903. /**
  61904. * Add a joint to the physics engine
  61905. * @param mainImpostor defines the main impostor to which the joint is added.
  61906. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61907. * @param joint defines the joint that will connect both impostors.
  61908. */
  61909. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61910. /**
  61911. * Removes a joint from the simulation
  61912. * @param mainImpostor defines the impostor used with the joint
  61913. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61914. * @param joint defines the joint to remove
  61915. */
  61916. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61917. /**
  61918. * Called by the scene. No need to call it.
  61919. * @param delta defines the timespam between frames
  61920. */
  61921. _step(delta: number): void;
  61922. /**
  61923. * Gets the current plugin used to run the simulation
  61924. * @returns current plugin
  61925. */
  61926. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61927. /**
  61928. * Gets the list of physic impostors
  61929. * @returns an array of PhysicsImpostor
  61930. */
  61931. getImpostors(): Array<PhysicsImpostor>;
  61932. /**
  61933. * Gets the impostor for a physics enabled object
  61934. * @param object defines the object impersonated by the impostor
  61935. * @returns the PhysicsImpostor or null if not found
  61936. */
  61937. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61938. /**
  61939. * Gets the impostor for a physics body object
  61940. * @param body defines physics body used by the impostor
  61941. * @returns the PhysicsImpostor or null if not found
  61942. */
  61943. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61944. /**
  61945. * Does a raycast in the physics world
  61946. * @param from when should the ray start?
  61947. * @param to when should the ray end?
  61948. * @returns PhysicsRaycastResult
  61949. */
  61950. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61951. }
  61952. }
  61953. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  61954. import { Nullable } from "babylonjs/types";
  61955. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  61956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61957. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  61958. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61959. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  61960. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61961. /** @hidden */
  61962. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61963. private _useDeltaForWorldStep;
  61964. world: any;
  61965. name: string;
  61966. private _physicsMaterials;
  61967. private _fixedTimeStep;
  61968. private _cannonRaycastResult;
  61969. private _raycastResult;
  61970. private _physicsBodysToRemoveAfterStep;
  61971. private _firstFrame;
  61972. BJSCANNON: any;
  61973. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61974. setGravity(gravity: Vector3): void;
  61975. setTimeStep(timeStep: number): void;
  61976. getTimeStep(): number;
  61977. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61978. private _removeMarkedPhysicsBodiesFromWorld;
  61979. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61980. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61981. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61982. private _processChildMeshes;
  61983. removePhysicsBody(impostor: PhysicsImpostor): void;
  61984. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61985. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61986. private _addMaterial;
  61987. private _checkWithEpsilon;
  61988. private _createShape;
  61989. private _createHeightmap;
  61990. private _minus90X;
  61991. private _plus90X;
  61992. private _tmpPosition;
  61993. private _tmpDeltaPosition;
  61994. private _tmpUnityRotation;
  61995. private _updatePhysicsBodyTransformation;
  61996. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61997. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61998. isSupported(): boolean;
  61999. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62000. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62001. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62002. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62003. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62004. getBodyMass(impostor: PhysicsImpostor): number;
  62005. getBodyFriction(impostor: PhysicsImpostor): number;
  62006. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62007. getBodyRestitution(impostor: PhysicsImpostor): number;
  62008. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62009. sleepBody(impostor: PhysicsImpostor): void;
  62010. wakeUpBody(impostor: PhysicsImpostor): void;
  62011. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62012. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62013. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62014. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62015. getRadius(impostor: PhysicsImpostor): number;
  62016. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62017. dispose(): void;
  62018. private _extendNamespace;
  62019. /**
  62020. * Does a raycast in the physics world
  62021. * @param from when should the ray start?
  62022. * @param to when should the ray end?
  62023. * @returns PhysicsRaycastResult
  62024. */
  62025. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62026. }
  62027. }
  62028. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  62029. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62030. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62031. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62033. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62034. import { Nullable } from "babylonjs/types";
  62035. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62036. /** @hidden */
  62037. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62038. private _useDeltaForWorldStep;
  62039. world: any;
  62040. name: string;
  62041. BJSOIMO: any;
  62042. private _raycastResult;
  62043. private _fixedTimeStep;
  62044. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62045. setGravity(gravity: Vector3): void;
  62046. setTimeStep(timeStep: number): void;
  62047. getTimeStep(): number;
  62048. private _tmpImpostorsArray;
  62049. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62050. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62051. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62052. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62053. private _tmpPositionVector;
  62054. removePhysicsBody(impostor: PhysicsImpostor): void;
  62055. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62056. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62057. isSupported(): boolean;
  62058. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62059. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62060. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62061. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62062. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62063. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62064. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62065. getBodyMass(impostor: PhysicsImpostor): number;
  62066. getBodyFriction(impostor: PhysicsImpostor): number;
  62067. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62068. getBodyRestitution(impostor: PhysicsImpostor): number;
  62069. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62070. sleepBody(impostor: PhysicsImpostor): void;
  62071. wakeUpBody(impostor: PhysicsImpostor): void;
  62072. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62073. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62074. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62075. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62076. getRadius(impostor: PhysicsImpostor): number;
  62077. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62078. dispose(): void;
  62079. /**
  62080. * Does a raycast in the physics world
  62081. * @param from when should the ray start?
  62082. * @param to when should the ray end?
  62083. * @returns PhysicsRaycastResult
  62084. */
  62085. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62086. }
  62087. }
  62088. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  62089. import { Nullable } from "babylonjs/types";
  62090. import { Scene } from "babylonjs/scene";
  62091. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  62092. import { Color4 } from "babylonjs/Maths/math.color";
  62093. import { Mesh } from "babylonjs/Meshes/mesh";
  62094. /**
  62095. * Class containing static functions to help procedurally build meshes
  62096. */
  62097. export class RibbonBuilder {
  62098. /**
  62099. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62100. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  62101. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  62102. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  62103. * * 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
  62104. * * 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
  62105. * * 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
  62106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62107. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62108. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62109. * * 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
  62110. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  62111. * * 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
  62112. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  62113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62114. * @param name defines the name of the mesh
  62115. * @param options defines the options used to create the mesh
  62116. * @param scene defines the hosting scene
  62117. * @returns the ribbon mesh
  62118. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  62119. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62120. */
  62121. static CreateRibbon(name: string, options: {
  62122. pathArray: Vector3[][];
  62123. closeArray?: boolean;
  62124. closePath?: boolean;
  62125. offset?: number;
  62126. updatable?: boolean;
  62127. sideOrientation?: number;
  62128. frontUVs?: Vector4;
  62129. backUVs?: Vector4;
  62130. instance?: Mesh;
  62131. invertUV?: boolean;
  62132. uvs?: Vector2[];
  62133. colors?: Color4[];
  62134. }, scene?: Nullable<Scene>): Mesh;
  62135. }
  62136. }
  62137. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  62138. import { Nullable } from "babylonjs/types";
  62139. import { Scene } from "babylonjs/scene";
  62140. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62141. import { Mesh } from "babylonjs/Meshes/mesh";
  62142. /**
  62143. * Class containing static functions to help procedurally build meshes
  62144. */
  62145. export class ShapeBuilder {
  62146. /**
  62147. * 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.
  62148. * * 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.
  62149. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62150. * * 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.
  62151. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62152. * * 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
  62153. * * 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
  62154. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62156. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62157. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62159. * @param name defines the name of the mesh
  62160. * @param options defines the options used to create the mesh
  62161. * @param scene defines the hosting scene
  62162. * @returns the extruded shape mesh
  62163. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62164. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62165. */
  62166. static ExtrudeShape(name: string, options: {
  62167. shape: Vector3[];
  62168. path: Vector3[];
  62169. scale?: number;
  62170. rotation?: number;
  62171. cap?: number;
  62172. updatable?: boolean;
  62173. sideOrientation?: number;
  62174. frontUVs?: Vector4;
  62175. backUVs?: Vector4;
  62176. instance?: Mesh;
  62177. invertUV?: boolean;
  62178. }, scene?: Nullable<Scene>): Mesh;
  62179. /**
  62180. * Creates an custom extruded shape mesh.
  62181. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62182. * * 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.
  62183. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62184. * * 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
  62185. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62186. * * 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
  62187. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62188. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62189. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62190. * * 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
  62191. * * 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
  62192. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62193. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62194. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62195. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62197. * @param name defines the name of the mesh
  62198. * @param options defines the options used to create the mesh
  62199. * @param scene defines the hosting scene
  62200. * @returns the custom extruded shape mesh
  62201. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62202. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62203. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62204. */
  62205. static ExtrudeShapeCustom(name: string, options: {
  62206. shape: Vector3[];
  62207. path: Vector3[];
  62208. scaleFunction?: any;
  62209. rotationFunction?: any;
  62210. ribbonCloseArray?: boolean;
  62211. ribbonClosePath?: boolean;
  62212. cap?: number;
  62213. updatable?: boolean;
  62214. sideOrientation?: number;
  62215. frontUVs?: Vector4;
  62216. backUVs?: Vector4;
  62217. instance?: Mesh;
  62218. invertUV?: boolean;
  62219. }, scene?: Nullable<Scene>): Mesh;
  62220. private static _ExtrudeShapeGeneric;
  62221. }
  62222. }
  62223. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  62224. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  62225. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62226. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62227. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62228. import { Nullable } from "babylonjs/types";
  62229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62230. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62231. /**
  62232. * AmmoJS Physics plugin
  62233. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62234. * @see https://github.com/kripken/ammo.js/
  62235. */
  62236. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62237. private _useDeltaForWorldStep;
  62238. /**
  62239. * Reference to the Ammo library
  62240. */
  62241. bjsAMMO: any;
  62242. /**
  62243. * Created ammoJS world which physics bodies are added to
  62244. */
  62245. world: any;
  62246. /**
  62247. * Name of the plugin
  62248. */
  62249. name: string;
  62250. private _timeStep;
  62251. private _fixedTimeStep;
  62252. private _maxSteps;
  62253. private _tmpQuaternion;
  62254. private _tmpAmmoTransform;
  62255. private _tmpAmmoQuaternion;
  62256. private _tmpAmmoConcreteContactResultCallback;
  62257. private _collisionConfiguration;
  62258. private _dispatcher;
  62259. private _overlappingPairCache;
  62260. private _solver;
  62261. private _softBodySolver;
  62262. private _tmpAmmoVectorA;
  62263. private _tmpAmmoVectorB;
  62264. private _tmpAmmoVectorC;
  62265. private _tmpAmmoVectorD;
  62266. private _tmpContactCallbackResult;
  62267. private _tmpAmmoVectorRCA;
  62268. private _tmpAmmoVectorRCB;
  62269. private _raycastResult;
  62270. private static readonly DISABLE_COLLISION_FLAG;
  62271. private static readonly KINEMATIC_FLAG;
  62272. private static readonly DISABLE_DEACTIVATION_FLAG;
  62273. /**
  62274. * Initializes the ammoJS plugin
  62275. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62276. * @param ammoInjection can be used to inject your own ammo reference
  62277. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62278. */
  62279. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62280. /**
  62281. * Sets the gravity of the physics world (m/(s^2))
  62282. * @param gravity Gravity to set
  62283. */
  62284. setGravity(gravity: Vector3): void;
  62285. /**
  62286. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62287. * @param timeStep timestep to use in seconds
  62288. */
  62289. setTimeStep(timeStep: number): void;
  62290. /**
  62291. * 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)
  62292. * @param fixedTimeStep fixedTimeStep to use in seconds
  62293. */
  62294. setFixedTimeStep(fixedTimeStep: number): void;
  62295. /**
  62296. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62297. * @param maxSteps the maximum number of steps by the physics engine per frame
  62298. */
  62299. setMaxSteps(maxSteps: number): void;
  62300. /**
  62301. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62302. * @returns the current timestep in seconds
  62303. */
  62304. getTimeStep(): number;
  62305. /**
  62306. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62307. */
  62308. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62309. private _isImpostorInContact;
  62310. private _isImpostorPairInContact;
  62311. private _stepSimulation;
  62312. /**
  62313. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  62314. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  62315. * After the step the babylon meshes are set to the position of the physics imposters
  62316. * @param delta amount of time to step forward
  62317. * @param impostors array of imposters to update before/after the step
  62318. */
  62319. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62320. /**
  62321. * Update babylon mesh to match physics world object
  62322. * @param impostor imposter to match
  62323. */
  62324. private _afterSoftStep;
  62325. /**
  62326. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62327. * @param impostor imposter to match
  62328. */
  62329. private _ropeStep;
  62330. /**
  62331. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62332. * @param impostor imposter to match
  62333. */
  62334. private _softbodyOrClothStep;
  62335. private _tmpMatrix;
  62336. /**
  62337. * Applies an impulse on the imposter
  62338. * @param impostor imposter to apply impulse to
  62339. * @param force amount of force to be applied to the imposter
  62340. * @param contactPoint the location to apply the impulse on the imposter
  62341. */
  62342. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62343. /**
  62344. * Applies a force on the imposter
  62345. * @param impostor imposter to apply force
  62346. * @param force amount of force to be applied to the imposter
  62347. * @param contactPoint the location to apply the force on the imposter
  62348. */
  62349. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62350. /**
  62351. * Creates a physics body using the plugin
  62352. * @param impostor the imposter to create the physics body on
  62353. */
  62354. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62355. /**
  62356. * Removes the physics body from the imposter and disposes of the body's memory
  62357. * @param impostor imposter to remove the physics body from
  62358. */
  62359. removePhysicsBody(impostor: PhysicsImpostor): void;
  62360. /**
  62361. * Generates a joint
  62362. * @param impostorJoint the imposter joint to create the joint with
  62363. */
  62364. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62365. /**
  62366. * Removes a joint
  62367. * @param impostorJoint the imposter joint to remove the joint from
  62368. */
  62369. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62370. private _addMeshVerts;
  62371. /**
  62372. * Initialise the soft body vertices to match its object's (mesh) vertices
  62373. * Softbody vertices (nodes) are in world space and to match this
  62374. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62375. * @param impostor to create the softbody for
  62376. */
  62377. private _softVertexData;
  62378. /**
  62379. * Create an impostor's soft body
  62380. * @param impostor to create the softbody for
  62381. */
  62382. private _createSoftbody;
  62383. /**
  62384. * Create cloth for an impostor
  62385. * @param impostor to create the softbody for
  62386. */
  62387. private _createCloth;
  62388. /**
  62389. * Create rope for an impostor
  62390. * @param impostor to create the softbody for
  62391. */
  62392. private _createRope;
  62393. /**
  62394. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62395. * @param impostor to create the custom physics shape for
  62396. */
  62397. private _createCustom;
  62398. private _addHullVerts;
  62399. private _createShape;
  62400. /**
  62401. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62402. * @param impostor imposter containing the physics body and babylon object
  62403. */
  62404. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62405. /**
  62406. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62407. * @param impostor imposter containing the physics body and babylon object
  62408. * @param newPosition new position
  62409. * @param newRotation new rotation
  62410. */
  62411. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62412. /**
  62413. * If this plugin is supported
  62414. * @returns true if its supported
  62415. */
  62416. isSupported(): boolean;
  62417. /**
  62418. * Sets the linear velocity of the physics body
  62419. * @param impostor imposter to set the velocity on
  62420. * @param velocity velocity to set
  62421. */
  62422. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62423. /**
  62424. * Sets the angular velocity of the physics body
  62425. * @param impostor imposter to set the velocity on
  62426. * @param velocity velocity to set
  62427. */
  62428. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62429. /**
  62430. * gets the linear velocity
  62431. * @param impostor imposter to get linear velocity from
  62432. * @returns linear velocity
  62433. */
  62434. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62435. /**
  62436. * gets the angular velocity
  62437. * @param impostor imposter to get angular velocity from
  62438. * @returns angular velocity
  62439. */
  62440. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62441. /**
  62442. * Sets the mass of physics body
  62443. * @param impostor imposter to set the mass on
  62444. * @param mass mass to set
  62445. */
  62446. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62447. /**
  62448. * Gets the mass of the physics body
  62449. * @param impostor imposter to get the mass from
  62450. * @returns mass
  62451. */
  62452. getBodyMass(impostor: PhysicsImpostor): number;
  62453. /**
  62454. * Gets friction of the impostor
  62455. * @param impostor impostor to get friction from
  62456. * @returns friction value
  62457. */
  62458. getBodyFriction(impostor: PhysicsImpostor): number;
  62459. /**
  62460. * Sets friction of the impostor
  62461. * @param impostor impostor to set friction on
  62462. * @param friction friction value
  62463. */
  62464. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62465. /**
  62466. * Gets restitution of the impostor
  62467. * @param impostor impostor to get restitution from
  62468. * @returns restitution value
  62469. */
  62470. getBodyRestitution(impostor: PhysicsImpostor): number;
  62471. /**
  62472. * Sets resitution of the impostor
  62473. * @param impostor impostor to set resitution on
  62474. * @param restitution resitution value
  62475. */
  62476. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62477. /**
  62478. * Gets pressure inside the impostor
  62479. * @param impostor impostor to get pressure from
  62480. * @returns pressure value
  62481. */
  62482. getBodyPressure(impostor: PhysicsImpostor): number;
  62483. /**
  62484. * Sets pressure inside a soft body impostor
  62485. * Cloth and rope must remain 0 pressure
  62486. * @param impostor impostor to set pressure on
  62487. * @param pressure pressure value
  62488. */
  62489. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62490. /**
  62491. * Gets stiffness of the impostor
  62492. * @param impostor impostor to get stiffness from
  62493. * @returns pressure value
  62494. */
  62495. getBodyStiffness(impostor: PhysicsImpostor): number;
  62496. /**
  62497. * Sets stiffness of the impostor
  62498. * @param impostor impostor to set stiffness on
  62499. * @param stiffness stiffness value from 0 to 1
  62500. */
  62501. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62502. /**
  62503. * Gets velocityIterations of the impostor
  62504. * @param impostor impostor to get velocity iterations from
  62505. * @returns velocityIterations value
  62506. */
  62507. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62508. /**
  62509. * Sets velocityIterations of the impostor
  62510. * @param impostor impostor to set velocity iterations on
  62511. * @param velocityIterations velocityIterations value
  62512. */
  62513. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62514. /**
  62515. * Gets positionIterations of the impostor
  62516. * @param impostor impostor to get position iterations from
  62517. * @returns positionIterations value
  62518. */
  62519. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62520. /**
  62521. * Sets positionIterations of the impostor
  62522. * @param impostor impostor to set position on
  62523. * @param positionIterations positionIterations value
  62524. */
  62525. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62526. /**
  62527. * Append an anchor to a cloth object
  62528. * @param impostor is the cloth impostor to add anchor to
  62529. * @param otherImpostor is the rigid impostor to anchor to
  62530. * @param width ratio across width from 0 to 1
  62531. * @param height ratio up height from 0 to 1
  62532. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62533. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62534. */
  62535. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62536. /**
  62537. * Append an hook to a rope object
  62538. * @param impostor is the rope impostor to add hook to
  62539. * @param otherImpostor is the rigid impostor to hook to
  62540. * @param length ratio along the rope from 0 to 1
  62541. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62542. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62543. */
  62544. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62545. /**
  62546. * Sleeps the physics body and stops it from being active
  62547. * @param impostor impostor to sleep
  62548. */
  62549. sleepBody(impostor: PhysicsImpostor): void;
  62550. /**
  62551. * Activates the physics body
  62552. * @param impostor impostor to activate
  62553. */
  62554. wakeUpBody(impostor: PhysicsImpostor): void;
  62555. /**
  62556. * Updates the distance parameters of the joint
  62557. * @param joint joint to update
  62558. * @param maxDistance maximum distance of the joint
  62559. * @param minDistance minimum distance of the joint
  62560. */
  62561. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62562. /**
  62563. * Sets a motor on the joint
  62564. * @param joint joint to set motor on
  62565. * @param speed speed of the motor
  62566. * @param maxForce maximum force of the motor
  62567. * @param motorIndex index of the motor
  62568. */
  62569. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62570. /**
  62571. * Sets the motors limit
  62572. * @param joint joint to set limit on
  62573. * @param upperLimit upper limit
  62574. * @param lowerLimit lower limit
  62575. */
  62576. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62577. /**
  62578. * Syncs the position and rotation of a mesh with the impostor
  62579. * @param mesh mesh to sync
  62580. * @param impostor impostor to update the mesh with
  62581. */
  62582. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62583. /**
  62584. * Gets the radius of the impostor
  62585. * @param impostor impostor to get radius from
  62586. * @returns the radius
  62587. */
  62588. getRadius(impostor: PhysicsImpostor): number;
  62589. /**
  62590. * Gets the box size of the impostor
  62591. * @param impostor impostor to get box size from
  62592. * @param result the resulting box size
  62593. */
  62594. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62595. /**
  62596. * Disposes of the impostor
  62597. */
  62598. dispose(): void;
  62599. /**
  62600. * Does a raycast in the physics world
  62601. * @param from when should the ray start?
  62602. * @param to when should the ray end?
  62603. * @returns PhysicsRaycastResult
  62604. */
  62605. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62606. }
  62607. }
  62608. declare module "babylonjs/Probes/reflectionProbe" {
  62609. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62610. import { Vector3 } from "babylonjs/Maths/math.vector";
  62611. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62612. import { Nullable } from "babylonjs/types";
  62613. import { Scene } from "babylonjs/scene";
  62614. module "babylonjs/abstractScene" {
  62615. interface AbstractScene {
  62616. /**
  62617. * The list of reflection probes added to the scene
  62618. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62619. */
  62620. reflectionProbes: Array<ReflectionProbe>;
  62621. /**
  62622. * Removes the given reflection probe from this scene.
  62623. * @param toRemove The reflection probe to remove
  62624. * @returns The index of the removed reflection probe
  62625. */
  62626. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62627. /**
  62628. * Adds the given reflection probe to this scene.
  62629. * @param newReflectionProbe The reflection probe to add
  62630. */
  62631. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62632. }
  62633. }
  62634. /**
  62635. * Class used to generate realtime reflection / refraction cube textures
  62636. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62637. */
  62638. export class ReflectionProbe {
  62639. /** defines the name of the probe */
  62640. name: string;
  62641. private _scene;
  62642. private _renderTargetTexture;
  62643. private _projectionMatrix;
  62644. private _viewMatrix;
  62645. private _target;
  62646. private _add;
  62647. private _attachedMesh;
  62648. private _invertYAxis;
  62649. /** Gets or sets probe position (center of the cube map) */
  62650. position: Vector3;
  62651. /**
  62652. * Creates a new reflection probe
  62653. * @param name defines the name of the probe
  62654. * @param size defines the texture resolution (for each face)
  62655. * @param scene defines the hosting scene
  62656. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62657. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62658. */
  62659. constructor(
  62660. /** defines the name of the probe */
  62661. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62662. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62663. get samples(): number;
  62664. set samples(value: number);
  62665. /** Gets or sets the refresh rate to use (on every frame by default) */
  62666. get refreshRate(): number;
  62667. set refreshRate(value: number);
  62668. /**
  62669. * Gets the hosting scene
  62670. * @returns a Scene
  62671. */
  62672. getScene(): Scene;
  62673. /** Gets the internal CubeTexture used to render to */
  62674. get cubeTexture(): RenderTargetTexture;
  62675. /** Gets the list of meshes to render */
  62676. get renderList(): Nullable<AbstractMesh[]>;
  62677. /**
  62678. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62679. * @param mesh defines the mesh to attach to
  62680. */
  62681. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62682. /**
  62683. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62684. * @param renderingGroupId The rendering group id corresponding to its index
  62685. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62686. */
  62687. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62688. /**
  62689. * Clean all associated resources
  62690. */
  62691. dispose(): void;
  62692. /**
  62693. * Converts the reflection probe information to a readable string for debug purpose.
  62694. * @param fullDetails Supports for multiple levels of logging within scene loading
  62695. * @returns the human readable reflection probe info
  62696. */
  62697. toString(fullDetails?: boolean): string;
  62698. /**
  62699. * Get the class name of the relfection probe.
  62700. * @returns "ReflectionProbe"
  62701. */
  62702. getClassName(): string;
  62703. /**
  62704. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62705. * @returns The JSON representation of the texture
  62706. */
  62707. serialize(): any;
  62708. /**
  62709. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62710. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62711. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62712. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62713. * @returns The parsed reflection probe if successful
  62714. */
  62715. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62716. }
  62717. }
  62718. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  62719. /** @hidden */
  62720. export var _BabylonLoaderRegistered: boolean;
  62721. /**
  62722. * Helps setting up some configuration for the babylon file loader.
  62723. */
  62724. export class BabylonFileLoaderConfiguration {
  62725. /**
  62726. * The loader does not allow injecting custom physix engine into the plugins.
  62727. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62728. * So you could set this variable to your engine import to make it work.
  62729. */
  62730. static LoaderInjectedPhysicsEngine: any;
  62731. }
  62732. }
  62733. declare module "babylonjs/Loading/Plugins/index" {
  62734. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  62735. }
  62736. declare module "babylonjs/Loading/index" {
  62737. export * from "babylonjs/Loading/loadingScreen";
  62738. export * from "babylonjs/Loading/Plugins/index";
  62739. export * from "babylonjs/Loading/sceneLoader";
  62740. export * from "babylonjs/Loading/sceneLoaderFlags";
  62741. }
  62742. declare module "babylonjs/Materials/Background/index" {
  62743. export * from "babylonjs/Materials/Background/backgroundMaterial";
  62744. }
  62745. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  62746. import { Scene } from "babylonjs/scene";
  62747. import { Color3 } from "babylonjs/Maths/math.color";
  62748. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62749. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62750. /**
  62751. * The Physically based simple base material of BJS.
  62752. *
  62753. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62754. * It is used as the base class for both the specGloss and metalRough conventions.
  62755. */
  62756. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62757. /**
  62758. * Number of Simultaneous lights allowed on the material.
  62759. */
  62760. maxSimultaneousLights: number;
  62761. /**
  62762. * If sets to true, disables all the lights affecting the material.
  62763. */
  62764. disableLighting: boolean;
  62765. /**
  62766. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62767. */
  62768. environmentTexture: BaseTexture;
  62769. /**
  62770. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62771. */
  62772. invertNormalMapX: boolean;
  62773. /**
  62774. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62775. */
  62776. invertNormalMapY: boolean;
  62777. /**
  62778. * Normal map used in the model.
  62779. */
  62780. normalTexture: BaseTexture;
  62781. /**
  62782. * Emissivie color used to self-illuminate the model.
  62783. */
  62784. emissiveColor: Color3;
  62785. /**
  62786. * Emissivie texture used to self-illuminate the model.
  62787. */
  62788. emissiveTexture: BaseTexture;
  62789. /**
  62790. * Occlusion Channel Strenght.
  62791. */
  62792. occlusionStrength: number;
  62793. /**
  62794. * Occlusion Texture of the material (adding extra occlusion effects).
  62795. */
  62796. occlusionTexture: BaseTexture;
  62797. /**
  62798. * Defines the alpha limits in alpha test mode.
  62799. */
  62800. alphaCutOff: number;
  62801. /**
  62802. * Gets the current double sided mode.
  62803. */
  62804. get doubleSided(): boolean;
  62805. /**
  62806. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62807. */
  62808. set doubleSided(value: boolean);
  62809. /**
  62810. * Stores the pre-calculated light information of a mesh in a texture.
  62811. */
  62812. lightmapTexture: BaseTexture;
  62813. /**
  62814. * If true, the light map contains occlusion information instead of lighting info.
  62815. */
  62816. useLightmapAsShadowmap: boolean;
  62817. /**
  62818. * Instantiates a new PBRMaterial instance.
  62819. *
  62820. * @param name The material name
  62821. * @param scene The scene the material will be use in.
  62822. */
  62823. constructor(name: string, scene: Scene);
  62824. getClassName(): string;
  62825. }
  62826. }
  62827. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  62828. import { Scene } from "babylonjs/scene";
  62829. import { Color3 } from "babylonjs/Maths/math.color";
  62830. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62831. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62832. /**
  62833. * The PBR material of BJS following the metal roughness convention.
  62834. *
  62835. * This fits to the PBR convention in the GLTF definition:
  62836. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62837. */
  62838. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62839. /**
  62840. * The base color has two different interpretations depending on the value of metalness.
  62841. * When the material is a metal, the base color is the specific measured reflectance value
  62842. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62843. * of the material.
  62844. */
  62845. baseColor: Color3;
  62846. /**
  62847. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62848. * well as opacity information in the alpha channel.
  62849. */
  62850. baseTexture: BaseTexture;
  62851. /**
  62852. * Specifies the metallic scalar value of the material.
  62853. * Can also be used to scale the metalness values of the metallic texture.
  62854. */
  62855. metallic: number;
  62856. /**
  62857. * Specifies the roughness scalar value of the material.
  62858. * Can also be used to scale the roughness values of the metallic texture.
  62859. */
  62860. roughness: number;
  62861. /**
  62862. * Texture containing both the metallic value in the B channel and the
  62863. * roughness value in the G channel to keep better precision.
  62864. */
  62865. metallicRoughnessTexture: BaseTexture;
  62866. /**
  62867. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62868. *
  62869. * @param name The material name
  62870. * @param scene The scene the material will be use in.
  62871. */
  62872. constructor(name: string, scene: Scene);
  62873. /**
  62874. * Return the currrent class name of the material.
  62875. */
  62876. getClassName(): string;
  62877. /**
  62878. * Makes a duplicate of the current material.
  62879. * @param name - name to use for the new material.
  62880. */
  62881. clone(name: string): PBRMetallicRoughnessMaterial;
  62882. /**
  62883. * Serialize the material to a parsable JSON object.
  62884. */
  62885. serialize(): any;
  62886. /**
  62887. * Parses a JSON object correponding to the serialize function.
  62888. */
  62889. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62890. }
  62891. }
  62892. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  62893. import { Scene } from "babylonjs/scene";
  62894. import { Color3 } from "babylonjs/Maths/math.color";
  62895. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62896. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62897. /**
  62898. * The PBR material of BJS following the specular glossiness convention.
  62899. *
  62900. * This fits to the PBR convention in the GLTF definition:
  62901. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62902. */
  62903. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62904. /**
  62905. * Specifies the diffuse color of the material.
  62906. */
  62907. diffuseColor: Color3;
  62908. /**
  62909. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62910. * channel.
  62911. */
  62912. diffuseTexture: BaseTexture;
  62913. /**
  62914. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62915. */
  62916. specularColor: Color3;
  62917. /**
  62918. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62919. */
  62920. glossiness: number;
  62921. /**
  62922. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62923. */
  62924. specularGlossinessTexture: BaseTexture;
  62925. /**
  62926. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62927. *
  62928. * @param name The material name
  62929. * @param scene The scene the material will be use in.
  62930. */
  62931. constructor(name: string, scene: Scene);
  62932. /**
  62933. * Return the currrent class name of the material.
  62934. */
  62935. getClassName(): string;
  62936. /**
  62937. * Makes a duplicate of the current material.
  62938. * @param name - name to use for the new material.
  62939. */
  62940. clone(name: string): PBRSpecularGlossinessMaterial;
  62941. /**
  62942. * Serialize the material to a parsable JSON object.
  62943. */
  62944. serialize(): any;
  62945. /**
  62946. * Parses a JSON object correponding to the serialize function.
  62947. */
  62948. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62949. }
  62950. }
  62951. declare module "babylonjs/Materials/PBR/index" {
  62952. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62953. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62954. export * from "babylonjs/Materials/PBR/pbrMaterial";
  62955. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  62956. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  62957. }
  62958. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  62959. import { Nullable } from "babylonjs/types";
  62960. import { Scene } from "babylonjs/scene";
  62961. import { Matrix } from "babylonjs/Maths/math.vector";
  62962. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62963. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62964. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62965. /**
  62966. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62967. * It can help converting any input color in a desired output one. This can then be used to create effects
  62968. * from sepia, black and white to sixties or futuristic rendering...
  62969. *
  62970. * The only supported format is currently 3dl.
  62971. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62972. */
  62973. export class ColorGradingTexture extends BaseTexture {
  62974. /**
  62975. * The texture URL.
  62976. */
  62977. url: string;
  62978. /**
  62979. * Empty line regex stored for GC.
  62980. */
  62981. private static _noneEmptyLineRegex;
  62982. private _textureMatrix;
  62983. private _onLoad;
  62984. /**
  62985. * Instantiates a ColorGradingTexture from the following parameters.
  62986. *
  62987. * @param url The location of the color gradind data (currently only supporting 3dl)
  62988. * @param sceneOrEngine The scene or engine the texture will be used in
  62989. * @param onLoad defines a callback triggered when the texture has been loaded
  62990. */
  62991. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62992. /**
  62993. * Fires the onload event from the constructor if requested.
  62994. */
  62995. private _triggerOnLoad;
  62996. /**
  62997. * Returns the texture matrix used in most of the material.
  62998. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62999. */
  63000. getTextureMatrix(): Matrix;
  63001. /**
  63002. * Occurs when the file being loaded is a .3dl LUT file.
  63003. */
  63004. private load3dlTexture;
  63005. /**
  63006. * Starts the loading process of the texture.
  63007. */
  63008. private loadTexture;
  63009. /**
  63010. * Clones the color gradind texture.
  63011. */
  63012. clone(): ColorGradingTexture;
  63013. /**
  63014. * Called during delayed load for textures.
  63015. */
  63016. delayLoad(): void;
  63017. /**
  63018. * Parses a color grading texture serialized by Babylon.
  63019. * @param parsedTexture The texture information being parsedTexture
  63020. * @param scene The scene to load the texture in
  63021. * @param rootUrl The root url of the data assets to load
  63022. * @return A color gradind texture
  63023. */
  63024. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63025. /**
  63026. * Serializes the LUT texture to json format.
  63027. */
  63028. serialize(): any;
  63029. }
  63030. }
  63031. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  63032. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63033. import { Scene } from "babylonjs/scene";
  63034. import { Nullable } from "babylonjs/types";
  63035. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63036. /**
  63037. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63038. */
  63039. export class EquiRectangularCubeTexture extends BaseTexture {
  63040. /** The six faces of the cube. */
  63041. private static _FacesMapping;
  63042. private _noMipmap;
  63043. private _onLoad;
  63044. private _onError;
  63045. /** The size of the cubemap. */
  63046. private _size;
  63047. /** The buffer of the image. */
  63048. private _buffer;
  63049. /** The width of the input image. */
  63050. private _width;
  63051. /** The height of the input image. */
  63052. private _height;
  63053. /** The URL to the image. */
  63054. url: string;
  63055. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  63056. coordinatesMode: number;
  63057. /**
  63058. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63059. * @param url The location of the image
  63060. * @param scene The scene the texture will be used in
  63061. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63062. * @param noMipmap Forces to not generate the mipmap if true
  63063. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63064. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63065. * @param onLoad — defines a callback called when texture is loaded
  63066. * @param onError — defines a callback called if there is an error
  63067. */
  63068. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63069. /**
  63070. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63071. */
  63072. private loadImage;
  63073. /**
  63074. * Convert the image buffer into a cubemap and create a CubeTexture.
  63075. */
  63076. private loadTexture;
  63077. /**
  63078. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63079. * @param buffer The ArrayBuffer that should be converted.
  63080. * @returns The buffer as Float32Array.
  63081. */
  63082. private getFloat32ArrayFromArrayBuffer;
  63083. /**
  63084. * Get the current class name of the texture useful for serialization or dynamic coding.
  63085. * @returns "EquiRectangularCubeTexture"
  63086. */
  63087. getClassName(): string;
  63088. /**
  63089. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63090. * @returns A clone of the current EquiRectangularCubeTexture.
  63091. */
  63092. clone(): EquiRectangularCubeTexture;
  63093. }
  63094. }
  63095. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  63096. import { Nullable } from "babylonjs/types";
  63097. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63098. import { Matrix } from "babylonjs/Maths/math.vector";
  63099. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  63100. import "babylonjs/Engines/Extensions/engine.videoTexture";
  63101. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63102. import { Scene } from "babylonjs/scene";
  63103. /**
  63104. * Defines the options related to the creation of an HtmlElementTexture
  63105. */
  63106. export interface IHtmlElementTextureOptions {
  63107. /**
  63108. * Defines wether mip maps should be created or not.
  63109. */
  63110. generateMipMaps?: boolean;
  63111. /**
  63112. * Defines the sampling mode of the texture.
  63113. */
  63114. samplingMode?: number;
  63115. /**
  63116. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63117. */
  63118. engine: Nullable<ThinEngine>;
  63119. /**
  63120. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63121. */
  63122. scene: Nullable<Scene>;
  63123. }
  63124. /**
  63125. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63126. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63127. * is automatically managed.
  63128. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63129. * in your application.
  63130. *
  63131. * As the update is not automatic, you need to call them manually.
  63132. */
  63133. export class HtmlElementTexture extends BaseTexture {
  63134. /**
  63135. * The texture URL.
  63136. */
  63137. element: HTMLVideoElement | HTMLCanvasElement;
  63138. private static readonly DefaultOptions;
  63139. private _textureMatrix;
  63140. private _isVideo;
  63141. private _generateMipMaps;
  63142. private _samplingMode;
  63143. /**
  63144. * Instantiates a HtmlElementTexture from the following parameters.
  63145. *
  63146. * @param name Defines the name of the texture
  63147. * @param element Defines the video or canvas the texture is filled with
  63148. * @param options Defines the other none mandatory texture creation options
  63149. */
  63150. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  63151. private _createInternalTexture;
  63152. /**
  63153. * Returns the texture matrix used in most of the material.
  63154. */
  63155. getTextureMatrix(): Matrix;
  63156. /**
  63157. * Updates the content of the texture.
  63158. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  63159. */
  63160. update(invertY?: Nullable<boolean>): void;
  63161. }
  63162. }
  63163. declare module "babylonjs/Misc/tga" {
  63164. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63165. /**
  63166. * Based on jsTGALoader - Javascript loader for TGA file
  63167. * By Vincent Thibault
  63168. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63169. */
  63170. export class TGATools {
  63171. private static _TYPE_INDEXED;
  63172. private static _TYPE_RGB;
  63173. private static _TYPE_GREY;
  63174. private static _TYPE_RLE_INDEXED;
  63175. private static _TYPE_RLE_RGB;
  63176. private static _TYPE_RLE_GREY;
  63177. private static _ORIGIN_MASK;
  63178. private static _ORIGIN_SHIFT;
  63179. private static _ORIGIN_BL;
  63180. private static _ORIGIN_BR;
  63181. private static _ORIGIN_UL;
  63182. private static _ORIGIN_UR;
  63183. /**
  63184. * Gets the header of a TGA file
  63185. * @param data defines the TGA data
  63186. * @returns the header
  63187. */
  63188. static GetTGAHeader(data: Uint8Array): any;
  63189. /**
  63190. * Uploads TGA content to a Babylon Texture
  63191. * @hidden
  63192. */
  63193. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63194. /** @hidden */
  63195. 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;
  63196. /** @hidden */
  63197. 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;
  63198. /** @hidden */
  63199. 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;
  63200. /** @hidden */
  63201. 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;
  63202. /** @hidden */
  63203. 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;
  63204. /** @hidden */
  63205. 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;
  63206. }
  63207. }
  63208. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  63209. import { Nullable } from "babylonjs/types";
  63210. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63211. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63212. /**
  63213. * Implementation of the TGA Texture Loader.
  63214. * @hidden
  63215. */
  63216. export class _TGATextureLoader implements IInternalTextureLoader {
  63217. /**
  63218. * Defines wether the loader supports cascade loading the different faces.
  63219. */
  63220. readonly supportCascades: boolean;
  63221. /**
  63222. * This returns if the loader support the current file information.
  63223. * @param extension defines the file extension of the file being loaded
  63224. * @returns true if the loader can load the specified file
  63225. */
  63226. canLoad(extension: string): boolean;
  63227. /**
  63228. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63229. * @param data contains the texture data
  63230. * @param texture defines the BabylonJS internal texture
  63231. * @param createPolynomials will be true if polynomials have been requested
  63232. * @param onLoad defines the callback to trigger once the texture is ready
  63233. * @param onError defines the callback to trigger in case of error
  63234. */
  63235. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63236. /**
  63237. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63238. * @param data contains the texture data
  63239. * @param texture defines the BabylonJS internal texture
  63240. * @param callback defines the method to call once ready to upload
  63241. */
  63242. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63243. }
  63244. }
  63245. declare module "babylonjs/Misc/basis" {
  63246. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63247. /**
  63248. * Info about the .basis files
  63249. */
  63250. class BasisFileInfo {
  63251. /**
  63252. * If the file has alpha
  63253. */
  63254. hasAlpha: boolean;
  63255. /**
  63256. * Info about each image of the basis file
  63257. */
  63258. images: Array<{
  63259. levels: Array<{
  63260. width: number;
  63261. height: number;
  63262. transcodedPixels: ArrayBufferView;
  63263. }>;
  63264. }>;
  63265. }
  63266. /**
  63267. * Result of transcoding a basis file
  63268. */
  63269. class TranscodeResult {
  63270. /**
  63271. * Info about the .basis file
  63272. */
  63273. fileInfo: BasisFileInfo;
  63274. /**
  63275. * Format to use when loading the file
  63276. */
  63277. format: number;
  63278. }
  63279. /**
  63280. * Configuration options for the Basis transcoder
  63281. */
  63282. export class BasisTranscodeConfiguration {
  63283. /**
  63284. * Supported compression formats used to determine the supported output format of the transcoder
  63285. */
  63286. supportedCompressionFormats?: {
  63287. /**
  63288. * etc1 compression format
  63289. */
  63290. etc1?: boolean;
  63291. /**
  63292. * s3tc compression format
  63293. */
  63294. s3tc?: boolean;
  63295. /**
  63296. * pvrtc compression format
  63297. */
  63298. pvrtc?: boolean;
  63299. /**
  63300. * etc2 compression format
  63301. */
  63302. etc2?: boolean;
  63303. };
  63304. /**
  63305. * If mipmap levels should be loaded for transcoded images (Default: true)
  63306. */
  63307. loadMipmapLevels?: boolean;
  63308. /**
  63309. * Index of a single image to load (Default: all images)
  63310. */
  63311. loadSingleImage?: number;
  63312. }
  63313. /**
  63314. * Used to load .Basis files
  63315. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  63316. */
  63317. export class BasisTools {
  63318. private static _IgnoreSupportedFormats;
  63319. /**
  63320. * URL to use when loading the basis transcoder
  63321. */
  63322. static JSModuleURL: string;
  63323. /**
  63324. * URL to use when loading the wasm module for the transcoder
  63325. */
  63326. static WasmModuleURL: string;
  63327. /**
  63328. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  63329. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  63330. * @returns internal format corresponding to the Basis format
  63331. */
  63332. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  63333. private static _WorkerPromise;
  63334. private static _Worker;
  63335. private static _actionId;
  63336. private static _CreateWorkerAsync;
  63337. /**
  63338. * Transcodes a loaded image file to compressed pixel data
  63339. * @param data image data to transcode
  63340. * @param config configuration options for the transcoding
  63341. * @returns a promise resulting in the transcoded image
  63342. */
  63343. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  63344. /**
  63345. * Loads a texture from the transcode result
  63346. * @param texture texture load to
  63347. * @param transcodeResult the result of transcoding the basis file to load from
  63348. */
  63349. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  63350. }
  63351. }
  63352. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  63353. import { Nullable } from "babylonjs/types";
  63354. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63355. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63356. /**
  63357. * Loader for .basis file format
  63358. */
  63359. export class _BasisTextureLoader implements IInternalTextureLoader {
  63360. /**
  63361. * Defines whether the loader supports cascade loading the different faces.
  63362. */
  63363. readonly supportCascades: boolean;
  63364. /**
  63365. * This returns if the loader support the current file information.
  63366. * @param extension defines the file extension of the file being loaded
  63367. * @returns true if the loader can load the specified file
  63368. */
  63369. canLoad(extension: string): boolean;
  63370. /**
  63371. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63372. * @param data contains the texture data
  63373. * @param texture defines the BabylonJS internal texture
  63374. * @param createPolynomials will be true if polynomials have been requested
  63375. * @param onLoad defines the callback to trigger once the texture is ready
  63376. * @param onError defines the callback to trigger in case of error
  63377. */
  63378. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63379. /**
  63380. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63381. * @param data contains the texture data
  63382. * @param texture defines the BabylonJS internal texture
  63383. * @param callback defines the method to call once ready to upload
  63384. */
  63385. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63386. }
  63387. }
  63388. declare module "babylonjs/Materials/Textures/Loaders/index" {
  63389. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  63390. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  63391. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  63392. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  63393. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  63394. }
  63395. declare module "babylonjs/Materials/Textures/Packer/frame" {
  63396. import { Vector2 } from "babylonjs/Maths/math.vector";
  63397. /**
  63398. * Defines the basic options interface of a TexturePacker Frame
  63399. */
  63400. export interface ITexturePackerFrame {
  63401. /**
  63402. * The frame ID
  63403. */
  63404. id: number;
  63405. /**
  63406. * The frames Scale
  63407. */
  63408. scale: Vector2;
  63409. /**
  63410. * The Frames offset
  63411. */
  63412. offset: Vector2;
  63413. }
  63414. /**
  63415. * This is a support class for frame Data on texture packer sets.
  63416. */
  63417. export class TexturePackerFrame implements ITexturePackerFrame {
  63418. /**
  63419. * The frame ID
  63420. */
  63421. id: number;
  63422. /**
  63423. * The frames Scale
  63424. */
  63425. scale: Vector2;
  63426. /**
  63427. * The Frames offset
  63428. */
  63429. offset: Vector2;
  63430. /**
  63431. * Initializes a texture package frame.
  63432. * @param id The numerical frame identifier
  63433. * @param scale Scalar Vector2 for UV frame
  63434. * @param offset Vector2 for the frame position in UV units.
  63435. * @returns TexturePackerFrame
  63436. */
  63437. constructor(id: number, scale: Vector2, offset: Vector2);
  63438. }
  63439. }
  63440. declare module "babylonjs/Materials/Textures/Packer/packer" {
  63441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63442. import { Scene } from "babylonjs/scene";
  63443. import { Nullable } from "babylonjs/types";
  63444. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  63445. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  63446. /**
  63447. * Defines the basic options interface of a TexturePacker
  63448. */
  63449. export interface ITexturePackerOptions {
  63450. /**
  63451. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63452. */
  63453. map?: string[];
  63454. /**
  63455. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63456. */
  63457. uvsIn?: string;
  63458. /**
  63459. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63460. */
  63461. uvsOut?: string;
  63462. /**
  63463. * number representing the layout style. Defaults to LAYOUT_STRIP
  63464. */
  63465. layout?: number;
  63466. /**
  63467. * number of columns if using custom column count layout(2). This defaults to 4.
  63468. */
  63469. colnum?: number;
  63470. /**
  63471. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63472. */
  63473. updateInputMeshes?: boolean;
  63474. /**
  63475. * boolean flag to dispose all the source textures. Defaults to true.
  63476. */
  63477. disposeSources?: boolean;
  63478. /**
  63479. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63480. */
  63481. fillBlanks?: boolean;
  63482. /**
  63483. * string value representing the context fill style color. Defaults to 'black'.
  63484. */
  63485. customFillColor?: string;
  63486. /**
  63487. * Width and Height Value of each Frame in the TexturePacker Sets
  63488. */
  63489. frameSize?: number;
  63490. /**
  63491. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63492. */
  63493. paddingRatio?: number;
  63494. /**
  63495. * Number that declares the fill method for the padding gutter.
  63496. */
  63497. paddingMode?: number;
  63498. /**
  63499. * If in SUBUV_COLOR padding mode what color to use.
  63500. */
  63501. paddingColor?: Color3 | Color4;
  63502. }
  63503. /**
  63504. * Defines the basic interface of a TexturePacker JSON File
  63505. */
  63506. export interface ITexturePackerJSON {
  63507. /**
  63508. * The frame ID
  63509. */
  63510. name: string;
  63511. /**
  63512. * The base64 channel data
  63513. */
  63514. sets: any;
  63515. /**
  63516. * The options of the Packer
  63517. */
  63518. options: ITexturePackerOptions;
  63519. /**
  63520. * The frame data of the Packer
  63521. */
  63522. frames: Array<number>;
  63523. }
  63524. /**
  63525. * This is a support class that generates a series of packed texture sets.
  63526. * @see https://doc.babylonjs.com/babylon101/materials
  63527. */
  63528. export class TexturePacker {
  63529. /** Packer Layout Constant 0 */
  63530. static readonly LAYOUT_STRIP: number;
  63531. /** Packer Layout Constant 1 */
  63532. static readonly LAYOUT_POWER2: number;
  63533. /** Packer Layout Constant 2 */
  63534. static readonly LAYOUT_COLNUM: number;
  63535. /** Packer Layout Constant 0 */
  63536. static readonly SUBUV_WRAP: number;
  63537. /** Packer Layout Constant 1 */
  63538. static readonly SUBUV_EXTEND: number;
  63539. /** Packer Layout Constant 2 */
  63540. static readonly SUBUV_COLOR: number;
  63541. /** The Name of the Texture Package */
  63542. name: string;
  63543. /** The scene scope of the TexturePacker */
  63544. scene: Scene;
  63545. /** The Meshes to target */
  63546. meshes: AbstractMesh[];
  63547. /** Arguments passed with the Constructor */
  63548. options: ITexturePackerOptions;
  63549. /** The promise that is started upon initialization */
  63550. promise: Nullable<Promise<TexturePacker | string>>;
  63551. /** The Container object for the channel sets that are generated */
  63552. sets: object;
  63553. /** The Container array for the frames that are generated */
  63554. frames: TexturePackerFrame[];
  63555. /** The expected number of textures the system is parsing. */
  63556. private _expecting;
  63557. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63558. private _paddingValue;
  63559. /**
  63560. * Initializes a texture package series from an array of meshes or a single mesh.
  63561. * @param name The name of the package
  63562. * @param meshes The target meshes to compose the package from
  63563. * @param options The arguments that texture packer should follow while building.
  63564. * @param scene The scene which the textures are scoped to.
  63565. * @returns TexturePacker
  63566. */
  63567. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63568. /**
  63569. * Starts the package process
  63570. * @param resolve The promises resolution function
  63571. * @returns TexturePacker
  63572. */
  63573. private _createFrames;
  63574. /**
  63575. * Calculates the Size of the Channel Sets
  63576. * @returns Vector2
  63577. */
  63578. private _calculateSize;
  63579. /**
  63580. * Calculates the UV data for the frames.
  63581. * @param baseSize the base frameSize
  63582. * @param padding the base frame padding
  63583. * @param dtSize size of the Dynamic Texture for that channel
  63584. * @param dtUnits is 1/dtSize
  63585. * @param update flag to update the input meshes
  63586. */
  63587. private _calculateMeshUVFrames;
  63588. /**
  63589. * Calculates the frames Offset.
  63590. * @param index of the frame
  63591. * @returns Vector2
  63592. */
  63593. private _getFrameOffset;
  63594. /**
  63595. * Updates a Mesh to the frame data
  63596. * @param mesh that is the target
  63597. * @param frameID or the frame index
  63598. */
  63599. private _updateMeshUV;
  63600. /**
  63601. * Updates a Meshes materials to use the texture packer channels
  63602. * @param m is the mesh to target
  63603. * @param force all channels on the packer to be set.
  63604. */
  63605. private _updateTextureReferences;
  63606. /**
  63607. * Public method to set a Mesh to a frame
  63608. * @param m that is the target
  63609. * @param frameID or the frame index
  63610. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63611. */
  63612. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63613. /**
  63614. * Starts the async promise to compile the texture packer.
  63615. * @returns Promise<void>
  63616. */
  63617. processAsync(): Promise<void>;
  63618. /**
  63619. * Disposes all textures associated with this packer
  63620. */
  63621. dispose(): void;
  63622. /**
  63623. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63624. * @param imageType is the image type to use.
  63625. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63626. */
  63627. download(imageType?: string, quality?: number): void;
  63628. /**
  63629. * Public method to load a texturePacker JSON file.
  63630. * @param data of the JSON file in string format.
  63631. */
  63632. updateFromJSON(data: string): void;
  63633. }
  63634. }
  63635. declare module "babylonjs/Materials/Textures/Packer/index" {
  63636. export * from "babylonjs/Materials/Textures/Packer/packer";
  63637. export * from "babylonjs/Materials/Textures/Packer/frame";
  63638. }
  63639. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  63640. import { Scene } from "babylonjs/scene";
  63641. import { Texture } from "babylonjs/Materials/Textures/texture";
  63642. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63643. /**
  63644. * 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.
  63645. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63646. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63647. */
  63648. export class CustomProceduralTexture extends ProceduralTexture {
  63649. private _animate;
  63650. private _time;
  63651. private _config;
  63652. private _texturePath;
  63653. /**
  63654. * Instantiates a new Custom Procedural Texture.
  63655. * 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.
  63656. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63657. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63658. * @param name Define the name of the texture
  63659. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63660. * @param size Define the size of the texture to create
  63661. * @param scene Define the scene the texture belongs to
  63662. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63663. * @param generateMipMaps Define if the texture should creates mip maps or not
  63664. */
  63665. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63666. private _loadJson;
  63667. /**
  63668. * Is the texture ready to be used ? (rendered at least once)
  63669. * @returns true if ready, otherwise, false.
  63670. */
  63671. isReady(): boolean;
  63672. /**
  63673. * Render the texture to its associated render target.
  63674. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63675. */
  63676. render(useCameraPostProcess?: boolean): void;
  63677. /**
  63678. * Update the list of dependant textures samplers in the shader.
  63679. */
  63680. updateTextures(): void;
  63681. /**
  63682. * Update the uniform values of the procedural texture in the shader.
  63683. */
  63684. updateShaderUniforms(): void;
  63685. /**
  63686. * Define if the texture animates or not.
  63687. */
  63688. get animate(): boolean;
  63689. set animate(value: boolean);
  63690. }
  63691. }
  63692. declare module "babylonjs/Shaders/noise.fragment" {
  63693. /** @hidden */
  63694. export var noisePixelShader: {
  63695. name: string;
  63696. shader: string;
  63697. };
  63698. }
  63699. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  63700. import { Nullable } from "babylonjs/types";
  63701. import { Scene } from "babylonjs/scene";
  63702. import { Texture } from "babylonjs/Materials/Textures/texture";
  63703. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63704. import "babylonjs/Shaders/noise.fragment";
  63705. /**
  63706. * Class used to generate noise procedural textures
  63707. */
  63708. export class NoiseProceduralTexture extends ProceduralTexture {
  63709. private _time;
  63710. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63711. brightness: number;
  63712. /** Defines the number of octaves to process */
  63713. octaves: number;
  63714. /** Defines the level of persistence (0.8 by default) */
  63715. persistence: number;
  63716. /** Gets or sets animation speed factor (default is 1) */
  63717. animationSpeedFactor: number;
  63718. /**
  63719. * Creates a new NoiseProceduralTexture
  63720. * @param name defines the name fo the texture
  63721. * @param size defines the size of the texture (default is 256)
  63722. * @param scene defines the hosting scene
  63723. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63724. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63725. */
  63726. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63727. private _updateShaderUniforms;
  63728. protected _getDefines(): string;
  63729. /** Generate the current state of the procedural texture */
  63730. render(useCameraPostProcess?: boolean): void;
  63731. /**
  63732. * Serializes this noise procedural texture
  63733. * @returns a serialized noise procedural texture object
  63734. */
  63735. serialize(): any;
  63736. /**
  63737. * Clone the texture.
  63738. * @returns the cloned texture
  63739. */
  63740. clone(): NoiseProceduralTexture;
  63741. /**
  63742. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63743. * @param parsedTexture defines parsed texture data
  63744. * @param scene defines the current scene
  63745. * @param rootUrl defines the root URL containing noise procedural texture information
  63746. * @returns a parsed NoiseProceduralTexture
  63747. */
  63748. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63749. }
  63750. }
  63751. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  63752. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  63753. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  63754. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63755. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  63756. }
  63757. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  63758. import { Nullable } from "babylonjs/types";
  63759. import { Scene } from "babylonjs/scene";
  63760. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  63761. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63762. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63763. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63764. /**
  63765. * Raw cube texture where the raw buffers are passed in
  63766. */
  63767. export class RawCubeTexture extends CubeTexture {
  63768. /**
  63769. * Creates a cube texture where the raw buffers are passed in.
  63770. * @param scene defines the scene the texture is attached to
  63771. * @param data defines the array of data to use to create each face
  63772. * @param size defines the size of the textures
  63773. * @param format defines the format of the data
  63774. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63775. * @param generateMipMaps defines if the engine should generate the mip levels
  63776. * @param invertY defines if data must be stored with Y axis inverted
  63777. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63778. * @param compression defines the compression used (null by default)
  63779. */
  63780. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63781. /**
  63782. * Updates the raw cube texture.
  63783. * @param data defines the data to store
  63784. * @param format defines the data format
  63785. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63786. * @param invertY defines if data must be stored with Y axis inverted
  63787. * @param compression defines the compression used (null by default)
  63788. * @param level defines which level of the texture to update
  63789. */
  63790. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63791. /**
  63792. * Updates a raw cube texture with RGBD encoded data.
  63793. * @param data defines the array of data [mipmap][face] to use to create each face
  63794. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63795. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63796. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63797. * @returns a promsie that resolves when the operation is complete
  63798. */
  63799. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63800. /**
  63801. * Clones the raw cube texture.
  63802. * @return a new cube texture
  63803. */
  63804. clone(): CubeTexture;
  63805. /** @hidden */
  63806. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63807. }
  63808. }
  63809. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  63810. import { Scene } from "babylonjs/scene";
  63811. import { Texture } from "babylonjs/Materials/Textures/texture";
  63812. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63813. /**
  63814. * Class used to store 2D array textures containing user data
  63815. */
  63816. export class RawTexture2DArray extends Texture {
  63817. /** Gets or sets the texture format to use */
  63818. format: number;
  63819. /**
  63820. * Create a new RawTexture2DArray
  63821. * @param data defines the data of the texture
  63822. * @param width defines the width of the texture
  63823. * @param height defines the height of the texture
  63824. * @param depth defines the number of layers of the texture
  63825. * @param format defines the texture format to use
  63826. * @param scene defines the hosting scene
  63827. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63828. * @param invertY defines if texture must be stored with Y axis inverted
  63829. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63830. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63831. */
  63832. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63833. /** Gets or sets the texture format to use */
  63834. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63835. /**
  63836. * Update the texture with new data
  63837. * @param data defines the data to store in the texture
  63838. */
  63839. update(data: ArrayBufferView): void;
  63840. }
  63841. }
  63842. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  63843. import { Scene } from "babylonjs/scene";
  63844. import { Texture } from "babylonjs/Materials/Textures/texture";
  63845. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63846. /**
  63847. * Class used to store 3D textures containing user data
  63848. */
  63849. export class RawTexture3D extends Texture {
  63850. /** Gets or sets the texture format to use */
  63851. format: number;
  63852. /**
  63853. * Create a new RawTexture3D
  63854. * @param data defines the data of the texture
  63855. * @param width defines the width of the texture
  63856. * @param height defines the height of the texture
  63857. * @param depth defines the depth of the texture
  63858. * @param format defines the texture format to use
  63859. * @param scene defines the hosting scene
  63860. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63861. * @param invertY defines if texture must be stored with Y axis inverted
  63862. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63863. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63864. */
  63865. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63866. /** Gets or sets the texture format to use */
  63867. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63868. /**
  63869. * Update the texture with new data
  63870. * @param data defines the data to store in the texture
  63871. */
  63872. update(data: ArrayBufferView): void;
  63873. }
  63874. }
  63875. declare module "babylonjs/Materials/Textures/refractionTexture" {
  63876. import { Scene } from "babylonjs/scene";
  63877. import { Plane } from "babylonjs/Maths/math.plane";
  63878. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63879. /**
  63880. * Creates a refraction texture used by refraction channel of the standard material.
  63881. * It is like a mirror but to see through a material.
  63882. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63883. */
  63884. export class RefractionTexture extends RenderTargetTexture {
  63885. /**
  63886. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63887. * 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.
  63888. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63889. */
  63890. refractionPlane: Plane;
  63891. /**
  63892. * Define how deep under the surface we should see.
  63893. */
  63894. depth: number;
  63895. /**
  63896. * Creates a refraction texture used by refraction channel of the standard material.
  63897. * It is like a mirror but to see through a material.
  63898. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63899. * @param name Define the texture name
  63900. * @param size Define the size of the underlying texture
  63901. * @param scene Define the scene the refraction belongs to
  63902. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63903. */
  63904. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63905. /**
  63906. * Clone the refraction texture.
  63907. * @returns the cloned texture
  63908. */
  63909. clone(): RefractionTexture;
  63910. /**
  63911. * Serialize the texture to a JSON representation you could use in Parse later on
  63912. * @returns the serialized JSON representation
  63913. */
  63914. serialize(): any;
  63915. }
  63916. }
  63917. declare module "babylonjs/Materials/Textures/index" {
  63918. export * from "babylonjs/Materials/Textures/baseTexture";
  63919. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  63920. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  63921. export * from "babylonjs/Materials/Textures/cubeTexture";
  63922. export * from "babylonjs/Materials/Textures/dynamicTexture";
  63923. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  63924. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  63925. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  63926. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  63927. export * from "babylonjs/Materials/Textures/internalTexture";
  63928. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  63929. export * from "babylonjs/Materials/Textures/Loaders/index";
  63930. export * from "babylonjs/Materials/Textures/mirrorTexture";
  63931. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  63932. export * from "babylonjs/Materials/Textures/Packer/index";
  63933. export * from "babylonjs/Materials/Textures/Procedurals/index";
  63934. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  63935. export * from "babylonjs/Materials/Textures/rawTexture";
  63936. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  63937. export * from "babylonjs/Materials/Textures/rawTexture3D";
  63938. export * from "babylonjs/Materials/Textures/refractionTexture";
  63939. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  63940. export * from "babylonjs/Materials/Textures/texture";
  63941. export * from "babylonjs/Materials/Textures/videoTexture";
  63942. }
  63943. declare module "babylonjs/Materials/Node/Enums/index" {
  63944. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  63945. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  63946. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  63947. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  63948. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  63949. }
  63950. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  63951. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63952. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63953. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63954. import { Mesh } from "babylonjs/Meshes/mesh";
  63955. import { Effect } from "babylonjs/Materials/effect";
  63956. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63957. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63958. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63959. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63960. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  63961. /**
  63962. * Block used to add support for vertex skinning (bones)
  63963. */
  63964. export class BonesBlock extends NodeMaterialBlock {
  63965. /**
  63966. * Creates a new BonesBlock
  63967. * @param name defines the block name
  63968. */
  63969. constructor(name: string);
  63970. /**
  63971. * Initialize the block and prepare the context for build
  63972. * @param state defines the state that will be used for the build
  63973. */
  63974. initialize(state: NodeMaterialBuildState): void;
  63975. /**
  63976. * Gets the current class name
  63977. * @returns the class name
  63978. */
  63979. getClassName(): string;
  63980. /**
  63981. * Gets the matrix indices input component
  63982. */
  63983. get matricesIndices(): NodeMaterialConnectionPoint;
  63984. /**
  63985. * Gets the matrix weights input component
  63986. */
  63987. get matricesWeights(): NodeMaterialConnectionPoint;
  63988. /**
  63989. * Gets the extra matrix indices input component
  63990. */
  63991. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63992. /**
  63993. * Gets the extra matrix weights input component
  63994. */
  63995. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63996. /**
  63997. * Gets the world input component
  63998. */
  63999. get world(): NodeMaterialConnectionPoint;
  64000. /**
  64001. * Gets the output component
  64002. */
  64003. get output(): NodeMaterialConnectionPoint;
  64004. autoConfigure(material: NodeMaterial): void;
  64005. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  64006. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64007. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64008. protected _buildBlock(state: NodeMaterialBuildState): this;
  64009. }
  64010. }
  64011. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  64012. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64013. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64014. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64016. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64017. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64018. /**
  64019. * Block used to add support for instances
  64020. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  64021. */
  64022. export class InstancesBlock extends NodeMaterialBlock {
  64023. /**
  64024. * Creates a new InstancesBlock
  64025. * @param name defines the block name
  64026. */
  64027. constructor(name: string);
  64028. /**
  64029. * Gets the current class name
  64030. * @returns the class name
  64031. */
  64032. getClassName(): string;
  64033. /**
  64034. * Gets the first world row input component
  64035. */
  64036. get world0(): NodeMaterialConnectionPoint;
  64037. /**
  64038. * Gets the second world row input component
  64039. */
  64040. get world1(): NodeMaterialConnectionPoint;
  64041. /**
  64042. * Gets the third world row input component
  64043. */
  64044. get world2(): NodeMaterialConnectionPoint;
  64045. /**
  64046. * Gets the forth world row input component
  64047. */
  64048. get world3(): NodeMaterialConnectionPoint;
  64049. /**
  64050. * Gets the world input component
  64051. */
  64052. get world(): NodeMaterialConnectionPoint;
  64053. /**
  64054. * Gets the output component
  64055. */
  64056. get output(): NodeMaterialConnectionPoint;
  64057. /**
  64058. * Gets the isntanceID component
  64059. */
  64060. get instanceID(): NodeMaterialConnectionPoint;
  64061. autoConfigure(material: NodeMaterial): void;
  64062. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  64063. protected _buildBlock(state: NodeMaterialBuildState): this;
  64064. }
  64065. }
  64066. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  64067. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64068. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64069. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64071. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64072. import { Effect } from "babylonjs/Materials/effect";
  64073. import { Mesh } from "babylonjs/Meshes/mesh";
  64074. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64075. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64076. /**
  64077. * Block used to add morph targets support to vertex shader
  64078. */
  64079. export class MorphTargetsBlock extends NodeMaterialBlock {
  64080. private _repeatableContentAnchor;
  64081. /**
  64082. * Create a new MorphTargetsBlock
  64083. * @param name defines the block name
  64084. */
  64085. constructor(name: string);
  64086. /**
  64087. * Gets the current class name
  64088. * @returns the class name
  64089. */
  64090. getClassName(): string;
  64091. /**
  64092. * Gets the position input component
  64093. */
  64094. get position(): NodeMaterialConnectionPoint;
  64095. /**
  64096. * Gets the normal input component
  64097. */
  64098. get normal(): NodeMaterialConnectionPoint;
  64099. /**
  64100. * Gets the tangent input component
  64101. */
  64102. get tangent(): NodeMaterialConnectionPoint;
  64103. /**
  64104. * Gets the tangent input component
  64105. */
  64106. get uv(): NodeMaterialConnectionPoint;
  64107. /**
  64108. * Gets the position output component
  64109. */
  64110. get positionOutput(): NodeMaterialConnectionPoint;
  64111. /**
  64112. * Gets the normal output component
  64113. */
  64114. get normalOutput(): NodeMaterialConnectionPoint;
  64115. /**
  64116. * Gets the tangent output component
  64117. */
  64118. get tangentOutput(): NodeMaterialConnectionPoint;
  64119. /**
  64120. * Gets the tangent output component
  64121. */
  64122. get uvOutput(): NodeMaterialConnectionPoint;
  64123. initialize(state: NodeMaterialBuildState): void;
  64124. autoConfigure(material: NodeMaterial): void;
  64125. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64126. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64127. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64128. protected _buildBlock(state: NodeMaterialBuildState): this;
  64129. }
  64130. }
  64131. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  64132. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64133. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64134. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64135. import { Nullable } from "babylonjs/types";
  64136. import { Scene } from "babylonjs/scene";
  64137. import { Effect } from "babylonjs/Materials/effect";
  64138. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64139. import { Mesh } from "babylonjs/Meshes/mesh";
  64140. import { Light } from "babylonjs/Lights/light";
  64141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64142. /**
  64143. * Block used to get data information from a light
  64144. */
  64145. export class LightInformationBlock extends NodeMaterialBlock {
  64146. private _lightDataUniformName;
  64147. private _lightColorUniformName;
  64148. private _lightTypeDefineName;
  64149. /**
  64150. * Gets or sets the light associated with this block
  64151. */
  64152. light: Nullable<Light>;
  64153. /**
  64154. * Creates a new LightInformationBlock
  64155. * @param name defines the block name
  64156. */
  64157. constructor(name: string);
  64158. /**
  64159. * Gets the current class name
  64160. * @returns the class name
  64161. */
  64162. getClassName(): string;
  64163. /**
  64164. * Gets the world position input component
  64165. */
  64166. get worldPosition(): NodeMaterialConnectionPoint;
  64167. /**
  64168. * Gets the direction output component
  64169. */
  64170. get direction(): NodeMaterialConnectionPoint;
  64171. /**
  64172. * Gets the direction output component
  64173. */
  64174. get color(): NodeMaterialConnectionPoint;
  64175. /**
  64176. * Gets the direction output component
  64177. */
  64178. get intensity(): NodeMaterialConnectionPoint;
  64179. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64180. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64181. protected _buildBlock(state: NodeMaterialBuildState): this;
  64182. serialize(): any;
  64183. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64184. }
  64185. }
  64186. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  64187. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  64188. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  64189. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  64190. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  64191. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  64192. }
  64193. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  64194. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64195. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64196. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64198. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64199. import { Effect } from "babylonjs/Materials/effect";
  64200. import { Mesh } from "babylonjs/Meshes/mesh";
  64201. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64202. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  64203. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  64204. /**
  64205. * Block used to add image processing support to fragment shader
  64206. */
  64207. export class ImageProcessingBlock extends NodeMaterialBlock {
  64208. /**
  64209. * Create a new ImageProcessingBlock
  64210. * @param name defines the block name
  64211. */
  64212. constructor(name: string);
  64213. /**
  64214. * Gets the current class name
  64215. * @returns the class name
  64216. */
  64217. getClassName(): string;
  64218. /**
  64219. * Gets the color input component
  64220. */
  64221. get color(): NodeMaterialConnectionPoint;
  64222. /**
  64223. * Gets the output component
  64224. */
  64225. get output(): NodeMaterialConnectionPoint;
  64226. /**
  64227. * Initialize the block and prepare the context for build
  64228. * @param state defines the state that will be used for the build
  64229. */
  64230. initialize(state: NodeMaterialBuildState): void;
  64231. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  64232. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64233. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64234. protected _buildBlock(state: NodeMaterialBuildState): this;
  64235. }
  64236. }
  64237. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  64238. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64239. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64240. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64241. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64243. import { Effect } from "babylonjs/Materials/effect";
  64244. import { Mesh } from "babylonjs/Meshes/mesh";
  64245. import { Scene } from "babylonjs/scene";
  64246. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  64247. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  64248. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  64249. /**
  64250. * Block used to pertub normals based on a normal map
  64251. */
  64252. export class PerturbNormalBlock extends NodeMaterialBlock {
  64253. private _tangentSpaceParameterName;
  64254. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64255. invertX: boolean;
  64256. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  64257. invertY: boolean;
  64258. /**
  64259. * Create a new PerturbNormalBlock
  64260. * @param name defines the block name
  64261. */
  64262. constructor(name: string);
  64263. /**
  64264. * Gets the current class name
  64265. * @returns the class name
  64266. */
  64267. getClassName(): string;
  64268. /**
  64269. * Gets the world position input component
  64270. */
  64271. get worldPosition(): NodeMaterialConnectionPoint;
  64272. /**
  64273. * Gets the world normal input component
  64274. */
  64275. get worldNormal(): NodeMaterialConnectionPoint;
  64276. /**
  64277. * Gets the world tangent input component
  64278. */
  64279. get worldTangent(): NodeMaterialConnectionPoint;
  64280. /**
  64281. * Gets the uv input component
  64282. */
  64283. get uv(): NodeMaterialConnectionPoint;
  64284. /**
  64285. * Gets the normal map color input component
  64286. */
  64287. get normalMapColor(): NodeMaterialConnectionPoint;
  64288. /**
  64289. * Gets the strength input component
  64290. */
  64291. get strength(): NodeMaterialConnectionPoint;
  64292. /**
  64293. * Gets the output component
  64294. */
  64295. get output(): NodeMaterialConnectionPoint;
  64296. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64297. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64298. autoConfigure(material: NodeMaterial): void;
  64299. protected _buildBlock(state: NodeMaterialBuildState): this;
  64300. protected _dumpPropertiesCode(): string;
  64301. serialize(): any;
  64302. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64303. }
  64304. }
  64305. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  64306. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64307. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64308. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64309. /**
  64310. * Block used to discard a pixel if a value is smaller than a cutoff
  64311. */
  64312. export class DiscardBlock extends NodeMaterialBlock {
  64313. /**
  64314. * Create a new DiscardBlock
  64315. * @param name defines the block name
  64316. */
  64317. constructor(name: string);
  64318. /**
  64319. * Gets the current class name
  64320. * @returns the class name
  64321. */
  64322. getClassName(): string;
  64323. /**
  64324. * Gets the color input component
  64325. */
  64326. get value(): NodeMaterialConnectionPoint;
  64327. /**
  64328. * Gets the cutoff input component
  64329. */
  64330. get cutoff(): NodeMaterialConnectionPoint;
  64331. protected _buildBlock(state: NodeMaterialBuildState): this;
  64332. }
  64333. }
  64334. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  64335. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64336. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64337. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64338. /**
  64339. * Block used to test if the fragment shader is front facing
  64340. */
  64341. export class FrontFacingBlock extends NodeMaterialBlock {
  64342. /**
  64343. * Creates a new FrontFacingBlock
  64344. * @param name defines the block name
  64345. */
  64346. constructor(name: string);
  64347. /**
  64348. * Gets the current class name
  64349. * @returns the class name
  64350. */
  64351. getClassName(): string;
  64352. /**
  64353. * Gets the output component
  64354. */
  64355. get output(): NodeMaterialConnectionPoint;
  64356. protected _buildBlock(state: NodeMaterialBuildState): this;
  64357. }
  64358. }
  64359. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  64360. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64361. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64362. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64363. /**
  64364. * Block used to get the derivative value on x and y of a given input
  64365. */
  64366. export class DerivativeBlock extends NodeMaterialBlock {
  64367. /**
  64368. * Create a new DerivativeBlock
  64369. * @param name defines the block name
  64370. */
  64371. constructor(name: string);
  64372. /**
  64373. * Gets the current class name
  64374. * @returns the class name
  64375. */
  64376. getClassName(): string;
  64377. /**
  64378. * Gets the input component
  64379. */
  64380. get input(): NodeMaterialConnectionPoint;
  64381. /**
  64382. * Gets the derivative output on x
  64383. */
  64384. get dx(): NodeMaterialConnectionPoint;
  64385. /**
  64386. * Gets the derivative output on y
  64387. */
  64388. get dy(): NodeMaterialConnectionPoint;
  64389. protected _buildBlock(state: NodeMaterialBuildState): this;
  64390. }
  64391. }
  64392. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  64393. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64394. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64395. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64396. /**
  64397. * Block used to make gl_FragCoord available
  64398. */
  64399. export class FragCoordBlock extends NodeMaterialBlock {
  64400. /**
  64401. * Creates a new FragCoordBlock
  64402. * @param name defines the block name
  64403. */
  64404. constructor(name: string);
  64405. /**
  64406. * Gets the current class name
  64407. * @returns the class name
  64408. */
  64409. getClassName(): string;
  64410. /**
  64411. * Gets the xy component
  64412. */
  64413. get xy(): NodeMaterialConnectionPoint;
  64414. /**
  64415. * Gets the xyz component
  64416. */
  64417. get xyz(): NodeMaterialConnectionPoint;
  64418. /**
  64419. * Gets the xyzw component
  64420. */
  64421. get xyzw(): NodeMaterialConnectionPoint;
  64422. /**
  64423. * Gets the x component
  64424. */
  64425. get x(): NodeMaterialConnectionPoint;
  64426. /**
  64427. * Gets the y component
  64428. */
  64429. get y(): NodeMaterialConnectionPoint;
  64430. /**
  64431. * Gets the z component
  64432. */
  64433. get z(): NodeMaterialConnectionPoint;
  64434. /**
  64435. * Gets the w component
  64436. */
  64437. get output(): NodeMaterialConnectionPoint;
  64438. protected writeOutputs(state: NodeMaterialBuildState): string;
  64439. protected _buildBlock(state: NodeMaterialBuildState): this;
  64440. }
  64441. }
  64442. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  64443. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64444. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64445. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64446. import { Effect } from "babylonjs/Materials/effect";
  64447. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64448. import { Mesh } from "babylonjs/Meshes/mesh";
  64449. /**
  64450. * Block used to get the screen sizes
  64451. */
  64452. export class ScreenSizeBlock extends NodeMaterialBlock {
  64453. private _varName;
  64454. private _scene;
  64455. /**
  64456. * Creates a new ScreenSizeBlock
  64457. * @param name defines the block name
  64458. */
  64459. constructor(name: string);
  64460. /**
  64461. * Gets the current class name
  64462. * @returns the class name
  64463. */
  64464. getClassName(): string;
  64465. /**
  64466. * Gets the xy component
  64467. */
  64468. get xy(): NodeMaterialConnectionPoint;
  64469. /**
  64470. * Gets the x component
  64471. */
  64472. get x(): NodeMaterialConnectionPoint;
  64473. /**
  64474. * Gets the y component
  64475. */
  64476. get y(): NodeMaterialConnectionPoint;
  64477. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64478. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64479. protected _buildBlock(state: NodeMaterialBuildState): this;
  64480. }
  64481. }
  64482. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  64483. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  64484. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  64485. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  64486. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  64487. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  64488. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  64489. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  64490. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  64491. }
  64492. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  64493. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64494. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64495. import { Mesh } from "babylonjs/Meshes/mesh";
  64496. import { Effect } from "babylonjs/Materials/effect";
  64497. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64499. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64500. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  64501. /**
  64502. * Block used to add support for scene fog
  64503. */
  64504. export class FogBlock extends NodeMaterialBlock {
  64505. private _fogDistanceName;
  64506. private _fogParameters;
  64507. /**
  64508. * Create a new FogBlock
  64509. * @param name defines the block name
  64510. */
  64511. constructor(name: string);
  64512. /**
  64513. * Gets the current class name
  64514. * @returns the class name
  64515. */
  64516. getClassName(): string;
  64517. /**
  64518. * Gets the world position input component
  64519. */
  64520. get worldPosition(): NodeMaterialConnectionPoint;
  64521. /**
  64522. * Gets the view input component
  64523. */
  64524. get view(): NodeMaterialConnectionPoint;
  64525. /**
  64526. * Gets the color input component
  64527. */
  64528. get input(): NodeMaterialConnectionPoint;
  64529. /**
  64530. * Gets the fog color input component
  64531. */
  64532. get fogColor(): NodeMaterialConnectionPoint;
  64533. /**
  64534. * Gets the output component
  64535. */
  64536. get output(): NodeMaterialConnectionPoint;
  64537. autoConfigure(material: NodeMaterial): void;
  64538. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64539. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64540. protected _buildBlock(state: NodeMaterialBuildState): this;
  64541. }
  64542. }
  64543. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  64544. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64545. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64546. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64548. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64549. import { Effect } from "babylonjs/Materials/effect";
  64550. import { Mesh } from "babylonjs/Meshes/mesh";
  64551. import { Light } from "babylonjs/Lights/light";
  64552. import { Nullable } from "babylonjs/types";
  64553. import { Scene } from "babylonjs/scene";
  64554. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  64555. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  64556. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  64557. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64558. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  64559. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  64560. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  64561. /**
  64562. * Block used to add light in the fragment shader
  64563. */
  64564. export class LightBlock extends NodeMaterialBlock {
  64565. private _lightId;
  64566. /**
  64567. * Gets or sets the light associated with this block
  64568. */
  64569. light: Nullable<Light>;
  64570. /**
  64571. * Create a new LightBlock
  64572. * @param name defines the block name
  64573. */
  64574. constructor(name: string);
  64575. /**
  64576. * Gets the current class name
  64577. * @returns the class name
  64578. */
  64579. getClassName(): string;
  64580. /**
  64581. * Gets the world position input component
  64582. */
  64583. get worldPosition(): NodeMaterialConnectionPoint;
  64584. /**
  64585. * Gets the world normal input component
  64586. */
  64587. get worldNormal(): NodeMaterialConnectionPoint;
  64588. /**
  64589. * Gets the camera (or eye) position component
  64590. */
  64591. get cameraPosition(): NodeMaterialConnectionPoint;
  64592. /**
  64593. * Gets the glossiness component
  64594. */
  64595. get glossiness(): NodeMaterialConnectionPoint;
  64596. /**
  64597. * Gets the glossinness power component
  64598. */
  64599. get glossPower(): NodeMaterialConnectionPoint;
  64600. /**
  64601. * Gets the diffuse color component
  64602. */
  64603. get diffuseColor(): NodeMaterialConnectionPoint;
  64604. /**
  64605. * Gets the specular color component
  64606. */
  64607. get specularColor(): NodeMaterialConnectionPoint;
  64608. /**
  64609. * Gets the diffuse output component
  64610. */
  64611. get diffuseOutput(): NodeMaterialConnectionPoint;
  64612. /**
  64613. * Gets the specular output component
  64614. */
  64615. get specularOutput(): NodeMaterialConnectionPoint;
  64616. /**
  64617. * Gets the shadow output component
  64618. */
  64619. get shadow(): NodeMaterialConnectionPoint;
  64620. autoConfigure(material: NodeMaterial): void;
  64621. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64622. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64623. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64624. private _injectVertexCode;
  64625. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64626. serialize(): any;
  64627. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64628. }
  64629. }
  64630. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  64631. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64632. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64633. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64634. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64635. /**
  64636. * Block used to read a reflection texture from a sampler
  64637. */
  64638. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64639. /**
  64640. * Create a new ReflectionTextureBlock
  64641. * @param name defines the block name
  64642. */
  64643. constructor(name: string);
  64644. /**
  64645. * Gets the current class name
  64646. * @returns the class name
  64647. */
  64648. getClassName(): string;
  64649. /**
  64650. * Gets the world position input component
  64651. */
  64652. get position(): NodeMaterialConnectionPoint;
  64653. /**
  64654. * Gets the world position input component
  64655. */
  64656. get worldPosition(): NodeMaterialConnectionPoint;
  64657. /**
  64658. * Gets the world normal input component
  64659. */
  64660. get worldNormal(): NodeMaterialConnectionPoint;
  64661. /**
  64662. * Gets the world input component
  64663. */
  64664. get world(): NodeMaterialConnectionPoint;
  64665. /**
  64666. * Gets the camera (or eye) position component
  64667. */
  64668. get cameraPosition(): NodeMaterialConnectionPoint;
  64669. /**
  64670. * Gets the view input component
  64671. */
  64672. get view(): NodeMaterialConnectionPoint;
  64673. /**
  64674. * Gets the rgb output component
  64675. */
  64676. get rgb(): NodeMaterialConnectionPoint;
  64677. /**
  64678. * Gets the r output component
  64679. */
  64680. get r(): NodeMaterialConnectionPoint;
  64681. /**
  64682. * Gets the g output component
  64683. */
  64684. get g(): NodeMaterialConnectionPoint;
  64685. /**
  64686. * Gets the b output component
  64687. */
  64688. get b(): NodeMaterialConnectionPoint;
  64689. autoConfigure(material: NodeMaterial): void;
  64690. protected _buildBlock(state: NodeMaterialBuildState): this;
  64691. }
  64692. }
  64693. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  64694. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  64695. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  64696. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  64697. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  64698. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  64699. }
  64700. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  64701. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  64702. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  64703. }
  64704. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  64705. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64706. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64707. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64708. /**
  64709. * Block used to add 2 vectors
  64710. */
  64711. export class AddBlock extends NodeMaterialBlock {
  64712. /**
  64713. * Creates a new AddBlock
  64714. * @param name defines the block name
  64715. */
  64716. constructor(name: string);
  64717. /**
  64718. * Gets the current class name
  64719. * @returns the class name
  64720. */
  64721. getClassName(): string;
  64722. /**
  64723. * Gets the left operand input component
  64724. */
  64725. get left(): NodeMaterialConnectionPoint;
  64726. /**
  64727. * Gets the right operand input component
  64728. */
  64729. get right(): NodeMaterialConnectionPoint;
  64730. /**
  64731. * Gets the output component
  64732. */
  64733. get output(): NodeMaterialConnectionPoint;
  64734. protected _buildBlock(state: NodeMaterialBuildState): this;
  64735. }
  64736. }
  64737. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  64738. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64739. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64740. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64741. /**
  64742. * Block used to scale a vector by a float
  64743. */
  64744. export class ScaleBlock extends NodeMaterialBlock {
  64745. /**
  64746. * Creates a new ScaleBlock
  64747. * @param name defines the block name
  64748. */
  64749. constructor(name: string);
  64750. /**
  64751. * Gets the current class name
  64752. * @returns the class name
  64753. */
  64754. getClassName(): string;
  64755. /**
  64756. * Gets the input component
  64757. */
  64758. get input(): NodeMaterialConnectionPoint;
  64759. /**
  64760. * Gets the factor input component
  64761. */
  64762. get factor(): NodeMaterialConnectionPoint;
  64763. /**
  64764. * Gets the output component
  64765. */
  64766. get output(): NodeMaterialConnectionPoint;
  64767. protected _buildBlock(state: NodeMaterialBuildState): this;
  64768. }
  64769. }
  64770. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  64771. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64772. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64773. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64774. import { Scene } from "babylonjs/scene";
  64775. /**
  64776. * Block used to clamp a float
  64777. */
  64778. export class ClampBlock extends NodeMaterialBlock {
  64779. /** Gets or sets the minimum range */
  64780. minimum: number;
  64781. /** Gets or sets the maximum range */
  64782. maximum: number;
  64783. /**
  64784. * Creates a new ClampBlock
  64785. * @param name defines the block name
  64786. */
  64787. constructor(name: string);
  64788. /**
  64789. * Gets the current class name
  64790. * @returns the class name
  64791. */
  64792. getClassName(): string;
  64793. /**
  64794. * Gets the value input component
  64795. */
  64796. get value(): NodeMaterialConnectionPoint;
  64797. /**
  64798. * Gets the output component
  64799. */
  64800. get output(): NodeMaterialConnectionPoint;
  64801. protected _buildBlock(state: NodeMaterialBuildState): this;
  64802. protected _dumpPropertiesCode(): string;
  64803. serialize(): any;
  64804. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64805. }
  64806. }
  64807. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  64808. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64809. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64810. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64811. /**
  64812. * Block used to apply a cross product between 2 vectors
  64813. */
  64814. export class CrossBlock extends NodeMaterialBlock {
  64815. /**
  64816. * Creates a new CrossBlock
  64817. * @param name defines the block name
  64818. */
  64819. constructor(name: string);
  64820. /**
  64821. * Gets the current class name
  64822. * @returns the class name
  64823. */
  64824. getClassName(): string;
  64825. /**
  64826. * Gets the left operand input component
  64827. */
  64828. get left(): NodeMaterialConnectionPoint;
  64829. /**
  64830. * Gets the right operand input component
  64831. */
  64832. get right(): NodeMaterialConnectionPoint;
  64833. /**
  64834. * Gets the output component
  64835. */
  64836. get output(): NodeMaterialConnectionPoint;
  64837. protected _buildBlock(state: NodeMaterialBuildState): this;
  64838. }
  64839. }
  64840. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  64841. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64842. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64843. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64844. /**
  64845. * Block used to apply a dot product between 2 vectors
  64846. */
  64847. export class DotBlock extends NodeMaterialBlock {
  64848. /**
  64849. * Creates a new DotBlock
  64850. * @param name defines the block name
  64851. */
  64852. constructor(name: string);
  64853. /**
  64854. * Gets the current class name
  64855. * @returns the class name
  64856. */
  64857. getClassName(): string;
  64858. /**
  64859. * Gets the left operand input component
  64860. */
  64861. get left(): NodeMaterialConnectionPoint;
  64862. /**
  64863. * Gets the right operand input component
  64864. */
  64865. get right(): NodeMaterialConnectionPoint;
  64866. /**
  64867. * Gets the output component
  64868. */
  64869. get output(): NodeMaterialConnectionPoint;
  64870. protected _buildBlock(state: NodeMaterialBuildState): this;
  64871. }
  64872. }
  64873. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  64874. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64875. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64876. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64877. /**
  64878. * Block used to normalize a vector
  64879. */
  64880. export class NormalizeBlock extends NodeMaterialBlock {
  64881. /**
  64882. * Creates a new NormalizeBlock
  64883. * @param name defines the block name
  64884. */
  64885. constructor(name: string);
  64886. /**
  64887. * Gets the current class name
  64888. * @returns the class name
  64889. */
  64890. getClassName(): string;
  64891. /**
  64892. * Gets the input component
  64893. */
  64894. get input(): NodeMaterialConnectionPoint;
  64895. /**
  64896. * Gets the output component
  64897. */
  64898. get output(): NodeMaterialConnectionPoint;
  64899. protected _buildBlock(state: NodeMaterialBuildState): this;
  64900. }
  64901. }
  64902. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  64903. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64904. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64905. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64906. import { Scene } from "babylonjs/scene";
  64907. /**
  64908. * Operations supported by the Trigonometry block
  64909. */
  64910. export enum TrigonometryBlockOperations {
  64911. /** Cos */
  64912. Cos = 0,
  64913. /** Sin */
  64914. Sin = 1,
  64915. /** Abs */
  64916. Abs = 2,
  64917. /** Exp */
  64918. Exp = 3,
  64919. /** Exp2 */
  64920. Exp2 = 4,
  64921. /** Round */
  64922. Round = 5,
  64923. /** Floor */
  64924. Floor = 6,
  64925. /** Ceiling */
  64926. Ceiling = 7,
  64927. /** Square root */
  64928. Sqrt = 8,
  64929. /** Log */
  64930. Log = 9,
  64931. /** Tangent */
  64932. Tan = 10,
  64933. /** Arc tangent */
  64934. ArcTan = 11,
  64935. /** Arc cosinus */
  64936. ArcCos = 12,
  64937. /** Arc sinus */
  64938. ArcSin = 13,
  64939. /** Fraction */
  64940. Fract = 14,
  64941. /** Sign */
  64942. Sign = 15,
  64943. /** To radians (from degrees) */
  64944. Radians = 16,
  64945. /** To degrees (from radians) */
  64946. Degrees = 17
  64947. }
  64948. /**
  64949. * Block used to apply trigonometry operation to floats
  64950. */
  64951. export class TrigonometryBlock extends NodeMaterialBlock {
  64952. /**
  64953. * Gets or sets the operation applied by the block
  64954. */
  64955. operation: TrigonometryBlockOperations;
  64956. /**
  64957. * Creates a new TrigonometryBlock
  64958. * @param name defines the block name
  64959. */
  64960. constructor(name: string);
  64961. /**
  64962. * Gets the current class name
  64963. * @returns the class name
  64964. */
  64965. getClassName(): string;
  64966. /**
  64967. * Gets the input component
  64968. */
  64969. get input(): NodeMaterialConnectionPoint;
  64970. /**
  64971. * Gets the output component
  64972. */
  64973. get output(): NodeMaterialConnectionPoint;
  64974. protected _buildBlock(state: NodeMaterialBuildState): this;
  64975. serialize(): any;
  64976. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64977. protected _dumpPropertiesCode(): string;
  64978. }
  64979. }
  64980. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  64981. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64982. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64983. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64984. /**
  64985. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64986. */
  64987. export class ColorMergerBlock extends NodeMaterialBlock {
  64988. /**
  64989. * Create a new ColorMergerBlock
  64990. * @param name defines the block name
  64991. */
  64992. constructor(name: string);
  64993. /**
  64994. * Gets the current class name
  64995. * @returns the class name
  64996. */
  64997. getClassName(): string;
  64998. /**
  64999. * Gets the rgb component (input)
  65000. */
  65001. get rgbIn(): NodeMaterialConnectionPoint;
  65002. /**
  65003. * Gets the r component (input)
  65004. */
  65005. get r(): NodeMaterialConnectionPoint;
  65006. /**
  65007. * Gets the g component (input)
  65008. */
  65009. get g(): NodeMaterialConnectionPoint;
  65010. /**
  65011. * Gets the b component (input)
  65012. */
  65013. get b(): NodeMaterialConnectionPoint;
  65014. /**
  65015. * Gets the a component (input)
  65016. */
  65017. get a(): NodeMaterialConnectionPoint;
  65018. /**
  65019. * Gets the rgba component (output)
  65020. */
  65021. get rgba(): NodeMaterialConnectionPoint;
  65022. /**
  65023. * Gets the rgb component (output)
  65024. */
  65025. get rgbOut(): NodeMaterialConnectionPoint;
  65026. /**
  65027. * Gets the rgb component (output)
  65028. * @deprecated Please use rgbOut instead.
  65029. */
  65030. get rgb(): NodeMaterialConnectionPoint;
  65031. protected _buildBlock(state: NodeMaterialBuildState): this;
  65032. }
  65033. }
  65034. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  65035. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65036. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65037. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65038. /**
  65039. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  65040. */
  65041. export class VectorSplitterBlock extends NodeMaterialBlock {
  65042. /**
  65043. * Create a new VectorSplitterBlock
  65044. * @param name defines the block name
  65045. */
  65046. constructor(name: string);
  65047. /**
  65048. * Gets the current class name
  65049. * @returns the class name
  65050. */
  65051. getClassName(): string;
  65052. /**
  65053. * Gets the xyzw component (input)
  65054. */
  65055. get xyzw(): NodeMaterialConnectionPoint;
  65056. /**
  65057. * Gets the xyz component (input)
  65058. */
  65059. get xyzIn(): NodeMaterialConnectionPoint;
  65060. /**
  65061. * Gets the xy component (input)
  65062. */
  65063. get xyIn(): NodeMaterialConnectionPoint;
  65064. /**
  65065. * Gets the xyz component (output)
  65066. */
  65067. get xyzOut(): NodeMaterialConnectionPoint;
  65068. /**
  65069. * Gets the xy component (output)
  65070. */
  65071. get xyOut(): NodeMaterialConnectionPoint;
  65072. /**
  65073. * Gets the x component (output)
  65074. */
  65075. get x(): NodeMaterialConnectionPoint;
  65076. /**
  65077. * Gets the y component (output)
  65078. */
  65079. get y(): NodeMaterialConnectionPoint;
  65080. /**
  65081. * Gets the z component (output)
  65082. */
  65083. get z(): NodeMaterialConnectionPoint;
  65084. /**
  65085. * Gets the w component (output)
  65086. */
  65087. get w(): NodeMaterialConnectionPoint;
  65088. protected _inputRename(name: string): string;
  65089. protected _outputRename(name: string): string;
  65090. protected _buildBlock(state: NodeMaterialBuildState): this;
  65091. }
  65092. }
  65093. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  65094. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65095. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65096. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65097. /**
  65098. * Block used to lerp between 2 values
  65099. */
  65100. export class LerpBlock extends NodeMaterialBlock {
  65101. /**
  65102. * Creates a new LerpBlock
  65103. * @param name defines the block name
  65104. */
  65105. constructor(name: string);
  65106. /**
  65107. * Gets the current class name
  65108. * @returns the class name
  65109. */
  65110. getClassName(): string;
  65111. /**
  65112. * Gets the left operand input component
  65113. */
  65114. get left(): NodeMaterialConnectionPoint;
  65115. /**
  65116. * Gets the right operand input component
  65117. */
  65118. get right(): NodeMaterialConnectionPoint;
  65119. /**
  65120. * Gets the gradient operand input component
  65121. */
  65122. get gradient(): NodeMaterialConnectionPoint;
  65123. /**
  65124. * Gets the output component
  65125. */
  65126. get output(): NodeMaterialConnectionPoint;
  65127. protected _buildBlock(state: NodeMaterialBuildState): this;
  65128. }
  65129. }
  65130. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  65131. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65132. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65133. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65134. /**
  65135. * Block used to divide 2 vectors
  65136. */
  65137. export class DivideBlock extends NodeMaterialBlock {
  65138. /**
  65139. * Creates a new DivideBlock
  65140. * @param name defines the block name
  65141. */
  65142. constructor(name: string);
  65143. /**
  65144. * Gets the current class name
  65145. * @returns the class name
  65146. */
  65147. getClassName(): string;
  65148. /**
  65149. * Gets the left operand input component
  65150. */
  65151. get left(): NodeMaterialConnectionPoint;
  65152. /**
  65153. * Gets the right operand input component
  65154. */
  65155. get right(): NodeMaterialConnectionPoint;
  65156. /**
  65157. * Gets the output component
  65158. */
  65159. get output(): NodeMaterialConnectionPoint;
  65160. protected _buildBlock(state: NodeMaterialBuildState): this;
  65161. }
  65162. }
  65163. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  65164. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65165. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65166. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65167. /**
  65168. * Block used to subtract 2 vectors
  65169. */
  65170. export class SubtractBlock extends NodeMaterialBlock {
  65171. /**
  65172. * Creates a new SubtractBlock
  65173. * @param name defines the block name
  65174. */
  65175. constructor(name: string);
  65176. /**
  65177. * Gets the current class name
  65178. * @returns the class name
  65179. */
  65180. getClassName(): string;
  65181. /**
  65182. * Gets the left operand input component
  65183. */
  65184. get left(): NodeMaterialConnectionPoint;
  65185. /**
  65186. * Gets the right operand input component
  65187. */
  65188. get right(): NodeMaterialConnectionPoint;
  65189. /**
  65190. * Gets the output component
  65191. */
  65192. get output(): NodeMaterialConnectionPoint;
  65193. protected _buildBlock(state: NodeMaterialBuildState): this;
  65194. }
  65195. }
  65196. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  65197. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65198. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65199. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65200. /**
  65201. * Block used to step a value
  65202. */
  65203. export class StepBlock extends NodeMaterialBlock {
  65204. /**
  65205. * Creates a new StepBlock
  65206. * @param name defines the block name
  65207. */
  65208. constructor(name: string);
  65209. /**
  65210. * Gets the current class name
  65211. * @returns the class name
  65212. */
  65213. getClassName(): string;
  65214. /**
  65215. * Gets the value operand input component
  65216. */
  65217. get value(): NodeMaterialConnectionPoint;
  65218. /**
  65219. * Gets the edge operand input component
  65220. */
  65221. get edge(): NodeMaterialConnectionPoint;
  65222. /**
  65223. * Gets the output component
  65224. */
  65225. get output(): NodeMaterialConnectionPoint;
  65226. protected _buildBlock(state: NodeMaterialBuildState): this;
  65227. }
  65228. }
  65229. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  65230. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65231. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65232. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65233. /**
  65234. * Block used to get the opposite (1 - x) of a value
  65235. */
  65236. export class OneMinusBlock extends NodeMaterialBlock {
  65237. /**
  65238. * Creates a new OneMinusBlock
  65239. * @param name defines the block name
  65240. */
  65241. constructor(name: string);
  65242. /**
  65243. * Gets the current class name
  65244. * @returns the class name
  65245. */
  65246. getClassName(): string;
  65247. /**
  65248. * Gets the input component
  65249. */
  65250. get input(): NodeMaterialConnectionPoint;
  65251. /**
  65252. * Gets the output component
  65253. */
  65254. get output(): NodeMaterialConnectionPoint;
  65255. protected _buildBlock(state: NodeMaterialBuildState): this;
  65256. }
  65257. }
  65258. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  65259. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65260. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65261. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65262. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65263. /**
  65264. * Block used to get the view direction
  65265. */
  65266. export class ViewDirectionBlock extends NodeMaterialBlock {
  65267. /**
  65268. * Creates a new ViewDirectionBlock
  65269. * @param name defines the block name
  65270. */
  65271. constructor(name: string);
  65272. /**
  65273. * Gets the current class name
  65274. * @returns the class name
  65275. */
  65276. getClassName(): string;
  65277. /**
  65278. * Gets the world position component
  65279. */
  65280. get worldPosition(): NodeMaterialConnectionPoint;
  65281. /**
  65282. * Gets the camera position component
  65283. */
  65284. get cameraPosition(): NodeMaterialConnectionPoint;
  65285. /**
  65286. * Gets the output component
  65287. */
  65288. get output(): NodeMaterialConnectionPoint;
  65289. autoConfigure(material: NodeMaterial): void;
  65290. protected _buildBlock(state: NodeMaterialBuildState): this;
  65291. }
  65292. }
  65293. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  65294. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65295. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65296. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65297. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65298. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  65299. /**
  65300. * Block used to compute fresnel value
  65301. */
  65302. export class FresnelBlock extends NodeMaterialBlock {
  65303. /**
  65304. * Create a new FresnelBlock
  65305. * @param name defines the block name
  65306. */
  65307. constructor(name: string);
  65308. /**
  65309. * Gets the current class name
  65310. * @returns the class name
  65311. */
  65312. getClassName(): string;
  65313. /**
  65314. * Gets the world normal input component
  65315. */
  65316. get worldNormal(): NodeMaterialConnectionPoint;
  65317. /**
  65318. * Gets the view direction input component
  65319. */
  65320. get viewDirection(): NodeMaterialConnectionPoint;
  65321. /**
  65322. * Gets the bias input component
  65323. */
  65324. get bias(): NodeMaterialConnectionPoint;
  65325. /**
  65326. * Gets the camera (or eye) position component
  65327. */
  65328. get power(): NodeMaterialConnectionPoint;
  65329. /**
  65330. * Gets the fresnel output component
  65331. */
  65332. get fresnel(): NodeMaterialConnectionPoint;
  65333. autoConfigure(material: NodeMaterial): void;
  65334. protected _buildBlock(state: NodeMaterialBuildState): this;
  65335. }
  65336. }
  65337. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  65338. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65339. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65340. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65341. /**
  65342. * Block used to get the max of 2 values
  65343. */
  65344. export class MaxBlock extends NodeMaterialBlock {
  65345. /**
  65346. * Creates a new MaxBlock
  65347. * @param name defines the block name
  65348. */
  65349. constructor(name: string);
  65350. /**
  65351. * Gets the current class name
  65352. * @returns the class name
  65353. */
  65354. getClassName(): string;
  65355. /**
  65356. * Gets the left operand input component
  65357. */
  65358. get left(): NodeMaterialConnectionPoint;
  65359. /**
  65360. * Gets the right operand input component
  65361. */
  65362. get right(): NodeMaterialConnectionPoint;
  65363. /**
  65364. * Gets the output component
  65365. */
  65366. get output(): NodeMaterialConnectionPoint;
  65367. protected _buildBlock(state: NodeMaterialBuildState): this;
  65368. }
  65369. }
  65370. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  65371. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65372. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65373. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65374. /**
  65375. * Block used to get the min of 2 values
  65376. */
  65377. export class MinBlock extends NodeMaterialBlock {
  65378. /**
  65379. * Creates a new MinBlock
  65380. * @param name defines the block name
  65381. */
  65382. constructor(name: string);
  65383. /**
  65384. * Gets the current class name
  65385. * @returns the class name
  65386. */
  65387. getClassName(): string;
  65388. /**
  65389. * Gets the left operand input component
  65390. */
  65391. get left(): NodeMaterialConnectionPoint;
  65392. /**
  65393. * Gets the right operand input component
  65394. */
  65395. get right(): NodeMaterialConnectionPoint;
  65396. /**
  65397. * Gets the output component
  65398. */
  65399. get output(): NodeMaterialConnectionPoint;
  65400. protected _buildBlock(state: NodeMaterialBuildState): this;
  65401. }
  65402. }
  65403. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  65404. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65405. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65406. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65407. /**
  65408. * Block used to get the distance between 2 values
  65409. */
  65410. export class DistanceBlock extends NodeMaterialBlock {
  65411. /**
  65412. * Creates a new DistanceBlock
  65413. * @param name defines the block name
  65414. */
  65415. constructor(name: string);
  65416. /**
  65417. * Gets the current class name
  65418. * @returns the class name
  65419. */
  65420. getClassName(): string;
  65421. /**
  65422. * Gets the left operand input component
  65423. */
  65424. get left(): NodeMaterialConnectionPoint;
  65425. /**
  65426. * Gets the right operand input component
  65427. */
  65428. get right(): NodeMaterialConnectionPoint;
  65429. /**
  65430. * Gets the output component
  65431. */
  65432. get output(): NodeMaterialConnectionPoint;
  65433. protected _buildBlock(state: NodeMaterialBuildState): this;
  65434. }
  65435. }
  65436. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  65437. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65438. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65439. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65440. /**
  65441. * Block used to get the length of a vector
  65442. */
  65443. export class LengthBlock extends NodeMaterialBlock {
  65444. /**
  65445. * Creates a new LengthBlock
  65446. * @param name defines the block name
  65447. */
  65448. constructor(name: string);
  65449. /**
  65450. * Gets the current class name
  65451. * @returns the class name
  65452. */
  65453. getClassName(): string;
  65454. /**
  65455. * Gets the value input component
  65456. */
  65457. get value(): NodeMaterialConnectionPoint;
  65458. /**
  65459. * Gets the output component
  65460. */
  65461. get output(): NodeMaterialConnectionPoint;
  65462. protected _buildBlock(state: NodeMaterialBuildState): this;
  65463. }
  65464. }
  65465. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  65466. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65467. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65468. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65469. /**
  65470. * Block used to get negative version of a value (i.e. x * -1)
  65471. */
  65472. export class NegateBlock extends NodeMaterialBlock {
  65473. /**
  65474. * Creates a new NegateBlock
  65475. * @param name defines the block name
  65476. */
  65477. constructor(name: string);
  65478. /**
  65479. * Gets the current class name
  65480. * @returns the class name
  65481. */
  65482. getClassName(): string;
  65483. /**
  65484. * Gets the value input component
  65485. */
  65486. get value(): NodeMaterialConnectionPoint;
  65487. /**
  65488. * Gets the output component
  65489. */
  65490. get output(): NodeMaterialConnectionPoint;
  65491. protected _buildBlock(state: NodeMaterialBuildState): this;
  65492. }
  65493. }
  65494. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  65495. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65496. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65497. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65498. /**
  65499. * Block used to get the value of the first parameter raised to the power of the second
  65500. */
  65501. export class PowBlock extends NodeMaterialBlock {
  65502. /**
  65503. * Creates a new PowBlock
  65504. * @param name defines the block name
  65505. */
  65506. constructor(name: string);
  65507. /**
  65508. * Gets the current class name
  65509. * @returns the class name
  65510. */
  65511. getClassName(): string;
  65512. /**
  65513. * Gets the value operand input component
  65514. */
  65515. get value(): NodeMaterialConnectionPoint;
  65516. /**
  65517. * Gets the power operand input component
  65518. */
  65519. get power(): NodeMaterialConnectionPoint;
  65520. /**
  65521. * Gets the output component
  65522. */
  65523. get output(): NodeMaterialConnectionPoint;
  65524. protected _buildBlock(state: NodeMaterialBuildState): this;
  65525. }
  65526. }
  65527. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  65528. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65529. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65530. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65531. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65532. /**
  65533. * Block used to get a random number
  65534. */
  65535. export class RandomNumberBlock extends NodeMaterialBlock {
  65536. /**
  65537. * Creates a new RandomNumberBlock
  65538. * @param name defines the block name
  65539. */
  65540. constructor(name: string);
  65541. /**
  65542. * Gets the current class name
  65543. * @returns the class name
  65544. */
  65545. getClassName(): string;
  65546. /**
  65547. * Gets the seed input component
  65548. */
  65549. get seed(): NodeMaterialConnectionPoint;
  65550. /**
  65551. * Gets the output component
  65552. */
  65553. get output(): NodeMaterialConnectionPoint;
  65554. protected _buildBlock(state: NodeMaterialBuildState): this;
  65555. }
  65556. }
  65557. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  65558. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65559. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65560. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65561. /**
  65562. * Block used to compute arc tangent of 2 values
  65563. */
  65564. export class ArcTan2Block extends NodeMaterialBlock {
  65565. /**
  65566. * Creates a new ArcTan2Block
  65567. * @param name defines the block name
  65568. */
  65569. constructor(name: string);
  65570. /**
  65571. * Gets the current class name
  65572. * @returns the class name
  65573. */
  65574. getClassName(): string;
  65575. /**
  65576. * Gets the x operand input component
  65577. */
  65578. get x(): NodeMaterialConnectionPoint;
  65579. /**
  65580. * Gets the y operand input component
  65581. */
  65582. get y(): NodeMaterialConnectionPoint;
  65583. /**
  65584. * Gets the output component
  65585. */
  65586. get output(): NodeMaterialConnectionPoint;
  65587. protected _buildBlock(state: NodeMaterialBuildState): this;
  65588. }
  65589. }
  65590. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  65591. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65592. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65593. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65594. /**
  65595. * Block used to smooth step a value
  65596. */
  65597. export class SmoothStepBlock extends NodeMaterialBlock {
  65598. /**
  65599. * Creates a new SmoothStepBlock
  65600. * @param name defines the block name
  65601. */
  65602. constructor(name: string);
  65603. /**
  65604. * Gets the current class name
  65605. * @returns the class name
  65606. */
  65607. getClassName(): string;
  65608. /**
  65609. * Gets the value operand input component
  65610. */
  65611. get value(): NodeMaterialConnectionPoint;
  65612. /**
  65613. * Gets the first edge operand input component
  65614. */
  65615. get edge0(): NodeMaterialConnectionPoint;
  65616. /**
  65617. * Gets the second edge operand input component
  65618. */
  65619. get edge1(): NodeMaterialConnectionPoint;
  65620. /**
  65621. * Gets the output component
  65622. */
  65623. get output(): NodeMaterialConnectionPoint;
  65624. protected _buildBlock(state: NodeMaterialBuildState): this;
  65625. }
  65626. }
  65627. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  65628. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65629. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65630. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65631. /**
  65632. * Block used to get the reciprocal (1 / x) of a value
  65633. */
  65634. export class ReciprocalBlock extends NodeMaterialBlock {
  65635. /**
  65636. * Creates a new ReciprocalBlock
  65637. * @param name defines the block name
  65638. */
  65639. constructor(name: string);
  65640. /**
  65641. * Gets the current class name
  65642. * @returns the class name
  65643. */
  65644. getClassName(): string;
  65645. /**
  65646. * Gets the input component
  65647. */
  65648. get input(): NodeMaterialConnectionPoint;
  65649. /**
  65650. * Gets the output component
  65651. */
  65652. get output(): NodeMaterialConnectionPoint;
  65653. protected _buildBlock(state: NodeMaterialBuildState): this;
  65654. }
  65655. }
  65656. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  65657. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65658. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65659. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65660. /**
  65661. * Block used to replace a color by another one
  65662. */
  65663. export class ReplaceColorBlock extends NodeMaterialBlock {
  65664. /**
  65665. * Creates a new ReplaceColorBlock
  65666. * @param name defines the block name
  65667. */
  65668. constructor(name: string);
  65669. /**
  65670. * Gets the current class name
  65671. * @returns the class name
  65672. */
  65673. getClassName(): string;
  65674. /**
  65675. * Gets the value input component
  65676. */
  65677. get value(): NodeMaterialConnectionPoint;
  65678. /**
  65679. * Gets the reference input component
  65680. */
  65681. get reference(): NodeMaterialConnectionPoint;
  65682. /**
  65683. * Gets the distance input component
  65684. */
  65685. get distance(): NodeMaterialConnectionPoint;
  65686. /**
  65687. * Gets the replacement input component
  65688. */
  65689. get replacement(): NodeMaterialConnectionPoint;
  65690. /**
  65691. * Gets the output component
  65692. */
  65693. get output(): NodeMaterialConnectionPoint;
  65694. protected _buildBlock(state: NodeMaterialBuildState): this;
  65695. }
  65696. }
  65697. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  65698. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65699. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65700. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65701. /**
  65702. * Block used to posterize a value
  65703. * @see https://en.wikipedia.org/wiki/Posterization
  65704. */
  65705. export class PosterizeBlock extends NodeMaterialBlock {
  65706. /**
  65707. * Creates a new PosterizeBlock
  65708. * @param name defines the block name
  65709. */
  65710. constructor(name: string);
  65711. /**
  65712. * Gets the current class name
  65713. * @returns the class name
  65714. */
  65715. getClassName(): string;
  65716. /**
  65717. * Gets the value input component
  65718. */
  65719. get value(): NodeMaterialConnectionPoint;
  65720. /**
  65721. * Gets the steps input component
  65722. */
  65723. get steps(): NodeMaterialConnectionPoint;
  65724. /**
  65725. * Gets the output component
  65726. */
  65727. get output(): NodeMaterialConnectionPoint;
  65728. protected _buildBlock(state: NodeMaterialBuildState): this;
  65729. }
  65730. }
  65731. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  65732. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65733. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65734. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65735. import { Scene } from "babylonjs/scene";
  65736. /**
  65737. * Operations supported by the Wave block
  65738. */
  65739. export enum WaveBlockKind {
  65740. /** SawTooth */
  65741. SawTooth = 0,
  65742. /** Square */
  65743. Square = 1,
  65744. /** Triangle */
  65745. Triangle = 2
  65746. }
  65747. /**
  65748. * Block used to apply wave operation to floats
  65749. */
  65750. export class WaveBlock extends NodeMaterialBlock {
  65751. /**
  65752. * Gets or sets the kibnd of wave to be applied by the block
  65753. */
  65754. kind: WaveBlockKind;
  65755. /**
  65756. * Creates a new WaveBlock
  65757. * @param name defines the block name
  65758. */
  65759. constructor(name: string);
  65760. /**
  65761. * Gets the current class name
  65762. * @returns the class name
  65763. */
  65764. getClassName(): string;
  65765. /**
  65766. * Gets the input component
  65767. */
  65768. get input(): NodeMaterialConnectionPoint;
  65769. /**
  65770. * Gets the output component
  65771. */
  65772. get output(): NodeMaterialConnectionPoint;
  65773. protected _buildBlock(state: NodeMaterialBuildState): this;
  65774. serialize(): any;
  65775. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65776. }
  65777. }
  65778. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  65779. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65780. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65781. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65782. import { Color3 } from "babylonjs/Maths/math.color";
  65783. import { Scene } from "babylonjs/scene";
  65784. /**
  65785. * Class used to store a color step for the GradientBlock
  65786. */
  65787. export class GradientBlockColorStep {
  65788. /**
  65789. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65790. */
  65791. step: number;
  65792. /**
  65793. * Gets or sets the color associated with this step
  65794. */
  65795. color: Color3;
  65796. /**
  65797. * Creates a new GradientBlockColorStep
  65798. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65799. * @param color defines the color associated with this step
  65800. */
  65801. constructor(
  65802. /**
  65803. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65804. */
  65805. step: number,
  65806. /**
  65807. * Gets or sets the color associated with this step
  65808. */
  65809. color: Color3);
  65810. }
  65811. /**
  65812. * Block used to return a color from a gradient based on an input value between 0 and 1
  65813. */
  65814. export class GradientBlock extends NodeMaterialBlock {
  65815. /**
  65816. * Gets or sets the list of color steps
  65817. */
  65818. colorSteps: GradientBlockColorStep[];
  65819. /**
  65820. * Creates a new GradientBlock
  65821. * @param name defines the block name
  65822. */
  65823. constructor(name: string);
  65824. /**
  65825. * Gets the current class name
  65826. * @returns the class name
  65827. */
  65828. getClassName(): string;
  65829. /**
  65830. * Gets the gradient input component
  65831. */
  65832. get gradient(): NodeMaterialConnectionPoint;
  65833. /**
  65834. * Gets the output component
  65835. */
  65836. get output(): NodeMaterialConnectionPoint;
  65837. private _writeColorConstant;
  65838. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65839. serialize(): any;
  65840. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65841. protected _dumpPropertiesCode(): string;
  65842. }
  65843. }
  65844. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  65845. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65846. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65847. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65848. /**
  65849. * Block used to normalize lerp between 2 values
  65850. */
  65851. export class NLerpBlock extends NodeMaterialBlock {
  65852. /**
  65853. * Creates a new NLerpBlock
  65854. * @param name defines the block name
  65855. */
  65856. constructor(name: string);
  65857. /**
  65858. * Gets the current class name
  65859. * @returns the class name
  65860. */
  65861. getClassName(): string;
  65862. /**
  65863. * Gets the left operand input component
  65864. */
  65865. get left(): NodeMaterialConnectionPoint;
  65866. /**
  65867. * Gets the right operand input component
  65868. */
  65869. get right(): NodeMaterialConnectionPoint;
  65870. /**
  65871. * Gets the gradient operand input component
  65872. */
  65873. get gradient(): NodeMaterialConnectionPoint;
  65874. /**
  65875. * Gets the output component
  65876. */
  65877. get output(): NodeMaterialConnectionPoint;
  65878. protected _buildBlock(state: NodeMaterialBuildState): this;
  65879. }
  65880. }
  65881. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  65882. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65883. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65884. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65885. import { Scene } from "babylonjs/scene";
  65886. /**
  65887. * block used to Generate a Worley Noise 3D Noise Pattern
  65888. */
  65889. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65890. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65891. manhattanDistance: boolean;
  65892. /**
  65893. * Creates a new WorleyNoise3DBlock
  65894. * @param name defines the block name
  65895. */
  65896. constructor(name: string);
  65897. /**
  65898. * Gets the current class name
  65899. * @returns the class name
  65900. */
  65901. getClassName(): string;
  65902. /**
  65903. * Gets the seed input component
  65904. */
  65905. get seed(): NodeMaterialConnectionPoint;
  65906. /**
  65907. * Gets the jitter input component
  65908. */
  65909. get jitter(): NodeMaterialConnectionPoint;
  65910. /**
  65911. * Gets the output component
  65912. */
  65913. get output(): NodeMaterialConnectionPoint;
  65914. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65915. /**
  65916. * Exposes the properties to the UI?
  65917. */
  65918. protected _dumpPropertiesCode(): string;
  65919. /**
  65920. * Exposes the properties to the Seralize?
  65921. */
  65922. serialize(): any;
  65923. /**
  65924. * Exposes the properties to the deseralize?
  65925. */
  65926. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65927. }
  65928. }
  65929. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  65930. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65931. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65932. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65933. /**
  65934. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65935. */
  65936. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65937. /**
  65938. * Creates a new SimplexPerlin3DBlock
  65939. * @param name defines the block name
  65940. */
  65941. constructor(name: string);
  65942. /**
  65943. * Gets the current class name
  65944. * @returns the class name
  65945. */
  65946. getClassName(): string;
  65947. /**
  65948. * Gets the seed operand input component
  65949. */
  65950. get seed(): NodeMaterialConnectionPoint;
  65951. /**
  65952. * Gets the output component
  65953. */
  65954. get output(): NodeMaterialConnectionPoint;
  65955. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65956. }
  65957. }
  65958. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  65959. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65960. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65961. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65962. /**
  65963. * Block used to blend normals
  65964. */
  65965. export class NormalBlendBlock extends NodeMaterialBlock {
  65966. /**
  65967. * Creates a new NormalBlendBlock
  65968. * @param name defines the block name
  65969. */
  65970. constructor(name: string);
  65971. /**
  65972. * Gets the current class name
  65973. * @returns the class name
  65974. */
  65975. getClassName(): string;
  65976. /**
  65977. * Gets the first input component
  65978. */
  65979. get normalMap0(): NodeMaterialConnectionPoint;
  65980. /**
  65981. * Gets the second input component
  65982. */
  65983. get normalMap1(): NodeMaterialConnectionPoint;
  65984. /**
  65985. * Gets the output component
  65986. */
  65987. get output(): NodeMaterialConnectionPoint;
  65988. protected _buildBlock(state: NodeMaterialBuildState): this;
  65989. }
  65990. }
  65991. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  65992. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65993. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65994. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65995. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65996. /**
  65997. * Block used to rotate a 2d vector by a given angle
  65998. */
  65999. export class Rotate2dBlock extends NodeMaterialBlock {
  66000. /**
  66001. * Creates a new Rotate2dBlock
  66002. * @param name defines the block name
  66003. */
  66004. constructor(name: string);
  66005. /**
  66006. * Gets the current class name
  66007. * @returns the class name
  66008. */
  66009. getClassName(): string;
  66010. /**
  66011. * Gets the input vector
  66012. */
  66013. get input(): NodeMaterialConnectionPoint;
  66014. /**
  66015. * Gets the input angle
  66016. */
  66017. get angle(): NodeMaterialConnectionPoint;
  66018. /**
  66019. * Gets the output component
  66020. */
  66021. get output(): NodeMaterialConnectionPoint;
  66022. autoConfigure(material: NodeMaterial): void;
  66023. protected _buildBlock(state: NodeMaterialBuildState): this;
  66024. }
  66025. }
  66026. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  66027. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66028. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66029. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66030. /**
  66031. * Block used to get the reflected vector from a direction and a normal
  66032. */
  66033. export class ReflectBlock extends NodeMaterialBlock {
  66034. /**
  66035. * Creates a new ReflectBlock
  66036. * @param name defines the block name
  66037. */
  66038. constructor(name: string);
  66039. /**
  66040. * Gets the current class name
  66041. * @returns the class name
  66042. */
  66043. getClassName(): string;
  66044. /**
  66045. * Gets the incident component
  66046. */
  66047. get incident(): NodeMaterialConnectionPoint;
  66048. /**
  66049. * Gets the normal component
  66050. */
  66051. get normal(): NodeMaterialConnectionPoint;
  66052. /**
  66053. * Gets the output component
  66054. */
  66055. get output(): NodeMaterialConnectionPoint;
  66056. protected _buildBlock(state: NodeMaterialBuildState): this;
  66057. }
  66058. }
  66059. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  66060. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66061. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66062. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66063. /**
  66064. * Block used to get the refracted vector from a direction and a normal
  66065. */
  66066. export class RefractBlock extends NodeMaterialBlock {
  66067. /**
  66068. * Creates a new RefractBlock
  66069. * @param name defines the block name
  66070. */
  66071. constructor(name: string);
  66072. /**
  66073. * Gets the current class name
  66074. * @returns the class name
  66075. */
  66076. getClassName(): string;
  66077. /**
  66078. * Gets the incident component
  66079. */
  66080. get incident(): NodeMaterialConnectionPoint;
  66081. /**
  66082. * Gets the normal component
  66083. */
  66084. get normal(): NodeMaterialConnectionPoint;
  66085. /**
  66086. * Gets the index of refraction component
  66087. */
  66088. get ior(): NodeMaterialConnectionPoint;
  66089. /**
  66090. * Gets the output component
  66091. */
  66092. get output(): NodeMaterialConnectionPoint;
  66093. protected _buildBlock(state: NodeMaterialBuildState): this;
  66094. }
  66095. }
  66096. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  66097. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66098. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66099. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66100. /**
  66101. * Block used to desaturate a color
  66102. */
  66103. export class DesaturateBlock extends NodeMaterialBlock {
  66104. /**
  66105. * Creates a new DesaturateBlock
  66106. * @param name defines the block name
  66107. */
  66108. constructor(name: string);
  66109. /**
  66110. * Gets the current class name
  66111. * @returns the class name
  66112. */
  66113. getClassName(): string;
  66114. /**
  66115. * Gets the color operand input component
  66116. */
  66117. get color(): NodeMaterialConnectionPoint;
  66118. /**
  66119. * Gets the level operand input component
  66120. */
  66121. get level(): NodeMaterialConnectionPoint;
  66122. /**
  66123. * Gets the output component
  66124. */
  66125. get output(): NodeMaterialConnectionPoint;
  66126. protected _buildBlock(state: NodeMaterialBuildState): this;
  66127. }
  66128. }
  66129. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  66130. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66131. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66132. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66133. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66134. import { Nullable } from "babylonjs/types";
  66135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66136. import { Scene } from "babylonjs/scene";
  66137. /**
  66138. * Block used to implement the ambient occlusion module of the PBR material
  66139. */
  66140. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  66141. /**
  66142. * Create a new AmbientOcclusionBlock
  66143. * @param name defines the block name
  66144. */
  66145. constructor(name: string);
  66146. /**
  66147. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  66148. */
  66149. useAmbientInGrayScale: boolean;
  66150. /**
  66151. * Initialize the block and prepare the context for build
  66152. * @param state defines the state that will be used for the build
  66153. */
  66154. initialize(state: NodeMaterialBuildState): void;
  66155. /**
  66156. * Gets the current class name
  66157. * @returns the class name
  66158. */
  66159. getClassName(): string;
  66160. /**
  66161. * Gets the texture input component
  66162. */
  66163. get texture(): NodeMaterialConnectionPoint;
  66164. /**
  66165. * Gets the texture intensity component
  66166. */
  66167. get intensity(): NodeMaterialConnectionPoint;
  66168. /**
  66169. * Gets the direct light intensity input component
  66170. */
  66171. get directLightIntensity(): NodeMaterialConnectionPoint;
  66172. /**
  66173. * Gets the ambient occlusion object output component
  66174. */
  66175. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66176. /**
  66177. * Gets the main code of the block (fragment side)
  66178. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  66179. * @returns the shader code
  66180. */
  66181. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  66182. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66183. protected _buildBlock(state: NodeMaterialBuildState): this;
  66184. protected _dumpPropertiesCode(): string;
  66185. serialize(): any;
  66186. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66187. }
  66188. }
  66189. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  66190. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66191. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66192. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66193. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66194. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66195. import { Nullable } from "babylonjs/types";
  66196. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66197. import { Mesh } from "babylonjs/Meshes/mesh";
  66198. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66199. import { Effect } from "babylonjs/Materials/effect";
  66200. import { Scene } from "babylonjs/scene";
  66201. /**
  66202. * Block used to implement the reflection module of the PBR material
  66203. */
  66204. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  66205. /** @hidden */
  66206. _defineLODReflectionAlpha: string;
  66207. /** @hidden */
  66208. _defineLinearSpecularReflection: string;
  66209. private _vEnvironmentIrradianceName;
  66210. /** @hidden */
  66211. _vReflectionMicrosurfaceInfosName: string;
  66212. /** @hidden */
  66213. _vReflectionInfosName: string;
  66214. /** @hidden */
  66215. _vReflectionFilteringInfoName: string;
  66216. private _scene;
  66217. /**
  66218. * The three properties below are set by the main PBR block prior to calling methods of this class.
  66219. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66220. * It's less burden on the user side in the editor part.
  66221. */
  66222. /** @hidden */
  66223. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66224. /** @hidden */
  66225. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66226. /** @hidden */
  66227. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  66228. /**
  66229. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  66230. * diffuse part of the IBL.
  66231. */
  66232. useSphericalHarmonics: boolean;
  66233. /**
  66234. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  66235. */
  66236. forceIrradianceInFragment: boolean;
  66237. /**
  66238. * Create a new ReflectionBlock
  66239. * @param name defines the block name
  66240. */
  66241. constructor(name: string);
  66242. /**
  66243. * Gets the current class name
  66244. * @returns the class name
  66245. */
  66246. getClassName(): string;
  66247. /**
  66248. * Gets the position input component
  66249. */
  66250. get position(): NodeMaterialConnectionPoint;
  66251. /**
  66252. * Gets the world position input component
  66253. */
  66254. get worldPosition(): NodeMaterialConnectionPoint;
  66255. /**
  66256. * Gets the world normal input component
  66257. */
  66258. get worldNormal(): NodeMaterialConnectionPoint;
  66259. /**
  66260. * Gets the world input component
  66261. */
  66262. get world(): NodeMaterialConnectionPoint;
  66263. /**
  66264. * Gets the camera (or eye) position component
  66265. */
  66266. get cameraPosition(): NodeMaterialConnectionPoint;
  66267. /**
  66268. * Gets the view input component
  66269. */
  66270. get view(): NodeMaterialConnectionPoint;
  66271. /**
  66272. * Gets the color input component
  66273. */
  66274. get color(): NodeMaterialConnectionPoint;
  66275. /**
  66276. * Gets the reflection object output component
  66277. */
  66278. get reflection(): NodeMaterialConnectionPoint;
  66279. /**
  66280. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  66281. */
  66282. get hasTexture(): boolean;
  66283. /**
  66284. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  66285. */
  66286. get reflectionColor(): string;
  66287. protected _getTexture(): Nullable<BaseTexture>;
  66288. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66289. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66290. /**
  66291. * Gets the code to inject in the vertex shader
  66292. * @param state current state of the node material building
  66293. * @returns the shader code
  66294. */
  66295. handleVertexSide(state: NodeMaterialBuildState): string;
  66296. /**
  66297. * Gets the main code of the block (fragment side)
  66298. * @param state current state of the node material building
  66299. * @param normalVarName name of the existing variable corresponding to the normal
  66300. * @returns the shader code
  66301. */
  66302. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  66303. protected _buildBlock(state: NodeMaterialBuildState): this;
  66304. protected _dumpPropertiesCode(): string;
  66305. serialize(): any;
  66306. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66307. }
  66308. }
  66309. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  66310. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66311. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66312. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66313. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66314. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66315. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66316. import { Scene } from "babylonjs/scene";
  66317. import { Nullable } from "babylonjs/types";
  66318. /**
  66319. * Block used to implement the sheen module of the PBR material
  66320. */
  66321. export class SheenBlock extends NodeMaterialBlock {
  66322. /**
  66323. * Create a new SheenBlock
  66324. * @param name defines the block name
  66325. */
  66326. constructor(name: string);
  66327. /**
  66328. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  66329. * It allows the strength of the sheen effect to not depend on the base color of the material,
  66330. * making it easier to setup and tweak the effect
  66331. */
  66332. albedoScaling: boolean;
  66333. /**
  66334. * Defines if the sheen is linked to the sheen color.
  66335. */
  66336. linkSheenWithAlbedo: boolean;
  66337. /**
  66338. * Initialize the block and prepare the context for build
  66339. * @param state defines the state that will be used for the build
  66340. */
  66341. initialize(state: NodeMaterialBuildState): void;
  66342. /**
  66343. * Gets the current class name
  66344. * @returns the class name
  66345. */
  66346. getClassName(): string;
  66347. /**
  66348. * Gets the intensity input component
  66349. */
  66350. get intensity(): NodeMaterialConnectionPoint;
  66351. /**
  66352. * Gets the color input component
  66353. */
  66354. get color(): NodeMaterialConnectionPoint;
  66355. /**
  66356. * Gets the roughness input component
  66357. */
  66358. get roughness(): NodeMaterialConnectionPoint;
  66359. /**
  66360. * Gets the sheen object output component
  66361. */
  66362. get sheen(): NodeMaterialConnectionPoint;
  66363. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66364. /**
  66365. * Gets the main code of the block (fragment side)
  66366. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66367. * @returns the shader code
  66368. */
  66369. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  66370. protected _buildBlock(state: NodeMaterialBuildState): this;
  66371. protected _dumpPropertiesCode(): string;
  66372. serialize(): any;
  66373. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66374. }
  66375. }
  66376. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  66377. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66378. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66379. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66381. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66382. import { Scene } from "babylonjs/scene";
  66383. import { Nullable } from "babylonjs/types";
  66384. import { Mesh } from "babylonjs/Meshes/mesh";
  66385. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66386. import { Effect } from "babylonjs/Materials/effect";
  66387. /**
  66388. * Block used to implement the reflectivity module of the PBR material
  66389. */
  66390. export class ReflectivityBlock extends NodeMaterialBlock {
  66391. private _metallicReflectanceColor;
  66392. private _metallicF0Factor;
  66393. /** @hidden */
  66394. _vMetallicReflectanceFactorsName: string;
  66395. /**
  66396. * The property below is set by the main PBR block prior to calling methods of this class.
  66397. */
  66398. /** @hidden */
  66399. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  66400. /**
  66401. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  66402. */
  66403. useAmbientOcclusionFromMetallicTextureRed: boolean;
  66404. /**
  66405. * Specifies if the metallic texture contains the metallness information in its blue channel.
  66406. */
  66407. useMetallnessFromMetallicTextureBlue: boolean;
  66408. /**
  66409. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  66410. */
  66411. useRoughnessFromMetallicTextureAlpha: boolean;
  66412. /**
  66413. * Specifies if the metallic texture contains the roughness information in its green channel.
  66414. */
  66415. useRoughnessFromMetallicTextureGreen: boolean;
  66416. /**
  66417. * Create a new ReflectivityBlock
  66418. * @param name defines the block name
  66419. */
  66420. constructor(name: string);
  66421. /**
  66422. * Initialize the block and prepare the context for build
  66423. * @param state defines the state that will be used for the build
  66424. */
  66425. initialize(state: NodeMaterialBuildState): void;
  66426. /**
  66427. * Gets the current class name
  66428. * @returns the class name
  66429. */
  66430. getClassName(): string;
  66431. /**
  66432. * Gets the metallic input component
  66433. */
  66434. get metallic(): NodeMaterialConnectionPoint;
  66435. /**
  66436. * Gets the roughness input component
  66437. */
  66438. get roughness(): NodeMaterialConnectionPoint;
  66439. /**
  66440. * Gets the texture input component
  66441. */
  66442. get texture(): NodeMaterialConnectionPoint;
  66443. /**
  66444. * Gets the reflectivity object output component
  66445. */
  66446. get reflectivity(): NodeMaterialConnectionPoint;
  66447. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66448. /**
  66449. * Gets the main code of the block (fragment side)
  66450. * @param state current state of the node material building
  66451. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  66452. * @returns the shader code
  66453. */
  66454. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  66455. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66456. protected _buildBlock(state: NodeMaterialBuildState): this;
  66457. protected _dumpPropertiesCode(): string;
  66458. serialize(): any;
  66459. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66460. }
  66461. }
  66462. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  66463. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66464. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66465. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66466. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66468. /**
  66469. * Block used to implement the anisotropy module of the PBR material
  66470. */
  66471. export class AnisotropyBlock extends NodeMaterialBlock {
  66472. /**
  66473. * The two properties below are set by the main PBR block prior to calling methods of this class.
  66474. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66475. * It's less burden on the user side in the editor part.
  66476. */
  66477. /** @hidden */
  66478. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66479. /** @hidden */
  66480. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66481. /**
  66482. * Create a new AnisotropyBlock
  66483. * @param name defines the block name
  66484. */
  66485. constructor(name: string);
  66486. /**
  66487. * Initialize the block and prepare the context for build
  66488. * @param state defines the state that will be used for the build
  66489. */
  66490. initialize(state: NodeMaterialBuildState): void;
  66491. /**
  66492. * Gets the current class name
  66493. * @returns the class name
  66494. */
  66495. getClassName(): string;
  66496. /**
  66497. * Gets the intensity input component
  66498. */
  66499. get intensity(): NodeMaterialConnectionPoint;
  66500. /**
  66501. * Gets the direction input component
  66502. */
  66503. get direction(): NodeMaterialConnectionPoint;
  66504. /**
  66505. * Gets the texture input component
  66506. */
  66507. get texture(): NodeMaterialConnectionPoint;
  66508. /**
  66509. * Gets the uv input component
  66510. */
  66511. get uv(): NodeMaterialConnectionPoint;
  66512. /**
  66513. * Gets the worldTangent input component
  66514. */
  66515. get worldTangent(): NodeMaterialConnectionPoint;
  66516. /**
  66517. * Gets the anisotropy object output component
  66518. */
  66519. get anisotropy(): NodeMaterialConnectionPoint;
  66520. private _generateTBNSpace;
  66521. /**
  66522. * Gets the main code of the block (fragment side)
  66523. * @param state current state of the node material building
  66524. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66525. * @returns the shader code
  66526. */
  66527. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  66528. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66529. protected _buildBlock(state: NodeMaterialBuildState): this;
  66530. }
  66531. }
  66532. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  66533. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66534. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66535. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66536. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66538. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66539. import { Nullable } from "babylonjs/types";
  66540. import { Mesh } from "babylonjs/Meshes/mesh";
  66541. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66542. import { Effect } from "babylonjs/Materials/effect";
  66543. /**
  66544. * Block used to implement the clear coat module of the PBR material
  66545. */
  66546. export class ClearCoatBlock extends NodeMaterialBlock {
  66547. private _scene;
  66548. /**
  66549. * Create a new ClearCoatBlock
  66550. * @param name defines the block name
  66551. */
  66552. constructor(name: string);
  66553. /**
  66554. * Initialize the block and prepare the context for build
  66555. * @param state defines the state that will be used for the build
  66556. */
  66557. initialize(state: NodeMaterialBuildState): void;
  66558. /**
  66559. * Gets the current class name
  66560. * @returns the class name
  66561. */
  66562. getClassName(): string;
  66563. /**
  66564. * Gets the intensity input component
  66565. */
  66566. get intensity(): NodeMaterialConnectionPoint;
  66567. /**
  66568. * Gets the roughness input component
  66569. */
  66570. get roughness(): NodeMaterialConnectionPoint;
  66571. /**
  66572. * Gets the ior input component
  66573. */
  66574. get ior(): NodeMaterialConnectionPoint;
  66575. /**
  66576. * Gets the texture input component
  66577. */
  66578. get texture(): NodeMaterialConnectionPoint;
  66579. /**
  66580. * Gets the bump texture input component
  66581. */
  66582. get bumpTexture(): NodeMaterialConnectionPoint;
  66583. /**
  66584. * Gets the uv input component
  66585. */
  66586. get uv(): NodeMaterialConnectionPoint;
  66587. /**
  66588. * Gets the tint color input component
  66589. */
  66590. get tintColor(): NodeMaterialConnectionPoint;
  66591. /**
  66592. * Gets the tint "at distance" input component
  66593. */
  66594. get tintAtDistance(): NodeMaterialConnectionPoint;
  66595. /**
  66596. * Gets the tint thickness input component
  66597. */
  66598. get tintThickness(): NodeMaterialConnectionPoint;
  66599. /**
  66600. * Gets the world tangent input component
  66601. */
  66602. get worldTangent(): NodeMaterialConnectionPoint;
  66603. /**
  66604. * Gets the clear coat object output component
  66605. */
  66606. get clearcoat(): NodeMaterialConnectionPoint;
  66607. autoConfigure(material: NodeMaterial): void;
  66608. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66609. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66610. private _generateTBNSpace;
  66611. /**
  66612. * Gets the main code of the block (fragment side)
  66613. * @param state current state of the node material building
  66614. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66615. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66616. * @param worldPosVarName name of the variable holding the world position
  66617. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66618. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66619. * @param worldNormalVarName name of the variable holding the world normal
  66620. * @returns the shader code
  66621. */
  66622. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66623. protected _buildBlock(state: NodeMaterialBuildState): this;
  66624. }
  66625. }
  66626. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  66627. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66628. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66629. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66630. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66632. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66633. import { Nullable } from "babylonjs/types";
  66634. /**
  66635. * Block used to implement the sub surface module of the PBR material
  66636. */
  66637. export class SubSurfaceBlock extends NodeMaterialBlock {
  66638. /**
  66639. * Create a new SubSurfaceBlock
  66640. * @param name defines the block name
  66641. */
  66642. constructor(name: string);
  66643. /**
  66644. * Stores the intensity of the different subsurface effects in the thickness texture.
  66645. * * the green channel is the translucency intensity.
  66646. * * the blue channel is the scattering intensity.
  66647. * * the alpha channel is the refraction intensity.
  66648. */
  66649. useMaskFromThicknessTexture: boolean;
  66650. /**
  66651. * Initialize the block and prepare the context for build
  66652. * @param state defines the state that will be used for the build
  66653. */
  66654. initialize(state: NodeMaterialBuildState): void;
  66655. /**
  66656. * Gets the current class name
  66657. * @returns the class name
  66658. */
  66659. getClassName(): string;
  66660. /**
  66661. * Gets the min thickness input component
  66662. */
  66663. get minThickness(): NodeMaterialConnectionPoint;
  66664. /**
  66665. * Gets the max thickness input component
  66666. */
  66667. get maxThickness(): NodeMaterialConnectionPoint;
  66668. /**
  66669. * Gets the thickness texture component
  66670. */
  66671. get thicknessTexture(): NodeMaterialConnectionPoint;
  66672. /**
  66673. * Gets the tint color input component
  66674. */
  66675. get tintColor(): NodeMaterialConnectionPoint;
  66676. /**
  66677. * Gets the translucency intensity input component
  66678. */
  66679. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66680. /**
  66681. * Gets the translucency diffusion distance input component
  66682. */
  66683. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  66684. /**
  66685. * Gets the refraction object parameters
  66686. */
  66687. get refraction(): NodeMaterialConnectionPoint;
  66688. /**
  66689. * Gets the sub surface object output component
  66690. */
  66691. get subsurface(): NodeMaterialConnectionPoint;
  66692. autoConfigure(material: NodeMaterial): void;
  66693. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66694. /**
  66695. * Gets the main code of the block (fragment side)
  66696. * @param state current state of the node material building
  66697. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66698. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66699. * @param worldPosVarName name of the variable holding the world position
  66700. * @returns the shader code
  66701. */
  66702. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66703. protected _buildBlock(state: NodeMaterialBuildState): this;
  66704. }
  66705. }
  66706. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  66707. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66708. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66709. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66710. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66711. import { Light } from "babylonjs/Lights/light";
  66712. import { Nullable } from "babylonjs/types";
  66713. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66714. import { Effect } from "babylonjs/Materials/effect";
  66715. import { Mesh } from "babylonjs/Meshes/mesh";
  66716. import { Scene } from "babylonjs/scene";
  66717. /**
  66718. * Block used to implement the PBR metallic/roughness model
  66719. */
  66720. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66721. /**
  66722. * Gets or sets the light associated with this block
  66723. */
  66724. light: Nullable<Light>;
  66725. private _lightId;
  66726. private _scene;
  66727. private _environmentBRDFTexture;
  66728. private _environmentBrdfSamplerName;
  66729. private _vNormalWName;
  66730. private _invertNormalName;
  66731. /**
  66732. * Create a new ReflectionBlock
  66733. * @param name defines the block name
  66734. */
  66735. constructor(name: string);
  66736. /**
  66737. * Intensity of the direct lights e.g. the four lights available in your scene.
  66738. * This impacts both the direct diffuse and specular highlights.
  66739. */
  66740. directIntensity: number;
  66741. /**
  66742. * Intensity of the environment e.g. how much the environment will light the object
  66743. * either through harmonics for rough material or through the refelction for shiny ones.
  66744. */
  66745. environmentIntensity: number;
  66746. /**
  66747. * This is a special control allowing the reduction of the specular highlights coming from the
  66748. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66749. */
  66750. specularIntensity: number;
  66751. /**
  66752. * Defines the falloff type used in this material.
  66753. * It by default is Physical.
  66754. */
  66755. lightFalloff: number;
  66756. /**
  66757. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  66758. */
  66759. useAlphaFromAlbedoTexture: boolean;
  66760. /**
  66761. * Specifies that alpha test should be used
  66762. */
  66763. useAlphaTest: boolean;
  66764. /**
  66765. * Defines the alpha limits in alpha test mode.
  66766. */
  66767. alphaTestCutoff: number;
  66768. /**
  66769. * Specifies that alpha blending should be used
  66770. */
  66771. useAlphaBlending: boolean;
  66772. /**
  66773. * Defines if the alpha value should be determined via the rgb values.
  66774. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  66775. */
  66776. opacityRGB: boolean;
  66777. /**
  66778. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66779. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66780. */
  66781. useRadianceOverAlpha: boolean;
  66782. /**
  66783. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66784. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66785. */
  66786. useSpecularOverAlpha: boolean;
  66787. /**
  66788. * Enables specular anti aliasing in the PBR shader.
  66789. * It will both interacts on the Geometry for analytical and IBL lighting.
  66790. * It also prefilter the roughness map based on the bump values.
  66791. */
  66792. enableSpecularAntiAliasing: boolean;
  66793. /**
  66794. * Enables realtime filtering on the texture.
  66795. */
  66796. realTimeFiltering: boolean;
  66797. /**
  66798. * Quality switch for realtime filtering
  66799. */
  66800. realTimeFilteringQuality: number;
  66801. /**
  66802. * Defines if the material uses energy conservation.
  66803. */
  66804. useEnergyConservation: boolean;
  66805. /**
  66806. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  66807. * too much the area relying on ambient texture to define their ambient occlusion.
  66808. */
  66809. useRadianceOcclusion: boolean;
  66810. /**
  66811. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  66812. * makes the reflect vector face the model (under horizon).
  66813. */
  66814. useHorizonOcclusion: boolean;
  66815. /**
  66816. * If set to true, no lighting calculations will be applied.
  66817. */
  66818. unlit: boolean;
  66819. /**
  66820. * Force normal to face away from face.
  66821. */
  66822. forceNormalForward: boolean;
  66823. /**
  66824. * Defines the material debug mode.
  66825. * It helps seeing only some components of the material while troubleshooting.
  66826. */
  66827. debugMode: number;
  66828. /**
  66829. * Specify from where on screen the debug mode should start.
  66830. * The value goes from -1 (full screen) to 1 (not visible)
  66831. * It helps with side by side comparison against the final render
  66832. * This defaults to 0
  66833. */
  66834. debugLimit: number;
  66835. /**
  66836. * As the default viewing range might not be enough (if the ambient is really small for instance)
  66837. * You can use the factor to better multiply the final value.
  66838. */
  66839. debugFactor: number;
  66840. /**
  66841. * Initialize the block and prepare the context for build
  66842. * @param state defines the state that will be used for the build
  66843. */
  66844. initialize(state: NodeMaterialBuildState): void;
  66845. /**
  66846. * Gets the current class name
  66847. * @returns the class name
  66848. */
  66849. getClassName(): string;
  66850. /**
  66851. * Gets the world position input component
  66852. */
  66853. get worldPosition(): NodeMaterialConnectionPoint;
  66854. /**
  66855. * Gets the world normal input component
  66856. */
  66857. get worldNormal(): NodeMaterialConnectionPoint;
  66858. /**
  66859. * Gets the perturbed normal input component
  66860. */
  66861. get perturbedNormal(): NodeMaterialConnectionPoint;
  66862. /**
  66863. * Gets the camera position input component
  66864. */
  66865. get cameraPosition(): NodeMaterialConnectionPoint;
  66866. /**
  66867. * Gets the base color input component
  66868. */
  66869. get baseColor(): NodeMaterialConnectionPoint;
  66870. /**
  66871. * Gets the opacity texture input component
  66872. */
  66873. get opacityTexture(): NodeMaterialConnectionPoint;
  66874. /**
  66875. * Gets the ambient color input component
  66876. */
  66877. get ambientColor(): NodeMaterialConnectionPoint;
  66878. /**
  66879. * Gets the reflectivity object parameters
  66880. */
  66881. get reflectivity(): NodeMaterialConnectionPoint;
  66882. /**
  66883. * Gets the ambient occlusion object parameters
  66884. */
  66885. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66886. /**
  66887. * Gets the reflection object parameters
  66888. */
  66889. get reflection(): NodeMaterialConnectionPoint;
  66890. /**
  66891. * Gets the sheen object parameters
  66892. */
  66893. get sheen(): NodeMaterialConnectionPoint;
  66894. /**
  66895. * Gets the clear coat object parameters
  66896. */
  66897. get clearcoat(): NodeMaterialConnectionPoint;
  66898. /**
  66899. * Gets the sub surface object parameters
  66900. */
  66901. get subsurface(): NodeMaterialConnectionPoint;
  66902. /**
  66903. * Gets the anisotropy object parameters
  66904. */
  66905. get anisotropy(): NodeMaterialConnectionPoint;
  66906. /**
  66907. * Gets the ambient output component
  66908. */
  66909. get ambient(): NodeMaterialConnectionPoint;
  66910. /**
  66911. * Gets the diffuse output component
  66912. */
  66913. get diffuse(): NodeMaterialConnectionPoint;
  66914. /**
  66915. * Gets the specular output component
  66916. */
  66917. get specular(): NodeMaterialConnectionPoint;
  66918. /**
  66919. * Gets the sheen output component
  66920. */
  66921. get sheenDir(): NodeMaterialConnectionPoint;
  66922. /**
  66923. * Gets the clear coat output component
  66924. */
  66925. get clearcoatDir(): NodeMaterialConnectionPoint;
  66926. /**
  66927. * Gets the indirect diffuse output component
  66928. */
  66929. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66930. /**
  66931. * Gets the indirect specular output component
  66932. */
  66933. get specularIndirect(): NodeMaterialConnectionPoint;
  66934. /**
  66935. * Gets the indirect sheen output component
  66936. */
  66937. get sheenIndirect(): NodeMaterialConnectionPoint;
  66938. /**
  66939. * Gets the indirect clear coat output component
  66940. */
  66941. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66942. /**
  66943. * Gets the refraction output component
  66944. */
  66945. get refraction(): NodeMaterialConnectionPoint;
  66946. /**
  66947. * Gets the global lighting output component
  66948. */
  66949. get lighting(): NodeMaterialConnectionPoint;
  66950. /**
  66951. * Gets the shadow output component
  66952. */
  66953. get shadow(): NodeMaterialConnectionPoint;
  66954. /**
  66955. * Gets the alpha output component
  66956. */
  66957. get alpha(): NodeMaterialConnectionPoint;
  66958. autoConfigure(material: NodeMaterial): void;
  66959. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66960. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66961. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66962. private _injectVertexCode;
  66963. /**
  66964. * Gets the code corresponding to the albedo/opacity module
  66965. * @returns the shader code
  66966. */
  66967. getAlbedoOpacityCode(): string;
  66968. protected _buildBlock(state: NodeMaterialBuildState): this;
  66969. protected _dumpPropertiesCode(): string;
  66970. serialize(): any;
  66971. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66972. }
  66973. }
  66974. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  66975. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  66976. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  66977. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  66978. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  66979. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  66980. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66981. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  66982. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  66983. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  66984. }
  66985. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  66986. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  66987. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  66988. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  66989. }
  66990. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  66991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66992. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66993. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66994. /**
  66995. * Block used to compute value of one parameter modulo another
  66996. */
  66997. export class ModBlock extends NodeMaterialBlock {
  66998. /**
  66999. * Creates a new ModBlock
  67000. * @param name defines the block name
  67001. */
  67002. constructor(name: string);
  67003. /**
  67004. * Gets the current class name
  67005. * @returns the class name
  67006. */
  67007. getClassName(): string;
  67008. /**
  67009. * Gets the left operand input component
  67010. */
  67011. get left(): NodeMaterialConnectionPoint;
  67012. /**
  67013. * Gets the right operand input component
  67014. */
  67015. get right(): NodeMaterialConnectionPoint;
  67016. /**
  67017. * Gets the output component
  67018. */
  67019. get output(): NodeMaterialConnectionPoint;
  67020. protected _buildBlock(state: NodeMaterialBuildState): this;
  67021. }
  67022. }
  67023. declare module "babylonjs/Materials/Node/Blocks/index" {
  67024. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  67025. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  67026. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  67027. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  67028. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  67029. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  67030. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  67031. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  67032. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  67033. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  67034. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  67035. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  67036. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  67037. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  67038. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  67039. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  67040. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  67041. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  67042. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  67043. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  67044. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  67045. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  67046. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  67047. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  67048. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  67049. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  67050. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  67051. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  67052. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  67053. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  67054. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  67055. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  67056. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  67057. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  67058. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  67059. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  67060. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  67061. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  67062. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  67063. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  67064. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  67065. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  67066. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  67067. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  67068. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  67069. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  67070. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  67071. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  67072. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  67073. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  67074. }
  67075. declare module "babylonjs/Materials/Node/Optimizers/index" {
  67076. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  67077. }
  67078. declare module "babylonjs/Materials/Node/index" {
  67079. export * from "babylonjs/Materials/Node/Enums/index";
  67080. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67081. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  67082. export * from "babylonjs/Materials/Node/nodeMaterial";
  67083. export * from "babylonjs/Materials/Node/Blocks/index";
  67084. export * from "babylonjs/Materials/Node/Optimizers/index";
  67085. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  67086. }
  67087. declare module "babylonjs/Materials/index" {
  67088. export * from "babylonjs/Materials/Background/index";
  67089. export * from "babylonjs/Materials/colorCurves";
  67090. export * from "babylonjs/Materials/iEffectFallbacks";
  67091. export * from "babylonjs/Materials/effectFallbacks";
  67092. export * from "babylonjs/Materials/effect";
  67093. export * from "babylonjs/Materials/fresnelParameters";
  67094. export * from "babylonjs/Materials/imageProcessingConfiguration";
  67095. export * from "babylonjs/Materials/material";
  67096. export * from "babylonjs/Materials/materialDefines";
  67097. export * from "babylonjs/Materials/materialHelper";
  67098. export * from "babylonjs/Materials/multiMaterial";
  67099. export * from "babylonjs/Materials/PBR/index";
  67100. export * from "babylonjs/Materials/pushMaterial";
  67101. export * from "babylonjs/Materials/shaderMaterial";
  67102. export * from "babylonjs/Materials/standardMaterial";
  67103. export * from "babylonjs/Materials/Textures/index";
  67104. export * from "babylonjs/Materials/uniformBuffer";
  67105. export * from "babylonjs/Materials/materialFlags";
  67106. export * from "babylonjs/Materials/Node/index";
  67107. export * from "babylonjs/Materials/effectRenderer";
  67108. export * from "babylonjs/Materials/shadowDepthWrapper";
  67109. }
  67110. declare module "babylonjs/Maths/index" {
  67111. export * from "babylonjs/Maths/math.scalar";
  67112. export * from "babylonjs/Maths/math";
  67113. export * from "babylonjs/Maths/sphericalPolynomial";
  67114. }
  67115. declare module "babylonjs/Misc/workerPool" {
  67116. import { IDisposable } from "babylonjs/scene";
  67117. /**
  67118. * Helper class to push actions to a pool of workers.
  67119. */
  67120. export class WorkerPool implements IDisposable {
  67121. private _workerInfos;
  67122. private _pendingActions;
  67123. /**
  67124. * Constructor
  67125. * @param workers Array of workers to use for actions
  67126. */
  67127. constructor(workers: Array<Worker>);
  67128. /**
  67129. * Terminates all workers and clears any pending actions.
  67130. */
  67131. dispose(): void;
  67132. /**
  67133. * Pushes an action to the worker pool. If all the workers are active, the action will be
  67134. * pended until a worker has completed its action.
  67135. * @param action The action to perform. Call onComplete when the action is complete.
  67136. */
  67137. push(action: (worker: Worker, onComplete: () => void) => void): void;
  67138. private _execute;
  67139. }
  67140. }
  67141. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  67142. import { IDisposable } from "babylonjs/scene";
  67143. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67144. /**
  67145. * Configuration for Draco compression
  67146. */
  67147. export interface IDracoCompressionConfiguration {
  67148. /**
  67149. * Configuration for the decoder.
  67150. */
  67151. decoder: {
  67152. /**
  67153. * The url to the WebAssembly module.
  67154. */
  67155. wasmUrl?: string;
  67156. /**
  67157. * The url to the WebAssembly binary.
  67158. */
  67159. wasmBinaryUrl?: string;
  67160. /**
  67161. * The url to the fallback JavaScript module.
  67162. */
  67163. fallbackUrl?: string;
  67164. };
  67165. }
  67166. /**
  67167. * Draco compression (https://google.github.io/draco/)
  67168. *
  67169. * This class wraps the Draco module.
  67170. *
  67171. * **Encoder**
  67172. *
  67173. * The encoder is not currently implemented.
  67174. *
  67175. * **Decoder**
  67176. *
  67177. * 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.
  67178. *
  67179. * To update the configuration, use the following code:
  67180. * ```javascript
  67181. * DracoCompression.Configuration = {
  67182. * decoder: {
  67183. * wasmUrl: "<url to the WebAssembly library>",
  67184. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  67185. * fallbackUrl: "<url to the fallback JavaScript library>",
  67186. * }
  67187. * };
  67188. * ```
  67189. *
  67190. * 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.
  67191. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  67192. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  67193. *
  67194. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  67195. * ```javascript
  67196. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  67197. * ```
  67198. *
  67199. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  67200. */
  67201. export class DracoCompression implements IDisposable {
  67202. private _workerPoolPromise?;
  67203. private _decoderModulePromise?;
  67204. /**
  67205. * The configuration. Defaults to the following urls:
  67206. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  67207. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  67208. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  67209. */
  67210. static Configuration: IDracoCompressionConfiguration;
  67211. /**
  67212. * Returns true if the decoder configuration is available.
  67213. */
  67214. static get DecoderAvailable(): boolean;
  67215. /**
  67216. * Default number of workers to create when creating the draco compression object.
  67217. */
  67218. static DefaultNumWorkers: number;
  67219. private static GetDefaultNumWorkers;
  67220. private static _Default;
  67221. /**
  67222. * Default instance for the draco compression object.
  67223. */
  67224. static get Default(): DracoCompression;
  67225. /**
  67226. * Constructor
  67227. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  67228. */
  67229. constructor(numWorkers?: number);
  67230. /**
  67231. * Stop all async operations and release resources.
  67232. */
  67233. dispose(): void;
  67234. /**
  67235. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  67236. * @returns a promise that resolves when ready
  67237. */
  67238. whenReadyAsync(): Promise<void>;
  67239. /**
  67240. * Decode Draco compressed mesh data to vertex data.
  67241. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  67242. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  67243. * @returns A promise that resolves with the decoded vertex data
  67244. */
  67245. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  67246. [kind: string]: number;
  67247. }): Promise<VertexData>;
  67248. }
  67249. }
  67250. declare module "babylonjs/Meshes/Compression/index" {
  67251. export * from "babylonjs/Meshes/Compression/dracoCompression";
  67252. }
  67253. declare module "babylonjs/Meshes/csg" {
  67254. import { Nullable } from "babylonjs/types";
  67255. import { Scene } from "babylonjs/scene";
  67256. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67257. import { Mesh } from "babylonjs/Meshes/mesh";
  67258. import { Material } from "babylonjs/Materials/material";
  67259. /**
  67260. * Class for building Constructive Solid Geometry
  67261. */
  67262. export class CSG {
  67263. private polygons;
  67264. /**
  67265. * The world matrix
  67266. */
  67267. matrix: Matrix;
  67268. /**
  67269. * Stores the position
  67270. */
  67271. position: Vector3;
  67272. /**
  67273. * Stores the rotation
  67274. */
  67275. rotation: Vector3;
  67276. /**
  67277. * Stores the rotation quaternion
  67278. */
  67279. rotationQuaternion: Nullable<Quaternion>;
  67280. /**
  67281. * Stores the scaling vector
  67282. */
  67283. scaling: Vector3;
  67284. /**
  67285. * Convert the Mesh to CSG
  67286. * @param mesh The Mesh to convert to CSG
  67287. * @returns A new CSG from the Mesh
  67288. */
  67289. static FromMesh(mesh: Mesh): CSG;
  67290. /**
  67291. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  67292. * @param polygons Polygons used to construct a CSG solid
  67293. */
  67294. private static FromPolygons;
  67295. /**
  67296. * Clones, or makes a deep copy, of the CSG
  67297. * @returns A new CSG
  67298. */
  67299. clone(): CSG;
  67300. /**
  67301. * Unions this CSG with another CSG
  67302. * @param csg The CSG to union against this CSG
  67303. * @returns The unioned CSG
  67304. */
  67305. union(csg: CSG): CSG;
  67306. /**
  67307. * Unions this CSG with another CSG in place
  67308. * @param csg The CSG to union against this CSG
  67309. */
  67310. unionInPlace(csg: CSG): void;
  67311. /**
  67312. * Subtracts this CSG with another CSG
  67313. * @param csg The CSG to subtract against this CSG
  67314. * @returns A new CSG
  67315. */
  67316. subtract(csg: CSG): CSG;
  67317. /**
  67318. * Subtracts this CSG with another CSG in place
  67319. * @param csg The CSG to subtact against this CSG
  67320. */
  67321. subtractInPlace(csg: CSG): void;
  67322. /**
  67323. * Intersect this CSG with another CSG
  67324. * @param csg The CSG to intersect against this CSG
  67325. * @returns A new CSG
  67326. */
  67327. intersect(csg: CSG): CSG;
  67328. /**
  67329. * Intersects this CSG with another CSG in place
  67330. * @param csg The CSG to intersect against this CSG
  67331. */
  67332. intersectInPlace(csg: CSG): void;
  67333. /**
  67334. * Return a new CSG solid with solid and empty space switched. This solid is
  67335. * not modified.
  67336. * @returns A new CSG solid with solid and empty space switched
  67337. */
  67338. inverse(): CSG;
  67339. /**
  67340. * Inverses the CSG in place
  67341. */
  67342. inverseInPlace(): void;
  67343. /**
  67344. * This is used to keep meshes transformations so they can be restored
  67345. * when we build back a Babylon Mesh
  67346. * NB : All CSG operations are performed in world coordinates
  67347. * @param csg The CSG to copy the transform attributes from
  67348. * @returns This CSG
  67349. */
  67350. copyTransformAttributes(csg: CSG): CSG;
  67351. /**
  67352. * Build Raw mesh from CSG
  67353. * Coordinates here are in world space
  67354. * @param name The name of the mesh geometry
  67355. * @param scene The Scene
  67356. * @param keepSubMeshes Specifies if the submeshes should be kept
  67357. * @returns A new Mesh
  67358. */
  67359. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67360. /**
  67361. * Build Mesh from CSG taking material and transforms into account
  67362. * @param name The name of the Mesh
  67363. * @param material The material of the Mesh
  67364. * @param scene The Scene
  67365. * @param keepSubMeshes Specifies if submeshes should be kept
  67366. * @returns The new Mesh
  67367. */
  67368. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67369. }
  67370. }
  67371. declare module "babylonjs/Meshes/trailMesh" {
  67372. import { Mesh } from "babylonjs/Meshes/mesh";
  67373. import { Scene } from "babylonjs/scene";
  67374. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67375. /**
  67376. * Class used to create a trail following a mesh
  67377. */
  67378. export class TrailMesh extends Mesh {
  67379. private _generator;
  67380. private _autoStart;
  67381. private _running;
  67382. private _diameter;
  67383. private _length;
  67384. private _sectionPolygonPointsCount;
  67385. private _sectionVectors;
  67386. private _sectionNormalVectors;
  67387. private _beforeRenderObserver;
  67388. /**
  67389. * @constructor
  67390. * @param name The value used by scene.getMeshByName() to do a lookup.
  67391. * @param generator The mesh or transform node to generate a trail.
  67392. * @param scene The scene to add this mesh to.
  67393. * @param diameter Diameter of trailing mesh. Default is 1.
  67394. * @param length Length of trailing mesh. Default is 60.
  67395. * @param autoStart Automatically start trailing mesh. Default true.
  67396. */
  67397. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  67398. /**
  67399. * "TrailMesh"
  67400. * @returns "TrailMesh"
  67401. */
  67402. getClassName(): string;
  67403. private _createMesh;
  67404. /**
  67405. * Start trailing mesh.
  67406. */
  67407. start(): void;
  67408. /**
  67409. * Stop trailing mesh.
  67410. */
  67411. stop(): void;
  67412. /**
  67413. * Update trailing mesh geometry.
  67414. */
  67415. update(): void;
  67416. /**
  67417. * Returns a new TrailMesh object.
  67418. * @param name is a string, the name given to the new mesh
  67419. * @param newGenerator use new generator object for cloned trail mesh
  67420. * @returns a new mesh
  67421. */
  67422. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  67423. /**
  67424. * Serializes this trail mesh
  67425. * @param serializationObject object to write serialization to
  67426. */
  67427. serialize(serializationObject: any): void;
  67428. /**
  67429. * Parses a serialized trail mesh
  67430. * @param parsedMesh the serialized mesh
  67431. * @param scene the scene to create the trail mesh in
  67432. * @returns the created trail mesh
  67433. */
  67434. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  67435. }
  67436. }
  67437. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  67438. import { Nullable } from "babylonjs/types";
  67439. import { Scene } from "babylonjs/scene";
  67440. import { Vector4 } from "babylonjs/Maths/math.vector";
  67441. import { Color4 } from "babylonjs/Maths/math.color";
  67442. import { Mesh } from "babylonjs/Meshes/mesh";
  67443. /**
  67444. * Class containing static functions to help procedurally build meshes
  67445. */
  67446. export class TiledBoxBuilder {
  67447. /**
  67448. * Creates a box mesh
  67449. * 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)
  67450. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67452. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67454. * @param name defines the name of the mesh
  67455. * @param options defines the options used to create the mesh
  67456. * @param scene defines the hosting scene
  67457. * @returns the box mesh
  67458. */
  67459. static CreateTiledBox(name: string, options: {
  67460. pattern?: number;
  67461. width?: number;
  67462. height?: number;
  67463. depth?: number;
  67464. tileSize?: number;
  67465. tileWidth?: number;
  67466. tileHeight?: number;
  67467. alignHorizontal?: number;
  67468. alignVertical?: number;
  67469. faceUV?: Vector4[];
  67470. faceColors?: Color4[];
  67471. sideOrientation?: number;
  67472. updatable?: boolean;
  67473. }, scene?: Nullable<Scene>): Mesh;
  67474. }
  67475. }
  67476. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  67477. import { Vector4 } from "babylonjs/Maths/math.vector";
  67478. import { Mesh } from "babylonjs/Meshes/mesh";
  67479. /**
  67480. * Class containing static functions to help procedurally build meshes
  67481. */
  67482. export class TorusKnotBuilder {
  67483. /**
  67484. * Creates a torus knot mesh
  67485. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67486. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67487. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67488. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67490. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67492. * @param name defines the name of the mesh
  67493. * @param options defines the options used to create the mesh
  67494. * @param scene defines the hosting scene
  67495. * @returns the torus knot mesh
  67496. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67497. */
  67498. static CreateTorusKnot(name: string, options: {
  67499. radius?: number;
  67500. tube?: number;
  67501. radialSegments?: number;
  67502. tubularSegments?: number;
  67503. p?: number;
  67504. q?: number;
  67505. updatable?: boolean;
  67506. sideOrientation?: number;
  67507. frontUVs?: Vector4;
  67508. backUVs?: Vector4;
  67509. }, scene: any): Mesh;
  67510. }
  67511. }
  67512. declare module "babylonjs/Meshes/polygonMesh" {
  67513. import { Scene } from "babylonjs/scene";
  67514. import { Vector2 } from "babylonjs/Maths/math.vector";
  67515. import { Mesh } from "babylonjs/Meshes/mesh";
  67516. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67517. import { Path2 } from "babylonjs/Maths/math.path";
  67518. /**
  67519. * Polygon
  67520. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  67521. */
  67522. export class Polygon {
  67523. /**
  67524. * Creates a rectangle
  67525. * @param xmin bottom X coord
  67526. * @param ymin bottom Y coord
  67527. * @param xmax top X coord
  67528. * @param ymax top Y coord
  67529. * @returns points that make the resulting rectation
  67530. */
  67531. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  67532. /**
  67533. * Creates a circle
  67534. * @param radius radius of circle
  67535. * @param cx scale in x
  67536. * @param cy scale in y
  67537. * @param numberOfSides number of sides that make up the circle
  67538. * @returns points that make the resulting circle
  67539. */
  67540. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  67541. /**
  67542. * Creates a polygon from input string
  67543. * @param input Input polygon data
  67544. * @returns the parsed points
  67545. */
  67546. static Parse(input: string): Vector2[];
  67547. /**
  67548. * Starts building a polygon from x and y coordinates
  67549. * @param x x coordinate
  67550. * @param y y coordinate
  67551. * @returns the started path2
  67552. */
  67553. static StartingAt(x: number, y: number): Path2;
  67554. }
  67555. /**
  67556. * Builds a polygon
  67557. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  67558. */
  67559. export class PolygonMeshBuilder {
  67560. private _points;
  67561. private _outlinepoints;
  67562. private _holes;
  67563. private _name;
  67564. private _scene;
  67565. private _epoints;
  67566. private _eholes;
  67567. private _addToepoint;
  67568. /**
  67569. * Babylon reference to the earcut plugin.
  67570. */
  67571. bjsEarcut: any;
  67572. /**
  67573. * Creates a PolygonMeshBuilder
  67574. * @param name name of the builder
  67575. * @param contours Path of the polygon
  67576. * @param scene scene to add to when creating the mesh
  67577. * @param earcutInjection can be used to inject your own earcut reference
  67578. */
  67579. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  67580. /**
  67581. * Adds a whole within the polygon
  67582. * @param hole Array of points defining the hole
  67583. * @returns this
  67584. */
  67585. addHole(hole: Vector2[]): PolygonMeshBuilder;
  67586. /**
  67587. * Creates the polygon
  67588. * @param updatable If the mesh should be updatable
  67589. * @param depth The depth of the mesh created
  67590. * @returns the created mesh
  67591. */
  67592. build(updatable?: boolean, depth?: number): Mesh;
  67593. /**
  67594. * Creates the polygon
  67595. * @param depth The depth of the mesh created
  67596. * @returns the created VertexData
  67597. */
  67598. buildVertexData(depth?: number): VertexData;
  67599. /**
  67600. * Adds a side to the polygon
  67601. * @param positions points that make the polygon
  67602. * @param normals normals of the polygon
  67603. * @param uvs uvs of the polygon
  67604. * @param indices indices of the polygon
  67605. * @param bounds bounds of the polygon
  67606. * @param points points of the polygon
  67607. * @param depth depth of the polygon
  67608. * @param flip flip of the polygon
  67609. */
  67610. private addSide;
  67611. }
  67612. }
  67613. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  67614. import { Scene } from "babylonjs/scene";
  67615. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67616. import { Color4 } from "babylonjs/Maths/math.color";
  67617. import { Mesh } from "babylonjs/Meshes/mesh";
  67618. import { Nullable } from "babylonjs/types";
  67619. /**
  67620. * Class containing static functions to help procedurally build meshes
  67621. */
  67622. export class PolygonBuilder {
  67623. /**
  67624. * Creates a polygon mesh
  67625. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67626. * * 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
  67627. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67629. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  67630. * * Remember you can only change the shape positions, not their number when updating a polygon
  67631. * @param name defines the name of the mesh
  67632. * @param options defines the options used to create the mesh
  67633. * @param scene defines the hosting scene
  67634. * @param earcutInjection can be used to inject your own earcut reference
  67635. * @returns the polygon mesh
  67636. */
  67637. static CreatePolygon(name: string, options: {
  67638. shape: Vector3[];
  67639. holes?: Vector3[][];
  67640. depth?: number;
  67641. faceUV?: Vector4[];
  67642. faceColors?: Color4[];
  67643. updatable?: boolean;
  67644. sideOrientation?: number;
  67645. frontUVs?: Vector4;
  67646. backUVs?: Vector4;
  67647. wrap?: boolean;
  67648. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67649. /**
  67650. * Creates an extruded polygon mesh, with depth in the Y direction.
  67651. * * 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)
  67652. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67653. * @param name defines the name of the mesh
  67654. * @param options defines the options used to create the mesh
  67655. * @param scene defines the hosting scene
  67656. * @param earcutInjection can be used to inject your own earcut reference
  67657. * @returns the polygon mesh
  67658. */
  67659. static ExtrudePolygon(name: string, options: {
  67660. shape: Vector3[];
  67661. holes?: Vector3[][];
  67662. depth?: number;
  67663. faceUV?: Vector4[];
  67664. faceColors?: Color4[];
  67665. updatable?: boolean;
  67666. sideOrientation?: number;
  67667. frontUVs?: Vector4;
  67668. backUVs?: Vector4;
  67669. wrap?: boolean;
  67670. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67671. }
  67672. }
  67673. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  67674. import { Scene } from "babylonjs/scene";
  67675. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67676. import { Mesh } from "babylonjs/Meshes/mesh";
  67677. import { Nullable } from "babylonjs/types";
  67678. /**
  67679. * Class containing static functions to help procedurally build meshes
  67680. */
  67681. export class LatheBuilder {
  67682. /**
  67683. * Creates lathe mesh.
  67684. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67685. * * 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
  67686. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67687. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67688. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67689. * * 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
  67690. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67691. * * 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
  67692. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67693. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67694. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67696. * @param name defines the name of the mesh
  67697. * @param options defines the options used to create the mesh
  67698. * @param scene defines the hosting scene
  67699. * @returns the lathe mesh
  67700. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67701. */
  67702. static CreateLathe(name: string, options: {
  67703. shape: Vector3[];
  67704. radius?: number;
  67705. tessellation?: number;
  67706. clip?: number;
  67707. arc?: number;
  67708. closed?: boolean;
  67709. updatable?: boolean;
  67710. sideOrientation?: number;
  67711. frontUVs?: Vector4;
  67712. backUVs?: Vector4;
  67713. cap?: number;
  67714. invertUV?: boolean;
  67715. }, scene?: Nullable<Scene>): Mesh;
  67716. }
  67717. }
  67718. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  67719. import { Nullable } from "babylonjs/types";
  67720. import { Scene } from "babylonjs/scene";
  67721. import { Vector4 } from "babylonjs/Maths/math.vector";
  67722. import { Mesh } from "babylonjs/Meshes/mesh";
  67723. /**
  67724. * Class containing static functions to help procedurally build meshes
  67725. */
  67726. export class TiledPlaneBuilder {
  67727. /**
  67728. * Creates a tiled plane mesh
  67729. * * The parameter `pattern` will, depending on value, do nothing or
  67730. * * * flip (reflect about central vertical) alternate tiles across and up
  67731. * * * flip every tile on alternate rows
  67732. * * * rotate (180 degs) alternate tiles across and up
  67733. * * * rotate every tile on alternate rows
  67734. * * * flip and rotate alternate tiles across and up
  67735. * * * flip and rotate every tile on alternate rows
  67736. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  67737. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  67738. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67739. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67740. * * 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)
  67741. * * 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)
  67742. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67743. * @param name defines the name of the mesh
  67744. * @param options defines the options used to create the mesh
  67745. * @param scene defines the hosting scene
  67746. * @returns the box mesh
  67747. */
  67748. static CreateTiledPlane(name: string, options: {
  67749. pattern?: number;
  67750. tileSize?: number;
  67751. tileWidth?: number;
  67752. tileHeight?: number;
  67753. size?: number;
  67754. width?: number;
  67755. height?: number;
  67756. alignHorizontal?: number;
  67757. alignVertical?: number;
  67758. sideOrientation?: number;
  67759. frontUVs?: Vector4;
  67760. backUVs?: Vector4;
  67761. updatable?: boolean;
  67762. }, scene?: Nullable<Scene>): Mesh;
  67763. }
  67764. }
  67765. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  67766. import { Nullable } from "babylonjs/types";
  67767. import { Scene } from "babylonjs/scene";
  67768. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67769. import { Mesh } from "babylonjs/Meshes/mesh";
  67770. /**
  67771. * Class containing static functions to help procedurally build meshes
  67772. */
  67773. export class TubeBuilder {
  67774. /**
  67775. * Creates a tube mesh.
  67776. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67777. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67778. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67779. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67780. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67781. * * 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)
  67782. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67783. * * 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
  67784. * * 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
  67785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67786. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67787. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67789. * @param name defines the name of the mesh
  67790. * @param options defines the options used to create the mesh
  67791. * @param scene defines the hosting scene
  67792. * @returns the tube mesh
  67793. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67794. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67795. */
  67796. static CreateTube(name: string, options: {
  67797. path: Vector3[];
  67798. radius?: number;
  67799. tessellation?: number;
  67800. radiusFunction?: {
  67801. (i: number, distance: number): number;
  67802. };
  67803. cap?: number;
  67804. arc?: number;
  67805. updatable?: boolean;
  67806. sideOrientation?: number;
  67807. frontUVs?: Vector4;
  67808. backUVs?: Vector4;
  67809. instance?: Mesh;
  67810. invertUV?: boolean;
  67811. }, scene?: Nullable<Scene>): Mesh;
  67812. }
  67813. }
  67814. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  67815. import { Scene } from "babylonjs/scene";
  67816. import { Vector4 } from "babylonjs/Maths/math.vector";
  67817. import { Mesh } from "babylonjs/Meshes/mesh";
  67818. import { Nullable } from "babylonjs/types";
  67819. /**
  67820. * Class containing static functions to help procedurally build meshes
  67821. */
  67822. export class IcoSphereBuilder {
  67823. /**
  67824. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67825. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67826. * * 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`)
  67827. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67828. * * 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
  67829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67830. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67832. * @param name defines the name of the mesh
  67833. * @param options defines the options used to create the mesh
  67834. * @param scene defines the hosting scene
  67835. * @returns the icosahedron mesh
  67836. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67837. */
  67838. static CreateIcoSphere(name: string, options: {
  67839. radius?: number;
  67840. radiusX?: number;
  67841. radiusY?: number;
  67842. radiusZ?: number;
  67843. flat?: boolean;
  67844. subdivisions?: number;
  67845. sideOrientation?: number;
  67846. frontUVs?: Vector4;
  67847. backUVs?: Vector4;
  67848. updatable?: boolean;
  67849. }, scene?: Nullable<Scene>): Mesh;
  67850. }
  67851. }
  67852. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  67853. import { Vector3 } from "babylonjs/Maths/math.vector";
  67854. import { Mesh } from "babylonjs/Meshes/mesh";
  67855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67856. /**
  67857. * Class containing static functions to help procedurally build meshes
  67858. */
  67859. export class DecalBuilder {
  67860. /**
  67861. * Creates a decal mesh.
  67862. * 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
  67863. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67864. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67865. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67866. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67867. * @param name defines the name of the mesh
  67868. * @param sourceMesh defines the mesh where the decal must be applied
  67869. * @param options defines the options used to create the mesh
  67870. * @param scene defines the hosting scene
  67871. * @returns the decal mesh
  67872. * @see https://doc.babylonjs.com/how_to/decals
  67873. */
  67874. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67875. position?: Vector3;
  67876. normal?: Vector3;
  67877. size?: Vector3;
  67878. angle?: number;
  67879. }): Mesh;
  67880. }
  67881. }
  67882. declare module "babylonjs/Meshes/meshBuilder" {
  67883. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  67884. import { Nullable } from "babylonjs/types";
  67885. import { Scene } from "babylonjs/scene";
  67886. import { Mesh } from "babylonjs/Meshes/mesh";
  67887. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  67888. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  67889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67890. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  67891. import { Plane } from "babylonjs/Maths/math.plane";
  67892. /**
  67893. * Class containing static functions to help procedurally build meshes
  67894. */
  67895. export class MeshBuilder {
  67896. /**
  67897. * Creates a box mesh
  67898. * * The parameter `size` sets the size (float) of each box side (default 1)
  67899. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  67900. * * 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)
  67901. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67903. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67905. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67906. * @param name defines the name of the mesh
  67907. * @param options defines the options used to create the mesh
  67908. * @param scene defines the hosting scene
  67909. * @returns the box mesh
  67910. */
  67911. static CreateBox(name: string, options: {
  67912. size?: number;
  67913. width?: number;
  67914. height?: number;
  67915. depth?: number;
  67916. faceUV?: Vector4[];
  67917. faceColors?: Color4[];
  67918. sideOrientation?: number;
  67919. frontUVs?: Vector4;
  67920. backUVs?: Vector4;
  67921. wrap?: boolean;
  67922. topBaseAt?: number;
  67923. bottomBaseAt?: number;
  67924. updatable?: boolean;
  67925. }, scene?: Nullable<Scene>): Mesh;
  67926. /**
  67927. * Creates a tiled box mesh
  67928. * * faceTiles sets the pattern, tile size and number of tiles for a face
  67929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67930. * @param name defines the name of the mesh
  67931. * @param options defines the options used to create the mesh
  67932. * @param scene defines the hosting scene
  67933. * @returns the tiled box mesh
  67934. */
  67935. static CreateTiledBox(name: string, options: {
  67936. pattern?: number;
  67937. size?: number;
  67938. width?: number;
  67939. height?: number;
  67940. depth: number;
  67941. tileSize?: number;
  67942. tileWidth?: number;
  67943. tileHeight?: number;
  67944. faceUV?: Vector4[];
  67945. faceColors?: Color4[];
  67946. alignHorizontal?: number;
  67947. alignVertical?: number;
  67948. sideOrientation?: number;
  67949. updatable?: boolean;
  67950. }, scene?: Nullable<Scene>): Mesh;
  67951. /**
  67952. * Creates a sphere mesh
  67953. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  67954. * * 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`)
  67955. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  67956. * * 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
  67957. * * 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)
  67958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67959. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67961. * @param name defines the name of the mesh
  67962. * @param options defines the options used to create the mesh
  67963. * @param scene defines the hosting scene
  67964. * @returns the sphere mesh
  67965. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  67966. */
  67967. static CreateSphere(name: string, options: {
  67968. segments?: number;
  67969. diameter?: number;
  67970. diameterX?: number;
  67971. diameterY?: number;
  67972. diameterZ?: number;
  67973. arc?: number;
  67974. slice?: number;
  67975. sideOrientation?: number;
  67976. frontUVs?: Vector4;
  67977. backUVs?: Vector4;
  67978. updatable?: boolean;
  67979. }, scene?: Nullable<Scene>): Mesh;
  67980. /**
  67981. * Creates a plane polygonal mesh. By default, this is a disc
  67982. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  67983. * * 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
  67984. * * 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
  67985. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67986. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67988. * @param name defines the name of the mesh
  67989. * @param options defines the options used to create the mesh
  67990. * @param scene defines the hosting scene
  67991. * @returns the plane polygonal mesh
  67992. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  67993. */
  67994. static CreateDisc(name: string, options: {
  67995. radius?: number;
  67996. tessellation?: number;
  67997. arc?: number;
  67998. updatable?: boolean;
  67999. sideOrientation?: number;
  68000. frontUVs?: Vector4;
  68001. backUVs?: Vector4;
  68002. }, scene?: Nullable<Scene>): Mesh;
  68003. /**
  68004. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68005. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68006. * * 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`)
  68007. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68008. * * 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
  68009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68012. * @param name defines the name of the mesh
  68013. * @param options defines the options used to create the mesh
  68014. * @param scene defines the hosting scene
  68015. * @returns the icosahedron mesh
  68016. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68017. */
  68018. static CreateIcoSphere(name: string, options: {
  68019. radius?: number;
  68020. radiusX?: number;
  68021. radiusY?: number;
  68022. radiusZ?: number;
  68023. flat?: boolean;
  68024. subdivisions?: number;
  68025. sideOrientation?: number;
  68026. frontUVs?: Vector4;
  68027. backUVs?: Vector4;
  68028. updatable?: boolean;
  68029. }, scene?: Nullable<Scene>): Mesh;
  68030. /**
  68031. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68032. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  68033. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  68034. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  68035. * * 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
  68036. * * 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
  68037. * * 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
  68038. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68039. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68040. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68041. * * 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
  68042. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  68043. * * 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
  68044. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  68045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68046. * @param name defines the name of the mesh
  68047. * @param options defines the options used to create the mesh
  68048. * @param scene defines the hosting scene
  68049. * @returns the ribbon mesh
  68050. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  68051. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68052. */
  68053. static CreateRibbon(name: string, options: {
  68054. pathArray: Vector3[][];
  68055. closeArray?: boolean;
  68056. closePath?: boolean;
  68057. offset?: number;
  68058. updatable?: boolean;
  68059. sideOrientation?: number;
  68060. frontUVs?: Vector4;
  68061. backUVs?: Vector4;
  68062. instance?: Mesh;
  68063. invertUV?: boolean;
  68064. uvs?: Vector2[];
  68065. colors?: Color4[];
  68066. }, scene?: Nullable<Scene>): Mesh;
  68067. /**
  68068. * Creates a cylinder or a cone mesh
  68069. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  68070. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  68071. * * 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.
  68072. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  68073. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  68074. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  68075. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  68076. * * 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).
  68077. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  68078. * * 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).
  68079. * * 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
  68080. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  68081. * * 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
  68082. * * 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.
  68083. * * If `enclose` is false, a ring surface is one element.
  68084. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  68085. * * 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
  68086. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68087. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68089. * @param name defines the name of the mesh
  68090. * @param options defines the options used to create the mesh
  68091. * @param scene defines the hosting scene
  68092. * @returns the cylinder mesh
  68093. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  68094. */
  68095. static CreateCylinder(name: string, options: {
  68096. height?: number;
  68097. diameterTop?: number;
  68098. diameterBottom?: number;
  68099. diameter?: number;
  68100. tessellation?: number;
  68101. subdivisions?: number;
  68102. arc?: number;
  68103. faceColors?: Color4[];
  68104. faceUV?: Vector4[];
  68105. updatable?: boolean;
  68106. hasRings?: boolean;
  68107. enclose?: boolean;
  68108. cap?: number;
  68109. sideOrientation?: number;
  68110. frontUVs?: Vector4;
  68111. backUVs?: Vector4;
  68112. }, scene?: Nullable<Scene>): Mesh;
  68113. /**
  68114. * Creates a torus mesh
  68115. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  68116. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  68117. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  68118. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68119. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68121. * @param name defines the name of the mesh
  68122. * @param options defines the options used to create the mesh
  68123. * @param scene defines the hosting scene
  68124. * @returns the torus mesh
  68125. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  68126. */
  68127. static CreateTorus(name: string, options: {
  68128. diameter?: number;
  68129. thickness?: number;
  68130. tessellation?: number;
  68131. updatable?: boolean;
  68132. sideOrientation?: number;
  68133. frontUVs?: Vector4;
  68134. backUVs?: Vector4;
  68135. }, scene?: Nullable<Scene>): Mesh;
  68136. /**
  68137. * Creates a torus knot mesh
  68138. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68139. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68140. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68141. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68143. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68145. * @param name defines the name of the mesh
  68146. * @param options defines the options used to create the mesh
  68147. * @param scene defines the hosting scene
  68148. * @returns the torus knot mesh
  68149. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68150. */
  68151. static CreateTorusKnot(name: string, options: {
  68152. radius?: number;
  68153. tube?: number;
  68154. radialSegments?: number;
  68155. tubularSegments?: number;
  68156. p?: number;
  68157. q?: number;
  68158. updatable?: boolean;
  68159. sideOrientation?: number;
  68160. frontUVs?: Vector4;
  68161. backUVs?: Vector4;
  68162. }, scene?: Nullable<Scene>): Mesh;
  68163. /**
  68164. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  68165. * * 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
  68166. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  68167. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  68168. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  68169. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  68170. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  68171. * * 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
  68172. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  68173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68174. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  68175. * @param name defines the name of the new line system
  68176. * @param options defines the options used to create the line system
  68177. * @param scene defines the hosting scene
  68178. * @returns a new line system mesh
  68179. */
  68180. static CreateLineSystem(name: string, options: {
  68181. lines: Vector3[][];
  68182. updatable?: boolean;
  68183. instance?: Nullable<LinesMesh>;
  68184. colors?: Nullable<Color4[][]>;
  68185. useVertexAlpha?: boolean;
  68186. }, scene: Nullable<Scene>): LinesMesh;
  68187. /**
  68188. * Creates a line mesh
  68189. * 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
  68190. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68191. * * The parameter `points` is an array successive Vector3
  68192. * * 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
  68193. * * The optional parameter `colors` is an array of successive Color4, one per line point
  68194. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  68195. * * When updating an instance, remember that only point positions can change, not the number of points
  68196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68197. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  68198. * @param name defines the name of the new line system
  68199. * @param options defines the options used to create the line system
  68200. * @param scene defines the hosting scene
  68201. * @returns a new line mesh
  68202. */
  68203. static CreateLines(name: string, options: {
  68204. points: Vector3[];
  68205. updatable?: boolean;
  68206. instance?: Nullable<LinesMesh>;
  68207. colors?: Color4[];
  68208. useVertexAlpha?: boolean;
  68209. }, scene?: Nullable<Scene>): LinesMesh;
  68210. /**
  68211. * Creates a dashed line mesh
  68212. * * 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
  68213. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68214. * * The parameter `points` is an array successive Vector3
  68215. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  68216. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  68217. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  68218. * * 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
  68219. * * When updating an instance, remember that only point positions can change, not the number of points
  68220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68221. * @param name defines the name of the mesh
  68222. * @param options defines the options used to create the mesh
  68223. * @param scene defines the hosting scene
  68224. * @returns the dashed line mesh
  68225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  68226. */
  68227. static CreateDashedLines(name: string, options: {
  68228. points: Vector3[];
  68229. dashSize?: number;
  68230. gapSize?: number;
  68231. dashNb?: number;
  68232. updatable?: boolean;
  68233. instance?: LinesMesh;
  68234. }, scene?: Nullable<Scene>): LinesMesh;
  68235. /**
  68236. * 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.
  68237. * * 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.
  68238. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68239. * * 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.
  68240. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  68241. * * 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
  68242. * * 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
  68243. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  68244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68245. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68246. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  68247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68248. * @param name defines the name of the mesh
  68249. * @param options defines the options used to create the mesh
  68250. * @param scene defines the hosting scene
  68251. * @returns the extruded shape mesh
  68252. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68253. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68254. */
  68255. static ExtrudeShape(name: string, options: {
  68256. shape: Vector3[];
  68257. path: Vector3[];
  68258. scale?: number;
  68259. rotation?: number;
  68260. cap?: number;
  68261. updatable?: boolean;
  68262. sideOrientation?: number;
  68263. frontUVs?: Vector4;
  68264. backUVs?: Vector4;
  68265. instance?: Mesh;
  68266. invertUV?: boolean;
  68267. }, scene?: Nullable<Scene>): Mesh;
  68268. /**
  68269. * Creates an custom extruded shape mesh.
  68270. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  68271. * * 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.
  68272. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68273. * * 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
  68274. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  68275. * * 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
  68276. * * It must returns a float value that will be the scale value applied to the shape on each path point
  68277. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  68278. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  68279. * * 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
  68280. * * 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
  68281. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  68282. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68283. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68284. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68286. * @param name defines the name of the mesh
  68287. * @param options defines the options used to create the mesh
  68288. * @param scene defines the hosting scene
  68289. * @returns the custom extruded shape mesh
  68290. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  68291. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68292. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68293. */
  68294. static ExtrudeShapeCustom(name: string, options: {
  68295. shape: Vector3[];
  68296. path: Vector3[];
  68297. scaleFunction?: any;
  68298. rotationFunction?: any;
  68299. ribbonCloseArray?: boolean;
  68300. ribbonClosePath?: boolean;
  68301. cap?: number;
  68302. updatable?: boolean;
  68303. sideOrientation?: number;
  68304. frontUVs?: Vector4;
  68305. backUVs?: Vector4;
  68306. instance?: Mesh;
  68307. invertUV?: boolean;
  68308. }, scene?: Nullable<Scene>): Mesh;
  68309. /**
  68310. * Creates lathe mesh.
  68311. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68312. * * 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
  68313. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68314. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68315. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68316. * * 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
  68317. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68318. * * 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
  68319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68320. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68321. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68323. * @param name defines the name of the mesh
  68324. * @param options defines the options used to create the mesh
  68325. * @param scene defines the hosting scene
  68326. * @returns the lathe mesh
  68327. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68328. */
  68329. static CreateLathe(name: string, options: {
  68330. shape: Vector3[];
  68331. radius?: number;
  68332. tessellation?: number;
  68333. clip?: number;
  68334. arc?: number;
  68335. closed?: boolean;
  68336. updatable?: boolean;
  68337. sideOrientation?: number;
  68338. frontUVs?: Vector4;
  68339. backUVs?: Vector4;
  68340. cap?: number;
  68341. invertUV?: boolean;
  68342. }, scene?: Nullable<Scene>): Mesh;
  68343. /**
  68344. * Creates a tiled plane mesh
  68345. * * You can set a limited pattern arrangement with the tiles
  68346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68349. * @param name defines the name of the mesh
  68350. * @param options defines the options used to create the mesh
  68351. * @param scene defines the hosting scene
  68352. * @returns the plane mesh
  68353. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68354. */
  68355. static CreateTiledPlane(name: string, options: {
  68356. pattern?: number;
  68357. tileSize?: number;
  68358. tileWidth?: number;
  68359. tileHeight?: number;
  68360. size?: number;
  68361. width?: number;
  68362. height?: number;
  68363. alignHorizontal?: number;
  68364. alignVertical?: number;
  68365. sideOrientation?: number;
  68366. frontUVs?: Vector4;
  68367. backUVs?: Vector4;
  68368. updatable?: boolean;
  68369. }, scene?: Nullable<Scene>): Mesh;
  68370. /**
  68371. * Creates a plane mesh
  68372. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  68373. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  68374. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  68375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68376. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68378. * @param name defines the name of the mesh
  68379. * @param options defines the options used to create the mesh
  68380. * @param scene defines the hosting scene
  68381. * @returns the plane mesh
  68382. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68383. */
  68384. static CreatePlane(name: string, options: {
  68385. size?: number;
  68386. width?: number;
  68387. height?: number;
  68388. sideOrientation?: number;
  68389. frontUVs?: Vector4;
  68390. backUVs?: Vector4;
  68391. updatable?: boolean;
  68392. sourcePlane?: Plane;
  68393. }, scene?: Nullable<Scene>): Mesh;
  68394. /**
  68395. * Creates a ground mesh
  68396. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  68397. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  68398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68399. * @param name defines the name of the mesh
  68400. * @param options defines the options used to create the mesh
  68401. * @param scene defines the hosting scene
  68402. * @returns the ground mesh
  68403. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  68404. */
  68405. static CreateGround(name: string, options: {
  68406. width?: number;
  68407. height?: number;
  68408. subdivisions?: number;
  68409. subdivisionsX?: number;
  68410. subdivisionsY?: number;
  68411. updatable?: boolean;
  68412. }, scene?: Nullable<Scene>): Mesh;
  68413. /**
  68414. * Creates a tiled ground mesh
  68415. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  68416. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  68417. * * 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
  68418. * * 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
  68419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68420. * @param name defines the name of the mesh
  68421. * @param options defines the options used to create the mesh
  68422. * @param scene defines the hosting scene
  68423. * @returns the tiled ground mesh
  68424. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  68425. */
  68426. static CreateTiledGround(name: string, options: {
  68427. xmin: number;
  68428. zmin: number;
  68429. xmax: number;
  68430. zmax: number;
  68431. subdivisions?: {
  68432. w: number;
  68433. h: number;
  68434. };
  68435. precision?: {
  68436. w: number;
  68437. h: number;
  68438. };
  68439. updatable?: boolean;
  68440. }, scene?: Nullable<Scene>): Mesh;
  68441. /**
  68442. * Creates a ground mesh from a height map
  68443. * * The parameter `url` sets the URL of the height map image resource.
  68444. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  68445. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  68446. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  68447. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  68448. * * 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.
  68449. * * 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).
  68450. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  68451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68452. * @param name defines the name of the mesh
  68453. * @param url defines the url to the height map
  68454. * @param options defines the options used to create the mesh
  68455. * @param scene defines the hosting scene
  68456. * @returns the ground mesh
  68457. * @see https://doc.babylonjs.com/babylon101/height_map
  68458. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  68459. */
  68460. static CreateGroundFromHeightMap(name: string, url: string, options: {
  68461. width?: number;
  68462. height?: number;
  68463. subdivisions?: number;
  68464. minHeight?: number;
  68465. maxHeight?: number;
  68466. colorFilter?: Color3;
  68467. alphaFilter?: number;
  68468. updatable?: boolean;
  68469. onReady?: (mesh: GroundMesh) => void;
  68470. }, scene?: Nullable<Scene>): GroundMesh;
  68471. /**
  68472. * Creates a polygon mesh
  68473. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68474. * * 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
  68475. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68477. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68478. * * Remember you can only change the shape positions, not their number when updating a polygon
  68479. * @param name defines the name of the mesh
  68480. * @param options defines the options used to create the mesh
  68481. * @param scene defines the hosting scene
  68482. * @param earcutInjection can be used to inject your own earcut reference
  68483. * @returns the polygon mesh
  68484. */
  68485. static CreatePolygon(name: string, options: {
  68486. shape: Vector3[];
  68487. holes?: Vector3[][];
  68488. depth?: number;
  68489. faceUV?: Vector4[];
  68490. faceColors?: Color4[];
  68491. updatable?: boolean;
  68492. sideOrientation?: number;
  68493. frontUVs?: Vector4;
  68494. backUVs?: Vector4;
  68495. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68496. /**
  68497. * Creates an extruded polygon mesh, with depth in the Y direction.
  68498. * * 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)
  68499. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68500. * @param name defines the name of the mesh
  68501. * @param options defines the options used to create the mesh
  68502. * @param scene defines the hosting scene
  68503. * @param earcutInjection can be used to inject your own earcut reference
  68504. * @returns the polygon mesh
  68505. */
  68506. static ExtrudePolygon(name: string, options: {
  68507. shape: Vector3[];
  68508. holes?: Vector3[][];
  68509. depth?: number;
  68510. faceUV?: Vector4[];
  68511. faceColors?: Color4[];
  68512. updatable?: boolean;
  68513. sideOrientation?: number;
  68514. frontUVs?: Vector4;
  68515. backUVs?: Vector4;
  68516. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68517. /**
  68518. * Creates a tube mesh.
  68519. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68520. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68521. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68522. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68523. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68524. * * 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)
  68525. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68526. * * 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
  68527. * * 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
  68528. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68529. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68530. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68532. * @param name defines the name of the mesh
  68533. * @param options defines the options used to create the mesh
  68534. * @param scene defines the hosting scene
  68535. * @returns the tube mesh
  68536. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68537. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68538. */
  68539. static CreateTube(name: string, options: {
  68540. path: Vector3[];
  68541. radius?: number;
  68542. tessellation?: number;
  68543. radiusFunction?: {
  68544. (i: number, distance: number): number;
  68545. };
  68546. cap?: number;
  68547. arc?: number;
  68548. updatable?: boolean;
  68549. sideOrientation?: number;
  68550. frontUVs?: Vector4;
  68551. backUVs?: Vector4;
  68552. instance?: Mesh;
  68553. invertUV?: boolean;
  68554. }, scene?: Nullable<Scene>): Mesh;
  68555. /**
  68556. * Creates a polyhedron mesh
  68557. * * 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
  68558. * * The parameter `size` (positive float, default 1) sets the polygon size
  68559. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  68560. * * 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`
  68561. * * 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
  68562. * * 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)`)
  68563. * * 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
  68564. * * 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
  68565. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68566. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68568. * @param name defines the name of the mesh
  68569. * @param options defines the options used to create the mesh
  68570. * @param scene defines the hosting scene
  68571. * @returns the polyhedron mesh
  68572. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  68573. */
  68574. static CreatePolyhedron(name: string, options: {
  68575. type?: number;
  68576. size?: number;
  68577. sizeX?: number;
  68578. sizeY?: number;
  68579. sizeZ?: number;
  68580. custom?: any;
  68581. faceUV?: Vector4[];
  68582. faceColors?: Color4[];
  68583. flat?: boolean;
  68584. updatable?: boolean;
  68585. sideOrientation?: number;
  68586. frontUVs?: Vector4;
  68587. backUVs?: Vector4;
  68588. }, scene?: Nullable<Scene>): Mesh;
  68589. /**
  68590. * Creates a decal mesh.
  68591. * 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
  68592. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68593. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68594. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68595. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68596. * @param name defines the name of the mesh
  68597. * @param sourceMesh defines the mesh where the decal must be applied
  68598. * @param options defines the options used to create the mesh
  68599. * @param scene defines the hosting scene
  68600. * @returns the decal mesh
  68601. * @see https://doc.babylonjs.com/how_to/decals
  68602. */
  68603. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68604. position?: Vector3;
  68605. normal?: Vector3;
  68606. size?: Vector3;
  68607. angle?: number;
  68608. }): Mesh;
  68609. }
  68610. }
  68611. declare module "babylonjs/Meshes/meshSimplification" {
  68612. import { Mesh } from "babylonjs/Meshes/mesh";
  68613. /**
  68614. * A simplifier interface for future simplification implementations
  68615. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68616. */
  68617. export interface ISimplifier {
  68618. /**
  68619. * Simplification of a given mesh according to the given settings.
  68620. * Since this requires computation, it is assumed that the function runs async.
  68621. * @param settings The settings of the simplification, including quality and distance
  68622. * @param successCallback A callback that will be called after the mesh was simplified.
  68623. * @param errorCallback in case of an error, this callback will be called. optional.
  68624. */
  68625. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  68626. }
  68627. /**
  68628. * Expected simplification settings.
  68629. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  68630. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68631. */
  68632. export interface ISimplificationSettings {
  68633. /**
  68634. * Gets or sets the expected quality
  68635. */
  68636. quality: number;
  68637. /**
  68638. * Gets or sets the distance when this optimized version should be used
  68639. */
  68640. distance: number;
  68641. /**
  68642. * Gets an already optimized mesh
  68643. */
  68644. optimizeMesh?: boolean;
  68645. }
  68646. /**
  68647. * Class used to specify simplification options
  68648. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68649. */
  68650. export class SimplificationSettings implements ISimplificationSettings {
  68651. /** expected quality */
  68652. quality: number;
  68653. /** distance when this optimized version should be used */
  68654. distance: number;
  68655. /** already optimized mesh */
  68656. optimizeMesh?: boolean | undefined;
  68657. /**
  68658. * Creates a SimplificationSettings
  68659. * @param quality expected quality
  68660. * @param distance distance when this optimized version should be used
  68661. * @param optimizeMesh already optimized mesh
  68662. */
  68663. constructor(
  68664. /** expected quality */
  68665. quality: number,
  68666. /** distance when this optimized version should be used */
  68667. distance: number,
  68668. /** already optimized mesh */
  68669. optimizeMesh?: boolean | undefined);
  68670. }
  68671. /**
  68672. * Interface used to define a simplification task
  68673. */
  68674. export interface ISimplificationTask {
  68675. /**
  68676. * Array of settings
  68677. */
  68678. settings: Array<ISimplificationSettings>;
  68679. /**
  68680. * Simplification type
  68681. */
  68682. simplificationType: SimplificationType;
  68683. /**
  68684. * Mesh to simplify
  68685. */
  68686. mesh: Mesh;
  68687. /**
  68688. * Callback called on success
  68689. */
  68690. successCallback?: () => void;
  68691. /**
  68692. * Defines if parallel processing can be used
  68693. */
  68694. parallelProcessing: boolean;
  68695. }
  68696. /**
  68697. * Queue used to order the simplification tasks
  68698. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68699. */
  68700. export class SimplificationQueue {
  68701. private _simplificationArray;
  68702. /**
  68703. * Gets a boolean indicating that the process is still running
  68704. */
  68705. running: boolean;
  68706. /**
  68707. * Creates a new queue
  68708. */
  68709. constructor();
  68710. /**
  68711. * Adds a new simplification task
  68712. * @param task defines a task to add
  68713. */
  68714. addTask(task: ISimplificationTask): void;
  68715. /**
  68716. * Execute next task
  68717. */
  68718. executeNext(): void;
  68719. /**
  68720. * Execute a simplification task
  68721. * @param task defines the task to run
  68722. */
  68723. runSimplification(task: ISimplificationTask): void;
  68724. private getSimplifier;
  68725. }
  68726. /**
  68727. * The implemented types of simplification
  68728. * At the moment only Quadratic Error Decimation is implemented
  68729. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68730. */
  68731. export enum SimplificationType {
  68732. /** Quadratic error decimation */
  68733. QUADRATIC = 0
  68734. }
  68735. /**
  68736. * An implementation of the Quadratic Error simplification algorithm.
  68737. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  68738. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  68739. * @author RaananW
  68740. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68741. */
  68742. export class QuadraticErrorSimplification implements ISimplifier {
  68743. private _mesh;
  68744. private triangles;
  68745. private vertices;
  68746. private references;
  68747. private _reconstructedMesh;
  68748. /** Gets or sets the number pf sync interations */
  68749. syncIterations: number;
  68750. /** Gets or sets the aggressiveness of the simplifier */
  68751. aggressiveness: number;
  68752. /** Gets or sets the number of allowed iterations for decimation */
  68753. decimationIterations: number;
  68754. /** Gets or sets the espilon to use for bounding box computation */
  68755. boundingBoxEpsilon: number;
  68756. /**
  68757. * Creates a new QuadraticErrorSimplification
  68758. * @param _mesh defines the target mesh
  68759. */
  68760. constructor(_mesh: Mesh);
  68761. /**
  68762. * Simplification of a given mesh according to the given settings.
  68763. * Since this requires computation, it is assumed that the function runs async.
  68764. * @param settings The settings of the simplification, including quality and distance
  68765. * @param successCallback A callback that will be called after the mesh was simplified.
  68766. */
  68767. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  68768. private runDecimation;
  68769. private initWithMesh;
  68770. private init;
  68771. private reconstructMesh;
  68772. private initDecimatedMesh;
  68773. private isFlipped;
  68774. private updateTriangles;
  68775. private identifyBorder;
  68776. private updateMesh;
  68777. private vertexError;
  68778. private calculateError;
  68779. }
  68780. }
  68781. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  68782. import { Scene } from "babylonjs/scene";
  68783. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  68784. import { ISceneComponent } from "babylonjs/sceneComponent";
  68785. module "babylonjs/scene" {
  68786. interface Scene {
  68787. /** @hidden (Backing field) */
  68788. _simplificationQueue: SimplificationQueue;
  68789. /**
  68790. * Gets or sets the simplification queue attached to the scene
  68791. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68792. */
  68793. simplificationQueue: SimplificationQueue;
  68794. }
  68795. }
  68796. module "babylonjs/Meshes/mesh" {
  68797. interface Mesh {
  68798. /**
  68799. * Simplify the mesh according to the given array of settings.
  68800. * Function will return immediately and will simplify async
  68801. * @param settings a collection of simplification settings
  68802. * @param parallelProcessing should all levels calculate parallel or one after the other
  68803. * @param simplificationType the type of simplification to run
  68804. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  68805. * @returns the current mesh
  68806. */
  68807. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  68808. }
  68809. }
  68810. /**
  68811. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  68812. * created in a scene
  68813. */
  68814. export class SimplicationQueueSceneComponent implements ISceneComponent {
  68815. /**
  68816. * The component name helpfull to identify the component in the list of scene components.
  68817. */
  68818. readonly name: string;
  68819. /**
  68820. * The scene the component belongs to.
  68821. */
  68822. scene: Scene;
  68823. /**
  68824. * Creates a new instance of the component for the given scene
  68825. * @param scene Defines the scene to register the component in
  68826. */
  68827. constructor(scene: Scene);
  68828. /**
  68829. * Registers the component in a given scene
  68830. */
  68831. register(): void;
  68832. /**
  68833. * Rebuilds the elements related to this component in case of
  68834. * context lost for instance.
  68835. */
  68836. rebuild(): void;
  68837. /**
  68838. * Disposes the component and the associated ressources
  68839. */
  68840. dispose(): void;
  68841. private _beforeCameraUpdate;
  68842. }
  68843. }
  68844. declare module "babylonjs/Meshes/Builders/index" {
  68845. export * from "babylonjs/Meshes/Builders/boxBuilder";
  68846. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  68847. export * from "babylonjs/Meshes/Builders/discBuilder";
  68848. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  68849. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  68850. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  68851. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  68852. export * from "babylonjs/Meshes/Builders/torusBuilder";
  68853. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  68854. export * from "babylonjs/Meshes/Builders/linesBuilder";
  68855. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  68856. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  68857. export * from "babylonjs/Meshes/Builders/latheBuilder";
  68858. export * from "babylonjs/Meshes/Builders/planeBuilder";
  68859. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  68860. export * from "babylonjs/Meshes/Builders/groundBuilder";
  68861. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  68862. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  68863. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  68864. export * from "babylonjs/Meshes/Builders/decalBuilder";
  68865. }
  68866. declare module "babylonjs/Meshes/thinInstanceMesh" {
  68867. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  68868. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  68869. import { Matrix } from "babylonjs/Maths/math.vector";
  68870. module "babylonjs/Meshes/mesh" {
  68871. interface Mesh {
  68872. /**
  68873. * Creates a new thin instance
  68874. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  68875. * @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
  68876. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  68877. */
  68878. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  68879. /**
  68880. * Adds the transformation (matrix) of the current mesh as a thin instance
  68881. * @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
  68882. * @returns the thin instance index number
  68883. */
  68884. thinInstanceAddSelf(refresh: boolean): number;
  68885. /**
  68886. * Registers a custom attribute to be used with thin instances
  68887. * @param kind name of the attribute
  68888. * @param stride size in floats of the attribute
  68889. */
  68890. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  68891. /**
  68892. * Sets the matrix of a thin instance
  68893. * @param index index of the thin instance
  68894. * @param matrix matrix to set
  68895. * @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
  68896. */
  68897. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  68898. /**
  68899. * Sets the value of a custom attribute for a thin instance
  68900. * @param kind name of the attribute
  68901. * @param index index of the thin instance
  68902. * @param value value to set
  68903. * @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
  68904. */
  68905. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  68906. /**
  68907. * 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.
  68908. */
  68909. thinInstanceCount: number;
  68910. /**
  68911. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  68912. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  68913. * @param buffer buffer to set
  68914. * @param stride size in floats of each value of the buffer
  68915. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  68916. */
  68917. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  68918. /**
  68919. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  68920. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68921. */
  68922. thinInstanceBufferUpdated(kind: string): void;
  68923. /**
  68924. * Refreshes the bounding info, taking into account all the thin instances defined
  68925. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  68926. */
  68927. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  68928. /** @hidden */
  68929. _thinInstanceInitializeUserStorage(): void;
  68930. /** @hidden */
  68931. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  68932. /** @hidden */
  68933. _userThinInstanceBuffersStorage: {
  68934. data: {
  68935. [key: string]: Float32Array;
  68936. };
  68937. sizes: {
  68938. [key: string]: number;
  68939. };
  68940. vertexBuffers: {
  68941. [key: string]: Nullable<VertexBuffer>;
  68942. };
  68943. strides: {
  68944. [key: string]: number;
  68945. };
  68946. };
  68947. }
  68948. }
  68949. }
  68950. declare module "babylonjs/Meshes/index" {
  68951. export * from "babylonjs/Meshes/abstractMesh";
  68952. export * from "babylonjs/Meshes/buffer";
  68953. export * from "babylonjs/Meshes/Compression/index";
  68954. export * from "babylonjs/Meshes/csg";
  68955. export * from "babylonjs/Meshes/geometry";
  68956. export * from "babylonjs/Meshes/groundMesh";
  68957. export * from "babylonjs/Meshes/trailMesh";
  68958. export * from "babylonjs/Meshes/instancedMesh";
  68959. export * from "babylonjs/Meshes/linesMesh";
  68960. export * from "babylonjs/Meshes/mesh";
  68961. export * from "babylonjs/Meshes/mesh.vertexData";
  68962. export * from "babylonjs/Meshes/meshBuilder";
  68963. export * from "babylonjs/Meshes/meshSimplification";
  68964. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  68965. export * from "babylonjs/Meshes/polygonMesh";
  68966. export * from "babylonjs/Meshes/subMesh";
  68967. export * from "babylonjs/Meshes/meshLODLevel";
  68968. export * from "babylonjs/Meshes/transformNode";
  68969. export * from "babylonjs/Meshes/Builders/index";
  68970. export * from "babylonjs/Meshes/dataBuffer";
  68971. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  68972. import "babylonjs/Meshes/thinInstanceMesh";
  68973. export * from "babylonjs/Meshes/thinInstanceMesh";
  68974. }
  68975. declare module "babylonjs/Morph/index" {
  68976. export * from "babylonjs/Morph/morphTarget";
  68977. export * from "babylonjs/Morph/morphTargetManager";
  68978. }
  68979. declare module "babylonjs/Navigation/INavigationEngine" {
  68980. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68981. import { Vector3 } from "babylonjs/Maths/math";
  68982. import { Mesh } from "babylonjs/Meshes/mesh";
  68983. import { Scene } from "babylonjs/scene";
  68984. /**
  68985. * Navigation plugin interface to add navigation constrained by a navigation mesh
  68986. */
  68987. export interface INavigationEnginePlugin {
  68988. /**
  68989. * plugin name
  68990. */
  68991. name: string;
  68992. /**
  68993. * Creates a navigation mesh
  68994. * @param meshes array of all the geometry used to compute the navigatio mesh
  68995. * @param parameters bunch of parameters used to filter geometry
  68996. */
  68997. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68998. /**
  68999. * Create a navigation mesh debug mesh
  69000. * @param scene is where the mesh will be added
  69001. * @returns debug display mesh
  69002. */
  69003. createDebugNavMesh(scene: Scene): Mesh;
  69004. /**
  69005. * Get a navigation mesh constrained position, closest to the parameter position
  69006. * @param position world position
  69007. * @returns the closest point to position constrained by the navigation mesh
  69008. */
  69009. getClosestPoint(position: Vector3): Vector3;
  69010. /**
  69011. * Get a navigation mesh constrained position, closest to the parameter position
  69012. * @param position world position
  69013. * @param result output the closest point to position constrained by the navigation mesh
  69014. */
  69015. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69016. /**
  69017. * Get a navigation mesh constrained position, within a particular radius
  69018. * @param position world position
  69019. * @param maxRadius the maximum distance to the constrained world position
  69020. * @returns the closest point to position constrained by the navigation mesh
  69021. */
  69022. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69023. /**
  69024. * Get a navigation mesh constrained position, within a particular radius
  69025. * @param position world position
  69026. * @param maxRadius the maximum distance to the constrained world position
  69027. * @param result output the closest point to position constrained by the navigation mesh
  69028. */
  69029. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69030. /**
  69031. * Compute the final position from a segment made of destination-position
  69032. * @param position world position
  69033. * @param destination world position
  69034. * @returns the resulting point along the navmesh
  69035. */
  69036. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69037. /**
  69038. * Compute the final position from a segment made of destination-position
  69039. * @param position world position
  69040. * @param destination world position
  69041. * @param result output the resulting point along the navmesh
  69042. */
  69043. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69044. /**
  69045. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69046. * @param start world position
  69047. * @param end world position
  69048. * @returns array containing world position composing the path
  69049. */
  69050. computePath(start: Vector3, end: Vector3): Vector3[];
  69051. /**
  69052. * If this plugin is supported
  69053. * @returns true if plugin is supported
  69054. */
  69055. isSupported(): boolean;
  69056. /**
  69057. * Create a new Crowd so you can add agents
  69058. * @param maxAgents the maximum agent count in the crowd
  69059. * @param maxAgentRadius the maximum radius an agent can have
  69060. * @param scene to attach the crowd to
  69061. * @returns the crowd you can add agents to
  69062. */
  69063. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69064. /**
  69065. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69066. * The queries will try to find a solution within those bounds
  69067. * default is (1,1,1)
  69068. * @param extent x,y,z value that define the extent around the queries point of reference
  69069. */
  69070. setDefaultQueryExtent(extent: Vector3): void;
  69071. /**
  69072. * Get the Bounding box extent specified by setDefaultQueryExtent
  69073. * @returns the box extent values
  69074. */
  69075. getDefaultQueryExtent(): Vector3;
  69076. /**
  69077. * build the navmesh from a previously saved state using getNavmeshData
  69078. * @param data the Uint8Array returned by getNavmeshData
  69079. */
  69080. buildFromNavmeshData(data: Uint8Array): void;
  69081. /**
  69082. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69083. * @returns data the Uint8Array that can be saved and reused
  69084. */
  69085. getNavmeshData(): Uint8Array;
  69086. /**
  69087. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69088. * @param result output the box extent values
  69089. */
  69090. getDefaultQueryExtentToRef(result: Vector3): void;
  69091. /**
  69092. * Release all resources
  69093. */
  69094. dispose(): void;
  69095. }
  69096. /**
  69097. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  69098. */
  69099. export interface ICrowd {
  69100. /**
  69101. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69102. * You can attach anything to that node. The node position is updated in the scene update tick.
  69103. * @param pos world position that will be constrained by the navigation mesh
  69104. * @param parameters agent parameters
  69105. * @param transform hooked to the agent that will be update by the scene
  69106. * @returns agent index
  69107. */
  69108. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69109. /**
  69110. * Returns the agent position in world space
  69111. * @param index agent index returned by addAgent
  69112. * @returns world space position
  69113. */
  69114. getAgentPosition(index: number): Vector3;
  69115. /**
  69116. * Gets the agent position result in world space
  69117. * @param index agent index returned by addAgent
  69118. * @param result output world space position
  69119. */
  69120. getAgentPositionToRef(index: number, result: Vector3): void;
  69121. /**
  69122. * Gets the agent velocity in world space
  69123. * @param index agent index returned by addAgent
  69124. * @returns world space velocity
  69125. */
  69126. getAgentVelocity(index: number): Vector3;
  69127. /**
  69128. * Gets the agent velocity result in world space
  69129. * @param index agent index returned by addAgent
  69130. * @param result output world space velocity
  69131. */
  69132. getAgentVelocityToRef(index: number, result: Vector3): void;
  69133. /**
  69134. * remove a particular agent previously created
  69135. * @param index agent index returned by addAgent
  69136. */
  69137. removeAgent(index: number): void;
  69138. /**
  69139. * get the list of all agents attached to this crowd
  69140. * @returns list of agent indices
  69141. */
  69142. getAgents(): number[];
  69143. /**
  69144. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69145. * @param deltaTime in seconds
  69146. */
  69147. update(deltaTime: number): void;
  69148. /**
  69149. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69150. * @param index agent index returned by addAgent
  69151. * @param destination targeted world position
  69152. */
  69153. agentGoto(index: number, destination: Vector3): void;
  69154. /**
  69155. * Teleport the agent to a new position
  69156. * @param index agent index returned by addAgent
  69157. * @param destination targeted world position
  69158. */
  69159. agentTeleport(index: number, destination: Vector3): void;
  69160. /**
  69161. * Update agent parameters
  69162. * @param index agent index returned by addAgent
  69163. * @param parameters agent parameters
  69164. */
  69165. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69166. /**
  69167. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69168. * The queries will try to find a solution within those bounds
  69169. * default is (1,1,1)
  69170. * @param extent x,y,z value that define the extent around the queries point of reference
  69171. */
  69172. setDefaultQueryExtent(extent: Vector3): void;
  69173. /**
  69174. * Get the Bounding box extent specified by setDefaultQueryExtent
  69175. * @returns the box extent values
  69176. */
  69177. getDefaultQueryExtent(): Vector3;
  69178. /**
  69179. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69180. * @param result output the box extent values
  69181. */
  69182. getDefaultQueryExtentToRef(result: Vector3): void;
  69183. /**
  69184. * Release all resources
  69185. */
  69186. dispose(): void;
  69187. }
  69188. /**
  69189. * Configures an agent
  69190. */
  69191. export interface IAgentParameters {
  69192. /**
  69193. * Agent radius. [Limit: >= 0]
  69194. */
  69195. radius: number;
  69196. /**
  69197. * Agent height. [Limit: > 0]
  69198. */
  69199. height: number;
  69200. /**
  69201. * Maximum allowed acceleration. [Limit: >= 0]
  69202. */
  69203. maxAcceleration: number;
  69204. /**
  69205. * Maximum allowed speed. [Limit: >= 0]
  69206. */
  69207. maxSpeed: number;
  69208. /**
  69209. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  69210. */
  69211. collisionQueryRange: number;
  69212. /**
  69213. * The path visibility optimization range. [Limit: > 0]
  69214. */
  69215. pathOptimizationRange: number;
  69216. /**
  69217. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  69218. */
  69219. separationWeight: number;
  69220. }
  69221. /**
  69222. * Configures the navigation mesh creation
  69223. */
  69224. export interface INavMeshParameters {
  69225. /**
  69226. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  69227. */
  69228. cs: number;
  69229. /**
  69230. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  69231. */
  69232. ch: number;
  69233. /**
  69234. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  69235. */
  69236. walkableSlopeAngle: number;
  69237. /**
  69238. * Minimum floor to 'ceiling' height that will still allow the floor area to
  69239. * be considered walkable. [Limit: >= 3] [Units: vx]
  69240. */
  69241. walkableHeight: number;
  69242. /**
  69243. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  69244. */
  69245. walkableClimb: number;
  69246. /**
  69247. * The distance to erode/shrink the walkable area of the heightfield away from
  69248. * obstructions. [Limit: >=0] [Units: vx]
  69249. */
  69250. walkableRadius: number;
  69251. /**
  69252. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  69253. */
  69254. maxEdgeLen: number;
  69255. /**
  69256. * The maximum distance a simplfied contour's border edges should deviate
  69257. * the original raw contour. [Limit: >=0] [Units: vx]
  69258. */
  69259. maxSimplificationError: number;
  69260. /**
  69261. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  69262. */
  69263. minRegionArea: number;
  69264. /**
  69265. * Any regions with a span count smaller than this value will, if possible,
  69266. * be merged with larger regions. [Limit: >=0] [Units: vx]
  69267. */
  69268. mergeRegionArea: number;
  69269. /**
  69270. * The maximum number of vertices allowed for polygons generated during the
  69271. * contour to polygon conversion process. [Limit: >= 3]
  69272. */
  69273. maxVertsPerPoly: number;
  69274. /**
  69275. * Sets the sampling distance to use when generating the detail mesh.
  69276. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  69277. */
  69278. detailSampleDist: number;
  69279. /**
  69280. * The maximum distance the detail mesh surface should deviate from heightfield
  69281. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  69282. */
  69283. detailSampleMaxError: number;
  69284. }
  69285. }
  69286. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  69287. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  69288. import { Mesh } from "babylonjs/Meshes/mesh";
  69289. import { Scene } from "babylonjs/scene";
  69290. import { Vector3 } from "babylonjs/Maths/math";
  69291. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69292. /**
  69293. * RecastJS navigation plugin
  69294. */
  69295. export class RecastJSPlugin implements INavigationEnginePlugin {
  69296. /**
  69297. * Reference to the Recast library
  69298. */
  69299. bjsRECAST: any;
  69300. /**
  69301. * plugin name
  69302. */
  69303. name: string;
  69304. /**
  69305. * the first navmesh created. We might extend this to support multiple navmeshes
  69306. */
  69307. navMesh: any;
  69308. /**
  69309. * Initializes the recastJS plugin
  69310. * @param recastInjection can be used to inject your own recast reference
  69311. */
  69312. constructor(recastInjection?: any);
  69313. /**
  69314. * Creates a navigation mesh
  69315. * @param meshes array of all the geometry used to compute the navigatio mesh
  69316. * @param parameters bunch of parameters used to filter geometry
  69317. */
  69318. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69319. /**
  69320. * Create a navigation mesh debug mesh
  69321. * @param scene is where the mesh will be added
  69322. * @returns debug display mesh
  69323. */
  69324. createDebugNavMesh(scene: Scene): Mesh;
  69325. /**
  69326. * Get a navigation mesh constrained position, closest to the parameter position
  69327. * @param position world position
  69328. * @returns the closest point to position constrained by the navigation mesh
  69329. */
  69330. getClosestPoint(position: Vector3): Vector3;
  69331. /**
  69332. * Get a navigation mesh constrained position, closest to the parameter position
  69333. * @param position world position
  69334. * @param result output the closest point to position constrained by the navigation mesh
  69335. */
  69336. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69337. /**
  69338. * Get a navigation mesh constrained position, within a particular radius
  69339. * @param position world position
  69340. * @param maxRadius the maximum distance to the constrained world position
  69341. * @returns the closest point to position constrained by the navigation mesh
  69342. */
  69343. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69344. /**
  69345. * Get a navigation mesh constrained position, within a particular radius
  69346. * @param position world position
  69347. * @param maxRadius the maximum distance to the constrained world position
  69348. * @param result output the closest point to position constrained by the navigation mesh
  69349. */
  69350. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69351. /**
  69352. * Compute the final position from a segment made of destination-position
  69353. * @param position world position
  69354. * @param destination world position
  69355. * @returns the resulting point along the navmesh
  69356. */
  69357. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69358. /**
  69359. * Compute the final position from a segment made of destination-position
  69360. * @param position world position
  69361. * @param destination world position
  69362. * @param result output the resulting point along the navmesh
  69363. */
  69364. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69365. /**
  69366. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69367. * @param start world position
  69368. * @param end world position
  69369. * @returns array containing world position composing the path
  69370. */
  69371. computePath(start: Vector3, end: Vector3): Vector3[];
  69372. /**
  69373. * Create a new Crowd so you can add agents
  69374. * @param maxAgents the maximum agent count in the crowd
  69375. * @param maxAgentRadius the maximum radius an agent can have
  69376. * @param scene to attach the crowd to
  69377. * @returns the crowd you can add agents to
  69378. */
  69379. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69380. /**
  69381. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69382. * The queries will try to find a solution within those bounds
  69383. * default is (1,1,1)
  69384. * @param extent x,y,z value that define the extent around the queries point of reference
  69385. */
  69386. setDefaultQueryExtent(extent: Vector3): void;
  69387. /**
  69388. * Get the Bounding box extent specified by setDefaultQueryExtent
  69389. * @returns the box extent values
  69390. */
  69391. getDefaultQueryExtent(): Vector3;
  69392. /**
  69393. * build the navmesh from a previously saved state using getNavmeshData
  69394. * @param data the Uint8Array returned by getNavmeshData
  69395. */
  69396. buildFromNavmeshData(data: Uint8Array): void;
  69397. /**
  69398. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69399. * @returns data the Uint8Array that can be saved and reused
  69400. */
  69401. getNavmeshData(): Uint8Array;
  69402. /**
  69403. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69404. * @param result output the box extent values
  69405. */
  69406. getDefaultQueryExtentToRef(result: Vector3): void;
  69407. /**
  69408. * Disposes
  69409. */
  69410. dispose(): void;
  69411. /**
  69412. * If this plugin is supported
  69413. * @returns true if plugin is supported
  69414. */
  69415. isSupported(): boolean;
  69416. }
  69417. /**
  69418. * Recast detour crowd implementation
  69419. */
  69420. export class RecastJSCrowd implements ICrowd {
  69421. /**
  69422. * Recast/detour plugin
  69423. */
  69424. bjsRECASTPlugin: RecastJSPlugin;
  69425. /**
  69426. * Link to the detour crowd
  69427. */
  69428. recastCrowd: any;
  69429. /**
  69430. * One transform per agent
  69431. */
  69432. transforms: TransformNode[];
  69433. /**
  69434. * All agents created
  69435. */
  69436. agents: number[];
  69437. /**
  69438. * Link to the scene is kept to unregister the crowd from the scene
  69439. */
  69440. private _scene;
  69441. /**
  69442. * Observer for crowd updates
  69443. */
  69444. private _onBeforeAnimationsObserver;
  69445. /**
  69446. * Constructor
  69447. * @param plugin recastJS plugin
  69448. * @param maxAgents the maximum agent count in the crowd
  69449. * @param maxAgentRadius the maximum radius an agent can have
  69450. * @param scene to attach the crowd to
  69451. * @returns the crowd you can add agents to
  69452. */
  69453. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  69454. /**
  69455. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69456. * You can attach anything to that node. The node position is updated in the scene update tick.
  69457. * @param pos world position that will be constrained by the navigation mesh
  69458. * @param parameters agent parameters
  69459. * @param transform hooked to the agent that will be update by the scene
  69460. * @returns agent index
  69461. */
  69462. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69463. /**
  69464. * Returns the agent position in world space
  69465. * @param index agent index returned by addAgent
  69466. * @returns world space position
  69467. */
  69468. getAgentPosition(index: number): Vector3;
  69469. /**
  69470. * Returns the agent position result in world space
  69471. * @param index agent index returned by addAgent
  69472. * @param result output world space position
  69473. */
  69474. getAgentPositionToRef(index: number, result: Vector3): void;
  69475. /**
  69476. * Returns the agent velocity in world space
  69477. * @param index agent index returned by addAgent
  69478. * @returns world space velocity
  69479. */
  69480. getAgentVelocity(index: number): Vector3;
  69481. /**
  69482. * Returns the agent velocity result in world space
  69483. * @param index agent index returned by addAgent
  69484. * @param result output world space velocity
  69485. */
  69486. getAgentVelocityToRef(index: number, result: Vector3): void;
  69487. /**
  69488. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69489. * @param index agent index returned by addAgent
  69490. * @param destination targeted world position
  69491. */
  69492. agentGoto(index: number, destination: Vector3): void;
  69493. /**
  69494. * Teleport the agent to a new position
  69495. * @param index agent index returned by addAgent
  69496. * @param destination targeted world position
  69497. */
  69498. agentTeleport(index: number, destination: Vector3): void;
  69499. /**
  69500. * Update agent parameters
  69501. * @param index agent index returned by addAgent
  69502. * @param parameters agent parameters
  69503. */
  69504. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69505. /**
  69506. * remove a particular agent previously created
  69507. * @param index agent index returned by addAgent
  69508. */
  69509. removeAgent(index: number): void;
  69510. /**
  69511. * get the list of all agents attached to this crowd
  69512. * @returns list of agent indices
  69513. */
  69514. getAgents(): number[];
  69515. /**
  69516. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69517. * @param deltaTime in seconds
  69518. */
  69519. update(deltaTime: number): void;
  69520. /**
  69521. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69522. * The queries will try to find a solution within those bounds
  69523. * default is (1,1,1)
  69524. * @param extent x,y,z value that define the extent around the queries point of reference
  69525. */
  69526. setDefaultQueryExtent(extent: Vector3): void;
  69527. /**
  69528. * Get the Bounding box extent specified by setDefaultQueryExtent
  69529. * @returns the box extent values
  69530. */
  69531. getDefaultQueryExtent(): Vector3;
  69532. /**
  69533. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69534. * @param result output the box extent values
  69535. */
  69536. getDefaultQueryExtentToRef(result: Vector3): void;
  69537. /**
  69538. * Release all resources
  69539. */
  69540. dispose(): void;
  69541. }
  69542. }
  69543. declare module "babylonjs/Navigation/Plugins/index" {
  69544. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  69545. }
  69546. declare module "babylonjs/Navigation/index" {
  69547. export * from "babylonjs/Navigation/INavigationEngine";
  69548. export * from "babylonjs/Navigation/Plugins/index";
  69549. }
  69550. declare module "babylonjs/Offline/database" {
  69551. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  69552. /**
  69553. * Class used to enable access to IndexedDB
  69554. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69555. */
  69556. export class Database implements IOfflineProvider {
  69557. private _callbackManifestChecked;
  69558. private _currentSceneUrl;
  69559. private _db;
  69560. private _enableSceneOffline;
  69561. private _enableTexturesOffline;
  69562. private _manifestVersionFound;
  69563. private _mustUpdateRessources;
  69564. private _hasReachedQuota;
  69565. private _isSupported;
  69566. private _idbFactory;
  69567. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  69568. private static IsUASupportingBlobStorage;
  69569. /**
  69570. * Gets a boolean indicating if Database storate is enabled (off by default)
  69571. */
  69572. static IDBStorageEnabled: boolean;
  69573. /**
  69574. * Gets a boolean indicating if scene must be saved in the database
  69575. */
  69576. get enableSceneOffline(): boolean;
  69577. /**
  69578. * Gets a boolean indicating if textures must be saved in the database
  69579. */
  69580. get enableTexturesOffline(): boolean;
  69581. /**
  69582. * Creates a new Database
  69583. * @param urlToScene defines the url to load the scene
  69584. * @param callbackManifestChecked defines the callback to use when manifest is checked
  69585. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  69586. */
  69587. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  69588. private static _ParseURL;
  69589. private static _ReturnFullUrlLocation;
  69590. private _checkManifestFile;
  69591. /**
  69592. * Open the database and make it available
  69593. * @param successCallback defines the callback to call on success
  69594. * @param errorCallback defines the callback to call on error
  69595. */
  69596. open(successCallback: () => void, errorCallback: () => void): void;
  69597. /**
  69598. * Loads an image from the database
  69599. * @param url defines the url to load from
  69600. * @param image defines the target DOM image
  69601. */
  69602. loadImage(url: string, image: HTMLImageElement): void;
  69603. private _loadImageFromDBAsync;
  69604. private _saveImageIntoDBAsync;
  69605. private _checkVersionFromDB;
  69606. private _loadVersionFromDBAsync;
  69607. private _saveVersionIntoDBAsync;
  69608. /**
  69609. * Loads a file from database
  69610. * @param url defines the URL to load from
  69611. * @param sceneLoaded defines a callback to call on success
  69612. * @param progressCallBack defines a callback to call when progress changed
  69613. * @param errorCallback defines a callback to call on error
  69614. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69615. */
  69616. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69617. private _loadFileAsync;
  69618. private _saveFileAsync;
  69619. /**
  69620. * Validates if xhr data is correct
  69621. * @param xhr defines the request to validate
  69622. * @param dataType defines the expected data type
  69623. * @returns true if data is correct
  69624. */
  69625. private static _ValidateXHRData;
  69626. }
  69627. }
  69628. declare module "babylonjs/Offline/index" {
  69629. export * from "babylonjs/Offline/database";
  69630. export * from "babylonjs/Offline/IOfflineProvider";
  69631. }
  69632. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  69633. /** @hidden */
  69634. export var gpuUpdateParticlesPixelShader: {
  69635. name: string;
  69636. shader: string;
  69637. };
  69638. }
  69639. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  69640. /** @hidden */
  69641. export var gpuUpdateParticlesVertexShader: {
  69642. name: string;
  69643. shader: string;
  69644. };
  69645. }
  69646. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  69647. /** @hidden */
  69648. export var clipPlaneFragmentDeclaration2: {
  69649. name: string;
  69650. shader: string;
  69651. };
  69652. }
  69653. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  69654. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  69655. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  69656. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69657. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  69658. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  69659. /** @hidden */
  69660. export var gpuRenderParticlesPixelShader: {
  69661. name: string;
  69662. shader: string;
  69663. };
  69664. }
  69665. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  69666. /** @hidden */
  69667. export var clipPlaneVertexDeclaration2: {
  69668. name: string;
  69669. shader: string;
  69670. };
  69671. }
  69672. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  69673. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  69674. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  69675. /** @hidden */
  69676. export var gpuRenderParticlesVertexShader: {
  69677. name: string;
  69678. shader: string;
  69679. };
  69680. }
  69681. declare module "babylonjs/Particles/gpuParticleSystem" {
  69682. import { Nullable } from "babylonjs/types";
  69683. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  69684. import { Observable } from "babylonjs/Misc/observable";
  69685. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69686. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69687. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  69688. import { Scene, IDisposable } from "babylonjs/scene";
  69689. import { Effect } from "babylonjs/Materials/effect";
  69690. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  69691. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69692. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  69693. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  69694. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  69695. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  69696. /**
  69697. * This represents a GPU particle system in Babylon
  69698. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  69699. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  69700. */
  69701. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  69702. /**
  69703. * The layer mask we are rendering the particles through.
  69704. */
  69705. layerMask: number;
  69706. private _capacity;
  69707. private _activeCount;
  69708. private _currentActiveCount;
  69709. private _accumulatedCount;
  69710. private _renderEffect;
  69711. private _updateEffect;
  69712. private _buffer0;
  69713. private _buffer1;
  69714. private _spriteBuffer;
  69715. private _updateVAO;
  69716. private _renderVAO;
  69717. private _targetIndex;
  69718. private _sourceBuffer;
  69719. private _targetBuffer;
  69720. private _engine;
  69721. private _currentRenderId;
  69722. private _started;
  69723. private _stopped;
  69724. private _timeDelta;
  69725. private _randomTexture;
  69726. private _randomTexture2;
  69727. private _attributesStrideSize;
  69728. private _updateEffectOptions;
  69729. private _randomTextureSize;
  69730. private _actualFrame;
  69731. private _customEffect;
  69732. private readonly _rawTextureWidth;
  69733. /**
  69734. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  69735. */
  69736. static get IsSupported(): boolean;
  69737. /**
  69738. * An event triggered when the system is disposed.
  69739. */
  69740. onDisposeObservable: Observable<IParticleSystem>;
  69741. /**
  69742. * Gets the maximum number of particles active at the same time.
  69743. * @returns The max number of active particles.
  69744. */
  69745. getCapacity(): number;
  69746. /**
  69747. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  69748. * to override the particles.
  69749. */
  69750. forceDepthWrite: boolean;
  69751. /**
  69752. * Gets or set the number of active particles
  69753. */
  69754. get activeParticleCount(): number;
  69755. set activeParticleCount(value: number);
  69756. private _preWarmDone;
  69757. /**
  69758. * Specifies if the particles are updated in emitter local space or world space.
  69759. */
  69760. isLocal: boolean;
  69761. /**
  69762. * Is this system ready to be used/rendered
  69763. * @return true if the system is ready
  69764. */
  69765. isReady(): boolean;
  69766. /**
  69767. * Gets if the system has been started. (Note: this will still be true after stop is called)
  69768. * @returns True if it has been started, otherwise false.
  69769. */
  69770. isStarted(): boolean;
  69771. /**
  69772. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  69773. * @returns True if it has been stopped, otherwise false.
  69774. */
  69775. isStopped(): boolean;
  69776. /**
  69777. * Gets a boolean indicating that the system is stopping
  69778. * @returns true if the system is currently stopping
  69779. */
  69780. isStopping(): boolean;
  69781. /**
  69782. * Gets the number of particles active at the same time.
  69783. * @returns The number of active particles.
  69784. */
  69785. getActiveCount(): number;
  69786. /**
  69787. * Starts the particle system and begins to emit
  69788. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  69789. */
  69790. start(delay?: number): void;
  69791. /**
  69792. * Stops the particle system.
  69793. */
  69794. stop(): void;
  69795. /**
  69796. * Remove all active particles
  69797. */
  69798. reset(): void;
  69799. /**
  69800. * Returns the string "GPUParticleSystem"
  69801. * @returns a string containing the class name
  69802. */
  69803. getClassName(): string;
  69804. /**
  69805. * Gets the custom effect used to render the particles
  69806. * @param blendMode Blend mode for which the effect should be retrieved
  69807. * @returns The effect
  69808. */
  69809. getCustomEffect(blendMode?: number): Nullable<Effect>;
  69810. /**
  69811. * Sets the custom effect used to render the particles
  69812. * @param effect The effect to set
  69813. * @param blendMode Blend mode for which the effect should be set
  69814. */
  69815. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  69816. /** @hidden */
  69817. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  69818. /**
  69819. * Observable that will be called just before the particles are drawn
  69820. */
  69821. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  69822. /**
  69823. * Gets the name of the particle vertex shader
  69824. */
  69825. get vertexShaderName(): string;
  69826. private _colorGradientsTexture;
  69827. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  69828. /**
  69829. * Adds a new color gradient
  69830. * @param gradient defines the gradient to use (between 0 and 1)
  69831. * @param color1 defines the color to affect to the specified gradient
  69832. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  69833. * @returns the current particle system
  69834. */
  69835. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  69836. private _refreshColorGradient;
  69837. /** Force the system to rebuild all gradients that need to be resync */
  69838. forceRefreshGradients(): void;
  69839. /**
  69840. * Remove a specific color gradient
  69841. * @param gradient defines the gradient to remove
  69842. * @returns the current particle system
  69843. */
  69844. removeColorGradient(gradient: number): GPUParticleSystem;
  69845. private _angularSpeedGradientsTexture;
  69846. private _sizeGradientsTexture;
  69847. private _velocityGradientsTexture;
  69848. private _limitVelocityGradientsTexture;
  69849. private _dragGradientsTexture;
  69850. private _addFactorGradient;
  69851. /**
  69852. * Adds a new size gradient
  69853. * @param gradient defines the gradient to use (between 0 and 1)
  69854. * @param factor defines the size factor to affect to the specified gradient
  69855. * @returns the current particle system
  69856. */
  69857. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  69858. /**
  69859. * Remove a specific size gradient
  69860. * @param gradient defines the gradient to remove
  69861. * @returns the current particle system
  69862. */
  69863. removeSizeGradient(gradient: number): GPUParticleSystem;
  69864. private _refreshFactorGradient;
  69865. /**
  69866. * Adds a new angular speed gradient
  69867. * @param gradient defines the gradient to use (between 0 and 1)
  69868. * @param factor defines the angular speed to affect to the specified gradient
  69869. * @returns the current particle system
  69870. */
  69871. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  69872. /**
  69873. * Remove a specific angular speed gradient
  69874. * @param gradient defines the gradient to remove
  69875. * @returns the current particle system
  69876. */
  69877. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  69878. /**
  69879. * Adds a new velocity gradient
  69880. * @param gradient defines the gradient to use (between 0 and 1)
  69881. * @param factor defines the velocity to affect to the specified gradient
  69882. * @returns the current particle system
  69883. */
  69884. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69885. /**
  69886. * Remove a specific velocity gradient
  69887. * @param gradient defines the gradient to remove
  69888. * @returns the current particle system
  69889. */
  69890. removeVelocityGradient(gradient: number): GPUParticleSystem;
  69891. /**
  69892. * Adds a new limit velocity gradient
  69893. * @param gradient defines the gradient to use (between 0 and 1)
  69894. * @param factor defines the limit velocity value to affect to the specified gradient
  69895. * @returns the current particle system
  69896. */
  69897. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69898. /**
  69899. * Remove a specific limit velocity gradient
  69900. * @param gradient defines the gradient to remove
  69901. * @returns the current particle system
  69902. */
  69903. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  69904. /**
  69905. * Adds a new drag gradient
  69906. * @param gradient defines the gradient to use (between 0 and 1)
  69907. * @param factor defines the drag value to affect to the specified gradient
  69908. * @returns the current particle system
  69909. */
  69910. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  69911. /**
  69912. * Remove a specific drag gradient
  69913. * @param gradient defines the gradient to remove
  69914. * @returns the current particle system
  69915. */
  69916. removeDragGradient(gradient: number): GPUParticleSystem;
  69917. /**
  69918. * Not supported by GPUParticleSystem
  69919. * @param gradient defines the gradient to use (between 0 and 1)
  69920. * @param factor defines the emit rate value to affect to the specified gradient
  69921. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69922. * @returns the current particle system
  69923. */
  69924. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69925. /**
  69926. * Not supported by GPUParticleSystem
  69927. * @param gradient defines the gradient to remove
  69928. * @returns the current particle system
  69929. */
  69930. removeEmitRateGradient(gradient: number): IParticleSystem;
  69931. /**
  69932. * Not supported by GPUParticleSystem
  69933. * @param gradient defines the gradient to use (between 0 and 1)
  69934. * @param factor defines the start size value to affect to the specified gradient
  69935. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69936. * @returns the current particle system
  69937. */
  69938. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69939. /**
  69940. * Not supported by GPUParticleSystem
  69941. * @param gradient defines the gradient to remove
  69942. * @returns the current particle system
  69943. */
  69944. removeStartSizeGradient(gradient: number): IParticleSystem;
  69945. /**
  69946. * Not supported by GPUParticleSystem
  69947. * @param gradient defines the gradient to use (between 0 and 1)
  69948. * @param min defines the color remap minimal range
  69949. * @param max defines the color remap maximal range
  69950. * @returns the current particle system
  69951. */
  69952. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69953. /**
  69954. * Not supported by GPUParticleSystem
  69955. * @param gradient defines the gradient to remove
  69956. * @returns the current particle system
  69957. */
  69958. removeColorRemapGradient(): IParticleSystem;
  69959. /**
  69960. * Not supported by GPUParticleSystem
  69961. * @param gradient defines the gradient to use (between 0 and 1)
  69962. * @param min defines the alpha remap minimal range
  69963. * @param max defines the alpha remap maximal range
  69964. * @returns the current particle system
  69965. */
  69966. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69967. /**
  69968. * Not supported by GPUParticleSystem
  69969. * @param gradient defines the gradient to remove
  69970. * @returns the current particle system
  69971. */
  69972. removeAlphaRemapGradient(): IParticleSystem;
  69973. /**
  69974. * Not supported by GPUParticleSystem
  69975. * @param gradient defines the gradient to use (between 0 and 1)
  69976. * @param color defines the color to affect to the specified gradient
  69977. * @returns the current particle system
  69978. */
  69979. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  69980. /**
  69981. * Not supported by GPUParticleSystem
  69982. * @param gradient defines the gradient to remove
  69983. * @returns the current particle system
  69984. */
  69985. removeRampGradient(): IParticleSystem;
  69986. /**
  69987. * Not supported by GPUParticleSystem
  69988. * @returns the list of ramp gradients
  69989. */
  69990. getRampGradients(): Nullable<Array<Color3Gradient>>;
  69991. /**
  69992. * Not supported by GPUParticleSystem
  69993. * Gets or sets a boolean indicating that ramp gradients must be used
  69994. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  69995. */
  69996. get useRampGradients(): boolean;
  69997. set useRampGradients(value: boolean);
  69998. /**
  69999. * Not supported by GPUParticleSystem
  70000. * @param gradient defines the gradient to use (between 0 and 1)
  70001. * @param factor defines the life time factor to affect to the specified gradient
  70002. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70003. * @returns the current particle system
  70004. */
  70005. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70006. /**
  70007. * Not supported by GPUParticleSystem
  70008. * @param gradient defines the gradient to remove
  70009. * @returns the current particle system
  70010. */
  70011. removeLifeTimeGradient(gradient: number): IParticleSystem;
  70012. /**
  70013. * Instantiates a GPU particle system.
  70014. * 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.
  70015. * @param name The name of the particle system
  70016. * @param options The options used to create the system
  70017. * @param scene The scene the particle system belongs to
  70018. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  70019. * @param customEffect a custom effect used to change the way particles are rendered by default
  70020. */
  70021. constructor(name: string, options: Partial<{
  70022. capacity: number;
  70023. randomTextureSize: number;
  70024. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  70025. protected _reset(): void;
  70026. private _createUpdateVAO;
  70027. private _createRenderVAO;
  70028. private _initialize;
  70029. /** @hidden */
  70030. _recreateUpdateEffect(): void;
  70031. private _getEffect;
  70032. /**
  70033. * Fill the defines array according to the current settings of the particle system
  70034. * @param defines Array to be updated
  70035. * @param blendMode blend mode to take into account when updating the array
  70036. */
  70037. fillDefines(defines: Array<string>, blendMode?: number): void;
  70038. /**
  70039. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  70040. * @param uniforms Uniforms array to fill
  70041. * @param attributes Attributes array to fill
  70042. * @param samplers Samplers array to fill
  70043. */
  70044. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  70045. /** @hidden */
  70046. _recreateRenderEffect(): Effect;
  70047. /**
  70048. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  70049. * @param preWarm defines if we are in the pre-warmimg phase
  70050. */
  70051. animate(preWarm?: boolean): void;
  70052. private _createFactorGradientTexture;
  70053. private _createSizeGradientTexture;
  70054. private _createAngularSpeedGradientTexture;
  70055. private _createVelocityGradientTexture;
  70056. private _createLimitVelocityGradientTexture;
  70057. private _createDragGradientTexture;
  70058. private _createColorGradientTexture;
  70059. /**
  70060. * Renders the particle system in its current state
  70061. * @param preWarm defines if the system should only update the particles but not render them
  70062. * @returns the current number of particles
  70063. */
  70064. render(preWarm?: boolean): number;
  70065. /**
  70066. * Rebuilds the particle system
  70067. */
  70068. rebuild(): void;
  70069. private _releaseBuffers;
  70070. private _releaseVAOs;
  70071. /**
  70072. * Disposes the particle system and free the associated resources
  70073. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  70074. */
  70075. dispose(disposeTexture?: boolean): void;
  70076. /**
  70077. * Clones the particle system.
  70078. * @param name The name of the cloned object
  70079. * @param newEmitter The new emitter to use
  70080. * @returns the cloned particle system
  70081. */
  70082. clone(name: string, newEmitter: any): GPUParticleSystem;
  70083. /**
  70084. * Serializes the particle system to a JSON object
  70085. * @param serializeTexture defines if the texture must be serialized as well
  70086. * @returns the JSON object
  70087. */
  70088. serialize(serializeTexture?: boolean): any;
  70089. /**
  70090. * Parses a JSON object to create a GPU particle system.
  70091. * @param parsedParticleSystem The JSON object to parse
  70092. * @param scene The scene to create the particle system in
  70093. * @param rootUrl The root url to use to load external dependencies like texture
  70094. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  70095. * @returns the parsed GPU particle system
  70096. */
  70097. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  70098. }
  70099. }
  70100. declare module "babylonjs/Particles/particleSystemSet" {
  70101. import { Nullable } from "babylonjs/types";
  70102. import { Color3 } from "babylonjs/Maths/math.color";
  70103. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70105. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70106. import { Scene, IDisposable } from "babylonjs/scene";
  70107. /**
  70108. * Represents a set of particle systems working together to create a specific effect
  70109. */
  70110. export class ParticleSystemSet implements IDisposable {
  70111. /**
  70112. * Gets or sets base Assets URL
  70113. */
  70114. static BaseAssetsUrl: string;
  70115. private _emitterCreationOptions;
  70116. private _emitterNode;
  70117. /**
  70118. * Gets the particle system list
  70119. */
  70120. systems: IParticleSystem[];
  70121. /**
  70122. * Gets the emitter node used with this set
  70123. */
  70124. get emitterNode(): Nullable<TransformNode>;
  70125. /**
  70126. * Creates a new emitter mesh as a sphere
  70127. * @param options defines the options used to create the sphere
  70128. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  70129. * @param scene defines the hosting scene
  70130. */
  70131. setEmitterAsSphere(options: {
  70132. diameter: number;
  70133. segments: number;
  70134. color: Color3;
  70135. }, renderingGroupId: number, scene: Scene): void;
  70136. /**
  70137. * Starts all particle systems of the set
  70138. * @param emitter defines an optional mesh to use as emitter for the particle systems
  70139. */
  70140. start(emitter?: AbstractMesh): void;
  70141. /**
  70142. * Release all associated resources
  70143. */
  70144. dispose(): void;
  70145. /**
  70146. * Serialize the set into a JSON compatible object
  70147. * @param serializeTexture defines if the texture must be serialized as well
  70148. * @returns a JSON compatible representation of the set
  70149. */
  70150. serialize(serializeTexture?: boolean): any;
  70151. /**
  70152. * Parse a new ParticleSystemSet from a serialized source
  70153. * @param data defines a JSON compatible representation of the set
  70154. * @param scene defines the hosting scene
  70155. * @param gpu defines if we want GPU particles or CPU particles
  70156. * @returns a new ParticleSystemSet
  70157. */
  70158. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  70159. }
  70160. }
  70161. declare module "babylonjs/Particles/particleHelper" {
  70162. import { Nullable } from "babylonjs/types";
  70163. import { Scene } from "babylonjs/scene";
  70164. import { Vector3 } from "babylonjs/Maths/math.vector";
  70165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70166. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70167. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  70168. /**
  70169. * This class is made for on one-liner static method to help creating particle system set.
  70170. */
  70171. export class ParticleHelper {
  70172. /**
  70173. * Gets or sets base Assets URL
  70174. */
  70175. static BaseAssetsUrl: string;
  70176. /** Define the Url to load snippets */
  70177. static SnippetUrl: string;
  70178. /**
  70179. * Create a default particle system that you can tweak
  70180. * @param emitter defines the emitter to use
  70181. * @param capacity defines the system capacity (default is 500 particles)
  70182. * @param scene defines the hosting scene
  70183. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  70184. * @returns the new Particle system
  70185. */
  70186. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  70187. /**
  70188. * This is the main static method (one-liner) of this helper to create different particle systems
  70189. * @param type This string represents the type to the particle system to create
  70190. * @param scene The scene where the particle system should live
  70191. * @param gpu If the system will use gpu
  70192. * @returns the ParticleSystemSet created
  70193. */
  70194. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  70195. /**
  70196. * Static function used to export a particle system to a ParticleSystemSet variable.
  70197. * Please note that the emitter shape is not exported
  70198. * @param systems defines the particle systems to export
  70199. * @returns the created particle system set
  70200. */
  70201. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  70202. /**
  70203. * Creates a particle system from a snippet saved in a remote file
  70204. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  70205. * @param url defines the url to load from
  70206. * @param scene defines the hosting scene
  70207. * @param gpu If the system will use gpu
  70208. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70209. * @returns a promise that will resolve to the new particle system
  70210. */
  70211. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70212. /**
  70213. * Creates a particle system from a snippet saved by the particle system editor
  70214. * @param snippetId defines the snippet to load
  70215. * @param scene defines the hosting scene
  70216. * @param gpu If the system will use gpu
  70217. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70218. * @returns a promise that will resolve to the new particle system
  70219. */
  70220. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70221. }
  70222. }
  70223. declare module "babylonjs/Particles/particleSystemComponent" {
  70224. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70225. import { Effect } from "babylonjs/Materials/effect";
  70226. import "babylonjs/Shaders/particles.vertex";
  70227. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  70228. module "babylonjs/Engines/engine" {
  70229. interface Engine {
  70230. /**
  70231. * Create an effect to use with particle systems.
  70232. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  70233. * the particle system for which you want to create a custom effect in the last parameter
  70234. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  70235. * @param uniformsNames defines a list of attribute names
  70236. * @param samplers defines an array of string used to represent textures
  70237. * @param defines defines the string containing the defines to use to compile the shaders
  70238. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  70239. * @param onCompiled defines a function to call when the effect creation is successful
  70240. * @param onError defines a function to call when the effect creation has failed
  70241. * @param particleSystem the particle system you want to create the effect for
  70242. * @returns the new Effect
  70243. */
  70244. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  70245. }
  70246. }
  70247. module "babylonjs/Meshes/mesh" {
  70248. interface Mesh {
  70249. /**
  70250. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  70251. * @returns an array of IParticleSystem
  70252. */
  70253. getEmittedParticleSystems(): IParticleSystem[];
  70254. /**
  70255. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  70256. * @returns an array of IParticleSystem
  70257. */
  70258. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  70259. }
  70260. }
  70261. }
  70262. declare module "babylonjs/Particles/pointsCloudSystem" {
  70263. import { Color4 } from "babylonjs/Maths/math";
  70264. import { Mesh } from "babylonjs/Meshes/mesh";
  70265. import { Scene, IDisposable } from "babylonjs/scene";
  70266. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  70267. /** Defines the 4 color options */
  70268. export enum PointColor {
  70269. /** color value */
  70270. Color = 2,
  70271. /** uv value */
  70272. UV = 1,
  70273. /** random value */
  70274. Random = 0,
  70275. /** stated value */
  70276. Stated = 3
  70277. }
  70278. /**
  70279. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  70280. * 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.
  70281. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  70282. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  70283. *
  70284. * Full documentation here : TO BE ENTERED
  70285. */
  70286. export class PointsCloudSystem implements IDisposable {
  70287. /**
  70288. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  70289. * Example : var p = SPS.particles[i];
  70290. */
  70291. particles: CloudPoint[];
  70292. /**
  70293. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  70294. */
  70295. nbParticles: number;
  70296. /**
  70297. * This a counter for your own usage. It's not set by any SPS functions.
  70298. */
  70299. counter: number;
  70300. /**
  70301. * The PCS name. This name is also given to the underlying mesh.
  70302. */
  70303. name: string;
  70304. /**
  70305. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  70306. */
  70307. mesh: Mesh;
  70308. /**
  70309. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  70310. * Please read :
  70311. */
  70312. vars: any;
  70313. /**
  70314. * @hidden
  70315. */
  70316. _size: number;
  70317. private _scene;
  70318. private _promises;
  70319. private _positions;
  70320. private _indices;
  70321. private _normals;
  70322. private _colors;
  70323. private _uvs;
  70324. private _indices32;
  70325. private _positions32;
  70326. private _colors32;
  70327. private _uvs32;
  70328. private _updatable;
  70329. private _isVisibilityBoxLocked;
  70330. private _alwaysVisible;
  70331. private _groups;
  70332. private _groupCounter;
  70333. private _computeParticleColor;
  70334. private _computeParticleTexture;
  70335. private _computeParticleRotation;
  70336. private _computeBoundingBox;
  70337. private _isReady;
  70338. /**
  70339. * Creates a PCS (Points Cloud System) object
  70340. * @param name (String) is the PCS name, this will be the underlying mesh name
  70341. * @param pointSize (number) is the size for each point
  70342. * @param scene (Scene) is the scene in which the PCS is added
  70343. * @param options defines the options of the PCS e.g.
  70344. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  70345. */
  70346. constructor(name: string, pointSize: number, scene: Scene, options?: {
  70347. updatable?: boolean;
  70348. });
  70349. /**
  70350. * Builds the PCS underlying mesh. Returns a standard Mesh.
  70351. * If no points were added to the PCS, the returned mesh is just a single point.
  70352. * @returns a promise for the created mesh
  70353. */
  70354. buildMeshAsync(): Promise<Mesh>;
  70355. /**
  70356. * @hidden
  70357. */
  70358. private _buildMesh;
  70359. private _addParticle;
  70360. private _randomUnitVector;
  70361. private _getColorIndicesForCoord;
  70362. private _setPointsColorOrUV;
  70363. private _colorFromTexture;
  70364. private _calculateDensity;
  70365. /**
  70366. * Adds points to the PCS in random positions within a unit sphere
  70367. * @param nb (positive integer) the number of particles to be created from this model
  70368. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  70369. * @returns the number of groups in the system
  70370. */
  70371. addPoints(nb: number, pointFunction?: any): number;
  70372. /**
  70373. * Adds points to the PCS from the surface of the model shape
  70374. * @param mesh is any Mesh object that will be used as a surface model for the points
  70375. * @param nb (positive integer) the number of particles to be created from this model
  70376. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70377. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70378. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70379. * @returns the number of groups in the system
  70380. */
  70381. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70382. /**
  70383. * Adds points to the PCS inside the model shape
  70384. * @param mesh is any Mesh object that will be used as a surface model for the points
  70385. * @param nb (positive integer) the number of particles to be created from this model
  70386. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70387. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70388. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70389. * @returns the number of groups in the system
  70390. */
  70391. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70392. /**
  70393. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  70394. * This method calls `updateParticle()` for each particle of the SPS.
  70395. * For an animated SPS, it is usually called within the render loop.
  70396. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  70397. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  70398. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  70399. * @returns the PCS.
  70400. */
  70401. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  70402. /**
  70403. * Disposes the PCS.
  70404. */
  70405. dispose(): void;
  70406. /**
  70407. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  70408. * doc :
  70409. * @returns the PCS.
  70410. */
  70411. refreshVisibleSize(): PointsCloudSystem;
  70412. /**
  70413. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  70414. * @param size the size (float) of the visibility box
  70415. * note : this doesn't lock the PCS mesh bounding box.
  70416. * doc :
  70417. */
  70418. setVisibilityBox(size: number): void;
  70419. /**
  70420. * Gets whether the PCS is always visible or not
  70421. * doc :
  70422. */
  70423. get isAlwaysVisible(): boolean;
  70424. /**
  70425. * Sets the PCS as always visible or not
  70426. * doc :
  70427. */
  70428. set isAlwaysVisible(val: boolean);
  70429. /**
  70430. * Tells to `setParticles()` to compute the particle rotations or not
  70431. * Default value : false. The PCS is faster when it's set to false
  70432. * Note : particle rotations are only applied to parent particles
  70433. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  70434. */
  70435. set computeParticleRotation(val: boolean);
  70436. /**
  70437. * Tells to `setParticles()` to compute the particle colors or not.
  70438. * Default value : true. The PCS is faster when it's set to false.
  70439. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70440. */
  70441. set computeParticleColor(val: boolean);
  70442. set computeParticleTexture(val: boolean);
  70443. /**
  70444. * Gets if `setParticles()` computes the particle colors or not.
  70445. * Default value : false. The PCS is faster when it's set to false.
  70446. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70447. */
  70448. get computeParticleColor(): boolean;
  70449. /**
  70450. * Gets if `setParticles()` computes the particle textures or not.
  70451. * Default value : false. The PCS is faster when it's set to false.
  70452. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  70453. */
  70454. get computeParticleTexture(): boolean;
  70455. /**
  70456. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  70457. */
  70458. set computeBoundingBox(val: boolean);
  70459. /**
  70460. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  70461. */
  70462. get computeBoundingBox(): boolean;
  70463. /**
  70464. * This function does nothing. It may be overwritten to set all the particle first values.
  70465. * The PCS doesn't call this function, you may have to call it by your own.
  70466. * doc :
  70467. */
  70468. initParticles(): void;
  70469. /**
  70470. * This function does nothing. It may be overwritten to recycle a particle
  70471. * The PCS doesn't call this function, you can to call it
  70472. * doc :
  70473. * @param particle The particle to recycle
  70474. * @returns the recycled particle
  70475. */
  70476. recycleParticle(particle: CloudPoint): CloudPoint;
  70477. /**
  70478. * Updates a particle : this function should be overwritten by the user.
  70479. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  70480. * doc :
  70481. * @example : just set a particle position or velocity and recycle conditions
  70482. * @param particle The particle to update
  70483. * @returns the updated particle
  70484. */
  70485. updateParticle(particle: CloudPoint): CloudPoint;
  70486. /**
  70487. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  70488. * This does nothing and may be overwritten by the user.
  70489. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70490. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70491. * @param update the boolean update value actually passed to setParticles()
  70492. */
  70493. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70494. /**
  70495. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  70496. * This will be passed three parameters.
  70497. * This does nothing and may be overwritten by the user.
  70498. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70499. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70500. * @param update the boolean update value actually passed to setParticles()
  70501. */
  70502. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70503. }
  70504. }
  70505. declare module "babylonjs/Particles/cloudPoint" {
  70506. import { Nullable } from "babylonjs/types";
  70507. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  70508. import { Mesh } from "babylonjs/Meshes/mesh";
  70509. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  70510. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  70511. /**
  70512. * Represents one particle of a points cloud system.
  70513. */
  70514. export class CloudPoint {
  70515. /**
  70516. * particle global index
  70517. */
  70518. idx: number;
  70519. /**
  70520. * The color of the particle
  70521. */
  70522. color: Nullable<Color4>;
  70523. /**
  70524. * The world space position of the particle.
  70525. */
  70526. position: Vector3;
  70527. /**
  70528. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  70529. */
  70530. rotation: Vector3;
  70531. /**
  70532. * The world space rotation quaternion of the particle.
  70533. */
  70534. rotationQuaternion: Nullable<Quaternion>;
  70535. /**
  70536. * The uv of the particle.
  70537. */
  70538. uv: Nullable<Vector2>;
  70539. /**
  70540. * The current speed of the particle.
  70541. */
  70542. velocity: Vector3;
  70543. /**
  70544. * The pivot point in the particle local space.
  70545. */
  70546. pivot: Vector3;
  70547. /**
  70548. * Must the particle be translated from its pivot point in its local space ?
  70549. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  70550. * Default : false
  70551. */
  70552. translateFromPivot: boolean;
  70553. /**
  70554. * Index of this particle in the global "positions" array (Internal use)
  70555. * @hidden
  70556. */
  70557. _pos: number;
  70558. /**
  70559. * @hidden Index of this particle in the global "indices" array (Internal use)
  70560. */
  70561. _ind: number;
  70562. /**
  70563. * Group this particle belongs to
  70564. */
  70565. _group: PointsGroup;
  70566. /**
  70567. * Group id of this particle
  70568. */
  70569. groupId: number;
  70570. /**
  70571. * Index of the particle in its group id (Internal use)
  70572. */
  70573. idxInGroup: number;
  70574. /**
  70575. * @hidden Particle BoundingInfo object (Internal use)
  70576. */
  70577. _boundingInfo: BoundingInfo;
  70578. /**
  70579. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  70580. */
  70581. _pcs: PointsCloudSystem;
  70582. /**
  70583. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  70584. */
  70585. _stillInvisible: boolean;
  70586. /**
  70587. * @hidden Last computed particle rotation matrix
  70588. */
  70589. _rotationMatrix: number[];
  70590. /**
  70591. * Parent particle Id, if any.
  70592. * Default null.
  70593. */
  70594. parentId: Nullable<number>;
  70595. /**
  70596. * @hidden Internal global position in the PCS.
  70597. */
  70598. _globalPosition: Vector3;
  70599. /**
  70600. * Creates a Point Cloud object.
  70601. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  70602. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  70603. * @param group (PointsGroup) is the group the particle belongs to
  70604. * @param groupId (integer) is the group identifier in the PCS.
  70605. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  70606. * @param pcs defines the PCS it is associated to
  70607. */
  70608. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  70609. /**
  70610. * get point size
  70611. */
  70612. get size(): Vector3;
  70613. /**
  70614. * Set point size
  70615. */
  70616. set size(scale: Vector3);
  70617. /**
  70618. * Legacy support, changed quaternion to rotationQuaternion
  70619. */
  70620. get quaternion(): Nullable<Quaternion>;
  70621. /**
  70622. * Legacy support, changed quaternion to rotationQuaternion
  70623. */
  70624. set quaternion(q: Nullable<Quaternion>);
  70625. /**
  70626. * Returns a boolean. True if the particle intersects a mesh, else false
  70627. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  70628. * @param target is the object (point or mesh) what the intersection is computed against
  70629. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  70630. * @returns true if it intersects
  70631. */
  70632. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  70633. /**
  70634. * get the rotation matrix of the particle
  70635. * @hidden
  70636. */
  70637. getRotationMatrix(m: Matrix): void;
  70638. }
  70639. /**
  70640. * Represents a group of points in a points cloud system
  70641. * * PCS internal tool, don't use it manually.
  70642. */
  70643. export class PointsGroup {
  70644. /**
  70645. * The group id
  70646. * @hidden
  70647. */
  70648. groupID: number;
  70649. /**
  70650. * image data for group (internal use)
  70651. * @hidden
  70652. */
  70653. _groupImageData: Nullable<ArrayBufferView>;
  70654. /**
  70655. * Image Width (internal use)
  70656. * @hidden
  70657. */
  70658. _groupImgWidth: number;
  70659. /**
  70660. * Image Height (internal use)
  70661. * @hidden
  70662. */
  70663. _groupImgHeight: number;
  70664. /**
  70665. * Custom position function (internal use)
  70666. * @hidden
  70667. */
  70668. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  70669. /**
  70670. * density per facet for surface points
  70671. * @hidden
  70672. */
  70673. _groupDensity: number[];
  70674. /**
  70675. * Only when points are colored by texture carries pointer to texture list array
  70676. * @hidden
  70677. */
  70678. _textureNb: number;
  70679. /**
  70680. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  70681. * PCS internal tool, don't use it manually.
  70682. * @hidden
  70683. */
  70684. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  70685. }
  70686. }
  70687. declare module "babylonjs/Particles/index" {
  70688. export * from "babylonjs/Particles/baseParticleSystem";
  70689. export * from "babylonjs/Particles/EmitterTypes/index";
  70690. export * from "babylonjs/Particles/gpuParticleSystem";
  70691. export * from "babylonjs/Particles/IParticleSystem";
  70692. export * from "babylonjs/Particles/particle";
  70693. export * from "babylonjs/Particles/particleHelper";
  70694. export * from "babylonjs/Particles/particleSystem";
  70695. import "babylonjs/Particles/particleSystemComponent";
  70696. export * from "babylonjs/Particles/particleSystemComponent";
  70697. export * from "babylonjs/Particles/particleSystemSet";
  70698. export * from "babylonjs/Particles/solidParticle";
  70699. export * from "babylonjs/Particles/solidParticleSystem";
  70700. export * from "babylonjs/Particles/cloudPoint";
  70701. export * from "babylonjs/Particles/pointsCloudSystem";
  70702. export * from "babylonjs/Particles/subEmitter";
  70703. }
  70704. declare module "babylonjs/Physics/physicsEngineComponent" {
  70705. import { Nullable } from "babylonjs/types";
  70706. import { Observable, Observer } from "babylonjs/Misc/observable";
  70707. import { Vector3 } from "babylonjs/Maths/math.vector";
  70708. import { Mesh } from "babylonjs/Meshes/mesh";
  70709. import { ISceneComponent } from "babylonjs/sceneComponent";
  70710. import { Scene } from "babylonjs/scene";
  70711. import { Node } from "babylonjs/node";
  70712. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  70713. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70714. module "babylonjs/scene" {
  70715. interface Scene {
  70716. /** @hidden (Backing field) */
  70717. _physicsEngine: Nullable<IPhysicsEngine>;
  70718. /** @hidden */
  70719. _physicsTimeAccumulator: number;
  70720. /**
  70721. * Gets the current physics engine
  70722. * @returns a IPhysicsEngine or null if none attached
  70723. */
  70724. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  70725. /**
  70726. * Enables physics to the current scene
  70727. * @param gravity defines the scene's gravity for the physics engine
  70728. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  70729. * @return a boolean indicating if the physics engine was initialized
  70730. */
  70731. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  70732. /**
  70733. * Disables and disposes the physics engine associated with the scene
  70734. */
  70735. disablePhysicsEngine(): void;
  70736. /**
  70737. * Gets a boolean indicating if there is an active physics engine
  70738. * @returns a boolean indicating if there is an active physics engine
  70739. */
  70740. isPhysicsEnabled(): boolean;
  70741. /**
  70742. * Deletes a physics compound impostor
  70743. * @param compound defines the compound to delete
  70744. */
  70745. deleteCompoundImpostor(compound: any): void;
  70746. /**
  70747. * An event triggered when physic simulation is about to be run
  70748. */
  70749. onBeforePhysicsObservable: Observable<Scene>;
  70750. /**
  70751. * An event triggered when physic simulation has been done
  70752. */
  70753. onAfterPhysicsObservable: Observable<Scene>;
  70754. }
  70755. }
  70756. module "babylonjs/Meshes/abstractMesh" {
  70757. interface AbstractMesh {
  70758. /** @hidden */
  70759. _physicsImpostor: Nullable<PhysicsImpostor>;
  70760. /**
  70761. * Gets or sets impostor used for physic simulation
  70762. * @see http://doc.babylonjs.com/features/physics_engine
  70763. */
  70764. physicsImpostor: Nullable<PhysicsImpostor>;
  70765. /**
  70766. * Gets the current physics impostor
  70767. * @see http://doc.babylonjs.com/features/physics_engine
  70768. * @returns a physics impostor or null
  70769. */
  70770. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  70771. /** Apply a physic impulse to the mesh
  70772. * @param force defines the force to apply
  70773. * @param contactPoint defines where to apply the force
  70774. * @returns the current mesh
  70775. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  70776. */
  70777. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  70778. /**
  70779. * Creates a physic joint between two meshes
  70780. * @param otherMesh defines the other mesh to use
  70781. * @param pivot1 defines the pivot to use on this mesh
  70782. * @param pivot2 defines the pivot to use on the other mesh
  70783. * @param options defines additional options (can be plugin dependent)
  70784. * @returns the current mesh
  70785. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  70786. */
  70787. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  70788. /** @hidden */
  70789. _disposePhysicsObserver: Nullable<Observer<Node>>;
  70790. }
  70791. }
  70792. /**
  70793. * Defines the physics engine scene component responsible to manage a physics engine
  70794. */
  70795. export class PhysicsEngineSceneComponent implements ISceneComponent {
  70796. /**
  70797. * The component name helpful to identify the component in the list of scene components.
  70798. */
  70799. readonly name: string;
  70800. /**
  70801. * The scene the component belongs to.
  70802. */
  70803. scene: Scene;
  70804. /**
  70805. * Creates a new instance of the component for the given scene
  70806. * @param scene Defines the scene to register the component in
  70807. */
  70808. constructor(scene: Scene);
  70809. /**
  70810. * Registers the component in a given scene
  70811. */
  70812. register(): void;
  70813. /**
  70814. * Rebuilds the elements related to this component in case of
  70815. * context lost for instance.
  70816. */
  70817. rebuild(): void;
  70818. /**
  70819. * Disposes the component and the associated ressources
  70820. */
  70821. dispose(): void;
  70822. }
  70823. }
  70824. declare module "babylonjs/Physics/physicsHelper" {
  70825. import { Nullable } from "babylonjs/types";
  70826. import { Vector3 } from "babylonjs/Maths/math.vector";
  70827. import { Mesh } from "babylonjs/Meshes/mesh";
  70828. import { Scene } from "babylonjs/scene";
  70829. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70830. /**
  70831. * A helper for physics simulations
  70832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70833. */
  70834. export class PhysicsHelper {
  70835. private _scene;
  70836. private _physicsEngine;
  70837. /**
  70838. * Initializes the Physics helper
  70839. * @param scene Babylon.js scene
  70840. */
  70841. constructor(scene: Scene);
  70842. /**
  70843. * Applies a radial explosion impulse
  70844. * @param origin the origin of the explosion
  70845. * @param radiusOrEventOptions the radius or the options of radial explosion
  70846. * @param strength the explosion strength
  70847. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70848. * @returns A physics radial explosion event, or null
  70849. */
  70850. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70851. /**
  70852. * Applies a radial explosion force
  70853. * @param origin the origin of the explosion
  70854. * @param radiusOrEventOptions the radius or the options of radial explosion
  70855. * @param strength the explosion strength
  70856. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70857. * @returns A physics radial explosion event, or null
  70858. */
  70859. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70860. /**
  70861. * Creates a gravitational field
  70862. * @param origin the origin of the explosion
  70863. * @param radiusOrEventOptions the radius or the options of radial explosion
  70864. * @param strength the explosion strength
  70865. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70866. * @returns A physics gravitational field event, or null
  70867. */
  70868. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  70869. /**
  70870. * Creates a physics updraft event
  70871. * @param origin the origin of the updraft
  70872. * @param radiusOrEventOptions the radius or the options of the updraft
  70873. * @param strength the strength of the updraft
  70874. * @param height the height of the updraft
  70875. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  70876. * @returns A physics updraft event, or null
  70877. */
  70878. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  70879. /**
  70880. * Creates a physics vortex event
  70881. * @param origin the of the vortex
  70882. * @param radiusOrEventOptions the radius or the options of the vortex
  70883. * @param strength the strength of the vortex
  70884. * @param height the height of the vortex
  70885. * @returns a Physics vortex event, or null
  70886. * A physics vortex event or null
  70887. */
  70888. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  70889. }
  70890. /**
  70891. * Represents a physics radial explosion event
  70892. */
  70893. class PhysicsRadialExplosionEvent {
  70894. private _scene;
  70895. private _options;
  70896. private _sphere;
  70897. private _dataFetched;
  70898. /**
  70899. * Initializes a radial explosioin event
  70900. * @param _scene BabylonJS scene
  70901. * @param _options The options for the vortex event
  70902. */
  70903. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  70904. /**
  70905. * Returns the data related to the radial explosion event (sphere).
  70906. * @returns The radial explosion event data
  70907. */
  70908. getData(): PhysicsRadialExplosionEventData;
  70909. /**
  70910. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  70911. * @param impostor A physics imposter
  70912. * @param origin the origin of the explosion
  70913. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  70914. */
  70915. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  70916. /**
  70917. * Triggers affecterd impostors callbacks
  70918. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  70919. */
  70920. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  70921. /**
  70922. * Disposes the sphere.
  70923. * @param force Specifies if the sphere should be disposed by force
  70924. */
  70925. dispose(force?: boolean): void;
  70926. /*** Helpers ***/
  70927. private _prepareSphere;
  70928. private _intersectsWithSphere;
  70929. }
  70930. /**
  70931. * Represents a gravitational field event
  70932. */
  70933. class PhysicsGravitationalFieldEvent {
  70934. private _physicsHelper;
  70935. private _scene;
  70936. private _origin;
  70937. private _options;
  70938. private _tickCallback;
  70939. private _sphere;
  70940. private _dataFetched;
  70941. /**
  70942. * Initializes the physics gravitational field event
  70943. * @param _physicsHelper A physics helper
  70944. * @param _scene BabylonJS scene
  70945. * @param _origin The origin position of the gravitational field event
  70946. * @param _options The options for the vortex event
  70947. */
  70948. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  70949. /**
  70950. * Returns the data related to the gravitational field event (sphere).
  70951. * @returns A gravitational field event
  70952. */
  70953. getData(): PhysicsGravitationalFieldEventData;
  70954. /**
  70955. * Enables the gravitational field.
  70956. */
  70957. enable(): void;
  70958. /**
  70959. * Disables the gravitational field.
  70960. */
  70961. disable(): void;
  70962. /**
  70963. * Disposes the sphere.
  70964. * @param force The force to dispose from the gravitational field event
  70965. */
  70966. dispose(force?: boolean): void;
  70967. private _tick;
  70968. }
  70969. /**
  70970. * Represents a physics updraft event
  70971. */
  70972. class PhysicsUpdraftEvent {
  70973. private _scene;
  70974. private _origin;
  70975. private _options;
  70976. private _physicsEngine;
  70977. private _originTop;
  70978. private _originDirection;
  70979. private _tickCallback;
  70980. private _cylinder;
  70981. private _cylinderPosition;
  70982. private _dataFetched;
  70983. /**
  70984. * Initializes the physics updraft event
  70985. * @param _scene BabylonJS scene
  70986. * @param _origin The origin position of the updraft
  70987. * @param _options The options for the updraft event
  70988. */
  70989. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  70990. /**
  70991. * Returns the data related to the updraft event (cylinder).
  70992. * @returns A physics updraft event
  70993. */
  70994. getData(): PhysicsUpdraftEventData;
  70995. /**
  70996. * Enables the updraft.
  70997. */
  70998. enable(): void;
  70999. /**
  71000. * Disables the updraft.
  71001. */
  71002. disable(): void;
  71003. /**
  71004. * Disposes the cylinder.
  71005. * @param force Specifies if the updraft should be disposed by force
  71006. */
  71007. dispose(force?: boolean): void;
  71008. private getImpostorHitData;
  71009. private _tick;
  71010. /*** Helpers ***/
  71011. private _prepareCylinder;
  71012. private _intersectsWithCylinder;
  71013. }
  71014. /**
  71015. * Represents a physics vortex event
  71016. */
  71017. class PhysicsVortexEvent {
  71018. private _scene;
  71019. private _origin;
  71020. private _options;
  71021. private _physicsEngine;
  71022. private _originTop;
  71023. private _tickCallback;
  71024. private _cylinder;
  71025. private _cylinderPosition;
  71026. private _dataFetched;
  71027. /**
  71028. * Initializes the physics vortex event
  71029. * @param _scene The BabylonJS scene
  71030. * @param _origin The origin position of the vortex
  71031. * @param _options The options for the vortex event
  71032. */
  71033. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  71034. /**
  71035. * Returns the data related to the vortex event (cylinder).
  71036. * @returns The physics vortex event data
  71037. */
  71038. getData(): PhysicsVortexEventData;
  71039. /**
  71040. * Enables the vortex.
  71041. */
  71042. enable(): void;
  71043. /**
  71044. * Disables the cortex.
  71045. */
  71046. disable(): void;
  71047. /**
  71048. * Disposes the sphere.
  71049. * @param force
  71050. */
  71051. dispose(force?: boolean): void;
  71052. private getImpostorHitData;
  71053. private _tick;
  71054. /*** Helpers ***/
  71055. private _prepareCylinder;
  71056. private _intersectsWithCylinder;
  71057. }
  71058. /**
  71059. * Options fot the radial explosion event
  71060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71061. */
  71062. export class PhysicsRadialExplosionEventOptions {
  71063. /**
  71064. * The radius of the sphere for the radial explosion.
  71065. */
  71066. radius: number;
  71067. /**
  71068. * The strenth of the explosion.
  71069. */
  71070. strength: number;
  71071. /**
  71072. * The strenght of the force in correspondence to the distance of the affected object
  71073. */
  71074. falloff: PhysicsRadialImpulseFalloff;
  71075. /**
  71076. * Sphere options for the radial explosion.
  71077. */
  71078. sphere: {
  71079. segments: number;
  71080. diameter: number;
  71081. };
  71082. /**
  71083. * Sphere options for the radial explosion.
  71084. */
  71085. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  71086. }
  71087. /**
  71088. * Options fot the updraft event
  71089. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71090. */
  71091. export class PhysicsUpdraftEventOptions {
  71092. /**
  71093. * The radius of the cylinder for the vortex
  71094. */
  71095. radius: number;
  71096. /**
  71097. * The strenth of the updraft.
  71098. */
  71099. strength: number;
  71100. /**
  71101. * The height of the cylinder for the updraft.
  71102. */
  71103. height: number;
  71104. /**
  71105. * The mode for the the updraft.
  71106. */
  71107. updraftMode: PhysicsUpdraftMode;
  71108. }
  71109. /**
  71110. * Options fot the vortex event
  71111. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71112. */
  71113. export class PhysicsVortexEventOptions {
  71114. /**
  71115. * The radius of the cylinder for the vortex
  71116. */
  71117. radius: number;
  71118. /**
  71119. * The strenth of the vortex.
  71120. */
  71121. strength: number;
  71122. /**
  71123. * The height of the cylinder for the vortex.
  71124. */
  71125. height: number;
  71126. /**
  71127. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  71128. */
  71129. centripetalForceThreshold: number;
  71130. /**
  71131. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  71132. */
  71133. centripetalForceMultiplier: number;
  71134. /**
  71135. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  71136. */
  71137. centrifugalForceMultiplier: number;
  71138. /**
  71139. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  71140. */
  71141. updraftForceMultiplier: number;
  71142. }
  71143. /**
  71144. * The strenght of the force in correspondence to the distance of the affected object
  71145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71146. */
  71147. export enum PhysicsRadialImpulseFalloff {
  71148. /** Defines that impulse is constant in strength across it's whole radius */
  71149. Constant = 0,
  71150. /** Defines that impulse gets weaker if it's further from the origin */
  71151. Linear = 1
  71152. }
  71153. /**
  71154. * The strength of the force in correspondence to the distance of the affected object
  71155. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71156. */
  71157. export enum PhysicsUpdraftMode {
  71158. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  71159. Center = 0,
  71160. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  71161. Perpendicular = 1
  71162. }
  71163. /**
  71164. * Interface for a physics hit data
  71165. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71166. */
  71167. export interface PhysicsHitData {
  71168. /**
  71169. * The force applied at the contact point
  71170. */
  71171. force: Vector3;
  71172. /**
  71173. * The contact point
  71174. */
  71175. contactPoint: Vector3;
  71176. /**
  71177. * The distance from the origin to the contact point
  71178. */
  71179. distanceFromOrigin: number;
  71180. }
  71181. /**
  71182. * Interface for radial explosion event data
  71183. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71184. */
  71185. export interface PhysicsRadialExplosionEventData {
  71186. /**
  71187. * A sphere used for the radial explosion event
  71188. */
  71189. sphere: Mesh;
  71190. }
  71191. /**
  71192. * Interface for gravitational field event data
  71193. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71194. */
  71195. export interface PhysicsGravitationalFieldEventData {
  71196. /**
  71197. * A sphere mesh used for the gravitational field event
  71198. */
  71199. sphere: Mesh;
  71200. }
  71201. /**
  71202. * Interface for updraft event data
  71203. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71204. */
  71205. export interface PhysicsUpdraftEventData {
  71206. /**
  71207. * A cylinder used for the updraft event
  71208. */
  71209. cylinder: Mesh;
  71210. }
  71211. /**
  71212. * Interface for vortex event data
  71213. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71214. */
  71215. export interface PhysicsVortexEventData {
  71216. /**
  71217. * A cylinder used for the vortex event
  71218. */
  71219. cylinder: Mesh;
  71220. }
  71221. /**
  71222. * Interface for an affected physics impostor
  71223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71224. */
  71225. export interface PhysicsAffectedImpostorWithData {
  71226. /**
  71227. * The impostor affected by the effect
  71228. */
  71229. impostor: PhysicsImpostor;
  71230. /**
  71231. * The data about the hit/horce from the explosion
  71232. */
  71233. hitData: PhysicsHitData;
  71234. }
  71235. }
  71236. declare module "babylonjs/Physics/Plugins/index" {
  71237. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  71238. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  71239. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  71240. }
  71241. declare module "babylonjs/Physics/index" {
  71242. export * from "babylonjs/Physics/IPhysicsEngine";
  71243. export * from "babylonjs/Physics/physicsEngine";
  71244. export * from "babylonjs/Physics/physicsEngineComponent";
  71245. export * from "babylonjs/Physics/physicsHelper";
  71246. export * from "babylonjs/Physics/physicsImpostor";
  71247. export * from "babylonjs/Physics/physicsJoint";
  71248. export * from "babylonjs/Physics/Plugins/index";
  71249. }
  71250. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  71251. /** @hidden */
  71252. export var blackAndWhitePixelShader: {
  71253. name: string;
  71254. shader: string;
  71255. };
  71256. }
  71257. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  71258. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71259. import { Camera } from "babylonjs/Cameras/camera";
  71260. import { Engine } from "babylonjs/Engines/engine";
  71261. import "babylonjs/Shaders/blackAndWhite.fragment";
  71262. /**
  71263. * Post process used to render in black and white
  71264. */
  71265. export class BlackAndWhitePostProcess extends PostProcess {
  71266. /**
  71267. * Linear about to convert he result to black and white (default: 1)
  71268. */
  71269. degree: number;
  71270. /**
  71271. * Creates a black and white post process
  71272. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  71273. * @param name The name of the effect.
  71274. * @param options The required width/height ratio to downsize to before computing the render pass.
  71275. * @param camera The camera to apply the render pass to.
  71276. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71277. * @param engine The engine which the post process will be applied. (default: current engine)
  71278. * @param reusable If the post process can be reused on the same frame. (default: false)
  71279. */
  71280. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71281. }
  71282. }
  71283. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  71284. import { Nullable } from "babylonjs/types";
  71285. import { Camera } from "babylonjs/Cameras/camera";
  71286. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71287. import { Engine } from "babylonjs/Engines/engine";
  71288. /**
  71289. * This represents a set of one or more post processes in Babylon.
  71290. * A post process can be used to apply a shader to a texture after it is rendered.
  71291. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71292. */
  71293. export class PostProcessRenderEffect {
  71294. private _postProcesses;
  71295. private _getPostProcesses;
  71296. private _singleInstance;
  71297. private _cameras;
  71298. private _indicesForCamera;
  71299. /**
  71300. * Name of the effect
  71301. * @hidden
  71302. */
  71303. _name: string;
  71304. /**
  71305. * Instantiates a post process render effect.
  71306. * A post process can be used to apply a shader to a texture after it is rendered.
  71307. * @param engine The engine the effect is tied to
  71308. * @param name The name of the effect
  71309. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  71310. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  71311. */
  71312. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  71313. /**
  71314. * Checks if all the post processes in the effect are supported.
  71315. */
  71316. get isSupported(): boolean;
  71317. /**
  71318. * Updates the current state of the effect
  71319. * @hidden
  71320. */
  71321. _update(): void;
  71322. /**
  71323. * Attaches the effect on cameras
  71324. * @param cameras The camera to attach to.
  71325. * @hidden
  71326. */
  71327. _attachCameras(cameras: Camera): void;
  71328. /**
  71329. * Attaches the effect on cameras
  71330. * @param cameras The camera to attach to.
  71331. * @hidden
  71332. */
  71333. _attachCameras(cameras: Camera[]): void;
  71334. /**
  71335. * Detaches the effect on cameras
  71336. * @param cameras The camera to detatch from.
  71337. * @hidden
  71338. */
  71339. _detachCameras(cameras: Camera): void;
  71340. /**
  71341. * Detatches the effect on cameras
  71342. * @param cameras The camera to detatch from.
  71343. * @hidden
  71344. */
  71345. _detachCameras(cameras: Camera[]): void;
  71346. /**
  71347. * Enables the effect on given cameras
  71348. * @param cameras The camera to enable.
  71349. * @hidden
  71350. */
  71351. _enable(cameras: Camera): void;
  71352. /**
  71353. * Enables the effect on given cameras
  71354. * @param cameras The camera to enable.
  71355. * @hidden
  71356. */
  71357. _enable(cameras: Nullable<Camera[]>): void;
  71358. /**
  71359. * Disables the effect on the given cameras
  71360. * @param cameras The camera to disable.
  71361. * @hidden
  71362. */
  71363. _disable(cameras: Camera): void;
  71364. /**
  71365. * Disables the effect on the given cameras
  71366. * @param cameras The camera to disable.
  71367. * @hidden
  71368. */
  71369. _disable(cameras: Nullable<Camera[]>): void;
  71370. /**
  71371. * Gets a list of the post processes contained in the effect.
  71372. * @param camera The camera to get the post processes on.
  71373. * @returns The list of the post processes in the effect.
  71374. */
  71375. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  71376. }
  71377. }
  71378. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  71379. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71380. /** @hidden */
  71381. export var extractHighlightsPixelShader: {
  71382. name: string;
  71383. shader: string;
  71384. };
  71385. }
  71386. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  71387. import { Nullable } from "babylonjs/types";
  71388. import { Camera } from "babylonjs/Cameras/camera";
  71389. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71390. import { Engine } from "babylonjs/Engines/engine";
  71391. import "babylonjs/Shaders/extractHighlights.fragment";
  71392. /**
  71393. * 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.
  71394. */
  71395. export class ExtractHighlightsPostProcess extends PostProcess {
  71396. /**
  71397. * The luminance threshold, pixels below this value will be set to black.
  71398. */
  71399. threshold: number;
  71400. /** @hidden */
  71401. _exposure: number;
  71402. /**
  71403. * Post process which has the input texture to be used when performing highlight extraction
  71404. * @hidden
  71405. */
  71406. _inputPostProcess: Nullable<PostProcess>;
  71407. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71408. }
  71409. }
  71410. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  71411. /** @hidden */
  71412. export var bloomMergePixelShader: {
  71413. name: string;
  71414. shader: string;
  71415. };
  71416. }
  71417. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  71418. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71419. import { Nullable } from "babylonjs/types";
  71420. import { Engine } from "babylonjs/Engines/engine";
  71421. import { Camera } from "babylonjs/Cameras/camera";
  71422. import "babylonjs/Shaders/bloomMerge.fragment";
  71423. /**
  71424. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71425. */
  71426. export class BloomMergePostProcess extends PostProcess {
  71427. /** Weight of the bloom to be added to the original input. */
  71428. weight: number;
  71429. /**
  71430. * Creates a new instance of @see BloomMergePostProcess
  71431. * @param name The name of the effect.
  71432. * @param originalFromInput Post process which's input will be used for the merge.
  71433. * @param blurred Blurred highlights post process which's output will be used.
  71434. * @param weight Weight of the bloom to be added to the original input.
  71435. * @param options The required width/height ratio to downsize to before computing the render pass.
  71436. * @param camera The camera to apply the render pass to.
  71437. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71438. * @param engine The engine which the post process will be applied. (default: current engine)
  71439. * @param reusable If the post process can be reused on the same frame. (default: false)
  71440. * @param textureType Type of textures used when performing the post process. (default: 0)
  71441. * @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)
  71442. */
  71443. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  71444. /** Weight of the bloom to be added to the original input. */
  71445. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71446. }
  71447. }
  71448. declare module "babylonjs/PostProcesses/bloomEffect" {
  71449. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71450. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71451. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  71452. import { Camera } from "babylonjs/Cameras/camera";
  71453. import { Scene } from "babylonjs/scene";
  71454. /**
  71455. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  71456. */
  71457. export class BloomEffect extends PostProcessRenderEffect {
  71458. private bloomScale;
  71459. /**
  71460. * @hidden Internal
  71461. */
  71462. _effects: Array<PostProcess>;
  71463. /**
  71464. * @hidden Internal
  71465. */
  71466. _downscale: ExtractHighlightsPostProcess;
  71467. private _blurX;
  71468. private _blurY;
  71469. private _merge;
  71470. /**
  71471. * The luminance threshold to find bright areas of the image to bloom.
  71472. */
  71473. get threshold(): number;
  71474. set threshold(value: number);
  71475. /**
  71476. * The strength of the bloom.
  71477. */
  71478. get weight(): number;
  71479. set weight(value: number);
  71480. /**
  71481. * Specifies the size of the bloom blur kernel, relative to the final output size
  71482. */
  71483. get kernel(): number;
  71484. set kernel(value: number);
  71485. /**
  71486. * Creates a new instance of @see BloomEffect
  71487. * @param scene The scene the effect belongs to.
  71488. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  71489. * @param bloomKernel The size of the kernel to be used when applying the blur.
  71490. * @param bloomWeight The the strength of bloom.
  71491. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71492. * @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)
  71493. */
  71494. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  71495. /**
  71496. * Disposes each of the internal effects for a given camera.
  71497. * @param camera The camera to dispose the effect on.
  71498. */
  71499. disposeEffects(camera: Camera): void;
  71500. /**
  71501. * @hidden Internal
  71502. */
  71503. _updateEffects(): void;
  71504. /**
  71505. * Internal
  71506. * @returns if all the contained post processes are ready.
  71507. * @hidden
  71508. */
  71509. _isReady(): boolean;
  71510. }
  71511. }
  71512. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  71513. /** @hidden */
  71514. export var chromaticAberrationPixelShader: {
  71515. name: string;
  71516. shader: string;
  71517. };
  71518. }
  71519. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  71520. import { Vector2 } from "babylonjs/Maths/math.vector";
  71521. import { Nullable } from "babylonjs/types";
  71522. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71523. import { Camera } from "babylonjs/Cameras/camera";
  71524. import { Engine } from "babylonjs/Engines/engine";
  71525. import "babylonjs/Shaders/chromaticAberration.fragment";
  71526. /**
  71527. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  71528. */
  71529. export class ChromaticAberrationPostProcess extends PostProcess {
  71530. /**
  71531. * The amount of seperation of rgb channels (default: 30)
  71532. */
  71533. aberrationAmount: number;
  71534. /**
  71535. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  71536. */
  71537. radialIntensity: number;
  71538. /**
  71539. * 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))
  71540. */
  71541. direction: Vector2;
  71542. /**
  71543. * 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))
  71544. */
  71545. centerPosition: Vector2;
  71546. /**
  71547. * Creates a new instance ChromaticAberrationPostProcess
  71548. * @param name The name of the effect.
  71549. * @param screenWidth The width of the screen to apply the effect on.
  71550. * @param screenHeight The height of the screen to apply the effect on.
  71551. * @param options The required width/height ratio to downsize to before computing the render pass.
  71552. * @param camera The camera to apply the render pass to.
  71553. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71554. * @param engine The engine which the post process will be applied. (default: current engine)
  71555. * @param reusable If the post process can be reused on the same frame. (default: false)
  71556. * @param textureType Type of textures used when performing the post process. (default: 0)
  71557. * @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)
  71558. */
  71559. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71560. }
  71561. }
  71562. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  71563. /** @hidden */
  71564. export var circleOfConfusionPixelShader: {
  71565. name: string;
  71566. shader: string;
  71567. };
  71568. }
  71569. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  71570. import { Nullable } from "babylonjs/types";
  71571. import { Engine } from "babylonjs/Engines/engine";
  71572. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71573. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71574. import { Camera } from "babylonjs/Cameras/camera";
  71575. import "babylonjs/Shaders/circleOfConfusion.fragment";
  71576. /**
  71577. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  71578. */
  71579. export class CircleOfConfusionPostProcess extends PostProcess {
  71580. /**
  71581. * 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.
  71582. */
  71583. lensSize: number;
  71584. /**
  71585. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71586. */
  71587. fStop: number;
  71588. /**
  71589. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71590. */
  71591. focusDistance: number;
  71592. /**
  71593. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  71594. */
  71595. focalLength: number;
  71596. private _depthTexture;
  71597. /**
  71598. * Creates a new instance CircleOfConfusionPostProcess
  71599. * @param name The name of the effect.
  71600. * @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.
  71601. * @param options The required width/height ratio to downsize to before computing the render pass.
  71602. * @param camera The camera to apply the render pass to.
  71603. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71604. * @param engine The engine which the post process will be applied. (default: current engine)
  71605. * @param reusable If the post process can be reused on the same frame. (default: false)
  71606. * @param textureType Type of textures used when performing the post process. (default: 0)
  71607. * @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)
  71608. */
  71609. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71610. /**
  71611. * 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.
  71612. */
  71613. set depthTexture(value: RenderTargetTexture);
  71614. }
  71615. }
  71616. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  71617. /** @hidden */
  71618. export var colorCorrectionPixelShader: {
  71619. name: string;
  71620. shader: string;
  71621. };
  71622. }
  71623. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  71624. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71625. import { Engine } from "babylonjs/Engines/engine";
  71626. import { Camera } from "babylonjs/Cameras/camera";
  71627. import "babylonjs/Shaders/colorCorrection.fragment";
  71628. /**
  71629. *
  71630. * This post-process allows the modification of rendered colors by using
  71631. * a 'look-up table' (LUT). This effect is also called Color Grading.
  71632. *
  71633. * The object needs to be provided an url to a texture containing the color
  71634. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  71635. * Use an image editing software to tweak the LUT to match your needs.
  71636. *
  71637. * For an example of a color LUT, see here:
  71638. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  71639. * For explanations on color grading, see here:
  71640. * @see http://udn.epicgames.com/Three/ColorGrading.html
  71641. *
  71642. */
  71643. export class ColorCorrectionPostProcess extends PostProcess {
  71644. private _colorTableTexture;
  71645. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71646. }
  71647. }
  71648. declare module "babylonjs/Shaders/convolution.fragment" {
  71649. /** @hidden */
  71650. export var convolutionPixelShader: {
  71651. name: string;
  71652. shader: string;
  71653. };
  71654. }
  71655. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  71656. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71657. import { Nullable } from "babylonjs/types";
  71658. import { Camera } from "babylonjs/Cameras/camera";
  71659. import { Engine } from "babylonjs/Engines/engine";
  71660. import "babylonjs/Shaders/convolution.fragment";
  71661. /**
  71662. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  71663. * input texture to perform effects such as edge detection or sharpening
  71664. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71665. */
  71666. export class ConvolutionPostProcess extends PostProcess {
  71667. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71668. kernel: number[];
  71669. /**
  71670. * Creates a new instance ConvolutionPostProcess
  71671. * @param name The name of the effect.
  71672. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  71673. * @param options The required width/height ratio to downsize to before computing the render pass.
  71674. * @param camera The camera to apply the render pass to.
  71675. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71676. * @param engine The engine which the post process will be applied. (default: current engine)
  71677. * @param reusable If the post process can be reused on the same frame. (default: false)
  71678. * @param textureType Type of textures used when performing the post process. (default: 0)
  71679. */
  71680. constructor(name: string,
  71681. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71682. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71683. /**
  71684. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71685. */
  71686. static EdgeDetect0Kernel: number[];
  71687. /**
  71688. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71689. */
  71690. static EdgeDetect1Kernel: number[];
  71691. /**
  71692. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71693. */
  71694. static EdgeDetect2Kernel: number[];
  71695. /**
  71696. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71697. */
  71698. static SharpenKernel: number[];
  71699. /**
  71700. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71701. */
  71702. static EmbossKernel: number[];
  71703. /**
  71704. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71705. */
  71706. static GaussianKernel: number[];
  71707. }
  71708. }
  71709. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  71710. import { Nullable } from "babylonjs/types";
  71711. import { Vector2 } from "babylonjs/Maths/math.vector";
  71712. import { Camera } from "babylonjs/Cameras/camera";
  71713. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71714. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  71715. import { Engine } from "babylonjs/Engines/engine";
  71716. import { Scene } from "babylonjs/scene";
  71717. /**
  71718. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  71719. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  71720. * based on samples that have a large difference in distance than the center pixel.
  71721. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  71722. */
  71723. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  71724. direction: Vector2;
  71725. /**
  71726. * Creates a new instance CircleOfConfusionPostProcess
  71727. * @param name The name of the effect.
  71728. * @param scene The scene the effect belongs to.
  71729. * @param direction The direction the blur should be applied.
  71730. * @param kernel The size of the kernel used to blur.
  71731. * @param options The required width/height ratio to downsize to before computing the render pass.
  71732. * @param camera The camera to apply the render pass to.
  71733. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  71734. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  71735. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71736. * @param engine The engine which the post process will be applied. (default: current engine)
  71737. * @param reusable If the post process can be reused on the same frame. (default: false)
  71738. * @param textureType Type of textures used when performing the post process. (default: 0)
  71739. * @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)
  71740. */
  71741. 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);
  71742. }
  71743. }
  71744. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  71745. /** @hidden */
  71746. export var depthOfFieldMergePixelShader: {
  71747. name: string;
  71748. shader: string;
  71749. };
  71750. }
  71751. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  71752. import { Nullable } from "babylonjs/types";
  71753. import { Camera } from "babylonjs/Cameras/camera";
  71754. import { Effect } from "babylonjs/Materials/effect";
  71755. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71756. import { Engine } from "babylonjs/Engines/engine";
  71757. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  71758. /**
  71759. * Options to be set when merging outputs from the default pipeline.
  71760. */
  71761. export class DepthOfFieldMergePostProcessOptions {
  71762. /**
  71763. * The original image to merge on top of
  71764. */
  71765. originalFromInput: PostProcess;
  71766. /**
  71767. * Parameters to perform the merge of the depth of field effect
  71768. */
  71769. depthOfField?: {
  71770. circleOfConfusion: PostProcess;
  71771. blurSteps: Array<PostProcess>;
  71772. };
  71773. /**
  71774. * Parameters to perform the merge of bloom effect
  71775. */
  71776. bloom?: {
  71777. blurred: PostProcess;
  71778. weight: number;
  71779. };
  71780. }
  71781. /**
  71782. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71783. */
  71784. export class DepthOfFieldMergePostProcess extends PostProcess {
  71785. private blurSteps;
  71786. /**
  71787. * Creates a new instance of DepthOfFieldMergePostProcess
  71788. * @param name The name of the effect.
  71789. * @param originalFromInput Post process which's input will be used for the merge.
  71790. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  71791. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  71792. * @param options The required width/height ratio to downsize to before computing the render pass.
  71793. * @param camera The camera to apply the render pass to.
  71794. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71795. * @param engine The engine which the post process will be applied. (default: current engine)
  71796. * @param reusable If the post process can be reused on the same frame. (default: false)
  71797. * @param textureType Type of textures used when performing the post process. (default: 0)
  71798. * @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)
  71799. */
  71800. 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);
  71801. /**
  71802. * Updates the effect with the current post process compile time values and recompiles the shader.
  71803. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71804. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71805. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71806. * @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
  71807. * @param onCompiled Called when the shader has been compiled.
  71808. * @param onError Called if there is an error when compiling a shader.
  71809. */
  71810. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71811. }
  71812. }
  71813. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  71814. import { Nullable } from "babylonjs/types";
  71815. import { Camera } from "babylonjs/Cameras/camera";
  71816. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71817. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71818. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71819. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  71820. import { Scene } from "babylonjs/scene";
  71821. /**
  71822. * Specifies the level of max blur that should be applied when using the depth of field effect
  71823. */
  71824. export enum DepthOfFieldEffectBlurLevel {
  71825. /**
  71826. * Subtle blur
  71827. */
  71828. Low = 0,
  71829. /**
  71830. * Medium blur
  71831. */
  71832. Medium = 1,
  71833. /**
  71834. * Large blur
  71835. */
  71836. High = 2
  71837. }
  71838. /**
  71839. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  71840. */
  71841. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  71842. private _circleOfConfusion;
  71843. /**
  71844. * @hidden Internal, blurs from high to low
  71845. */
  71846. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  71847. private _depthOfFieldBlurY;
  71848. private _dofMerge;
  71849. /**
  71850. * @hidden Internal post processes in depth of field effect
  71851. */
  71852. _effects: Array<PostProcess>;
  71853. /**
  71854. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  71855. */
  71856. set focalLength(value: number);
  71857. get focalLength(): number;
  71858. /**
  71859. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71860. */
  71861. set fStop(value: number);
  71862. get fStop(): number;
  71863. /**
  71864. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71865. */
  71866. set focusDistance(value: number);
  71867. get focusDistance(): number;
  71868. /**
  71869. * 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.
  71870. */
  71871. set lensSize(value: number);
  71872. get lensSize(): number;
  71873. /**
  71874. * Creates a new instance DepthOfFieldEffect
  71875. * @param scene The scene the effect belongs to.
  71876. * @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.
  71877. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71878. * @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)
  71879. */
  71880. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  71881. /**
  71882. * Get the current class name of the current effet
  71883. * @returns "DepthOfFieldEffect"
  71884. */
  71885. getClassName(): string;
  71886. /**
  71887. * 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.
  71888. */
  71889. set depthTexture(value: RenderTargetTexture);
  71890. /**
  71891. * Disposes each of the internal effects for a given camera.
  71892. * @param camera The camera to dispose the effect on.
  71893. */
  71894. disposeEffects(camera: Camera): void;
  71895. /**
  71896. * @hidden Internal
  71897. */
  71898. _updateEffects(): void;
  71899. /**
  71900. * Internal
  71901. * @returns if all the contained post processes are ready.
  71902. * @hidden
  71903. */
  71904. _isReady(): boolean;
  71905. }
  71906. }
  71907. declare module "babylonjs/Shaders/displayPass.fragment" {
  71908. /** @hidden */
  71909. export var displayPassPixelShader: {
  71910. name: string;
  71911. shader: string;
  71912. };
  71913. }
  71914. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  71915. import { Nullable } from "babylonjs/types";
  71916. import { Camera } from "babylonjs/Cameras/camera";
  71917. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71918. import { Engine } from "babylonjs/Engines/engine";
  71919. import "babylonjs/Shaders/displayPass.fragment";
  71920. /**
  71921. * DisplayPassPostProcess which produces an output the same as it's input
  71922. */
  71923. export class DisplayPassPostProcess extends PostProcess {
  71924. /**
  71925. * Creates the DisplayPassPostProcess
  71926. * @param name The name of the effect.
  71927. * @param options The required width/height ratio to downsize to before computing the render pass.
  71928. * @param camera The camera to apply the render pass to.
  71929. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71930. * @param engine The engine which the post process will be applied. (default: current engine)
  71931. * @param reusable If the post process can be reused on the same frame. (default: false)
  71932. */
  71933. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71934. }
  71935. }
  71936. declare module "babylonjs/Shaders/filter.fragment" {
  71937. /** @hidden */
  71938. export var filterPixelShader: {
  71939. name: string;
  71940. shader: string;
  71941. };
  71942. }
  71943. declare module "babylonjs/PostProcesses/filterPostProcess" {
  71944. import { Nullable } from "babylonjs/types";
  71945. import { Matrix } from "babylonjs/Maths/math.vector";
  71946. import { Camera } from "babylonjs/Cameras/camera";
  71947. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71948. import { Engine } from "babylonjs/Engines/engine";
  71949. import "babylonjs/Shaders/filter.fragment";
  71950. /**
  71951. * Applies a kernel filter to the image
  71952. */
  71953. export class FilterPostProcess extends PostProcess {
  71954. /** The matrix to be applied to the image */
  71955. kernelMatrix: Matrix;
  71956. /**
  71957. *
  71958. * @param name The name of the effect.
  71959. * @param kernelMatrix The matrix to be applied to the image
  71960. * @param options The required width/height ratio to downsize to before computing the render pass.
  71961. * @param camera The camera to apply the render pass to.
  71962. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71963. * @param engine The engine which the post process will be applied. (default: current engine)
  71964. * @param reusable If the post process can be reused on the same frame. (default: false)
  71965. */
  71966. constructor(name: string,
  71967. /** The matrix to be applied to the image */
  71968. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71969. }
  71970. }
  71971. declare module "babylonjs/Shaders/fxaa.fragment" {
  71972. /** @hidden */
  71973. export var fxaaPixelShader: {
  71974. name: string;
  71975. shader: string;
  71976. };
  71977. }
  71978. declare module "babylonjs/Shaders/fxaa.vertex" {
  71979. /** @hidden */
  71980. export var fxaaVertexShader: {
  71981. name: string;
  71982. shader: string;
  71983. };
  71984. }
  71985. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  71986. import { Nullable } from "babylonjs/types";
  71987. import { Camera } from "babylonjs/Cameras/camera";
  71988. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71989. import { Engine } from "babylonjs/Engines/engine";
  71990. import "babylonjs/Shaders/fxaa.fragment";
  71991. import "babylonjs/Shaders/fxaa.vertex";
  71992. /**
  71993. * Fxaa post process
  71994. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  71995. */
  71996. export class FxaaPostProcess extends PostProcess {
  71997. /** @hidden */
  71998. texelWidth: number;
  71999. /** @hidden */
  72000. texelHeight: number;
  72001. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72002. private _getDefines;
  72003. }
  72004. }
  72005. declare module "babylonjs/Shaders/grain.fragment" {
  72006. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72007. /** @hidden */
  72008. export var grainPixelShader: {
  72009. name: string;
  72010. shader: string;
  72011. };
  72012. }
  72013. declare module "babylonjs/PostProcesses/grainPostProcess" {
  72014. import { Nullable } from "babylonjs/types";
  72015. import { Camera } from "babylonjs/Cameras/camera";
  72016. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72017. import { Engine } from "babylonjs/Engines/engine";
  72018. import "babylonjs/Shaders/grain.fragment";
  72019. /**
  72020. * The GrainPostProcess adds noise to the image at mid luminance levels
  72021. */
  72022. export class GrainPostProcess extends PostProcess {
  72023. /**
  72024. * The intensity of the grain added (default: 30)
  72025. */
  72026. intensity: number;
  72027. /**
  72028. * If the grain should be randomized on every frame
  72029. */
  72030. animated: boolean;
  72031. /**
  72032. * Creates a new instance of @see GrainPostProcess
  72033. * @param name The name of the effect.
  72034. * @param options The required width/height ratio to downsize to before computing the render pass.
  72035. * @param camera The camera to apply the render pass to.
  72036. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72037. * @param engine The engine which the post process will be applied. (default: current engine)
  72038. * @param reusable If the post process can be reused on the same frame. (default: false)
  72039. * @param textureType Type of textures used when performing the post process. (default: 0)
  72040. * @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)
  72041. */
  72042. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72043. }
  72044. }
  72045. declare module "babylonjs/Shaders/highlights.fragment" {
  72046. /** @hidden */
  72047. export var highlightsPixelShader: {
  72048. name: string;
  72049. shader: string;
  72050. };
  72051. }
  72052. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  72053. import { Nullable } from "babylonjs/types";
  72054. import { Camera } from "babylonjs/Cameras/camera";
  72055. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72056. import { Engine } from "babylonjs/Engines/engine";
  72057. import "babylonjs/Shaders/highlights.fragment";
  72058. /**
  72059. * Extracts highlights from the image
  72060. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72061. */
  72062. export class HighlightsPostProcess extends PostProcess {
  72063. /**
  72064. * Extracts highlights from the image
  72065. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72066. * @param name The name of the effect.
  72067. * @param options The required width/height ratio to downsize to before computing the render pass.
  72068. * @param camera The camera to apply the render pass to.
  72069. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72070. * @param engine The engine which the post process will be applied. (default: current engine)
  72071. * @param reusable If the post process can be reused on the same frame. (default: false)
  72072. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  72073. */
  72074. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72075. }
  72076. }
  72077. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  72078. /** @hidden */
  72079. export var mrtFragmentDeclaration: {
  72080. name: string;
  72081. shader: string;
  72082. };
  72083. }
  72084. declare module "babylonjs/Shaders/geometry.fragment" {
  72085. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  72086. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  72087. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  72088. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  72089. /** @hidden */
  72090. export var geometryPixelShader: {
  72091. name: string;
  72092. shader: string;
  72093. };
  72094. }
  72095. declare module "babylonjs/Shaders/geometry.vertex" {
  72096. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72097. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72098. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72099. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72100. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72101. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72102. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72103. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  72104. /** @hidden */
  72105. export var geometryVertexShader: {
  72106. name: string;
  72107. shader: string;
  72108. };
  72109. }
  72110. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  72111. import { Matrix } from "babylonjs/Maths/math.vector";
  72112. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72113. import { Mesh } from "babylonjs/Meshes/mesh";
  72114. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  72115. import { Effect } from "babylonjs/Materials/effect";
  72116. import { Scene } from "babylonjs/scene";
  72117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72118. import "babylonjs/Shaders/geometry.fragment";
  72119. import "babylonjs/Shaders/geometry.vertex";
  72120. /** @hidden */
  72121. interface ISavedTransformationMatrix {
  72122. world: Matrix;
  72123. viewProjection: Matrix;
  72124. }
  72125. /**
  72126. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  72127. */
  72128. export class GeometryBufferRenderer {
  72129. /**
  72130. * Constant used to retrieve the position texture index in the G-Buffer textures array
  72131. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  72132. */
  72133. static readonly POSITION_TEXTURE_TYPE: number;
  72134. /**
  72135. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  72136. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  72137. */
  72138. static readonly VELOCITY_TEXTURE_TYPE: number;
  72139. /**
  72140. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  72141. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  72142. */
  72143. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  72144. /**
  72145. * Dictionary used to store the previous transformation matrices of each rendered mesh
  72146. * in order to compute objects velocities when enableVelocity is set to "true"
  72147. * @hidden
  72148. */
  72149. _previousTransformationMatrices: {
  72150. [index: number]: ISavedTransformationMatrix;
  72151. };
  72152. /**
  72153. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  72154. * in order to compute objects velocities when enableVelocity is set to "true"
  72155. * @hidden
  72156. */
  72157. _previousBonesTransformationMatrices: {
  72158. [index: number]: Float32Array;
  72159. };
  72160. /**
  72161. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  72162. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  72163. */
  72164. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  72165. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  72166. renderTransparentMeshes: boolean;
  72167. private _scene;
  72168. private _multiRenderTarget;
  72169. private _ratio;
  72170. private _enablePosition;
  72171. private _enableVelocity;
  72172. private _enableReflectivity;
  72173. private _positionIndex;
  72174. private _velocityIndex;
  72175. private _reflectivityIndex;
  72176. protected _effect: Effect;
  72177. protected _cachedDefines: string;
  72178. /**
  72179. * Set the render list (meshes to be rendered) used in the G buffer.
  72180. */
  72181. set renderList(meshes: Mesh[]);
  72182. /**
  72183. * Gets wether or not G buffer are supported by the running hardware.
  72184. * This requires draw buffer supports
  72185. */
  72186. get isSupported(): boolean;
  72187. /**
  72188. * Returns the index of the given texture type in the G-Buffer textures array
  72189. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  72190. * @returns the index of the given texture type in the G-Buffer textures array
  72191. */
  72192. getTextureIndex(textureType: number): number;
  72193. /**
  72194. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  72195. */
  72196. get enablePosition(): boolean;
  72197. /**
  72198. * Sets whether or not objects positions are enabled for the G buffer.
  72199. */
  72200. set enablePosition(enable: boolean);
  72201. /**
  72202. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  72203. */
  72204. get enableVelocity(): boolean;
  72205. /**
  72206. * Sets wether or not objects velocities are enabled for the G buffer.
  72207. */
  72208. set enableVelocity(enable: boolean);
  72209. /**
  72210. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  72211. */
  72212. get enableReflectivity(): boolean;
  72213. /**
  72214. * Sets wether or not objects roughness are enabled for the G buffer.
  72215. */
  72216. set enableReflectivity(enable: boolean);
  72217. /**
  72218. * Gets the scene associated with the buffer.
  72219. */
  72220. get scene(): Scene;
  72221. /**
  72222. * Gets the ratio used by the buffer during its creation.
  72223. * How big is the buffer related to the main canvas.
  72224. */
  72225. get ratio(): number;
  72226. /** @hidden */
  72227. static _SceneComponentInitialization: (scene: Scene) => void;
  72228. /**
  72229. * Creates a new G Buffer for the scene
  72230. * @param scene The scene the buffer belongs to
  72231. * @param ratio How big is the buffer related to the main canvas.
  72232. */
  72233. constructor(scene: Scene, ratio?: number);
  72234. /**
  72235. * Checks wether everything is ready to render a submesh to the G buffer.
  72236. * @param subMesh the submesh to check readiness for
  72237. * @param useInstances is the mesh drawn using instance or not
  72238. * @returns true if ready otherwise false
  72239. */
  72240. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72241. /**
  72242. * Gets the current underlying G Buffer.
  72243. * @returns the buffer
  72244. */
  72245. getGBuffer(): MultiRenderTarget;
  72246. /**
  72247. * Gets the number of samples used to render the buffer (anti aliasing).
  72248. */
  72249. get samples(): number;
  72250. /**
  72251. * Sets the number of samples used to render the buffer (anti aliasing).
  72252. */
  72253. set samples(value: number);
  72254. /**
  72255. * Disposes the renderer and frees up associated resources.
  72256. */
  72257. dispose(): void;
  72258. protected _createRenderTargets(): void;
  72259. private _copyBonesTransformationMatrices;
  72260. }
  72261. }
  72262. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  72263. import { Nullable } from "babylonjs/types";
  72264. import { Scene } from "babylonjs/scene";
  72265. import { ISceneComponent } from "babylonjs/sceneComponent";
  72266. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  72267. module "babylonjs/scene" {
  72268. interface Scene {
  72269. /** @hidden (Backing field) */
  72270. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72271. /**
  72272. * Gets or Sets the current geometry buffer associated to the scene.
  72273. */
  72274. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72275. /**
  72276. * Enables a GeometryBufferRender and associates it with the scene
  72277. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  72278. * @returns the GeometryBufferRenderer
  72279. */
  72280. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  72281. /**
  72282. * Disables the GeometryBufferRender associated with the scene
  72283. */
  72284. disableGeometryBufferRenderer(): void;
  72285. }
  72286. }
  72287. /**
  72288. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72289. * in several rendering techniques.
  72290. */
  72291. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  72292. /**
  72293. * The component name helpful to identify the component in the list of scene components.
  72294. */
  72295. readonly name: string;
  72296. /**
  72297. * The scene the component belongs to.
  72298. */
  72299. scene: Scene;
  72300. /**
  72301. * Creates a new instance of the component for the given scene
  72302. * @param scene Defines the scene to register the component in
  72303. */
  72304. constructor(scene: Scene);
  72305. /**
  72306. * Registers the component in a given scene
  72307. */
  72308. register(): void;
  72309. /**
  72310. * Rebuilds the elements related to this component in case of
  72311. * context lost for instance.
  72312. */
  72313. rebuild(): void;
  72314. /**
  72315. * Disposes the component and the associated ressources
  72316. */
  72317. dispose(): void;
  72318. private _gatherRenderTargets;
  72319. }
  72320. }
  72321. declare module "babylonjs/Shaders/motionBlur.fragment" {
  72322. /** @hidden */
  72323. export var motionBlurPixelShader: {
  72324. name: string;
  72325. shader: string;
  72326. };
  72327. }
  72328. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  72329. import { Nullable } from "babylonjs/types";
  72330. import { Camera } from "babylonjs/Cameras/camera";
  72331. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72332. import { Scene } from "babylonjs/scene";
  72333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72334. import "babylonjs/Animations/animatable";
  72335. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  72336. import "babylonjs/Shaders/motionBlur.fragment";
  72337. import { Engine } from "babylonjs/Engines/engine";
  72338. /**
  72339. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  72340. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  72341. * As an example, all you have to do is to create the post-process:
  72342. * var mb = new BABYLON.MotionBlurPostProcess(
  72343. * 'mb', // The name of the effect.
  72344. * scene, // The scene containing the objects to blur according to their velocity.
  72345. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  72346. * camera // The camera to apply the render pass to.
  72347. * );
  72348. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  72349. */
  72350. export class MotionBlurPostProcess extends PostProcess {
  72351. /**
  72352. * Defines how much the image is blurred by the movement. Default value is equal to 1
  72353. */
  72354. motionStrength: number;
  72355. /**
  72356. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  72357. */
  72358. get motionBlurSamples(): number;
  72359. /**
  72360. * Sets the number of iterations to be used for motion blur quality
  72361. */
  72362. set motionBlurSamples(samples: number);
  72363. private _motionBlurSamples;
  72364. private _geometryBufferRenderer;
  72365. /**
  72366. * Creates a new instance MotionBlurPostProcess
  72367. * @param name The name of the effect.
  72368. * @param scene The scene containing the objects to blur according to their velocity.
  72369. * @param options The required width/height ratio to downsize to before computing the render pass.
  72370. * @param camera The camera to apply the render pass to.
  72371. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72372. * @param engine The engine which the post process will be applied. (default: current engine)
  72373. * @param reusable If the post process can be reused on the same frame. (default: false)
  72374. * @param textureType Type of textures used when performing the post process. (default: 0)
  72375. * @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)
  72376. */
  72377. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72378. /**
  72379. * Excludes the given skinned mesh from computing bones velocities.
  72380. * 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.
  72381. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  72382. */
  72383. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72384. /**
  72385. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  72386. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  72387. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  72388. */
  72389. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72390. /**
  72391. * Disposes the post process.
  72392. * @param camera The camera to dispose the post process on.
  72393. */
  72394. dispose(camera?: Camera): void;
  72395. }
  72396. }
  72397. declare module "babylonjs/Shaders/refraction.fragment" {
  72398. /** @hidden */
  72399. export var refractionPixelShader: {
  72400. name: string;
  72401. shader: string;
  72402. };
  72403. }
  72404. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  72405. import { Color3 } from "babylonjs/Maths/math.color";
  72406. import { Camera } from "babylonjs/Cameras/camera";
  72407. import { Texture } from "babylonjs/Materials/Textures/texture";
  72408. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72409. import { Engine } from "babylonjs/Engines/engine";
  72410. import "babylonjs/Shaders/refraction.fragment";
  72411. /**
  72412. * Post process which applies a refractin texture
  72413. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72414. */
  72415. export class RefractionPostProcess extends PostProcess {
  72416. /** the base color of the refraction (used to taint the rendering) */
  72417. color: Color3;
  72418. /** simulated refraction depth */
  72419. depth: number;
  72420. /** the coefficient of the base color (0 to remove base color tainting) */
  72421. colorLevel: number;
  72422. private _refTexture;
  72423. private _ownRefractionTexture;
  72424. /**
  72425. * Gets or sets the refraction texture
  72426. * Please note that you are responsible for disposing the texture if you set it manually
  72427. */
  72428. get refractionTexture(): Texture;
  72429. set refractionTexture(value: Texture);
  72430. /**
  72431. * Initializes the RefractionPostProcess
  72432. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72433. * @param name The name of the effect.
  72434. * @param refractionTextureUrl Url of the refraction texture to use
  72435. * @param color the base color of the refraction (used to taint the rendering)
  72436. * @param depth simulated refraction depth
  72437. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  72438. * @param camera The camera to apply the render pass to.
  72439. * @param options The required width/height ratio to downsize to before computing the render pass.
  72440. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72441. * @param engine The engine which the post process will be applied. (default: current engine)
  72442. * @param reusable If the post process can be reused on the same frame. (default: false)
  72443. */
  72444. constructor(name: string, refractionTextureUrl: string,
  72445. /** the base color of the refraction (used to taint the rendering) */
  72446. color: Color3,
  72447. /** simulated refraction depth */
  72448. depth: number,
  72449. /** the coefficient of the base color (0 to remove base color tainting) */
  72450. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72451. /**
  72452. * Disposes of the post process
  72453. * @param camera Camera to dispose post process on
  72454. */
  72455. dispose(camera: Camera): void;
  72456. }
  72457. }
  72458. declare module "babylonjs/Shaders/sharpen.fragment" {
  72459. /** @hidden */
  72460. export var sharpenPixelShader: {
  72461. name: string;
  72462. shader: string;
  72463. };
  72464. }
  72465. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  72466. import { Nullable } from "babylonjs/types";
  72467. import { Camera } from "babylonjs/Cameras/camera";
  72468. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72469. import "babylonjs/Shaders/sharpen.fragment";
  72470. import { Engine } from "babylonjs/Engines/engine";
  72471. /**
  72472. * The SharpenPostProcess applies a sharpen kernel to every pixel
  72473. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72474. */
  72475. export class SharpenPostProcess extends PostProcess {
  72476. /**
  72477. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  72478. */
  72479. colorAmount: number;
  72480. /**
  72481. * How much sharpness should be applied (default: 0.3)
  72482. */
  72483. edgeAmount: number;
  72484. /**
  72485. * Creates a new instance ConvolutionPostProcess
  72486. * @param name The name of the effect.
  72487. * @param options The required width/height ratio to downsize to before computing the render pass.
  72488. * @param camera The camera to apply the render pass to.
  72489. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72490. * @param engine The engine which the post process will be applied. (default: current engine)
  72491. * @param reusable If the post process can be reused on the same frame. (default: false)
  72492. * @param textureType Type of textures used when performing the post process. (default: 0)
  72493. * @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)
  72494. */
  72495. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72496. }
  72497. }
  72498. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  72499. import { Nullable } from "babylonjs/types";
  72500. import { Camera } from "babylonjs/Cameras/camera";
  72501. import { Engine } from "babylonjs/Engines/engine";
  72502. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72503. import { IInspectable } from "babylonjs/Misc/iInspectable";
  72504. /**
  72505. * PostProcessRenderPipeline
  72506. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72507. */
  72508. export class PostProcessRenderPipeline {
  72509. private engine;
  72510. private _renderEffects;
  72511. private _renderEffectsForIsolatedPass;
  72512. /**
  72513. * List of inspectable custom properties (used by the Inspector)
  72514. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72515. */
  72516. inspectableCustomProperties: IInspectable[];
  72517. /**
  72518. * @hidden
  72519. */
  72520. protected _cameras: Camera[];
  72521. /** @hidden */
  72522. _name: string;
  72523. /**
  72524. * Gets pipeline name
  72525. */
  72526. get name(): string;
  72527. /** Gets the list of attached cameras */
  72528. get cameras(): Camera[];
  72529. /**
  72530. * Initializes a PostProcessRenderPipeline
  72531. * @param engine engine to add the pipeline to
  72532. * @param name name of the pipeline
  72533. */
  72534. constructor(engine: Engine, name: string);
  72535. /**
  72536. * Gets the class name
  72537. * @returns "PostProcessRenderPipeline"
  72538. */
  72539. getClassName(): string;
  72540. /**
  72541. * If all the render effects in the pipeline are supported
  72542. */
  72543. get isSupported(): boolean;
  72544. /**
  72545. * Adds an effect to the pipeline
  72546. * @param renderEffect the effect to add
  72547. */
  72548. addEffect(renderEffect: PostProcessRenderEffect): void;
  72549. /** @hidden */
  72550. _rebuild(): void;
  72551. /** @hidden */
  72552. _enableEffect(renderEffectName: string, cameras: Camera): void;
  72553. /** @hidden */
  72554. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  72555. /** @hidden */
  72556. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72557. /** @hidden */
  72558. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72559. /** @hidden */
  72560. _attachCameras(cameras: Camera, unique: boolean): void;
  72561. /** @hidden */
  72562. _attachCameras(cameras: Camera[], unique: boolean): void;
  72563. /** @hidden */
  72564. _detachCameras(cameras: Camera): void;
  72565. /** @hidden */
  72566. _detachCameras(cameras: Nullable<Camera[]>): void;
  72567. /** @hidden */
  72568. _update(): void;
  72569. /** @hidden */
  72570. _reset(): void;
  72571. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  72572. /**
  72573. * Disposes of the pipeline
  72574. */
  72575. dispose(): void;
  72576. }
  72577. }
  72578. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  72579. import { Camera } from "babylonjs/Cameras/camera";
  72580. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72581. /**
  72582. * PostProcessRenderPipelineManager class
  72583. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72584. */
  72585. export class PostProcessRenderPipelineManager {
  72586. private _renderPipelines;
  72587. /**
  72588. * Initializes a PostProcessRenderPipelineManager
  72589. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72590. */
  72591. constructor();
  72592. /**
  72593. * Gets the list of supported render pipelines
  72594. */
  72595. get supportedPipelines(): PostProcessRenderPipeline[];
  72596. /**
  72597. * Adds a pipeline to the manager
  72598. * @param renderPipeline The pipeline to add
  72599. */
  72600. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  72601. /**
  72602. * Attaches a camera to the pipeline
  72603. * @param renderPipelineName The name of the pipeline to attach to
  72604. * @param cameras the camera to attach
  72605. * @param unique if the camera can be attached multiple times to the pipeline
  72606. */
  72607. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  72608. /**
  72609. * Detaches a camera from the pipeline
  72610. * @param renderPipelineName The name of the pipeline to detach from
  72611. * @param cameras the camera to detach
  72612. */
  72613. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  72614. /**
  72615. * Enables an effect by name on a pipeline
  72616. * @param renderPipelineName the name of the pipeline to enable the effect in
  72617. * @param renderEffectName the name of the effect to enable
  72618. * @param cameras the cameras that the effect should be enabled on
  72619. */
  72620. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72621. /**
  72622. * Disables an effect by name on a pipeline
  72623. * @param renderPipelineName the name of the pipeline to disable the effect in
  72624. * @param renderEffectName the name of the effect to disable
  72625. * @param cameras the cameras that the effect should be disabled on
  72626. */
  72627. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72628. /**
  72629. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  72630. */
  72631. update(): void;
  72632. /** @hidden */
  72633. _rebuild(): void;
  72634. /**
  72635. * Disposes of the manager and pipelines
  72636. */
  72637. dispose(): void;
  72638. }
  72639. }
  72640. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  72641. import { ISceneComponent } from "babylonjs/sceneComponent";
  72642. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  72643. import { Scene } from "babylonjs/scene";
  72644. module "babylonjs/scene" {
  72645. interface Scene {
  72646. /** @hidden (Backing field) */
  72647. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72648. /**
  72649. * Gets the postprocess render pipeline manager
  72650. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72651. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72652. */
  72653. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72654. }
  72655. }
  72656. /**
  72657. * Defines the Render Pipeline scene component responsible to rendering pipelines
  72658. */
  72659. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  72660. /**
  72661. * The component name helpfull to identify the component in the list of scene components.
  72662. */
  72663. readonly name: string;
  72664. /**
  72665. * The scene the component belongs to.
  72666. */
  72667. scene: Scene;
  72668. /**
  72669. * Creates a new instance of the component for the given scene
  72670. * @param scene Defines the scene to register the component in
  72671. */
  72672. constructor(scene: Scene);
  72673. /**
  72674. * Registers the component in a given scene
  72675. */
  72676. register(): void;
  72677. /**
  72678. * Rebuilds the elements related to this component in case of
  72679. * context lost for instance.
  72680. */
  72681. rebuild(): void;
  72682. /**
  72683. * Disposes the component and the associated ressources
  72684. */
  72685. dispose(): void;
  72686. private _gatherRenderTargets;
  72687. }
  72688. }
  72689. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  72690. import { Nullable } from "babylonjs/types";
  72691. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72692. import { Camera } from "babylonjs/Cameras/camera";
  72693. import { IDisposable } from "babylonjs/scene";
  72694. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  72695. import { Scene } from "babylonjs/scene";
  72696. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  72697. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  72698. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  72699. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  72700. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  72701. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72702. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  72703. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72704. import { Animation } from "babylonjs/Animations/animation";
  72705. /**
  72706. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  72707. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72708. */
  72709. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72710. private _scene;
  72711. private _camerasToBeAttached;
  72712. /**
  72713. * ID of the sharpen post process,
  72714. */
  72715. private readonly SharpenPostProcessId;
  72716. /**
  72717. * @ignore
  72718. * ID of the image processing post process;
  72719. */
  72720. readonly ImageProcessingPostProcessId: string;
  72721. /**
  72722. * @ignore
  72723. * ID of the Fast Approximate Anti-Aliasing post process;
  72724. */
  72725. readonly FxaaPostProcessId: string;
  72726. /**
  72727. * ID of the chromatic aberration post process,
  72728. */
  72729. private readonly ChromaticAberrationPostProcessId;
  72730. /**
  72731. * ID of the grain post process
  72732. */
  72733. private readonly GrainPostProcessId;
  72734. /**
  72735. * Sharpen post process which will apply a sharpen convolution to enhance edges
  72736. */
  72737. sharpen: SharpenPostProcess;
  72738. private _sharpenEffect;
  72739. private bloom;
  72740. /**
  72741. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  72742. */
  72743. depthOfField: DepthOfFieldEffect;
  72744. /**
  72745. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72746. */
  72747. fxaa: FxaaPostProcess;
  72748. /**
  72749. * Image post processing pass used to perform operations such as tone mapping or color grading.
  72750. */
  72751. imageProcessing: ImageProcessingPostProcess;
  72752. /**
  72753. * Chromatic aberration post process which will shift rgb colors in the image
  72754. */
  72755. chromaticAberration: ChromaticAberrationPostProcess;
  72756. private _chromaticAberrationEffect;
  72757. /**
  72758. * Grain post process which add noise to the image
  72759. */
  72760. grain: GrainPostProcess;
  72761. private _grainEffect;
  72762. /**
  72763. * Glow post process which adds a glow to emissive areas of the image
  72764. */
  72765. private _glowLayer;
  72766. /**
  72767. * Animations which can be used to tweak settings over a period of time
  72768. */
  72769. animations: Animation[];
  72770. private _imageProcessingConfigurationObserver;
  72771. private _sharpenEnabled;
  72772. private _bloomEnabled;
  72773. private _depthOfFieldEnabled;
  72774. private _depthOfFieldBlurLevel;
  72775. private _fxaaEnabled;
  72776. private _imageProcessingEnabled;
  72777. private _defaultPipelineTextureType;
  72778. private _bloomScale;
  72779. private _chromaticAberrationEnabled;
  72780. private _grainEnabled;
  72781. private _buildAllowed;
  72782. /**
  72783. * Gets active scene
  72784. */
  72785. get scene(): Scene;
  72786. /**
  72787. * Enable or disable the sharpen process from the pipeline
  72788. */
  72789. set sharpenEnabled(enabled: boolean);
  72790. get sharpenEnabled(): boolean;
  72791. private _resizeObserver;
  72792. private _hardwareScaleLevel;
  72793. private _bloomKernel;
  72794. /**
  72795. * Specifies the size of the bloom blur kernel, relative to the final output size
  72796. */
  72797. get bloomKernel(): number;
  72798. set bloomKernel(value: number);
  72799. /**
  72800. * Specifies the weight of the bloom in the final rendering
  72801. */
  72802. private _bloomWeight;
  72803. /**
  72804. * Specifies the luma threshold for the area that will be blurred by the bloom
  72805. */
  72806. private _bloomThreshold;
  72807. private _hdr;
  72808. /**
  72809. * The strength of the bloom.
  72810. */
  72811. set bloomWeight(value: number);
  72812. get bloomWeight(): number;
  72813. /**
  72814. * The strength of the bloom.
  72815. */
  72816. set bloomThreshold(value: number);
  72817. get bloomThreshold(): number;
  72818. /**
  72819. * The scale of the bloom, lower value will provide better performance.
  72820. */
  72821. set bloomScale(value: number);
  72822. get bloomScale(): number;
  72823. /**
  72824. * Enable or disable the bloom from the pipeline
  72825. */
  72826. set bloomEnabled(enabled: boolean);
  72827. get bloomEnabled(): boolean;
  72828. private _rebuildBloom;
  72829. /**
  72830. * If the depth of field is enabled.
  72831. */
  72832. get depthOfFieldEnabled(): boolean;
  72833. set depthOfFieldEnabled(enabled: boolean);
  72834. /**
  72835. * Blur level of the depth of field effect. (Higher blur will effect performance)
  72836. */
  72837. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  72838. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  72839. /**
  72840. * If the anti aliasing is enabled.
  72841. */
  72842. set fxaaEnabled(enabled: boolean);
  72843. get fxaaEnabled(): boolean;
  72844. private _samples;
  72845. /**
  72846. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72847. */
  72848. set samples(sampleCount: number);
  72849. get samples(): number;
  72850. /**
  72851. * If image processing is enabled.
  72852. */
  72853. set imageProcessingEnabled(enabled: boolean);
  72854. get imageProcessingEnabled(): boolean;
  72855. /**
  72856. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  72857. */
  72858. set glowLayerEnabled(enabled: boolean);
  72859. get glowLayerEnabled(): boolean;
  72860. /**
  72861. * Gets the glow layer (or null if not defined)
  72862. */
  72863. get glowLayer(): Nullable<GlowLayer>;
  72864. /**
  72865. * Enable or disable the chromaticAberration process from the pipeline
  72866. */
  72867. set chromaticAberrationEnabled(enabled: boolean);
  72868. get chromaticAberrationEnabled(): boolean;
  72869. /**
  72870. * Enable or disable the grain process from the pipeline
  72871. */
  72872. set grainEnabled(enabled: boolean);
  72873. get grainEnabled(): boolean;
  72874. /**
  72875. * @constructor
  72876. * @param name - The rendering pipeline name (default: "")
  72877. * @param hdr - If high dynamic range textures should be used (default: true)
  72878. * @param scene - The scene linked to this pipeline (default: the last created scene)
  72879. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  72880. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  72881. */
  72882. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  72883. /**
  72884. * Get the class name
  72885. * @returns "DefaultRenderingPipeline"
  72886. */
  72887. getClassName(): string;
  72888. /**
  72889. * Force the compilation of the entire pipeline.
  72890. */
  72891. prepare(): void;
  72892. private _hasCleared;
  72893. private _prevPostProcess;
  72894. private _prevPrevPostProcess;
  72895. private _setAutoClearAndTextureSharing;
  72896. private _depthOfFieldSceneObserver;
  72897. private _buildPipeline;
  72898. private _disposePostProcesses;
  72899. /**
  72900. * Adds a camera to the pipeline
  72901. * @param camera the camera to be added
  72902. */
  72903. addCamera(camera: Camera): void;
  72904. /**
  72905. * Removes a camera from the pipeline
  72906. * @param camera the camera to remove
  72907. */
  72908. removeCamera(camera: Camera): void;
  72909. /**
  72910. * Dispose of the pipeline and stop all post processes
  72911. */
  72912. dispose(): void;
  72913. /**
  72914. * Serialize the rendering pipeline (Used when exporting)
  72915. * @returns the serialized object
  72916. */
  72917. serialize(): any;
  72918. /**
  72919. * Parse the serialized pipeline
  72920. * @param source Source pipeline.
  72921. * @param scene The scene to load the pipeline to.
  72922. * @param rootUrl The URL of the serialized pipeline.
  72923. * @returns An instantiated pipeline from the serialized object.
  72924. */
  72925. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  72926. }
  72927. }
  72928. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  72929. /** @hidden */
  72930. export var lensHighlightsPixelShader: {
  72931. name: string;
  72932. shader: string;
  72933. };
  72934. }
  72935. declare module "babylonjs/Shaders/depthOfField.fragment" {
  72936. /** @hidden */
  72937. export var depthOfFieldPixelShader: {
  72938. name: string;
  72939. shader: string;
  72940. };
  72941. }
  72942. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  72943. import { Camera } from "babylonjs/Cameras/camera";
  72944. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72945. import { Scene } from "babylonjs/scene";
  72946. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72947. import "babylonjs/Shaders/chromaticAberration.fragment";
  72948. import "babylonjs/Shaders/lensHighlights.fragment";
  72949. import "babylonjs/Shaders/depthOfField.fragment";
  72950. /**
  72951. * BABYLON.JS Chromatic Aberration GLSL Shader
  72952. * Author: Olivier Guyot
  72953. * Separates very slightly R, G and B colors on the edges of the screen
  72954. * Inspired by Francois Tarlier & Martins Upitis
  72955. */
  72956. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  72957. /**
  72958. * @ignore
  72959. * The chromatic aberration PostProcess id in the pipeline
  72960. */
  72961. LensChromaticAberrationEffect: string;
  72962. /**
  72963. * @ignore
  72964. * The highlights enhancing PostProcess id in the pipeline
  72965. */
  72966. HighlightsEnhancingEffect: string;
  72967. /**
  72968. * @ignore
  72969. * The depth-of-field PostProcess id in the pipeline
  72970. */
  72971. LensDepthOfFieldEffect: string;
  72972. private _scene;
  72973. private _depthTexture;
  72974. private _grainTexture;
  72975. private _chromaticAberrationPostProcess;
  72976. private _highlightsPostProcess;
  72977. private _depthOfFieldPostProcess;
  72978. private _edgeBlur;
  72979. private _grainAmount;
  72980. private _chromaticAberration;
  72981. private _distortion;
  72982. private _highlightsGain;
  72983. private _highlightsThreshold;
  72984. private _dofDistance;
  72985. private _dofAperture;
  72986. private _dofDarken;
  72987. private _dofPentagon;
  72988. private _blurNoise;
  72989. /**
  72990. * @constructor
  72991. *
  72992. * Effect parameters are as follow:
  72993. * {
  72994. * chromatic_aberration: number; // from 0 to x (1 for realism)
  72995. * edge_blur: number; // from 0 to x (1 for realism)
  72996. * distortion: number; // from 0 to x (1 for realism)
  72997. * grain_amount: number; // from 0 to 1
  72998. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  72999. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  73000. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  73001. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  73002. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  73003. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  73004. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  73005. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  73006. * }
  73007. * Note: if an effect parameter is unset, effect is disabled
  73008. *
  73009. * @param name The rendering pipeline name
  73010. * @param parameters - An object containing all parameters (see above)
  73011. * @param scene The scene linked to this pipeline
  73012. * @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)
  73013. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73014. */
  73015. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  73016. /**
  73017. * Get the class name
  73018. * @returns "LensRenderingPipeline"
  73019. */
  73020. getClassName(): string;
  73021. /**
  73022. * Gets associated scene
  73023. */
  73024. get scene(): Scene;
  73025. /**
  73026. * Gets or sets the edge blur
  73027. */
  73028. get edgeBlur(): number;
  73029. set edgeBlur(value: number);
  73030. /**
  73031. * Gets or sets the grain amount
  73032. */
  73033. get grainAmount(): number;
  73034. set grainAmount(value: number);
  73035. /**
  73036. * Gets or sets the chromatic aberration amount
  73037. */
  73038. get chromaticAberration(): number;
  73039. set chromaticAberration(value: number);
  73040. /**
  73041. * Gets or sets the depth of field aperture
  73042. */
  73043. get dofAperture(): number;
  73044. set dofAperture(value: number);
  73045. /**
  73046. * Gets or sets the edge distortion
  73047. */
  73048. get edgeDistortion(): number;
  73049. set edgeDistortion(value: number);
  73050. /**
  73051. * Gets or sets the depth of field distortion
  73052. */
  73053. get dofDistortion(): number;
  73054. set dofDistortion(value: number);
  73055. /**
  73056. * Gets or sets the darken out of focus amount
  73057. */
  73058. get darkenOutOfFocus(): number;
  73059. set darkenOutOfFocus(value: number);
  73060. /**
  73061. * Gets or sets a boolean indicating if blur noise is enabled
  73062. */
  73063. get blurNoise(): boolean;
  73064. set blurNoise(value: boolean);
  73065. /**
  73066. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  73067. */
  73068. get pentagonBokeh(): boolean;
  73069. set pentagonBokeh(value: boolean);
  73070. /**
  73071. * Gets or sets the highlight grain amount
  73072. */
  73073. get highlightsGain(): number;
  73074. set highlightsGain(value: number);
  73075. /**
  73076. * Gets or sets the highlight threshold
  73077. */
  73078. get highlightsThreshold(): number;
  73079. set highlightsThreshold(value: number);
  73080. /**
  73081. * Sets the amount of blur at the edges
  73082. * @param amount blur amount
  73083. */
  73084. setEdgeBlur(amount: number): void;
  73085. /**
  73086. * Sets edge blur to 0
  73087. */
  73088. disableEdgeBlur(): void;
  73089. /**
  73090. * Sets the amout of grain
  73091. * @param amount Amount of grain
  73092. */
  73093. setGrainAmount(amount: number): void;
  73094. /**
  73095. * Set grain amount to 0
  73096. */
  73097. disableGrain(): void;
  73098. /**
  73099. * Sets the chromatic aberration amount
  73100. * @param amount amount of chromatic aberration
  73101. */
  73102. setChromaticAberration(amount: number): void;
  73103. /**
  73104. * Sets chromatic aberration amount to 0
  73105. */
  73106. disableChromaticAberration(): void;
  73107. /**
  73108. * Sets the EdgeDistortion amount
  73109. * @param amount amount of EdgeDistortion
  73110. */
  73111. setEdgeDistortion(amount: number): void;
  73112. /**
  73113. * Sets edge distortion to 0
  73114. */
  73115. disableEdgeDistortion(): void;
  73116. /**
  73117. * Sets the FocusDistance amount
  73118. * @param amount amount of FocusDistance
  73119. */
  73120. setFocusDistance(amount: number): void;
  73121. /**
  73122. * Disables depth of field
  73123. */
  73124. disableDepthOfField(): void;
  73125. /**
  73126. * Sets the Aperture amount
  73127. * @param amount amount of Aperture
  73128. */
  73129. setAperture(amount: number): void;
  73130. /**
  73131. * Sets the DarkenOutOfFocus amount
  73132. * @param amount amount of DarkenOutOfFocus
  73133. */
  73134. setDarkenOutOfFocus(amount: number): void;
  73135. private _pentagonBokehIsEnabled;
  73136. /**
  73137. * Creates a pentagon bokeh effect
  73138. */
  73139. enablePentagonBokeh(): void;
  73140. /**
  73141. * Disables the pentagon bokeh effect
  73142. */
  73143. disablePentagonBokeh(): void;
  73144. /**
  73145. * Enables noise blur
  73146. */
  73147. enableNoiseBlur(): void;
  73148. /**
  73149. * Disables noise blur
  73150. */
  73151. disableNoiseBlur(): void;
  73152. /**
  73153. * Sets the HighlightsGain amount
  73154. * @param amount amount of HighlightsGain
  73155. */
  73156. setHighlightsGain(amount: number): void;
  73157. /**
  73158. * Sets the HighlightsThreshold amount
  73159. * @param amount amount of HighlightsThreshold
  73160. */
  73161. setHighlightsThreshold(amount: number): void;
  73162. /**
  73163. * Disables highlights
  73164. */
  73165. disableHighlights(): void;
  73166. /**
  73167. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  73168. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  73169. */
  73170. dispose(disableDepthRender?: boolean): void;
  73171. private _createChromaticAberrationPostProcess;
  73172. private _createHighlightsPostProcess;
  73173. private _createDepthOfFieldPostProcess;
  73174. private _createGrainTexture;
  73175. }
  73176. }
  73177. declare module "babylonjs/Shaders/ssao2.fragment" {
  73178. /** @hidden */
  73179. export var ssao2PixelShader: {
  73180. name: string;
  73181. shader: string;
  73182. };
  73183. }
  73184. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  73185. /** @hidden */
  73186. export var ssaoCombinePixelShader: {
  73187. name: string;
  73188. shader: string;
  73189. };
  73190. }
  73191. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  73192. import { Camera } from "babylonjs/Cameras/camera";
  73193. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73194. import { Scene } from "babylonjs/scene";
  73195. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73196. import "babylonjs/Shaders/ssao2.fragment";
  73197. import "babylonjs/Shaders/ssaoCombine.fragment";
  73198. /**
  73199. * Render pipeline to produce ssao effect
  73200. */
  73201. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  73202. /**
  73203. * @ignore
  73204. * The PassPostProcess id in the pipeline that contains the original scene color
  73205. */
  73206. SSAOOriginalSceneColorEffect: string;
  73207. /**
  73208. * @ignore
  73209. * The SSAO PostProcess id in the pipeline
  73210. */
  73211. SSAORenderEffect: string;
  73212. /**
  73213. * @ignore
  73214. * The horizontal blur PostProcess id in the pipeline
  73215. */
  73216. SSAOBlurHRenderEffect: string;
  73217. /**
  73218. * @ignore
  73219. * The vertical blur PostProcess id in the pipeline
  73220. */
  73221. SSAOBlurVRenderEffect: string;
  73222. /**
  73223. * @ignore
  73224. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73225. */
  73226. SSAOCombineRenderEffect: string;
  73227. /**
  73228. * The output strength of the SSAO post-process. Default value is 1.0.
  73229. */
  73230. totalStrength: number;
  73231. /**
  73232. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  73233. */
  73234. maxZ: number;
  73235. /**
  73236. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  73237. */
  73238. minZAspect: number;
  73239. private _samples;
  73240. /**
  73241. * Number of samples used for the SSAO calculations. Default value is 8
  73242. */
  73243. set samples(n: number);
  73244. get samples(): number;
  73245. private _textureSamples;
  73246. /**
  73247. * Number of samples to use for antialiasing
  73248. */
  73249. set textureSamples(n: number);
  73250. get textureSamples(): number;
  73251. /**
  73252. * Ratio object used for SSAO ratio and blur ratio
  73253. */
  73254. private _ratio;
  73255. /**
  73256. * Dynamically generated sphere sampler.
  73257. */
  73258. private _sampleSphere;
  73259. /**
  73260. * Blur filter offsets
  73261. */
  73262. private _samplerOffsets;
  73263. private _expensiveBlur;
  73264. /**
  73265. * If bilateral blur should be used
  73266. */
  73267. set expensiveBlur(b: boolean);
  73268. get expensiveBlur(): boolean;
  73269. /**
  73270. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  73271. */
  73272. radius: number;
  73273. /**
  73274. * The base color of the SSAO post-process
  73275. * The final result is "base + ssao" between [0, 1]
  73276. */
  73277. base: number;
  73278. /**
  73279. * Support test.
  73280. */
  73281. static get IsSupported(): boolean;
  73282. private _scene;
  73283. private _depthTexture;
  73284. private _normalTexture;
  73285. private _randomTexture;
  73286. private _originalColorPostProcess;
  73287. private _ssaoPostProcess;
  73288. private _blurHPostProcess;
  73289. private _blurVPostProcess;
  73290. private _ssaoCombinePostProcess;
  73291. /**
  73292. * Gets active scene
  73293. */
  73294. get scene(): Scene;
  73295. /**
  73296. * @constructor
  73297. * @param name The rendering pipeline name
  73298. * @param scene The scene linked to this pipeline
  73299. * @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 }
  73300. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73301. */
  73302. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  73303. /**
  73304. * Get the class name
  73305. * @returns "SSAO2RenderingPipeline"
  73306. */
  73307. getClassName(): string;
  73308. /**
  73309. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73310. */
  73311. dispose(disableGeometryBufferRenderer?: boolean): void;
  73312. private _createBlurPostProcess;
  73313. /** @hidden */
  73314. _rebuild(): void;
  73315. private _bits;
  73316. private _radicalInverse_VdC;
  73317. private _hammersley;
  73318. private _hemisphereSample_uniform;
  73319. private _generateHemisphere;
  73320. private _createSSAOPostProcess;
  73321. private _createSSAOCombinePostProcess;
  73322. private _createRandomTexture;
  73323. /**
  73324. * Serialize the rendering pipeline (Used when exporting)
  73325. * @returns the serialized object
  73326. */
  73327. serialize(): any;
  73328. /**
  73329. * Parse the serialized pipeline
  73330. * @param source Source pipeline.
  73331. * @param scene The scene to load the pipeline to.
  73332. * @param rootUrl The URL of the serialized pipeline.
  73333. * @returns An instantiated pipeline from the serialized object.
  73334. */
  73335. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  73336. }
  73337. }
  73338. declare module "babylonjs/Shaders/ssao.fragment" {
  73339. /** @hidden */
  73340. export var ssaoPixelShader: {
  73341. name: string;
  73342. shader: string;
  73343. };
  73344. }
  73345. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  73346. import { Camera } from "babylonjs/Cameras/camera";
  73347. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73348. import { Scene } from "babylonjs/scene";
  73349. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73350. import "babylonjs/Shaders/ssao.fragment";
  73351. import "babylonjs/Shaders/ssaoCombine.fragment";
  73352. /**
  73353. * Render pipeline to produce ssao effect
  73354. */
  73355. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  73356. /**
  73357. * @ignore
  73358. * The PassPostProcess id in the pipeline that contains the original scene color
  73359. */
  73360. SSAOOriginalSceneColorEffect: string;
  73361. /**
  73362. * @ignore
  73363. * The SSAO PostProcess id in the pipeline
  73364. */
  73365. SSAORenderEffect: string;
  73366. /**
  73367. * @ignore
  73368. * The horizontal blur PostProcess id in the pipeline
  73369. */
  73370. SSAOBlurHRenderEffect: string;
  73371. /**
  73372. * @ignore
  73373. * The vertical blur PostProcess id in the pipeline
  73374. */
  73375. SSAOBlurVRenderEffect: string;
  73376. /**
  73377. * @ignore
  73378. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73379. */
  73380. SSAOCombineRenderEffect: string;
  73381. /**
  73382. * The output strength of the SSAO post-process. Default value is 1.0.
  73383. */
  73384. totalStrength: number;
  73385. /**
  73386. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  73387. */
  73388. radius: number;
  73389. /**
  73390. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  73391. * Must not be equal to fallOff and superior to fallOff.
  73392. * Default value is 0.0075
  73393. */
  73394. area: number;
  73395. /**
  73396. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  73397. * Must not be equal to area and inferior to area.
  73398. * Default value is 0.000001
  73399. */
  73400. fallOff: number;
  73401. /**
  73402. * The base color of the SSAO post-process
  73403. * The final result is "base + ssao" between [0, 1]
  73404. */
  73405. base: number;
  73406. private _scene;
  73407. private _depthTexture;
  73408. private _randomTexture;
  73409. private _originalColorPostProcess;
  73410. private _ssaoPostProcess;
  73411. private _blurHPostProcess;
  73412. private _blurVPostProcess;
  73413. private _ssaoCombinePostProcess;
  73414. private _firstUpdate;
  73415. /**
  73416. * Gets active scene
  73417. */
  73418. get scene(): Scene;
  73419. /**
  73420. * @constructor
  73421. * @param name - The rendering pipeline name
  73422. * @param scene - The scene linked to this pipeline
  73423. * @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 }
  73424. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  73425. */
  73426. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  73427. /**
  73428. * Get the class name
  73429. * @returns "SSAORenderingPipeline"
  73430. */
  73431. getClassName(): string;
  73432. /**
  73433. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73434. */
  73435. dispose(disableDepthRender?: boolean): void;
  73436. private _createBlurPostProcess;
  73437. /** @hidden */
  73438. _rebuild(): void;
  73439. private _createSSAOPostProcess;
  73440. private _createSSAOCombinePostProcess;
  73441. private _createRandomTexture;
  73442. }
  73443. }
  73444. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  73445. /** @hidden */
  73446. export var screenSpaceReflectionPixelShader: {
  73447. name: string;
  73448. shader: string;
  73449. };
  73450. }
  73451. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  73452. import { Nullable } from "babylonjs/types";
  73453. import { Camera } from "babylonjs/Cameras/camera";
  73454. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73455. import { Scene } from "babylonjs/scene";
  73456. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  73457. import { Engine } from "babylonjs/Engines/engine";
  73458. /**
  73459. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  73460. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  73461. */
  73462. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  73463. /**
  73464. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  73465. */
  73466. threshold: number;
  73467. /**
  73468. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  73469. */
  73470. strength: number;
  73471. /**
  73472. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  73473. */
  73474. reflectionSpecularFalloffExponent: number;
  73475. /**
  73476. * 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]
  73477. */
  73478. step: number;
  73479. /**
  73480. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  73481. */
  73482. roughnessFactor: number;
  73483. private _geometryBufferRenderer;
  73484. private _enableSmoothReflections;
  73485. private _reflectionSamples;
  73486. private _smoothSteps;
  73487. /**
  73488. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  73489. * @param name The name of the effect.
  73490. * @param scene The scene containing the objects to calculate reflections.
  73491. * @param options The required width/height ratio to downsize to before computing the render pass.
  73492. * @param camera The camera to apply the render pass to.
  73493. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73494. * @param engine The engine which the post process will be applied. (default: current engine)
  73495. * @param reusable If the post process can be reused on the same frame. (default: false)
  73496. * @param textureType Type of textures used when performing the post process. (default: 0)
  73497. * @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)
  73498. */
  73499. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73500. /**
  73501. * Gets wether or not smoothing reflections is enabled.
  73502. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  73503. */
  73504. get enableSmoothReflections(): boolean;
  73505. /**
  73506. * Sets wether or not smoothing reflections is enabled.
  73507. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  73508. */
  73509. set enableSmoothReflections(enabled: boolean);
  73510. /**
  73511. * Gets the number of samples taken while computing reflections. More samples count is high,
  73512. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  73513. */
  73514. get reflectionSamples(): number;
  73515. /**
  73516. * Sets the number of samples taken while computing reflections. More samples count is high,
  73517. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  73518. */
  73519. set reflectionSamples(samples: number);
  73520. /**
  73521. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  73522. * more the post-process will require GPU power and can generate a drop in FPS.
  73523. * Default value (5.0) work pretty well in all cases but can be adjusted.
  73524. */
  73525. get smoothSteps(): number;
  73526. set smoothSteps(steps: number);
  73527. private _updateEffectDefines;
  73528. }
  73529. }
  73530. declare module "babylonjs/Shaders/standard.fragment" {
  73531. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  73532. /** @hidden */
  73533. export var standardPixelShader: {
  73534. name: string;
  73535. shader: string;
  73536. };
  73537. }
  73538. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  73539. import { Nullable } from "babylonjs/types";
  73540. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  73541. import { Camera } from "babylonjs/Cameras/camera";
  73542. import { Texture } from "babylonjs/Materials/Textures/texture";
  73543. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73544. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73545. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73546. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  73547. import { IDisposable } from "babylonjs/scene";
  73548. import { SpotLight } from "babylonjs/Lights/spotLight";
  73549. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  73550. import { Scene } from "babylonjs/scene";
  73551. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  73552. import { Animation } from "babylonjs/Animations/animation";
  73553. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73554. import "babylonjs/Shaders/standard.fragment";
  73555. /**
  73556. * Standard rendering pipeline
  73557. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73558. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  73559. */
  73560. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73561. /**
  73562. * Public members
  73563. */
  73564. /**
  73565. * Post-process which contains the original scene color before the pipeline applies all the effects
  73566. */
  73567. originalPostProcess: Nullable<PostProcess>;
  73568. /**
  73569. * Post-process used to down scale an image x4
  73570. */
  73571. downSampleX4PostProcess: Nullable<PostProcess>;
  73572. /**
  73573. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  73574. */
  73575. brightPassPostProcess: Nullable<PostProcess>;
  73576. /**
  73577. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  73578. */
  73579. blurHPostProcesses: PostProcess[];
  73580. /**
  73581. * Post-process array storing all the vertical blur post-processes used by the pipeline
  73582. */
  73583. blurVPostProcesses: PostProcess[];
  73584. /**
  73585. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  73586. */
  73587. textureAdderPostProcess: Nullable<PostProcess>;
  73588. /**
  73589. * Post-process used to create volumetric lighting effect
  73590. */
  73591. volumetricLightPostProcess: Nullable<PostProcess>;
  73592. /**
  73593. * Post-process used to smooth the previous volumetric light post-process on the X axis
  73594. */
  73595. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  73596. /**
  73597. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  73598. */
  73599. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  73600. /**
  73601. * Post-process used to merge the volumetric light effect and the real scene color
  73602. */
  73603. volumetricLightMergePostProces: Nullable<PostProcess>;
  73604. /**
  73605. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  73606. */
  73607. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  73608. /**
  73609. * Base post-process used to calculate the average luminance of the final image for HDR
  73610. */
  73611. luminancePostProcess: Nullable<PostProcess>;
  73612. /**
  73613. * Post-processes used to create down sample post-processes in order to get
  73614. * the average luminance of the final image for HDR
  73615. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  73616. */
  73617. luminanceDownSamplePostProcesses: PostProcess[];
  73618. /**
  73619. * Post-process used to create a HDR effect (light adaptation)
  73620. */
  73621. hdrPostProcess: Nullable<PostProcess>;
  73622. /**
  73623. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  73624. */
  73625. textureAdderFinalPostProcess: Nullable<PostProcess>;
  73626. /**
  73627. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  73628. */
  73629. lensFlareFinalPostProcess: Nullable<PostProcess>;
  73630. /**
  73631. * Post-process used to merge the final HDR post-process and the real scene color
  73632. */
  73633. hdrFinalPostProcess: Nullable<PostProcess>;
  73634. /**
  73635. * Post-process used to create a lens flare effect
  73636. */
  73637. lensFlarePostProcess: Nullable<PostProcess>;
  73638. /**
  73639. * Post-process that merges the result of the lens flare post-process and the real scene color
  73640. */
  73641. lensFlareComposePostProcess: Nullable<PostProcess>;
  73642. /**
  73643. * Post-process used to create a motion blur effect
  73644. */
  73645. motionBlurPostProcess: Nullable<PostProcess>;
  73646. /**
  73647. * Post-process used to create a depth of field effect
  73648. */
  73649. depthOfFieldPostProcess: Nullable<PostProcess>;
  73650. /**
  73651. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73652. */
  73653. fxaaPostProcess: Nullable<FxaaPostProcess>;
  73654. /**
  73655. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  73656. */
  73657. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  73658. /**
  73659. * Represents the brightness threshold in order to configure the illuminated surfaces
  73660. */
  73661. brightThreshold: number;
  73662. /**
  73663. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  73664. */
  73665. blurWidth: number;
  73666. /**
  73667. * Sets if the blur for highlighted surfaces must be only horizontal
  73668. */
  73669. horizontalBlur: boolean;
  73670. /**
  73671. * Gets the overall exposure used by the pipeline
  73672. */
  73673. get exposure(): number;
  73674. /**
  73675. * Sets the overall exposure used by the pipeline
  73676. */
  73677. set exposure(value: number);
  73678. /**
  73679. * Texture used typically to simulate "dirty" on camera lens
  73680. */
  73681. lensTexture: Nullable<Texture>;
  73682. /**
  73683. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  73684. */
  73685. volumetricLightCoefficient: number;
  73686. /**
  73687. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  73688. */
  73689. volumetricLightPower: number;
  73690. /**
  73691. * Used the set the blur intensity to smooth the volumetric lights
  73692. */
  73693. volumetricLightBlurScale: number;
  73694. /**
  73695. * Light (spot or directional) used to generate the volumetric lights rays
  73696. * The source light must have a shadow generate so the pipeline can get its
  73697. * depth map
  73698. */
  73699. sourceLight: Nullable<SpotLight | DirectionalLight>;
  73700. /**
  73701. * For eye adaptation, represents the minimum luminance the eye can see
  73702. */
  73703. hdrMinimumLuminance: number;
  73704. /**
  73705. * For eye adaptation, represents the decrease luminance speed
  73706. */
  73707. hdrDecreaseRate: number;
  73708. /**
  73709. * For eye adaptation, represents the increase luminance speed
  73710. */
  73711. hdrIncreaseRate: number;
  73712. /**
  73713. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73714. */
  73715. get hdrAutoExposure(): boolean;
  73716. /**
  73717. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73718. */
  73719. set hdrAutoExposure(value: boolean);
  73720. /**
  73721. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  73722. */
  73723. lensColorTexture: Nullable<Texture>;
  73724. /**
  73725. * The overall strengh for the lens flare effect
  73726. */
  73727. lensFlareStrength: number;
  73728. /**
  73729. * Dispersion coefficient for lens flare ghosts
  73730. */
  73731. lensFlareGhostDispersal: number;
  73732. /**
  73733. * Main lens flare halo width
  73734. */
  73735. lensFlareHaloWidth: number;
  73736. /**
  73737. * Based on the lens distortion effect, defines how much the lens flare result
  73738. * is distorted
  73739. */
  73740. lensFlareDistortionStrength: number;
  73741. /**
  73742. * Configures the blur intensity used for for lens flare (halo)
  73743. */
  73744. lensFlareBlurWidth: number;
  73745. /**
  73746. * Lens star texture must be used to simulate rays on the flares and is available
  73747. * in the documentation
  73748. */
  73749. lensStarTexture: Nullable<Texture>;
  73750. /**
  73751. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  73752. * flare effect by taking account of the dirt texture
  73753. */
  73754. lensFlareDirtTexture: Nullable<Texture>;
  73755. /**
  73756. * Represents the focal length for the depth of field effect
  73757. */
  73758. depthOfFieldDistance: number;
  73759. /**
  73760. * Represents the blur intensity for the blurred part of the depth of field effect
  73761. */
  73762. depthOfFieldBlurWidth: number;
  73763. /**
  73764. * Gets how much the image is blurred by the movement while using the motion blur post-process
  73765. */
  73766. get motionStrength(): number;
  73767. /**
  73768. * Sets how much the image is blurred by the movement while using the motion blur post-process
  73769. */
  73770. set motionStrength(strength: number);
  73771. /**
  73772. * Gets wether or not the motion blur post-process is object based or screen based.
  73773. */
  73774. get objectBasedMotionBlur(): boolean;
  73775. /**
  73776. * Sets wether or not the motion blur post-process should be object based or screen based
  73777. */
  73778. set objectBasedMotionBlur(value: boolean);
  73779. /**
  73780. * List of animations for the pipeline (IAnimatable implementation)
  73781. */
  73782. animations: Animation[];
  73783. /**
  73784. * Private members
  73785. */
  73786. private _scene;
  73787. private _currentDepthOfFieldSource;
  73788. private _basePostProcess;
  73789. private _fixedExposure;
  73790. private _currentExposure;
  73791. private _hdrAutoExposure;
  73792. private _hdrCurrentLuminance;
  73793. private _motionStrength;
  73794. private _isObjectBasedMotionBlur;
  73795. private _floatTextureType;
  73796. private _camerasToBeAttached;
  73797. private _ratio;
  73798. private _bloomEnabled;
  73799. private _depthOfFieldEnabled;
  73800. private _vlsEnabled;
  73801. private _lensFlareEnabled;
  73802. private _hdrEnabled;
  73803. private _motionBlurEnabled;
  73804. private _fxaaEnabled;
  73805. private _screenSpaceReflectionsEnabled;
  73806. private _motionBlurSamples;
  73807. private _volumetricLightStepsCount;
  73808. private _samples;
  73809. /**
  73810. * @ignore
  73811. * Specifies if the bloom pipeline is enabled
  73812. */
  73813. get BloomEnabled(): boolean;
  73814. set BloomEnabled(enabled: boolean);
  73815. /**
  73816. * @ignore
  73817. * Specifies if the depth of field pipeline is enabed
  73818. */
  73819. get DepthOfFieldEnabled(): boolean;
  73820. set DepthOfFieldEnabled(enabled: boolean);
  73821. /**
  73822. * @ignore
  73823. * Specifies if the lens flare pipeline is enabed
  73824. */
  73825. get LensFlareEnabled(): boolean;
  73826. set LensFlareEnabled(enabled: boolean);
  73827. /**
  73828. * @ignore
  73829. * Specifies if the HDR pipeline is enabled
  73830. */
  73831. get HDREnabled(): boolean;
  73832. set HDREnabled(enabled: boolean);
  73833. /**
  73834. * @ignore
  73835. * Specifies if the volumetric lights scattering effect is enabled
  73836. */
  73837. get VLSEnabled(): boolean;
  73838. set VLSEnabled(enabled: boolean);
  73839. /**
  73840. * @ignore
  73841. * Specifies if the motion blur effect is enabled
  73842. */
  73843. get MotionBlurEnabled(): boolean;
  73844. set MotionBlurEnabled(enabled: boolean);
  73845. /**
  73846. * Specifies if anti-aliasing is enabled
  73847. */
  73848. get fxaaEnabled(): boolean;
  73849. set fxaaEnabled(enabled: boolean);
  73850. /**
  73851. * Specifies if screen space reflections are enabled.
  73852. */
  73853. get screenSpaceReflectionsEnabled(): boolean;
  73854. set screenSpaceReflectionsEnabled(enabled: boolean);
  73855. /**
  73856. * Specifies the number of steps used to calculate the volumetric lights
  73857. * Typically in interval [50, 200]
  73858. */
  73859. get volumetricLightStepsCount(): number;
  73860. set volumetricLightStepsCount(count: number);
  73861. /**
  73862. * Specifies the number of samples used for the motion blur effect
  73863. * Typically in interval [16, 64]
  73864. */
  73865. get motionBlurSamples(): number;
  73866. set motionBlurSamples(samples: number);
  73867. /**
  73868. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73869. */
  73870. get samples(): number;
  73871. set samples(sampleCount: number);
  73872. /**
  73873. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73874. * @constructor
  73875. * @param name The rendering pipeline name
  73876. * @param scene The scene linked to this pipeline
  73877. * @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)
  73878. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  73879. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73880. */
  73881. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  73882. private _buildPipeline;
  73883. private _createDownSampleX4PostProcess;
  73884. private _createBrightPassPostProcess;
  73885. private _createBlurPostProcesses;
  73886. private _createTextureAdderPostProcess;
  73887. private _createVolumetricLightPostProcess;
  73888. private _createLuminancePostProcesses;
  73889. private _createHdrPostProcess;
  73890. private _createLensFlarePostProcess;
  73891. private _createDepthOfFieldPostProcess;
  73892. private _createMotionBlurPostProcess;
  73893. private _getDepthTexture;
  73894. private _disposePostProcesses;
  73895. /**
  73896. * Dispose of the pipeline and stop all post processes
  73897. */
  73898. dispose(): void;
  73899. /**
  73900. * Serialize the rendering pipeline (Used when exporting)
  73901. * @returns the serialized object
  73902. */
  73903. serialize(): any;
  73904. /**
  73905. * Parse the serialized pipeline
  73906. * @param source Source pipeline.
  73907. * @param scene The scene to load the pipeline to.
  73908. * @param rootUrl The URL of the serialized pipeline.
  73909. * @returns An instantiated pipeline from the serialized object.
  73910. */
  73911. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  73912. /**
  73913. * Luminance steps
  73914. */
  73915. static LuminanceSteps: number;
  73916. }
  73917. }
  73918. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  73919. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  73920. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  73921. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  73922. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  73923. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  73924. }
  73925. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  73926. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  73927. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73928. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73929. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  73930. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73931. }
  73932. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  73933. /** @hidden */
  73934. export var stereoscopicInterlacePixelShader: {
  73935. name: string;
  73936. shader: string;
  73937. };
  73938. }
  73939. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  73940. import { Camera } from "babylonjs/Cameras/camera";
  73941. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73942. import { Engine } from "babylonjs/Engines/engine";
  73943. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  73944. /**
  73945. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  73946. */
  73947. export class StereoscopicInterlacePostProcessI extends PostProcess {
  73948. private _stepSize;
  73949. private _passedProcess;
  73950. /**
  73951. * Initializes a StereoscopicInterlacePostProcessI
  73952. * @param name The name of the effect.
  73953. * @param rigCameras The rig cameras to be appled to the post process
  73954. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  73955. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  73956. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73957. * @param engine The engine which the post process will be applied. (default: current engine)
  73958. * @param reusable If the post process can be reused on the same frame. (default: false)
  73959. */
  73960. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73961. }
  73962. /**
  73963. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  73964. */
  73965. export class StereoscopicInterlacePostProcess extends PostProcess {
  73966. private _stepSize;
  73967. private _passedProcess;
  73968. /**
  73969. * Initializes a StereoscopicInterlacePostProcess
  73970. * @param name The name of the effect.
  73971. * @param rigCameras The rig cameras to be appled to the post process
  73972. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  73973. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73974. * @param engine The engine which the post process will be applied. (default: current engine)
  73975. * @param reusable If the post process can be reused on the same frame. (default: false)
  73976. */
  73977. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73978. }
  73979. }
  73980. declare module "babylonjs/Shaders/tonemap.fragment" {
  73981. /** @hidden */
  73982. export var tonemapPixelShader: {
  73983. name: string;
  73984. shader: string;
  73985. };
  73986. }
  73987. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  73988. import { Camera } from "babylonjs/Cameras/camera";
  73989. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73990. import "babylonjs/Shaders/tonemap.fragment";
  73991. import { Engine } from "babylonjs/Engines/engine";
  73992. /** Defines operator used for tonemapping */
  73993. export enum TonemappingOperator {
  73994. /** Hable */
  73995. Hable = 0,
  73996. /** Reinhard */
  73997. Reinhard = 1,
  73998. /** HejiDawson */
  73999. HejiDawson = 2,
  74000. /** Photographic */
  74001. Photographic = 3
  74002. }
  74003. /**
  74004. * Defines a post process to apply tone mapping
  74005. */
  74006. export class TonemapPostProcess extends PostProcess {
  74007. private _operator;
  74008. /** Defines the required exposure adjustement */
  74009. exposureAdjustment: number;
  74010. /**
  74011. * Creates a new TonemapPostProcess
  74012. * @param name defines the name of the postprocess
  74013. * @param _operator defines the operator to use
  74014. * @param exposureAdjustment defines the required exposure adjustement
  74015. * @param camera defines the camera to use (can be null)
  74016. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  74017. * @param engine defines the hosting engine (can be ignore if camera is set)
  74018. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  74019. */
  74020. constructor(name: string, _operator: TonemappingOperator,
  74021. /** Defines the required exposure adjustement */
  74022. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  74023. }
  74024. }
  74025. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  74026. /** @hidden */
  74027. export var volumetricLightScatteringPixelShader: {
  74028. name: string;
  74029. shader: string;
  74030. };
  74031. }
  74032. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  74033. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74034. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74035. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74036. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74037. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74038. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74039. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74040. /** @hidden */
  74041. export var volumetricLightScatteringPassVertexShader: {
  74042. name: string;
  74043. shader: string;
  74044. };
  74045. }
  74046. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  74047. /** @hidden */
  74048. export var volumetricLightScatteringPassPixelShader: {
  74049. name: string;
  74050. shader: string;
  74051. };
  74052. }
  74053. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  74054. import { Vector3 } from "babylonjs/Maths/math.vector";
  74055. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74056. import { Mesh } from "babylonjs/Meshes/mesh";
  74057. import { Camera } from "babylonjs/Cameras/camera";
  74058. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74059. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74060. import { Scene } from "babylonjs/scene";
  74061. import "babylonjs/Meshes/Builders/planeBuilder";
  74062. import "babylonjs/Shaders/depth.vertex";
  74063. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  74064. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  74065. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  74066. import { Engine } from "babylonjs/Engines/engine";
  74067. /**
  74068. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  74069. */
  74070. export class VolumetricLightScatteringPostProcess extends PostProcess {
  74071. private _volumetricLightScatteringPass;
  74072. private _volumetricLightScatteringRTT;
  74073. private _viewPort;
  74074. private _screenCoordinates;
  74075. private _cachedDefines;
  74076. /**
  74077. * If not undefined, the mesh position is computed from the attached node position
  74078. */
  74079. attachedNode: {
  74080. position: Vector3;
  74081. };
  74082. /**
  74083. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  74084. */
  74085. customMeshPosition: Vector3;
  74086. /**
  74087. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  74088. */
  74089. useCustomMeshPosition: boolean;
  74090. /**
  74091. * If the post-process should inverse the light scattering direction
  74092. */
  74093. invert: boolean;
  74094. /**
  74095. * The internal mesh used by the post-process
  74096. */
  74097. mesh: Mesh;
  74098. /**
  74099. * @hidden
  74100. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  74101. */
  74102. get useDiffuseColor(): boolean;
  74103. set useDiffuseColor(useDiffuseColor: boolean);
  74104. /**
  74105. * Array containing the excluded meshes not rendered in the internal pass
  74106. */
  74107. excludedMeshes: AbstractMesh[];
  74108. /**
  74109. * Controls the overall intensity of the post-process
  74110. */
  74111. exposure: number;
  74112. /**
  74113. * Dissipates each sample's contribution in range [0, 1]
  74114. */
  74115. decay: number;
  74116. /**
  74117. * Controls the overall intensity of each sample
  74118. */
  74119. weight: number;
  74120. /**
  74121. * Controls the density of each sample
  74122. */
  74123. density: number;
  74124. /**
  74125. * @constructor
  74126. * @param name The post-process name
  74127. * @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)
  74128. * @param camera The camera that the post-process will be attached to
  74129. * @param mesh The mesh used to create the light scattering
  74130. * @param samples The post-process quality, default 100
  74131. * @param samplingModeThe post-process filtering mode
  74132. * @param engine The babylon engine
  74133. * @param reusable If the post-process is reusable
  74134. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  74135. */
  74136. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  74137. /**
  74138. * Returns the string "VolumetricLightScatteringPostProcess"
  74139. * @returns "VolumetricLightScatteringPostProcess"
  74140. */
  74141. getClassName(): string;
  74142. private _isReady;
  74143. /**
  74144. * Sets the new light position for light scattering effect
  74145. * @param position The new custom light position
  74146. */
  74147. setCustomMeshPosition(position: Vector3): void;
  74148. /**
  74149. * Returns the light position for light scattering effect
  74150. * @return Vector3 The custom light position
  74151. */
  74152. getCustomMeshPosition(): Vector3;
  74153. /**
  74154. * Disposes the internal assets and detaches the post-process from the camera
  74155. */
  74156. dispose(camera: Camera): void;
  74157. /**
  74158. * Returns the render target texture used by the post-process
  74159. * @return the render target texture used by the post-process
  74160. */
  74161. getPass(): RenderTargetTexture;
  74162. private _meshExcluded;
  74163. private _createPass;
  74164. private _updateMeshScreenCoordinates;
  74165. /**
  74166. * Creates a default mesh for the Volumeric Light Scattering post-process
  74167. * @param name The mesh name
  74168. * @param scene The scene where to create the mesh
  74169. * @return the default mesh
  74170. */
  74171. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  74172. }
  74173. }
  74174. declare module "babylonjs/PostProcesses/index" {
  74175. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  74176. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  74177. export * from "babylonjs/PostProcesses/bloomEffect";
  74178. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  74179. export * from "babylonjs/PostProcesses/blurPostProcess";
  74180. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74181. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  74182. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  74183. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  74184. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74185. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  74186. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  74187. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  74188. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  74189. export * from "babylonjs/PostProcesses/filterPostProcess";
  74190. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  74191. export * from "babylonjs/PostProcesses/grainPostProcess";
  74192. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  74193. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74194. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  74195. export * from "babylonjs/PostProcesses/passPostProcess";
  74196. export * from "babylonjs/PostProcesses/postProcess";
  74197. export * from "babylonjs/PostProcesses/postProcessManager";
  74198. export * from "babylonjs/PostProcesses/refractionPostProcess";
  74199. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  74200. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  74201. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  74202. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  74203. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  74204. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  74205. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  74206. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74207. }
  74208. declare module "babylonjs/Probes/index" {
  74209. export * from "babylonjs/Probes/reflectionProbe";
  74210. }
  74211. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  74212. import { Scene } from "babylonjs/scene";
  74213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74214. import { SmartArray } from "babylonjs/Misc/smartArray";
  74215. import { ISceneComponent } from "babylonjs/sceneComponent";
  74216. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  74217. import "babylonjs/Meshes/Builders/boxBuilder";
  74218. import "babylonjs/Shaders/color.fragment";
  74219. import "babylonjs/Shaders/color.vertex";
  74220. import { Color3 } from "babylonjs/Maths/math.color";
  74221. import { Observable } from "babylonjs/Misc/observable";
  74222. module "babylonjs/scene" {
  74223. interface Scene {
  74224. /** @hidden (Backing field) */
  74225. _boundingBoxRenderer: BoundingBoxRenderer;
  74226. /** @hidden (Backing field) */
  74227. _forceShowBoundingBoxes: boolean;
  74228. /**
  74229. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  74230. */
  74231. forceShowBoundingBoxes: boolean;
  74232. /**
  74233. * Gets the bounding box renderer associated with the scene
  74234. * @returns a BoundingBoxRenderer
  74235. */
  74236. getBoundingBoxRenderer(): BoundingBoxRenderer;
  74237. }
  74238. }
  74239. module "babylonjs/Meshes/abstractMesh" {
  74240. interface AbstractMesh {
  74241. /** @hidden (Backing field) */
  74242. _showBoundingBox: boolean;
  74243. /**
  74244. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  74245. */
  74246. showBoundingBox: boolean;
  74247. }
  74248. }
  74249. /**
  74250. * Component responsible of rendering the bounding box of the meshes in a scene.
  74251. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  74252. */
  74253. export class BoundingBoxRenderer implements ISceneComponent {
  74254. /**
  74255. * The component name helpfull to identify the component in the list of scene components.
  74256. */
  74257. readonly name: string;
  74258. /**
  74259. * The scene the component belongs to.
  74260. */
  74261. scene: Scene;
  74262. /**
  74263. * Color of the bounding box lines placed in front of an object
  74264. */
  74265. frontColor: Color3;
  74266. /**
  74267. * Color of the bounding box lines placed behind an object
  74268. */
  74269. backColor: Color3;
  74270. /**
  74271. * Defines if the renderer should show the back lines or not
  74272. */
  74273. showBackLines: boolean;
  74274. /**
  74275. * Observable raised before rendering a bounding box
  74276. */
  74277. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  74278. /**
  74279. * Observable raised after rendering a bounding box
  74280. */
  74281. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  74282. /**
  74283. * @hidden
  74284. */
  74285. renderList: SmartArray<BoundingBox>;
  74286. private _colorShader;
  74287. private _vertexBuffers;
  74288. private _indexBuffer;
  74289. private _fillIndexBuffer;
  74290. private _fillIndexData;
  74291. /**
  74292. * Instantiates a new bounding box renderer in a scene.
  74293. * @param scene the scene the renderer renders in
  74294. */
  74295. constructor(scene: Scene);
  74296. /**
  74297. * Registers the component in a given scene
  74298. */
  74299. register(): void;
  74300. private _evaluateSubMesh;
  74301. private _activeMesh;
  74302. private _prepareRessources;
  74303. private _createIndexBuffer;
  74304. /**
  74305. * Rebuilds the elements related to this component in case of
  74306. * context lost for instance.
  74307. */
  74308. rebuild(): void;
  74309. /**
  74310. * @hidden
  74311. */
  74312. reset(): void;
  74313. /**
  74314. * Render the bounding boxes of a specific rendering group
  74315. * @param renderingGroupId defines the rendering group to render
  74316. */
  74317. render(renderingGroupId: number): void;
  74318. /**
  74319. * In case of occlusion queries, we can render the occlusion bounding box through this method
  74320. * @param mesh Define the mesh to render the occlusion bounding box for
  74321. */
  74322. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  74323. /**
  74324. * Dispose and release the resources attached to this renderer.
  74325. */
  74326. dispose(): void;
  74327. }
  74328. }
  74329. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  74330. import { Nullable } from "babylonjs/types";
  74331. import { Scene } from "babylonjs/scene";
  74332. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  74333. import { Camera } from "babylonjs/Cameras/camera";
  74334. import { ISceneComponent } from "babylonjs/sceneComponent";
  74335. module "babylonjs/scene" {
  74336. interface Scene {
  74337. /** @hidden (Backing field) */
  74338. _depthRenderer: {
  74339. [id: string]: DepthRenderer;
  74340. };
  74341. /**
  74342. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  74343. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  74344. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  74345. * @returns the created depth renderer
  74346. */
  74347. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  74348. /**
  74349. * Disables a depth renderer for a given camera
  74350. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  74351. */
  74352. disableDepthRenderer(camera?: Nullable<Camera>): void;
  74353. }
  74354. }
  74355. /**
  74356. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  74357. * in several rendering techniques.
  74358. */
  74359. export class DepthRendererSceneComponent implements ISceneComponent {
  74360. /**
  74361. * The component name helpfull to identify the component in the list of scene components.
  74362. */
  74363. readonly name: string;
  74364. /**
  74365. * The scene the component belongs to.
  74366. */
  74367. scene: Scene;
  74368. /**
  74369. * Creates a new instance of the component for the given scene
  74370. * @param scene Defines the scene to register the component in
  74371. */
  74372. constructor(scene: Scene);
  74373. /**
  74374. * Registers the component in a given scene
  74375. */
  74376. register(): void;
  74377. /**
  74378. * Rebuilds the elements related to this component in case of
  74379. * context lost for instance.
  74380. */
  74381. rebuild(): void;
  74382. /**
  74383. * Disposes the component and the associated ressources
  74384. */
  74385. dispose(): void;
  74386. private _gatherRenderTargets;
  74387. private _gatherActiveCameraRenderTargets;
  74388. }
  74389. }
  74390. declare module "babylonjs/Shaders/outline.fragment" {
  74391. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  74392. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  74393. /** @hidden */
  74394. export var outlinePixelShader: {
  74395. name: string;
  74396. shader: string;
  74397. };
  74398. }
  74399. declare module "babylonjs/Shaders/outline.vertex" {
  74400. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74401. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74402. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74403. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74404. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  74405. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74406. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74407. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74408. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  74409. /** @hidden */
  74410. export var outlineVertexShader: {
  74411. name: string;
  74412. shader: string;
  74413. };
  74414. }
  74415. declare module "babylonjs/Rendering/outlineRenderer" {
  74416. import { SubMesh } from "babylonjs/Meshes/subMesh";
  74417. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  74418. import { Scene } from "babylonjs/scene";
  74419. import { ISceneComponent } from "babylonjs/sceneComponent";
  74420. import "babylonjs/Shaders/outline.fragment";
  74421. import "babylonjs/Shaders/outline.vertex";
  74422. module "babylonjs/scene" {
  74423. interface Scene {
  74424. /** @hidden */
  74425. _outlineRenderer: OutlineRenderer;
  74426. /**
  74427. * Gets the outline renderer associated with the scene
  74428. * @returns a OutlineRenderer
  74429. */
  74430. getOutlineRenderer(): OutlineRenderer;
  74431. }
  74432. }
  74433. module "babylonjs/Meshes/abstractMesh" {
  74434. interface AbstractMesh {
  74435. /** @hidden (Backing field) */
  74436. _renderOutline: boolean;
  74437. /**
  74438. * Gets or sets a boolean indicating if the outline must be rendered as well
  74439. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  74440. */
  74441. renderOutline: boolean;
  74442. /** @hidden (Backing field) */
  74443. _renderOverlay: boolean;
  74444. /**
  74445. * Gets or sets a boolean indicating if the overlay must be rendered as well
  74446. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  74447. */
  74448. renderOverlay: boolean;
  74449. }
  74450. }
  74451. /**
  74452. * This class is responsible to draw bothe outline/overlay of meshes.
  74453. * It should not be used directly but through the available method on mesh.
  74454. */
  74455. export class OutlineRenderer implements ISceneComponent {
  74456. /**
  74457. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  74458. */
  74459. private static _StencilReference;
  74460. /**
  74461. * The name of the component. Each component must have a unique name.
  74462. */
  74463. name: string;
  74464. /**
  74465. * The scene the component belongs to.
  74466. */
  74467. scene: Scene;
  74468. /**
  74469. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  74470. */
  74471. zOffset: number;
  74472. private _engine;
  74473. private _effect;
  74474. private _cachedDefines;
  74475. private _savedDepthWrite;
  74476. /**
  74477. * Instantiates a new outline renderer. (There could be only one per scene).
  74478. * @param scene Defines the scene it belongs to
  74479. */
  74480. constructor(scene: Scene);
  74481. /**
  74482. * Register the component to one instance of a scene.
  74483. */
  74484. register(): void;
  74485. /**
  74486. * Rebuilds the elements related to this component in case of
  74487. * context lost for instance.
  74488. */
  74489. rebuild(): void;
  74490. /**
  74491. * Disposes the component and the associated ressources.
  74492. */
  74493. dispose(): void;
  74494. /**
  74495. * Renders the outline in the canvas.
  74496. * @param subMesh Defines the sumesh to render
  74497. * @param batch Defines the batch of meshes in case of instances
  74498. * @param useOverlay Defines if the rendering is for the overlay or the outline
  74499. */
  74500. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  74501. /**
  74502. * Returns whether or not the outline renderer is ready for a given submesh.
  74503. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  74504. * @param subMesh Defines the submesh to check readyness for
  74505. * @param useInstances Defines wheter wee are trying to render instances or not
  74506. * @returns true if ready otherwise false
  74507. */
  74508. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74509. private _beforeRenderingMesh;
  74510. private _afterRenderingMesh;
  74511. }
  74512. }
  74513. declare module "babylonjs/Rendering/index" {
  74514. export * from "babylonjs/Rendering/boundingBoxRenderer";
  74515. export * from "babylonjs/Rendering/depthRenderer";
  74516. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  74517. export * from "babylonjs/Rendering/edgesRenderer";
  74518. export * from "babylonjs/Rendering/geometryBufferRenderer";
  74519. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74520. export * from "babylonjs/Rendering/outlineRenderer";
  74521. export * from "babylonjs/Rendering/renderingGroup";
  74522. export * from "babylonjs/Rendering/renderingManager";
  74523. export * from "babylonjs/Rendering/utilityLayerRenderer";
  74524. }
  74525. declare module "babylonjs/Sprites/ISprites" {
  74526. /**
  74527. * Defines the basic options interface of a Sprite Frame Source Size.
  74528. */
  74529. export interface ISpriteJSONSpriteSourceSize {
  74530. /**
  74531. * number of the original width of the Frame
  74532. */
  74533. w: number;
  74534. /**
  74535. * number of the original height of the Frame
  74536. */
  74537. h: number;
  74538. }
  74539. /**
  74540. * Defines the basic options interface of a Sprite Frame Data.
  74541. */
  74542. export interface ISpriteJSONSpriteFrameData {
  74543. /**
  74544. * number of the x offset of the Frame
  74545. */
  74546. x: number;
  74547. /**
  74548. * number of the y offset of the Frame
  74549. */
  74550. y: number;
  74551. /**
  74552. * number of the width of the Frame
  74553. */
  74554. w: number;
  74555. /**
  74556. * number of the height of the Frame
  74557. */
  74558. h: number;
  74559. }
  74560. /**
  74561. * Defines the basic options interface of a JSON Sprite.
  74562. */
  74563. export interface ISpriteJSONSprite {
  74564. /**
  74565. * string name of the Frame
  74566. */
  74567. filename: string;
  74568. /**
  74569. * ISpriteJSONSpriteFrame basic object of the frame data
  74570. */
  74571. frame: ISpriteJSONSpriteFrameData;
  74572. /**
  74573. * boolean to flag is the frame was rotated.
  74574. */
  74575. rotated: boolean;
  74576. /**
  74577. * boolean to flag is the frame was trimmed.
  74578. */
  74579. trimmed: boolean;
  74580. /**
  74581. * ISpriteJSONSpriteFrame basic object of the source data
  74582. */
  74583. spriteSourceSize: ISpriteJSONSpriteFrameData;
  74584. /**
  74585. * ISpriteJSONSpriteFrame basic object of the source data
  74586. */
  74587. sourceSize: ISpriteJSONSpriteSourceSize;
  74588. }
  74589. /**
  74590. * Defines the basic options interface of a JSON atlas.
  74591. */
  74592. export interface ISpriteJSONAtlas {
  74593. /**
  74594. * Array of objects that contain the frame data.
  74595. */
  74596. frames: Array<ISpriteJSONSprite>;
  74597. /**
  74598. * object basic object containing the sprite meta data.
  74599. */
  74600. meta?: object;
  74601. }
  74602. }
  74603. declare module "babylonjs/Shaders/spriteMap.fragment" {
  74604. /** @hidden */
  74605. export var spriteMapPixelShader: {
  74606. name: string;
  74607. shader: string;
  74608. };
  74609. }
  74610. declare module "babylonjs/Shaders/spriteMap.vertex" {
  74611. /** @hidden */
  74612. export var spriteMapVertexShader: {
  74613. name: string;
  74614. shader: string;
  74615. };
  74616. }
  74617. declare module "babylonjs/Sprites/spriteMap" {
  74618. import { IDisposable, Scene } from "babylonjs/scene";
  74619. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  74620. import { Texture } from "babylonjs/Materials/Textures/texture";
  74621. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  74622. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  74623. import "babylonjs/Meshes/Builders/planeBuilder";
  74624. import "babylonjs/Shaders/spriteMap.fragment";
  74625. import "babylonjs/Shaders/spriteMap.vertex";
  74626. /**
  74627. * Defines the basic options interface of a SpriteMap
  74628. */
  74629. export interface ISpriteMapOptions {
  74630. /**
  74631. * Vector2 of the number of cells in the grid.
  74632. */
  74633. stageSize?: Vector2;
  74634. /**
  74635. * Vector2 of the size of the output plane in World Units.
  74636. */
  74637. outputSize?: Vector2;
  74638. /**
  74639. * Vector3 of the position of the output plane in World Units.
  74640. */
  74641. outputPosition?: Vector3;
  74642. /**
  74643. * Vector3 of the rotation of the output plane.
  74644. */
  74645. outputRotation?: Vector3;
  74646. /**
  74647. * number of layers that the system will reserve in resources.
  74648. */
  74649. layerCount?: number;
  74650. /**
  74651. * number of max animation frames a single cell will reserve in resources.
  74652. */
  74653. maxAnimationFrames?: number;
  74654. /**
  74655. * number cell index of the base tile when the system compiles.
  74656. */
  74657. baseTile?: number;
  74658. /**
  74659. * boolean flip the sprite after its been repositioned by the framing data.
  74660. */
  74661. flipU?: boolean;
  74662. /**
  74663. * Vector3 scalar of the global RGB values of the SpriteMap.
  74664. */
  74665. colorMultiply?: Vector3;
  74666. }
  74667. /**
  74668. * Defines the IDisposable interface in order to be cleanable from resources.
  74669. */
  74670. export interface ISpriteMap extends IDisposable {
  74671. /**
  74672. * String name of the SpriteMap.
  74673. */
  74674. name: string;
  74675. /**
  74676. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  74677. */
  74678. atlasJSON: ISpriteJSONAtlas;
  74679. /**
  74680. * Texture of the SpriteMap.
  74681. */
  74682. spriteSheet: Texture;
  74683. /**
  74684. * The parameters to initialize the SpriteMap with.
  74685. */
  74686. options: ISpriteMapOptions;
  74687. }
  74688. /**
  74689. * Class used to manage a grid restricted sprite deployment on an Output plane.
  74690. */
  74691. export class SpriteMap implements ISpriteMap {
  74692. /** The Name of the spriteMap */
  74693. name: string;
  74694. /** The JSON file with the frame and meta data */
  74695. atlasJSON: ISpriteJSONAtlas;
  74696. /** The systems Sprite Sheet Texture */
  74697. spriteSheet: Texture;
  74698. /** Arguments passed with the Constructor */
  74699. options: ISpriteMapOptions;
  74700. /** Public Sprite Storage array, parsed from atlasJSON */
  74701. sprites: Array<ISpriteJSONSprite>;
  74702. /** Returns the Number of Sprites in the System */
  74703. get spriteCount(): number;
  74704. /** Returns the Position of Output Plane*/
  74705. get position(): Vector3;
  74706. /** Returns the Position of Output Plane*/
  74707. set position(v: Vector3);
  74708. /** Returns the Rotation of Output Plane*/
  74709. get rotation(): Vector3;
  74710. /** Returns the Rotation of Output Plane*/
  74711. set rotation(v: Vector3);
  74712. /** Sets the AnimationMap*/
  74713. get animationMap(): RawTexture;
  74714. /** Sets the AnimationMap*/
  74715. set animationMap(v: RawTexture);
  74716. /** Scene that the SpriteMap was created in */
  74717. private _scene;
  74718. /** Texture Buffer of Float32 that holds tile frame data*/
  74719. private _frameMap;
  74720. /** Texture Buffers of Float32 that holds tileMap data*/
  74721. private _tileMaps;
  74722. /** Texture Buffer of Float32 that holds Animation Data*/
  74723. private _animationMap;
  74724. /** Custom ShaderMaterial Central to the System*/
  74725. private _material;
  74726. /** Custom ShaderMaterial Central to the System*/
  74727. private _output;
  74728. /** Systems Time Ticker*/
  74729. private _time;
  74730. /**
  74731. * Creates a new SpriteMap
  74732. * @param name defines the SpriteMaps Name
  74733. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  74734. * @param spriteSheet is the Texture that the Sprites are on.
  74735. * @param options a basic deployment configuration
  74736. * @param scene The Scene that the map is deployed on
  74737. */
  74738. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  74739. /**
  74740. * Returns tileID location
  74741. * @returns Vector2 the cell position ID
  74742. */
  74743. getTileID(): Vector2;
  74744. /**
  74745. * Gets the UV location of the mouse over the SpriteMap.
  74746. * @returns Vector2 the UV position of the mouse interaction
  74747. */
  74748. getMousePosition(): Vector2;
  74749. /**
  74750. * Creates the "frame" texture Buffer
  74751. * -------------------------------------
  74752. * Structure of frames
  74753. * "filename": "Falling-Water-2.png",
  74754. * "frame": {"x":69,"y":103,"w":24,"h":32},
  74755. * "rotated": true,
  74756. * "trimmed": true,
  74757. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  74758. * "sourceSize": {"w":32,"h":32}
  74759. * @returns RawTexture of the frameMap
  74760. */
  74761. private _createFrameBuffer;
  74762. /**
  74763. * Creates the tileMap texture Buffer
  74764. * @param buffer normally and array of numbers, or a false to generate from scratch
  74765. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  74766. * @returns RawTexture of the tileMap
  74767. */
  74768. private _createTileBuffer;
  74769. /**
  74770. * Modifies the data of the tileMaps
  74771. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  74772. * @param pos is the iVector2 Coordinates of the Tile
  74773. * @param tile The SpriteIndex of the new Tile
  74774. */
  74775. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  74776. /**
  74777. * Creates the animationMap texture Buffer
  74778. * @param buffer normally and array of numbers, or a false to generate from scratch
  74779. * @returns RawTexture of the animationMap
  74780. */
  74781. private _createTileAnimationBuffer;
  74782. /**
  74783. * Modifies the data of the animationMap
  74784. * @param cellID is the Index of the Sprite
  74785. * @param _frame is the target Animation frame
  74786. * @param toCell is the Target Index of the next frame of the animation
  74787. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  74788. * @param speed is a global scalar of the time variable on the map.
  74789. */
  74790. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  74791. /**
  74792. * Exports the .tilemaps file
  74793. */
  74794. saveTileMaps(): void;
  74795. /**
  74796. * Imports the .tilemaps file
  74797. * @param url of the .tilemaps file
  74798. */
  74799. loadTileMaps(url: string): void;
  74800. /**
  74801. * Release associated resources
  74802. */
  74803. dispose(): void;
  74804. }
  74805. }
  74806. declare module "babylonjs/Sprites/spritePackedManager" {
  74807. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  74808. import { Scene } from "babylonjs/scene";
  74809. /**
  74810. * Class used to manage multiple sprites of different sizes on the same spritesheet
  74811. * @see http://doc.babylonjs.com/babylon101/sprites
  74812. */
  74813. export class SpritePackedManager extends SpriteManager {
  74814. /** defines the packed manager's name */
  74815. name: string;
  74816. /**
  74817. * Creates a new sprite manager from a packed sprite sheet
  74818. * @param name defines the manager's name
  74819. * @param imgUrl defines the sprite sheet url
  74820. * @param capacity defines the maximum allowed number of sprites
  74821. * @param scene defines the hosting scene
  74822. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  74823. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  74824. * @param samplingMode defines the smapling mode to use with spritesheet
  74825. * @param fromPacked set to true; do not alter
  74826. */
  74827. constructor(
  74828. /** defines the packed manager's name */
  74829. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  74830. }
  74831. }
  74832. declare module "babylonjs/Sprites/index" {
  74833. export * from "babylonjs/Sprites/sprite";
  74834. export * from "babylonjs/Sprites/ISprites";
  74835. export * from "babylonjs/Sprites/spriteManager";
  74836. export * from "babylonjs/Sprites/spriteMap";
  74837. export * from "babylonjs/Sprites/spritePackedManager";
  74838. export * from "babylonjs/Sprites/spriteSceneComponent";
  74839. }
  74840. declare module "babylonjs/States/index" {
  74841. export * from "babylonjs/States/alphaCullingState";
  74842. export * from "babylonjs/States/depthCullingState";
  74843. export * from "babylonjs/States/stencilState";
  74844. }
  74845. declare module "babylonjs/Misc/assetsManager" {
  74846. import { Scene } from "babylonjs/scene";
  74847. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74848. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  74849. import { Skeleton } from "babylonjs/Bones/skeleton";
  74850. import { Observable } from "babylonjs/Misc/observable";
  74851. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  74852. import { Texture } from "babylonjs/Materials/Textures/texture";
  74853. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  74854. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  74855. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  74856. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  74857. /**
  74858. * Defines the list of states available for a task inside a AssetsManager
  74859. */
  74860. export enum AssetTaskState {
  74861. /**
  74862. * Initialization
  74863. */
  74864. INIT = 0,
  74865. /**
  74866. * Running
  74867. */
  74868. RUNNING = 1,
  74869. /**
  74870. * Done
  74871. */
  74872. DONE = 2,
  74873. /**
  74874. * Error
  74875. */
  74876. ERROR = 3
  74877. }
  74878. /**
  74879. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  74880. */
  74881. export abstract class AbstractAssetTask {
  74882. /**
  74883. * Task name
  74884. */ name: string;
  74885. /**
  74886. * Callback called when the task is successful
  74887. */
  74888. onSuccess: (task: any) => void;
  74889. /**
  74890. * Callback called when the task is not successful
  74891. */
  74892. onError: (task: any, message?: string, exception?: any) => void;
  74893. /**
  74894. * Creates a new AssetsManager
  74895. * @param name defines the name of the task
  74896. */
  74897. constructor(
  74898. /**
  74899. * Task name
  74900. */ name: string);
  74901. private _isCompleted;
  74902. private _taskState;
  74903. private _errorObject;
  74904. /**
  74905. * Get if the task is completed
  74906. */
  74907. get isCompleted(): boolean;
  74908. /**
  74909. * Gets the current state of the task
  74910. */
  74911. get taskState(): AssetTaskState;
  74912. /**
  74913. * Gets the current error object (if task is in error)
  74914. */
  74915. get errorObject(): {
  74916. message?: string;
  74917. exception?: any;
  74918. };
  74919. /**
  74920. * Internal only
  74921. * @hidden
  74922. */
  74923. _setErrorObject(message?: string, exception?: any): void;
  74924. /**
  74925. * Execute the current task
  74926. * @param scene defines the scene where you want your assets to be loaded
  74927. * @param onSuccess is a callback called when the task is successfully executed
  74928. * @param onError is a callback called if an error occurs
  74929. */
  74930. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74931. /**
  74932. * Execute the current task
  74933. * @param scene defines the scene where you want your assets to be loaded
  74934. * @param onSuccess is a callback called when the task is successfully executed
  74935. * @param onError is a callback called if an error occurs
  74936. */
  74937. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74938. /**
  74939. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  74940. * This can be used with failed tasks that have the reason for failure fixed.
  74941. */
  74942. reset(): void;
  74943. private onErrorCallback;
  74944. private onDoneCallback;
  74945. }
  74946. /**
  74947. * Define the interface used by progress events raised during assets loading
  74948. */
  74949. export interface IAssetsProgressEvent {
  74950. /**
  74951. * Defines the number of remaining tasks to process
  74952. */
  74953. remainingCount: number;
  74954. /**
  74955. * Defines the total number of tasks
  74956. */
  74957. totalCount: number;
  74958. /**
  74959. * Defines the task that was just processed
  74960. */
  74961. task: AbstractAssetTask;
  74962. }
  74963. /**
  74964. * Class used to share progress information about assets loading
  74965. */
  74966. export class AssetsProgressEvent implements IAssetsProgressEvent {
  74967. /**
  74968. * Defines the number of remaining tasks to process
  74969. */
  74970. remainingCount: number;
  74971. /**
  74972. * Defines the total number of tasks
  74973. */
  74974. totalCount: number;
  74975. /**
  74976. * Defines the task that was just processed
  74977. */
  74978. task: AbstractAssetTask;
  74979. /**
  74980. * Creates a AssetsProgressEvent
  74981. * @param remainingCount defines the number of remaining tasks to process
  74982. * @param totalCount defines the total number of tasks
  74983. * @param task defines the task that was just processed
  74984. */
  74985. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  74986. }
  74987. /**
  74988. * Define a task used by AssetsManager to load meshes
  74989. */
  74990. export class MeshAssetTask extends AbstractAssetTask {
  74991. /**
  74992. * Defines the name of the task
  74993. */
  74994. name: string;
  74995. /**
  74996. * Defines the list of mesh's names you want to load
  74997. */
  74998. meshesNames: any;
  74999. /**
  75000. * Defines the root url to use as a base to load your meshes and associated resources
  75001. */
  75002. rootUrl: string;
  75003. /**
  75004. * Defines the filename or File of the scene to load from
  75005. */
  75006. sceneFilename: string | File;
  75007. /**
  75008. * Gets the list of loaded meshes
  75009. */
  75010. loadedMeshes: Array<AbstractMesh>;
  75011. /**
  75012. * Gets the list of loaded particle systems
  75013. */
  75014. loadedParticleSystems: Array<IParticleSystem>;
  75015. /**
  75016. * Gets the list of loaded skeletons
  75017. */
  75018. loadedSkeletons: Array<Skeleton>;
  75019. /**
  75020. * Gets the list of loaded animation groups
  75021. */
  75022. loadedAnimationGroups: Array<AnimationGroup>;
  75023. /**
  75024. * Callback called when the task is successful
  75025. */
  75026. onSuccess: (task: MeshAssetTask) => void;
  75027. /**
  75028. * Callback called when the task is successful
  75029. */
  75030. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  75031. /**
  75032. * Creates a new MeshAssetTask
  75033. * @param name defines the name of the task
  75034. * @param meshesNames defines the list of mesh's names you want to load
  75035. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  75036. * @param sceneFilename defines the filename or File of the scene to load from
  75037. */
  75038. constructor(
  75039. /**
  75040. * Defines the name of the task
  75041. */
  75042. name: string,
  75043. /**
  75044. * Defines the list of mesh's names you want to load
  75045. */
  75046. meshesNames: any,
  75047. /**
  75048. * Defines the root url to use as a base to load your meshes and associated resources
  75049. */
  75050. rootUrl: string,
  75051. /**
  75052. * Defines the filename or File of the scene to load from
  75053. */
  75054. sceneFilename: string | File);
  75055. /**
  75056. * Execute the current task
  75057. * @param scene defines the scene where you want your assets to be loaded
  75058. * @param onSuccess is a callback called when the task is successfully executed
  75059. * @param onError is a callback called if an error occurs
  75060. */
  75061. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75062. }
  75063. /**
  75064. * Define a task used by AssetsManager to load text content
  75065. */
  75066. export class TextFileAssetTask extends AbstractAssetTask {
  75067. /**
  75068. * Defines the name of the task
  75069. */
  75070. name: string;
  75071. /**
  75072. * Defines the location of the file to load
  75073. */
  75074. url: string;
  75075. /**
  75076. * Gets the loaded text string
  75077. */
  75078. text: string;
  75079. /**
  75080. * Callback called when the task is successful
  75081. */
  75082. onSuccess: (task: TextFileAssetTask) => void;
  75083. /**
  75084. * Callback called when the task is successful
  75085. */
  75086. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  75087. /**
  75088. * Creates a new TextFileAssetTask object
  75089. * @param name defines the name of the task
  75090. * @param url defines the location of the file to load
  75091. */
  75092. constructor(
  75093. /**
  75094. * Defines the name of the task
  75095. */
  75096. name: string,
  75097. /**
  75098. * Defines the location of the file to load
  75099. */
  75100. url: string);
  75101. /**
  75102. * Execute the current task
  75103. * @param scene defines the scene where you want your assets to be loaded
  75104. * @param onSuccess is a callback called when the task is successfully executed
  75105. * @param onError is a callback called if an error occurs
  75106. */
  75107. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75108. }
  75109. /**
  75110. * Define a task used by AssetsManager to load binary data
  75111. */
  75112. export class BinaryFileAssetTask extends AbstractAssetTask {
  75113. /**
  75114. * Defines the name of the task
  75115. */
  75116. name: string;
  75117. /**
  75118. * Defines the location of the file to load
  75119. */
  75120. url: string;
  75121. /**
  75122. * Gets the lodaded data (as an array buffer)
  75123. */
  75124. data: ArrayBuffer;
  75125. /**
  75126. * Callback called when the task is successful
  75127. */
  75128. onSuccess: (task: BinaryFileAssetTask) => void;
  75129. /**
  75130. * Callback called when the task is successful
  75131. */
  75132. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  75133. /**
  75134. * Creates a new BinaryFileAssetTask object
  75135. * @param name defines the name of the new task
  75136. * @param url defines the location of the file to load
  75137. */
  75138. constructor(
  75139. /**
  75140. * Defines the name of the task
  75141. */
  75142. name: string,
  75143. /**
  75144. * Defines the location of the file to load
  75145. */
  75146. url: string);
  75147. /**
  75148. * Execute the current task
  75149. * @param scene defines the scene where you want your assets to be loaded
  75150. * @param onSuccess is a callback called when the task is successfully executed
  75151. * @param onError is a callback called if an error occurs
  75152. */
  75153. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75154. }
  75155. /**
  75156. * Define a task used by AssetsManager to load images
  75157. */
  75158. export class ImageAssetTask extends AbstractAssetTask {
  75159. /**
  75160. * Defines the name of the task
  75161. */
  75162. name: string;
  75163. /**
  75164. * Defines the location of the image to load
  75165. */
  75166. url: string;
  75167. /**
  75168. * Gets the loaded images
  75169. */
  75170. image: HTMLImageElement;
  75171. /**
  75172. * Callback called when the task is successful
  75173. */
  75174. onSuccess: (task: ImageAssetTask) => void;
  75175. /**
  75176. * Callback called when the task is successful
  75177. */
  75178. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  75179. /**
  75180. * Creates a new ImageAssetTask
  75181. * @param name defines the name of the task
  75182. * @param url defines the location of the image to load
  75183. */
  75184. constructor(
  75185. /**
  75186. * Defines the name of the task
  75187. */
  75188. name: string,
  75189. /**
  75190. * Defines the location of the image to load
  75191. */
  75192. url: string);
  75193. /**
  75194. * Execute the current task
  75195. * @param scene defines the scene where you want your assets to be loaded
  75196. * @param onSuccess is a callback called when the task is successfully executed
  75197. * @param onError is a callback called if an error occurs
  75198. */
  75199. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75200. }
  75201. /**
  75202. * Defines the interface used by texture loading tasks
  75203. */
  75204. export interface ITextureAssetTask<TEX extends BaseTexture> {
  75205. /**
  75206. * Gets the loaded texture
  75207. */
  75208. texture: TEX;
  75209. }
  75210. /**
  75211. * Define a task used by AssetsManager to load 2D textures
  75212. */
  75213. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  75214. /**
  75215. * Defines the name of the task
  75216. */
  75217. name: string;
  75218. /**
  75219. * Defines the location of the file to load
  75220. */
  75221. url: string;
  75222. /**
  75223. * Defines if mipmap should not be generated (default is false)
  75224. */
  75225. noMipmap?: boolean | undefined;
  75226. /**
  75227. * Defines if texture must be inverted on Y axis (default is true)
  75228. */
  75229. invertY: boolean;
  75230. /**
  75231. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75232. */
  75233. samplingMode: number;
  75234. /**
  75235. * Gets the loaded texture
  75236. */
  75237. texture: Texture;
  75238. /**
  75239. * Callback called when the task is successful
  75240. */
  75241. onSuccess: (task: TextureAssetTask) => void;
  75242. /**
  75243. * Callback called when the task is successful
  75244. */
  75245. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  75246. /**
  75247. * Creates a new TextureAssetTask object
  75248. * @param name defines the name of the task
  75249. * @param url defines the location of the file to load
  75250. * @param noMipmap defines if mipmap should not be generated (default is false)
  75251. * @param invertY defines if texture must be inverted on Y axis (default is true)
  75252. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75253. */
  75254. constructor(
  75255. /**
  75256. * Defines the name of the task
  75257. */
  75258. name: string,
  75259. /**
  75260. * Defines the location of the file to load
  75261. */
  75262. url: string,
  75263. /**
  75264. * Defines if mipmap should not be generated (default is false)
  75265. */
  75266. noMipmap?: boolean | undefined,
  75267. /**
  75268. * Defines if texture must be inverted on Y axis (default is true)
  75269. */
  75270. invertY?: boolean,
  75271. /**
  75272. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75273. */
  75274. samplingMode?: number);
  75275. /**
  75276. * Execute the current task
  75277. * @param scene defines the scene where you want your assets to be loaded
  75278. * @param onSuccess is a callback called when the task is successfully executed
  75279. * @param onError is a callback called if an error occurs
  75280. */
  75281. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75282. }
  75283. /**
  75284. * Define a task used by AssetsManager to load cube textures
  75285. */
  75286. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  75287. /**
  75288. * Defines the name of the task
  75289. */
  75290. name: string;
  75291. /**
  75292. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75293. */
  75294. url: string;
  75295. /**
  75296. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75297. */
  75298. extensions?: string[] | undefined;
  75299. /**
  75300. * Defines if mipmaps should not be generated (default is false)
  75301. */
  75302. noMipmap?: boolean | undefined;
  75303. /**
  75304. * Defines the explicit list of files (undefined by default)
  75305. */
  75306. files?: string[] | undefined;
  75307. /**
  75308. * Gets the loaded texture
  75309. */
  75310. texture: CubeTexture;
  75311. /**
  75312. * Callback called when the task is successful
  75313. */
  75314. onSuccess: (task: CubeTextureAssetTask) => void;
  75315. /**
  75316. * Callback called when the task is successful
  75317. */
  75318. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  75319. /**
  75320. * Creates a new CubeTextureAssetTask
  75321. * @param name defines the name of the task
  75322. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75323. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75324. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75325. * @param files defines the explicit list of files (undefined by default)
  75326. */
  75327. constructor(
  75328. /**
  75329. * Defines the name of the task
  75330. */
  75331. name: string,
  75332. /**
  75333. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75334. */
  75335. url: string,
  75336. /**
  75337. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75338. */
  75339. extensions?: string[] | undefined,
  75340. /**
  75341. * Defines if mipmaps should not be generated (default is false)
  75342. */
  75343. noMipmap?: boolean | undefined,
  75344. /**
  75345. * Defines the explicit list of files (undefined by default)
  75346. */
  75347. files?: string[] | undefined);
  75348. /**
  75349. * Execute the current task
  75350. * @param scene defines the scene where you want your assets to be loaded
  75351. * @param onSuccess is a callback called when the task is successfully executed
  75352. * @param onError is a callback called if an error occurs
  75353. */
  75354. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75355. }
  75356. /**
  75357. * Define a task used by AssetsManager to load HDR cube textures
  75358. */
  75359. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  75360. /**
  75361. * Defines the name of the task
  75362. */
  75363. name: string;
  75364. /**
  75365. * Defines the location of the file to load
  75366. */
  75367. url: string;
  75368. /**
  75369. * Defines the desired size (the more it increases the longer the generation will be)
  75370. */
  75371. size: number;
  75372. /**
  75373. * Defines if mipmaps should not be generated (default is false)
  75374. */
  75375. noMipmap: boolean;
  75376. /**
  75377. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75378. */
  75379. generateHarmonics: boolean;
  75380. /**
  75381. * 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)
  75382. */
  75383. gammaSpace: boolean;
  75384. /**
  75385. * Internal Use Only
  75386. */
  75387. reserved: boolean;
  75388. /**
  75389. * Gets the loaded texture
  75390. */
  75391. texture: HDRCubeTexture;
  75392. /**
  75393. * Callback called when the task is successful
  75394. */
  75395. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  75396. /**
  75397. * Callback called when the task is successful
  75398. */
  75399. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  75400. /**
  75401. * Creates a new HDRCubeTextureAssetTask object
  75402. * @param name defines the name of the task
  75403. * @param url defines the location of the file to load
  75404. * @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.
  75405. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75406. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75407. * @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)
  75408. * @param reserved Internal use only
  75409. */
  75410. constructor(
  75411. /**
  75412. * Defines the name of the task
  75413. */
  75414. name: string,
  75415. /**
  75416. * Defines the location of the file to load
  75417. */
  75418. url: string,
  75419. /**
  75420. * Defines the desired size (the more it increases the longer the generation will be)
  75421. */
  75422. size: number,
  75423. /**
  75424. * Defines if mipmaps should not be generated (default is false)
  75425. */
  75426. noMipmap?: boolean,
  75427. /**
  75428. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75429. */
  75430. generateHarmonics?: boolean,
  75431. /**
  75432. * 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)
  75433. */
  75434. gammaSpace?: boolean,
  75435. /**
  75436. * Internal Use Only
  75437. */
  75438. reserved?: boolean);
  75439. /**
  75440. * Execute the current task
  75441. * @param scene defines the scene where you want your assets to be loaded
  75442. * @param onSuccess is a callback called when the task is successfully executed
  75443. * @param onError is a callback called if an error occurs
  75444. */
  75445. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75446. }
  75447. /**
  75448. * Define a task used by AssetsManager to load Equirectangular cube textures
  75449. */
  75450. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  75451. /**
  75452. * Defines the name of the task
  75453. */
  75454. name: string;
  75455. /**
  75456. * Defines the location of the file to load
  75457. */
  75458. url: string;
  75459. /**
  75460. * Defines the desired size (the more it increases the longer the generation will be)
  75461. */
  75462. size: number;
  75463. /**
  75464. * Defines if mipmaps should not be generated (default is false)
  75465. */
  75466. noMipmap: boolean;
  75467. /**
  75468. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  75469. * but the standard material would require them in Gamma space) (default is true)
  75470. */
  75471. gammaSpace: boolean;
  75472. /**
  75473. * Gets the loaded texture
  75474. */
  75475. texture: EquiRectangularCubeTexture;
  75476. /**
  75477. * Callback called when the task is successful
  75478. */
  75479. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  75480. /**
  75481. * Callback called when the task is successful
  75482. */
  75483. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  75484. /**
  75485. * Creates a new EquiRectangularCubeTextureAssetTask object
  75486. * @param name defines the name of the task
  75487. * @param url defines the location of the file to load
  75488. * @param size defines the desired size (the more it increases the longer the generation will be)
  75489. * If the size is omitted this implies you are using a preprocessed cubemap.
  75490. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75491. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  75492. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  75493. * (default is true)
  75494. */
  75495. constructor(
  75496. /**
  75497. * Defines the name of the task
  75498. */
  75499. name: string,
  75500. /**
  75501. * Defines the location of the file to load
  75502. */
  75503. url: string,
  75504. /**
  75505. * Defines the desired size (the more it increases the longer the generation will be)
  75506. */
  75507. size: number,
  75508. /**
  75509. * Defines if mipmaps should not be generated (default is false)
  75510. */
  75511. noMipmap?: boolean,
  75512. /**
  75513. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  75514. * but the standard material would require them in Gamma space) (default is true)
  75515. */
  75516. gammaSpace?: boolean);
  75517. /**
  75518. * Execute the current task
  75519. * @param scene defines the scene where you want your assets to be loaded
  75520. * @param onSuccess is a callback called when the task is successfully executed
  75521. * @param onError is a callback called if an error occurs
  75522. */
  75523. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75524. }
  75525. /**
  75526. * This class can be used to easily import assets into a scene
  75527. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  75528. */
  75529. export class AssetsManager {
  75530. private _scene;
  75531. private _isLoading;
  75532. protected _tasks: AbstractAssetTask[];
  75533. protected _waitingTasksCount: number;
  75534. protected _totalTasksCount: number;
  75535. /**
  75536. * Callback called when all tasks are processed
  75537. */
  75538. onFinish: (tasks: AbstractAssetTask[]) => void;
  75539. /**
  75540. * Callback called when a task is successful
  75541. */
  75542. onTaskSuccess: (task: AbstractAssetTask) => void;
  75543. /**
  75544. * Callback called when a task had an error
  75545. */
  75546. onTaskError: (task: AbstractAssetTask) => void;
  75547. /**
  75548. * Callback called when a task is done (whatever the result is)
  75549. */
  75550. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  75551. /**
  75552. * Observable called when all tasks are processed
  75553. */
  75554. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  75555. /**
  75556. * Observable called when a task had an error
  75557. */
  75558. onTaskErrorObservable: Observable<AbstractAssetTask>;
  75559. /**
  75560. * Observable called when all tasks were executed
  75561. */
  75562. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  75563. /**
  75564. * Observable called when a task is done (whatever the result is)
  75565. */
  75566. onProgressObservable: Observable<IAssetsProgressEvent>;
  75567. /**
  75568. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  75569. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  75570. */
  75571. useDefaultLoadingScreen: boolean;
  75572. /**
  75573. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  75574. * when all assets have been downloaded.
  75575. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  75576. */
  75577. autoHideLoadingUI: boolean;
  75578. /**
  75579. * Creates a new AssetsManager
  75580. * @param scene defines the scene to work on
  75581. */
  75582. constructor(scene: Scene);
  75583. /**
  75584. * Add a MeshAssetTask to the list of active tasks
  75585. * @param taskName defines the name of the new task
  75586. * @param meshesNames defines the name of meshes to load
  75587. * @param rootUrl defines the root url to use to locate files
  75588. * @param sceneFilename defines the filename of the scene file
  75589. * @returns a new MeshAssetTask object
  75590. */
  75591. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  75592. /**
  75593. * Add a TextFileAssetTask to the list of active tasks
  75594. * @param taskName defines the name of the new task
  75595. * @param url defines the url of the file to load
  75596. * @returns a new TextFileAssetTask object
  75597. */
  75598. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  75599. /**
  75600. * Add a BinaryFileAssetTask to the list of active tasks
  75601. * @param taskName defines the name of the new task
  75602. * @param url defines the url of the file to load
  75603. * @returns a new BinaryFileAssetTask object
  75604. */
  75605. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  75606. /**
  75607. * Add a ImageAssetTask to the list of active tasks
  75608. * @param taskName defines the name of the new task
  75609. * @param url defines the url of the file to load
  75610. * @returns a new ImageAssetTask object
  75611. */
  75612. addImageTask(taskName: string, url: string): ImageAssetTask;
  75613. /**
  75614. * Add a TextureAssetTask to the list of active tasks
  75615. * @param taskName defines the name of the new task
  75616. * @param url defines the url of the file to load
  75617. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75618. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  75619. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  75620. * @returns a new TextureAssetTask object
  75621. */
  75622. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  75623. /**
  75624. * Add a CubeTextureAssetTask to the list of active tasks
  75625. * @param taskName defines the name of the new task
  75626. * @param url defines the url of the file to load
  75627. * @param extensions defines the extension to use to load the cube map (can be null)
  75628. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75629. * @param files defines the list of files to load (can be null)
  75630. * @returns a new CubeTextureAssetTask object
  75631. */
  75632. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  75633. /**
  75634. *
  75635. * Add a HDRCubeTextureAssetTask to the list of active tasks
  75636. * @param taskName defines the name of the new task
  75637. * @param url defines the url of the file to load
  75638. * @param size defines the size you want for the cubemap (can be null)
  75639. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75640. * @param generateHarmonics defines if you want to automatically generate (true by default)
  75641. * @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)
  75642. * @param reserved Internal use only
  75643. * @returns a new HDRCubeTextureAssetTask object
  75644. */
  75645. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  75646. /**
  75647. *
  75648. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  75649. * @param taskName defines the name of the new task
  75650. * @param url defines the url of the file to load
  75651. * @param size defines the size you want for the cubemap (can be null)
  75652. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75653. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  75654. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  75655. * @returns a new EquiRectangularCubeTextureAssetTask object
  75656. */
  75657. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  75658. /**
  75659. * Remove a task from the assets manager.
  75660. * @param task the task to remove
  75661. */
  75662. removeTask(task: AbstractAssetTask): void;
  75663. private _decreaseWaitingTasksCount;
  75664. private _runTask;
  75665. /**
  75666. * Reset the AssetsManager and remove all tasks
  75667. * @return the current instance of the AssetsManager
  75668. */
  75669. reset(): AssetsManager;
  75670. /**
  75671. * Start the loading process
  75672. * @return the current instance of the AssetsManager
  75673. */
  75674. load(): AssetsManager;
  75675. /**
  75676. * Start the loading process as an async operation
  75677. * @return a promise returning the list of failed tasks
  75678. */
  75679. loadAsync(): Promise<void>;
  75680. }
  75681. }
  75682. declare module "babylonjs/Misc/deferred" {
  75683. /**
  75684. * Wrapper class for promise with external resolve and reject.
  75685. */
  75686. export class Deferred<T> {
  75687. /**
  75688. * The promise associated with this deferred object.
  75689. */
  75690. readonly promise: Promise<T>;
  75691. private _resolve;
  75692. private _reject;
  75693. /**
  75694. * The resolve method of the promise associated with this deferred object.
  75695. */
  75696. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  75697. /**
  75698. * The reject method of the promise associated with this deferred object.
  75699. */
  75700. get reject(): (reason?: any) => void;
  75701. /**
  75702. * Constructor for this deferred object.
  75703. */
  75704. constructor();
  75705. }
  75706. }
  75707. declare module "babylonjs/Misc/meshExploder" {
  75708. import { Mesh } from "babylonjs/Meshes/mesh";
  75709. /**
  75710. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  75711. */
  75712. export class MeshExploder {
  75713. private _centerMesh;
  75714. private _meshes;
  75715. private _meshesOrigins;
  75716. private _toCenterVectors;
  75717. private _scaledDirection;
  75718. private _newPosition;
  75719. private _centerPosition;
  75720. /**
  75721. * Explodes meshes from a center mesh.
  75722. * @param meshes The meshes to explode.
  75723. * @param centerMesh The mesh to be center of explosion.
  75724. */
  75725. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  75726. private _setCenterMesh;
  75727. /**
  75728. * Get class name
  75729. * @returns "MeshExploder"
  75730. */
  75731. getClassName(): string;
  75732. /**
  75733. * "Exploded meshes"
  75734. * @returns Array of meshes with the centerMesh at index 0.
  75735. */
  75736. getMeshes(): Array<Mesh>;
  75737. /**
  75738. * Explodes meshes giving a specific direction
  75739. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  75740. */
  75741. explode(direction?: number): void;
  75742. }
  75743. }
  75744. declare module "babylonjs/Misc/filesInput" {
  75745. import { Engine } from "babylonjs/Engines/engine";
  75746. import { Scene } from "babylonjs/scene";
  75747. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  75748. /**
  75749. * Class used to help managing file picking and drag'n'drop
  75750. */
  75751. export class FilesInput {
  75752. /**
  75753. * List of files ready to be loaded
  75754. */
  75755. static get FilesToLoad(): {
  75756. [key: string]: File;
  75757. };
  75758. /**
  75759. * Callback called when a file is processed
  75760. */
  75761. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  75762. private _engine;
  75763. private _currentScene;
  75764. private _sceneLoadedCallback;
  75765. private _progressCallback;
  75766. private _additionalRenderLoopLogicCallback;
  75767. private _textureLoadingCallback;
  75768. private _startingProcessingFilesCallback;
  75769. private _onReloadCallback;
  75770. private _errorCallback;
  75771. private _elementToMonitor;
  75772. private _sceneFileToLoad;
  75773. private _filesToLoad;
  75774. /**
  75775. * Creates a new FilesInput
  75776. * @param engine defines the rendering engine
  75777. * @param scene defines the hosting scene
  75778. * @param sceneLoadedCallback callback called when scene is loaded
  75779. * @param progressCallback callback called to track progress
  75780. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  75781. * @param textureLoadingCallback callback called when a texture is loading
  75782. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  75783. * @param onReloadCallback callback called when a reload is requested
  75784. * @param errorCallback callback call if an error occurs
  75785. */
  75786. 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);
  75787. private _dragEnterHandler;
  75788. private _dragOverHandler;
  75789. private _dropHandler;
  75790. /**
  75791. * Calls this function to listen to drag'n'drop events on a specific DOM element
  75792. * @param elementToMonitor defines the DOM element to track
  75793. */
  75794. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  75795. /**
  75796. * Release all associated resources
  75797. */
  75798. dispose(): void;
  75799. private renderFunction;
  75800. private drag;
  75801. private drop;
  75802. private _traverseFolder;
  75803. private _processFiles;
  75804. /**
  75805. * Load files from a drop event
  75806. * @param event defines the drop event to use as source
  75807. */
  75808. loadFiles(event: any): void;
  75809. private _processReload;
  75810. /**
  75811. * Reload the current scene from the loaded files
  75812. */
  75813. reload(): void;
  75814. }
  75815. }
  75816. declare module "babylonjs/Misc/HighDynamicRange/index" {
  75817. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  75818. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  75819. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  75820. }
  75821. declare module "babylonjs/Misc/sceneOptimizer" {
  75822. import { Scene, IDisposable } from "babylonjs/scene";
  75823. import { Observable } from "babylonjs/Misc/observable";
  75824. /**
  75825. * Defines the root class used to create scene optimization to use with SceneOptimizer
  75826. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75827. */
  75828. export class SceneOptimization {
  75829. /**
  75830. * Defines the priority of this optimization (0 by default which means first in the list)
  75831. */
  75832. priority: number;
  75833. /**
  75834. * Gets a string describing the action executed by the current optimization
  75835. * @returns description string
  75836. */
  75837. getDescription(): string;
  75838. /**
  75839. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75840. * @param scene defines the current scene where to apply this optimization
  75841. * @param optimizer defines the current optimizer
  75842. * @returns true if everything that can be done was applied
  75843. */
  75844. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75845. /**
  75846. * Creates the SceneOptimization object
  75847. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75848. * @param desc defines the description associated with the optimization
  75849. */
  75850. constructor(
  75851. /**
  75852. * Defines the priority of this optimization (0 by default which means first in the list)
  75853. */
  75854. priority?: number);
  75855. }
  75856. /**
  75857. * Defines an optimization used to reduce the size of render target textures
  75858. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75859. */
  75860. export class TextureOptimization extends SceneOptimization {
  75861. /**
  75862. * Defines the priority of this optimization (0 by default which means first in the list)
  75863. */
  75864. priority: number;
  75865. /**
  75866. * 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
  75867. */
  75868. maximumSize: number;
  75869. /**
  75870. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75871. */
  75872. step: number;
  75873. /**
  75874. * Gets a string describing the action executed by the current optimization
  75875. * @returns description string
  75876. */
  75877. getDescription(): string;
  75878. /**
  75879. * Creates the TextureOptimization object
  75880. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75881. * @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
  75882. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75883. */
  75884. constructor(
  75885. /**
  75886. * Defines the priority of this optimization (0 by default which means first in the list)
  75887. */
  75888. priority?: number,
  75889. /**
  75890. * 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
  75891. */
  75892. maximumSize?: number,
  75893. /**
  75894. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75895. */
  75896. step?: number);
  75897. /**
  75898. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75899. * @param scene defines the current scene where to apply this optimization
  75900. * @param optimizer defines the current optimizer
  75901. * @returns true if everything that can be done was applied
  75902. */
  75903. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75904. }
  75905. /**
  75906. * Defines an optimization used to increase or decrease the rendering resolution
  75907. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75908. */
  75909. export class HardwareScalingOptimization extends SceneOptimization {
  75910. /**
  75911. * Defines the priority of this optimization (0 by default which means first in the list)
  75912. */
  75913. priority: number;
  75914. /**
  75915. * Defines the maximum scale to use (2 by default)
  75916. */
  75917. maximumScale: number;
  75918. /**
  75919. * Defines the step to use between two passes (0.5 by default)
  75920. */
  75921. step: number;
  75922. private _currentScale;
  75923. private _directionOffset;
  75924. /**
  75925. * Gets a string describing the action executed by the current optimization
  75926. * @return description string
  75927. */
  75928. getDescription(): string;
  75929. /**
  75930. * Creates the HardwareScalingOptimization object
  75931. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75932. * @param maximumScale defines the maximum scale to use (2 by default)
  75933. * @param step defines the step to use between two passes (0.5 by default)
  75934. */
  75935. constructor(
  75936. /**
  75937. * Defines the priority of this optimization (0 by default which means first in the list)
  75938. */
  75939. priority?: number,
  75940. /**
  75941. * Defines the maximum scale to use (2 by default)
  75942. */
  75943. maximumScale?: number,
  75944. /**
  75945. * Defines the step to use between two passes (0.5 by default)
  75946. */
  75947. step?: number);
  75948. /**
  75949. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75950. * @param scene defines the current scene where to apply this optimization
  75951. * @param optimizer defines the current optimizer
  75952. * @returns true if everything that can be done was applied
  75953. */
  75954. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75955. }
  75956. /**
  75957. * Defines an optimization used to remove shadows
  75958. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75959. */
  75960. export class ShadowsOptimization extends SceneOptimization {
  75961. /**
  75962. * Gets a string describing the action executed by the current optimization
  75963. * @return description string
  75964. */
  75965. getDescription(): string;
  75966. /**
  75967. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75968. * @param scene defines the current scene where to apply this optimization
  75969. * @param optimizer defines the current optimizer
  75970. * @returns true if everything that can be done was applied
  75971. */
  75972. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75973. }
  75974. /**
  75975. * Defines an optimization used to turn post-processes off
  75976. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75977. */
  75978. export class PostProcessesOptimization extends SceneOptimization {
  75979. /**
  75980. * Gets a string describing the action executed by the current optimization
  75981. * @return description string
  75982. */
  75983. getDescription(): string;
  75984. /**
  75985. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75986. * @param scene defines the current scene where to apply this optimization
  75987. * @param optimizer defines the current optimizer
  75988. * @returns true if everything that can be done was applied
  75989. */
  75990. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75991. }
  75992. /**
  75993. * Defines an optimization used to turn lens flares off
  75994. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75995. */
  75996. export class LensFlaresOptimization extends SceneOptimization {
  75997. /**
  75998. * Gets a string describing the action executed by the current optimization
  75999. * @return description string
  76000. */
  76001. getDescription(): string;
  76002. /**
  76003. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76004. * @param scene defines the current scene where to apply this optimization
  76005. * @param optimizer defines the current optimizer
  76006. * @returns true if everything that can be done was applied
  76007. */
  76008. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76009. }
  76010. /**
  76011. * Defines an optimization based on user defined callback.
  76012. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76013. */
  76014. export class CustomOptimization extends SceneOptimization {
  76015. /**
  76016. * Callback called to apply the custom optimization.
  76017. */
  76018. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  76019. /**
  76020. * Callback called to get custom description
  76021. */
  76022. onGetDescription: () => string;
  76023. /**
  76024. * Gets a string describing the action executed by the current optimization
  76025. * @returns description string
  76026. */
  76027. getDescription(): string;
  76028. /**
  76029. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76030. * @param scene defines the current scene where to apply this optimization
  76031. * @param optimizer defines the current optimizer
  76032. * @returns true if everything that can be done was applied
  76033. */
  76034. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76035. }
  76036. /**
  76037. * Defines an optimization used to turn particles off
  76038. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76039. */
  76040. export class ParticlesOptimization extends SceneOptimization {
  76041. /**
  76042. * Gets a string describing the action executed by the current optimization
  76043. * @return description string
  76044. */
  76045. getDescription(): string;
  76046. /**
  76047. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76048. * @param scene defines the current scene where to apply this optimization
  76049. * @param optimizer defines the current optimizer
  76050. * @returns true if everything that can be done was applied
  76051. */
  76052. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76053. }
  76054. /**
  76055. * Defines an optimization used to turn render targets off
  76056. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76057. */
  76058. export class RenderTargetsOptimization extends SceneOptimization {
  76059. /**
  76060. * Gets a string describing the action executed by the current optimization
  76061. * @return description string
  76062. */
  76063. getDescription(): string;
  76064. /**
  76065. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76066. * @param scene defines the current scene where to apply this optimization
  76067. * @param optimizer defines the current optimizer
  76068. * @returns true if everything that can be done was applied
  76069. */
  76070. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76071. }
  76072. /**
  76073. * Defines an optimization used to merge meshes with compatible materials
  76074. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76075. */
  76076. export class MergeMeshesOptimization extends SceneOptimization {
  76077. private static _UpdateSelectionTree;
  76078. /**
  76079. * Gets or sets a boolean which defines if optimization octree has to be updated
  76080. */
  76081. static get UpdateSelectionTree(): boolean;
  76082. /**
  76083. * Gets or sets a boolean which defines if optimization octree has to be updated
  76084. */
  76085. static set UpdateSelectionTree(value: boolean);
  76086. /**
  76087. * Gets a string describing the action executed by the current optimization
  76088. * @return description string
  76089. */
  76090. getDescription(): string;
  76091. private _canBeMerged;
  76092. /**
  76093. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76094. * @param scene defines the current scene where to apply this optimization
  76095. * @param optimizer defines the current optimizer
  76096. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  76097. * @returns true if everything that can be done was applied
  76098. */
  76099. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  76100. }
  76101. /**
  76102. * Defines a list of options used by SceneOptimizer
  76103. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76104. */
  76105. export class SceneOptimizerOptions {
  76106. /**
  76107. * Defines the target frame rate to reach (60 by default)
  76108. */
  76109. targetFrameRate: number;
  76110. /**
  76111. * Defines the interval between two checkes (2000ms by default)
  76112. */
  76113. trackerDuration: number;
  76114. /**
  76115. * Gets the list of optimizations to apply
  76116. */
  76117. optimizations: SceneOptimization[];
  76118. /**
  76119. * Creates a new list of options used by SceneOptimizer
  76120. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  76121. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  76122. */
  76123. constructor(
  76124. /**
  76125. * Defines the target frame rate to reach (60 by default)
  76126. */
  76127. targetFrameRate?: number,
  76128. /**
  76129. * Defines the interval between two checkes (2000ms by default)
  76130. */
  76131. trackerDuration?: number);
  76132. /**
  76133. * Add a new optimization
  76134. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  76135. * @returns the current SceneOptimizerOptions
  76136. */
  76137. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  76138. /**
  76139. * Add a new custom optimization
  76140. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  76141. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  76142. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76143. * @returns the current SceneOptimizerOptions
  76144. */
  76145. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  76146. /**
  76147. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  76148. * @param targetFrameRate defines the target frame rate (60 by default)
  76149. * @returns a SceneOptimizerOptions object
  76150. */
  76151. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76152. /**
  76153. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  76154. * @param targetFrameRate defines the target frame rate (60 by default)
  76155. * @returns a SceneOptimizerOptions object
  76156. */
  76157. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76158. /**
  76159. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  76160. * @param targetFrameRate defines the target frame rate (60 by default)
  76161. * @returns a SceneOptimizerOptions object
  76162. */
  76163. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76164. }
  76165. /**
  76166. * Class used to run optimizations in order to reach a target frame rate
  76167. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76168. */
  76169. export class SceneOptimizer implements IDisposable {
  76170. private _isRunning;
  76171. private _options;
  76172. private _scene;
  76173. private _currentPriorityLevel;
  76174. private _targetFrameRate;
  76175. private _trackerDuration;
  76176. private _currentFrameRate;
  76177. private _sceneDisposeObserver;
  76178. private _improvementMode;
  76179. /**
  76180. * Defines an observable called when the optimizer reaches the target frame rate
  76181. */
  76182. onSuccessObservable: Observable<SceneOptimizer>;
  76183. /**
  76184. * Defines an observable called when the optimizer enables an optimization
  76185. */
  76186. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  76187. /**
  76188. * Defines an observable called when the optimizer is not able to reach the target frame rate
  76189. */
  76190. onFailureObservable: Observable<SceneOptimizer>;
  76191. /**
  76192. * Gets a boolean indicating if the optimizer is in improvement mode
  76193. */
  76194. get isInImprovementMode(): boolean;
  76195. /**
  76196. * Gets the current priority level (0 at start)
  76197. */
  76198. get currentPriorityLevel(): number;
  76199. /**
  76200. * Gets the current frame rate checked by the SceneOptimizer
  76201. */
  76202. get currentFrameRate(): number;
  76203. /**
  76204. * Gets or sets the current target frame rate (60 by default)
  76205. */
  76206. get targetFrameRate(): number;
  76207. /**
  76208. * Gets or sets the current target frame rate (60 by default)
  76209. */
  76210. set targetFrameRate(value: number);
  76211. /**
  76212. * Gets or sets the current interval between two checks (every 2000ms by default)
  76213. */
  76214. get trackerDuration(): number;
  76215. /**
  76216. * Gets or sets the current interval between two checks (every 2000ms by default)
  76217. */
  76218. set trackerDuration(value: number);
  76219. /**
  76220. * Gets the list of active optimizations
  76221. */
  76222. get optimizations(): SceneOptimization[];
  76223. /**
  76224. * Creates a new SceneOptimizer
  76225. * @param scene defines the scene to work on
  76226. * @param options defines the options to use with the SceneOptimizer
  76227. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  76228. * @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)
  76229. */
  76230. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  76231. /**
  76232. * Stops the current optimizer
  76233. */
  76234. stop(): void;
  76235. /**
  76236. * Reset the optimizer to initial step (current priority level = 0)
  76237. */
  76238. reset(): void;
  76239. /**
  76240. * Start the optimizer. By default it will try to reach a specific framerate
  76241. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  76242. */
  76243. start(): void;
  76244. private _checkCurrentState;
  76245. /**
  76246. * Release all resources
  76247. */
  76248. dispose(): void;
  76249. /**
  76250. * Helper function to create a SceneOptimizer with one single line of code
  76251. * @param scene defines the scene to work on
  76252. * @param options defines the options to use with the SceneOptimizer
  76253. * @param onSuccess defines a callback to call on success
  76254. * @param onFailure defines a callback to call on failure
  76255. * @returns the new SceneOptimizer object
  76256. */
  76257. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  76258. }
  76259. }
  76260. declare module "babylonjs/Misc/sceneSerializer" {
  76261. import { Scene } from "babylonjs/scene";
  76262. /**
  76263. * Class used to serialize a scene into a string
  76264. */
  76265. export class SceneSerializer {
  76266. /**
  76267. * Clear cache used by a previous serialization
  76268. */
  76269. static ClearCache(): void;
  76270. /**
  76271. * Serialize a scene into a JSON compatible object
  76272. * @param scene defines the scene to serialize
  76273. * @returns a JSON compatible object
  76274. */
  76275. static Serialize(scene: Scene): any;
  76276. /**
  76277. * Serialize a mesh into a JSON compatible object
  76278. * @param toSerialize defines the mesh to serialize
  76279. * @param withParents defines if parents must be serialized as well
  76280. * @param withChildren defines if children must be serialized as well
  76281. * @returns a JSON compatible object
  76282. */
  76283. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  76284. }
  76285. }
  76286. declare module "babylonjs/Misc/textureTools" {
  76287. import { Texture } from "babylonjs/Materials/Textures/texture";
  76288. /**
  76289. * Class used to host texture specific utilities
  76290. */
  76291. export class TextureTools {
  76292. /**
  76293. * Uses the GPU to create a copy texture rescaled at a given size
  76294. * @param texture Texture to copy from
  76295. * @param width defines the desired width
  76296. * @param height defines the desired height
  76297. * @param useBilinearMode defines if bilinear mode has to be used
  76298. * @return the generated texture
  76299. */
  76300. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  76301. }
  76302. }
  76303. declare module "babylonjs/Misc/videoRecorder" {
  76304. import { Nullable } from "babylonjs/types";
  76305. import { Engine } from "babylonjs/Engines/engine";
  76306. /**
  76307. * This represents the different options available for the video capture.
  76308. */
  76309. export interface VideoRecorderOptions {
  76310. /** Defines the mime type of the video. */
  76311. mimeType: string;
  76312. /** Defines the FPS the video should be recorded at. */
  76313. fps: number;
  76314. /** Defines the chunk size for the recording data. */
  76315. recordChunckSize: number;
  76316. /** The audio tracks to attach to the recording. */
  76317. audioTracks?: MediaStreamTrack[];
  76318. }
  76319. /**
  76320. * This can help with recording videos from BabylonJS.
  76321. * This is based on the available WebRTC functionalities of the browser.
  76322. *
  76323. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  76324. */
  76325. export class VideoRecorder {
  76326. private static readonly _defaultOptions;
  76327. /**
  76328. * Returns whether or not the VideoRecorder is available in your browser.
  76329. * @param engine Defines the Babylon Engine.
  76330. * @returns true if supported otherwise false.
  76331. */
  76332. static IsSupported(engine: Engine): boolean;
  76333. private readonly _options;
  76334. private _canvas;
  76335. private _mediaRecorder;
  76336. private _recordedChunks;
  76337. private _fileName;
  76338. private _resolve;
  76339. private _reject;
  76340. /**
  76341. * True when a recording is already in progress.
  76342. */
  76343. get isRecording(): boolean;
  76344. /**
  76345. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  76346. * @param engine Defines the BabylonJS Engine you wish to record.
  76347. * @param options Defines options that can be used to customize the capture.
  76348. */
  76349. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  76350. /**
  76351. * Stops the current recording before the default capture timeout passed in the startRecording function.
  76352. */
  76353. stopRecording(): void;
  76354. /**
  76355. * Starts recording the canvas for a max duration specified in parameters.
  76356. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  76357. * If null no automatic download will start and you can rely on the promise to get the data back.
  76358. * @param maxDuration Defines the maximum recording time in seconds.
  76359. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  76360. * @return A promise callback at the end of the recording with the video data in Blob.
  76361. */
  76362. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  76363. /**
  76364. * Releases internal resources used during the recording.
  76365. */
  76366. dispose(): void;
  76367. private _handleDataAvailable;
  76368. private _handleError;
  76369. private _handleStop;
  76370. }
  76371. }
  76372. declare module "babylonjs/Misc/screenshotTools" {
  76373. import { Camera } from "babylonjs/Cameras/camera";
  76374. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  76375. import { Engine } from "babylonjs/Engines/engine";
  76376. /**
  76377. * Class containing a set of static utilities functions for screenshots
  76378. */
  76379. export class ScreenshotTools {
  76380. /**
  76381. * Captures a screenshot of the current rendering
  76382. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76383. * @param engine defines the rendering engine
  76384. * @param camera defines the source camera
  76385. * @param size This parameter can be set to a single number or to an object with the
  76386. * following (optional) properties: precision, width, height. If a single number is passed,
  76387. * it will be used for both width and height. If an object is passed, the screenshot size
  76388. * will be derived from the parameters. The precision property is a multiplier allowing
  76389. * rendering at a higher or lower resolution
  76390. * @param successCallback defines the callback receives a single parameter which contains the
  76391. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  76392. * src parameter of an <img> to display it
  76393. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  76394. * Check your browser for supported MIME types
  76395. */
  76396. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  76397. /**
  76398. * Captures a screenshot of the current rendering
  76399. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76400. * @param engine defines the rendering engine
  76401. * @param camera defines the source camera
  76402. * @param size This parameter can be set to a single number or to an object with the
  76403. * following (optional) properties: precision, width, height. If a single number is passed,
  76404. * it will be used for both width and height. If an object is passed, the screenshot size
  76405. * will be derived from the parameters. The precision property is a multiplier allowing
  76406. * rendering at a higher or lower resolution
  76407. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  76408. * Check your browser for supported MIME types
  76409. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  76410. * to the src parameter of an <img> to display it
  76411. */
  76412. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  76413. /**
  76414. * Generates an image screenshot from the specified camera.
  76415. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76416. * @param engine The engine to use for rendering
  76417. * @param camera The camera to use for rendering
  76418. * @param size This parameter can be set to a single number or to an object with the
  76419. * following (optional) properties: precision, width, height. If a single number is passed,
  76420. * it will be used for both width and height. If an object is passed, the screenshot size
  76421. * will be derived from the parameters. The precision property is a multiplier allowing
  76422. * rendering at a higher or lower resolution
  76423. * @param successCallback The callback receives a single parameter which contains the
  76424. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  76425. * src parameter of an <img> to display it
  76426. * @param mimeType The MIME type of the screenshot image (default: image/png).
  76427. * Check your browser for supported MIME types
  76428. * @param samples Texture samples (default: 1)
  76429. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  76430. * @param fileName A name for for the downloaded file.
  76431. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  76432. */
  76433. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  76434. /**
  76435. * Generates an image screenshot from the specified camera.
  76436. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76437. * @param engine The engine to use for rendering
  76438. * @param camera The camera to use for rendering
  76439. * @param size This parameter can be set to a single number or to an object with the
  76440. * following (optional) properties: precision, width, height. If a single number is passed,
  76441. * it will be used for both width and height. If an object is passed, the screenshot size
  76442. * will be derived from the parameters. The precision property is a multiplier allowing
  76443. * rendering at a higher or lower resolution
  76444. * @param mimeType The MIME type of the screenshot image (default: image/png).
  76445. * Check your browser for supported MIME types
  76446. * @param samples Texture samples (default: 1)
  76447. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  76448. * @param fileName A name for for the downloaded file.
  76449. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  76450. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  76451. * to the src parameter of an <img> to display it
  76452. */
  76453. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  76454. /**
  76455. * Gets height and width for screenshot size
  76456. * @private
  76457. */
  76458. private static _getScreenshotSize;
  76459. }
  76460. }
  76461. declare module "babylonjs/Misc/dataReader" {
  76462. /**
  76463. * Interface for a data buffer
  76464. */
  76465. export interface IDataBuffer {
  76466. /**
  76467. * Reads bytes from the data buffer.
  76468. * @param byteOffset The byte offset to read
  76469. * @param byteLength The byte length to read
  76470. * @returns A promise that resolves when the bytes are read
  76471. */
  76472. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  76473. /**
  76474. * The byte length of the buffer.
  76475. */
  76476. readonly byteLength: number;
  76477. }
  76478. /**
  76479. * Utility class for reading from a data buffer
  76480. */
  76481. export class DataReader {
  76482. /**
  76483. * The data buffer associated with this data reader.
  76484. */
  76485. readonly buffer: IDataBuffer;
  76486. /**
  76487. * The current byte offset from the beginning of the data buffer.
  76488. */
  76489. byteOffset: number;
  76490. private _dataView;
  76491. private _dataByteOffset;
  76492. /**
  76493. * Constructor
  76494. * @param buffer The buffer to read
  76495. */
  76496. constructor(buffer: IDataBuffer);
  76497. /**
  76498. * Loads the given byte length.
  76499. * @param byteLength The byte length to load
  76500. * @returns A promise that resolves when the load is complete
  76501. */
  76502. loadAsync(byteLength: number): Promise<void>;
  76503. /**
  76504. * Read a unsigned 32-bit integer from the currently loaded data range.
  76505. * @returns The 32-bit integer read
  76506. */
  76507. readUint32(): number;
  76508. /**
  76509. * Read a byte array from the currently loaded data range.
  76510. * @param byteLength The byte length to read
  76511. * @returns The byte array read
  76512. */
  76513. readUint8Array(byteLength: number): Uint8Array;
  76514. /**
  76515. * Read a string from the currently loaded data range.
  76516. * @param byteLength The byte length to read
  76517. * @returns The string read
  76518. */
  76519. readString(byteLength: number): string;
  76520. /**
  76521. * Skips the given byte length the currently loaded data range.
  76522. * @param byteLength The byte length to skip
  76523. */
  76524. skipBytes(byteLength: number): void;
  76525. }
  76526. }
  76527. declare module "babylonjs/Misc/dataStorage" {
  76528. /**
  76529. * Class for storing data to local storage if available or in-memory storage otherwise
  76530. */
  76531. export class DataStorage {
  76532. private static _Storage;
  76533. private static _GetStorage;
  76534. /**
  76535. * Reads a string from the data storage
  76536. * @param key The key to read
  76537. * @param defaultValue The value if the key doesn't exist
  76538. * @returns The string value
  76539. */
  76540. static ReadString(key: string, defaultValue: string): string;
  76541. /**
  76542. * Writes a string to the data storage
  76543. * @param key The key to write
  76544. * @param value The value to write
  76545. */
  76546. static WriteString(key: string, value: string): void;
  76547. /**
  76548. * Reads a boolean from the data storage
  76549. * @param key The key to read
  76550. * @param defaultValue The value if the key doesn't exist
  76551. * @returns The boolean value
  76552. */
  76553. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  76554. /**
  76555. * Writes a boolean to the data storage
  76556. * @param key The key to write
  76557. * @param value The value to write
  76558. */
  76559. static WriteBoolean(key: string, value: boolean): void;
  76560. /**
  76561. * Reads a number from the data storage
  76562. * @param key The key to read
  76563. * @param defaultValue The value if the key doesn't exist
  76564. * @returns The number value
  76565. */
  76566. static ReadNumber(key: string, defaultValue: number): number;
  76567. /**
  76568. * Writes a number to the data storage
  76569. * @param key The key to write
  76570. * @param value The value to write
  76571. */
  76572. static WriteNumber(key: string, value: number): void;
  76573. }
  76574. }
  76575. declare module "babylonjs/Misc/index" {
  76576. export * from "babylonjs/Misc/andOrNotEvaluator";
  76577. export * from "babylonjs/Misc/assetsManager";
  76578. export * from "babylonjs/Misc/basis";
  76579. export * from "babylonjs/Misc/dds";
  76580. export * from "babylonjs/Misc/decorators";
  76581. export * from "babylonjs/Misc/deferred";
  76582. export * from "babylonjs/Misc/environmentTextureTools";
  76583. export * from "babylonjs/Misc/meshExploder";
  76584. export * from "babylonjs/Misc/filesInput";
  76585. export * from "babylonjs/Misc/HighDynamicRange/index";
  76586. export * from "babylonjs/Misc/khronosTextureContainer";
  76587. export * from "babylonjs/Misc/observable";
  76588. export * from "babylonjs/Misc/performanceMonitor";
  76589. export * from "babylonjs/Misc/promise";
  76590. export * from "babylonjs/Misc/sceneOptimizer";
  76591. export * from "babylonjs/Misc/sceneSerializer";
  76592. export * from "babylonjs/Misc/smartArray";
  76593. export * from "babylonjs/Misc/stringDictionary";
  76594. export * from "babylonjs/Misc/tags";
  76595. export * from "babylonjs/Misc/textureTools";
  76596. export * from "babylonjs/Misc/tga";
  76597. export * from "babylonjs/Misc/tools";
  76598. export * from "babylonjs/Misc/videoRecorder";
  76599. export * from "babylonjs/Misc/virtualJoystick";
  76600. export * from "babylonjs/Misc/workerPool";
  76601. export * from "babylonjs/Misc/logger";
  76602. export * from "babylonjs/Misc/typeStore";
  76603. export * from "babylonjs/Misc/filesInputStore";
  76604. export * from "babylonjs/Misc/deepCopier";
  76605. export * from "babylonjs/Misc/pivotTools";
  76606. export * from "babylonjs/Misc/precisionDate";
  76607. export * from "babylonjs/Misc/screenshotTools";
  76608. export * from "babylonjs/Misc/typeStore";
  76609. export * from "babylonjs/Misc/webRequest";
  76610. export * from "babylonjs/Misc/iInspectable";
  76611. export * from "babylonjs/Misc/brdfTextureTools";
  76612. export * from "babylonjs/Misc/rgbdTextureTools";
  76613. export * from "babylonjs/Misc/gradients";
  76614. export * from "babylonjs/Misc/perfCounter";
  76615. export * from "babylonjs/Misc/fileRequest";
  76616. export * from "babylonjs/Misc/customAnimationFrameRequester";
  76617. export * from "babylonjs/Misc/retryStrategy";
  76618. export * from "babylonjs/Misc/interfaces/screenshotSize";
  76619. export * from "babylonjs/Misc/canvasGenerator";
  76620. export * from "babylonjs/Misc/fileTools";
  76621. export * from "babylonjs/Misc/stringTools";
  76622. export * from "babylonjs/Misc/dataReader";
  76623. export * from "babylonjs/Misc/minMaxReducer";
  76624. export * from "babylonjs/Misc/depthReducer";
  76625. export * from "babylonjs/Misc/dataStorage";
  76626. }
  76627. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  76628. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  76629. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76630. import { Observable } from "babylonjs/Misc/observable";
  76631. import { Matrix } from "babylonjs/Maths/math.vector";
  76632. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76633. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76634. /**
  76635. * An interface for all Hit test features
  76636. */
  76637. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  76638. /**
  76639. * Triggered when new babylon (transformed) hit test results are available
  76640. */
  76641. onHitTestResultObservable: Observable<T[]>;
  76642. }
  76643. /**
  76644. * Options used for hit testing
  76645. */
  76646. export interface IWebXRLegacyHitTestOptions {
  76647. /**
  76648. * Only test when user interacted with the scene. Default - hit test every frame
  76649. */
  76650. testOnPointerDownOnly?: boolean;
  76651. /**
  76652. * The node to use to transform the local results to world coordinates
  76653. */
  76654. worldParentNode?: TransformNode;
  76655. }
  76656. /**
  76657. * Interface defining the babylon result of raycasting/hit-test
  76658. */
  76659. export interface IWebXRLegacyHitResult {
  76660. /**
  76661. * Transformation matrix that can be applied to a node that will put it in the hit point location
  76662. */
  76663. transformationMatrix: Matrix;
  76664. /**
  76665. * The native hit test result
  76666. */
  76667. xrHitResult: XRHitResult | XRHitTestResult;
  76668. }
  76669. /**
  76670. * The currently-working hit-test module.
  76671. * Hit test (or Ray-casting) is used to interact with the real world.
  76672. * For further information read here - https://github.com/immersive-web/hit-test
  76673. */
  76674. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  76675. /**
  76676. * options to use when constructing this feature
  76677. */
  76678. readonly options: IWebXRLegacyHitTestOptions;
  76679. private _direction;
  76680. private _mat;
  76681. private _onSelectEnabled;
  76682. private _origin;
  76683. /**
  76684. * The module's name
  76685. */
  76686. static readonly Name: string;
  76687. /**
  76688. * The (Babylon) version of this module.
  76689. * This is an integer representing the implementation version.
  76690. * This number does not correspond to the WebXR specs version
  76691. */
  76692. static readonly Version: number;
  76693. /**
  76694. * Populated with the last native XR Hit Results
  76695. */
  76696. lastNativeXRHitResults: XRHitResult[];
  76697. /**
  76698. * Triggered when new babylon (transformed) hit test results are available
  76699. */
  76700. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  76701. /**
  76702. * Creates a new instance of the (legacy version) hit test feature
  76703. * @param _xrSessionManager an instance of WebXRSessionManager
  76704. * @param options options to use when constructing this feature
  76705. */
  76706. constructor(_xrSessionManager: WebXRSessionManager,
  76707. /**
  76708. * options to use when constructing this feature
  76709. */
  76710. options?: IWebXRLegacyHitTestOptions);
  76711. /**
  76712. * execute a hit test with an XR Ray
  76713. *
  76714. * @param xrSession a native xrSession that will execute this hit test
  76715. * @param xrRay the ray (position and direction) to use for ray-casting
  76716. * @param referenceSpace native XR reference space to use for the hit-test
  76717. * @param filter filter function that will filter the results
  76718. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76719. */
  76720. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  76721. /**
  76722. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  76723. * @param event the (select) event to use to select with
  76724. * @param referenceSpace the reference space to use for this hit test
  76725. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76726. */
  76727. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76728. /**
  76729. * attach this feature
  76730. * Will usually be called by the features manager
  76731. *
  76732. * @returns true if successful.
  76733. */
  76734. attach(): boolean;
  76735. /**
  76736. * detach this feature.
  76737. * Will usually be called by the features manager
  76738. *
  76739. * @returns true if successful.
  76740. */
  76741. detach(): boolean;
  76742. /**
  76743. * Dispose this feature and all of the resources attached
  76744. */
  76745. dispose(): void;
  76746. protected _onXRFrame(frame: XRFrame): void;
  76747. private _onHitTestResults;
  76748. private _onSelect;
  76749. }
  76750. }
  76751. declare module "babylonjs/XR/features/WebXRHitTest" {
  76752. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76753. import { Observable } from "babylonjs/Misc/observable";
  76754. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  76755. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76756. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  76757. /**
  76758. * Options used for hit testing (version 2)
  76759. */
  76760. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  76761. /**
  76762. * Do not create a permanent hit test. Will usually be used when only
  76763. * transient inputs are needed.
  76764. */
  76765. disablePermanentHitTest?: boolean;
  76766. /**
  76767. * Enable transient (for example touch-based) hit test inspections
  76768. */
  76769. enableTransientHitTest?: boolean;
  76770. /**
  76771. * Offset ray for the permanent hit test
  76772. */
  76773. offsetRay?: Vector3;
  76774. /**
  76775. * Offset ray for the transient hit test
  76776. */
  76777. transientOffsetRay?: Vector3;
  76778. /**
  76779. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  76780. */
  76781. useReferenceSpace?: boolean;
  76782. }
  76783. /**
  76784. * Interface defining the babylon result of hit-test
  76785. */
  76786. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  76787. /**
  76788. * The input source that generated this hit test (if transient)
  76789. */
  76790. inputSource?: XRInputSource;
  76791. /**
  76792. * Is this a transient hit test
  76793. */
  76794. isTransient?: boolean;
  76795. /**
  76796. * Position of the hit test result
  76797. */
  76798. position: Vector3;
  76799. /**
  76800. * Rotation of the hit test result
  76801. */
  76802. rotationQuaternion: Quaternion;
  76803. /**
  76804. * The native hit test result
  76805. */
  76806. xrHitResult: XRHitTestResult;
  76807. }
  76808. /**
  76809. * The currently-working hit-test module.
  76810. * Hit test (or Ray-casting) is used to interact with the real world.
  76811. * For further information read here - https://github.com/immersive-web/hit-test
  76812. *
  76813. * Tested on chrome (mobile) 80.
  76814. */
  76815. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  76816. /**
  76817. * options to use when constructing this feature
  76818. */
  76819. readonly options: IWebXRHitTestOptions;
  76820. private _tmpMat;
  76821. private _tmpPos;
  76822. private _tmpQuat;
  76823. private _transientXrHitTestSource;
  76824. private _xrHitTestSource;
  76825. private initHitTestSource;
  76826. /**
  76827. * The module's name
  76828. */
  76829. static readonly Name: string;
  76830. /**
  76831. * The (Babylon) version of this module.
  76832. * This is an integer representing the implementation version.
  76833. * This number does not correspond to the WebXR specs version
  76834. */
  76835. static readonly Version: number;
  76836. /**
  76837. * When set to true, each hit test will have its own position/rotation objects
  76838. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  76839. * the developers will clone them or copy them as they see fit.
  76840. */
  76841. autoCloneTransformation: boolean;
  76842. /**
  76843. * Triggered when new babylon (transformed) hit test results are available
  76844. */
  76845. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  76846. /**
  76847. * Use this to temporarily pause hit test checks.
  76848. */
  76849. paused: boolean;
  76850. /**
  76851. * Creates a new instance of the hit test feature
  76852. * @param _xrSessionManager an instance of WebXRSessionManager
  76853. * @param options options to use when constructing this feature
  76854. */
  76855. constructor(_xrSessionManager: WebXRSessionManager,
  76856. /**
  76857. * options to use when constructing this feature
  76858. */
  76859. options?: IWebXRHitTestOptions);
  76860. /**
  76861. * attach this feature
  76862. * Will usually be called by the features manager
  76863. *
  76864. * @returns true if successful.
  76865. */
  76866. attach(): boolean;
  76867. /**
  76868. * detach this feature.
  76869. * Will usually be called by the features manager
  76870. *
  76871. * @returns true if successful.
  76872. */
  76873. detach(): boolean;
  76874. /**
  76875. * Dispose this feature and all of the resources attached
  76876. */
  76877. dispose(): void;
  76878. protected _onXRFrame(frame: XRFrame): void;
  76879. private _processWebXRHitTestResult;
  76880. }
  76881. }
  76882. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  76883. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76884. import { Observable } from "babylonjs/Misc/observable";
  76885. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  76886. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76887. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76888. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  76889. /**
  76890. * Configuration options of the anchor system
  76891. */
  76892. export interface IWebXRAnchorSystemOptions {
  76893. /**
  76894. * a node that will be used to convert local to world coordinates
  76895. */
  76896. worldParentNode?: TransformNode;
  76897. /**
  76898. * If set to true a reference of the created anchors will be kept until the next session starts
  76899. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  76900. */
  76901. doNotRemoveAnchorsOnSessionEnded?: boolean;
  76902. }
  76903. /**
  76904. * A babylon container for an XR Anchor
  76905. */
  76906. export interface IWebXRAnchor {
  76907. /**
  76908. * A babylon-assigned ID for this anchor
  76909. */
  76910. id: number;
  76911. /**
  76912. * Transformation matrix to apply to an object attached to this anchor
  76913. */
  76914. transformationMatrix: Matrix;
  76915. /**
  76916. * The native anchor object
  76917. */
  76918. xrAnchor: XRAnchor;
  76919. /**
  76920. * if defined, this object will be constantly updated by the anchor's position and rotation
  76921. */
  76922. attachedNode?: TransformNode;
  76923. }
  76924. /**
  76925. * An implementation of the anchor system for WebXR.
  76926. * For further information see https://github.com/immersive-web/anchors/
  76927. */
  76928. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  76929. private _options;
  76930. private _lastFrameDetected;
  76931. private _trackedAnchors;
  76932. private _referenceSpaceForFrameAnchors;
  76933. private _futureAnchors;
  76934. /**
  76935. * The module's name
  76936. */
  76937. static readonly Name: string;
  76938. /**
  76939. * The (Babylon) version of this module.
  76940. * This is an integer representing the implementation version.
  76941. * This number does not correspond to the WebXR specs version
  76942. */
  76943. static readonly Version: number;
  76944. /**
  76945. * Observers registered here will be executed when a new anchor was added to the session
  76946. */
  76947. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  76948. /**
  76949. * Observers registered here will be executed when an anchor was removed from the session
  76950. */
  76951. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  76952. /**
  76953. * Observers registered here will be executed when an existing anchor updates
  76954. * This can execute N times every frame
  76955. */
  76956. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  76957. /**
  76958. * Set the reference space to use for anchor creation, when not using a hit test.
  76959. * Will default to the session's reference space if not defined
  76960. */
  76961. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  76962. /**
  76963. * constructs a new anchor system
  76964. * @param _xrSessionManager an instance of WebXRSessionManager
  76965. * @param _options configuration object for this feature
  76966. */
  76967. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  76968. private _tmpVector;
  76969. private _tmpQuaternion;
  76970. private _populateTmpTransformation;
  76971. /**
  76972. * Create a new anchor point using a hit test result at a specific point in the scene
  76973. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76974. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76975. *
  76976. * @param hitTestResult The hit test result to use for this anchor creation
  76977. * @param position an optional position offset for this anchor
  76978. * @param rotationQuaternion an optional rotation offset for this anchor
  76979. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  76980. */
  76981. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  76982. /**
  76983. * Add a new anchor at a specific position and rotation
  76984. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  76985. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  76986. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76987. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76988. *
  76989. * @param position the position in which to add an anchor
  76990. * @param rotationQuaternion an optional rotation for the anchor transformation
  76991. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  76992. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  76993. */
  76994. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  76995. /**
  76996. * detach this feature.
  76997. * Will usually be called by the features manager
  76998. *
  76999. * @returns true if successful.
  77000. */
  77001. detach(): boolean;
  77002. /**
  77003. * Dispose this feature and all of the resources attached
  77004. */
  77005. dispose(): void;
  77006. protected _onXRFrame(frame: XRFrame): void;
  77007. /**
  77008. * avoiding using Array.find for global support.
  77009. * @param xrAnchor the plane to find in the array
  77010. */
  77011. private _findIndexInAnchorArray;
  77012. private _updateAnchorWithXRFrame;
  77013. private _createAnchorAtTransformation;
  77014. }
  77015. }
  77016. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  77017. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77018. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77019. import { Observable } from "babylonjs/Misc/observable";
  77020. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  77021. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77022. /**
  77023. * Options used in the plane detector module
  77024. */
  77025. export interface IWebXRPlaneDetectorOptions {
  77026. /**
  77027. * The node to use to transform the local results to world coordinates
  77028. */
  77029. worldParentNode?: TransformNode;
  77030. /**
  77031. * If set to true a reference of the created planes will be kept until the next session starts
  77032. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  77033. */
  77034. doNotRemovePlanesOnSessionEnded?: boolean;
  77035. }
  77036. /**
  77037. * A babylon interface for a WebXR plane.
  77038. * A Plane is actually a polygon, built from N points in space
  77039. *
  77040. * Supported in chrome 79, not supported in canary 81 ATM
  77041. */
  77042. export interface IWebXRPlane {
  77043. /**
  77044. * a babylon-assigned ID for this polygon
  77045. */
  77046. id: number;
  77047. /**
  77048. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  77049. */
  77050. polygonDefinition: Array<Vector3>;
  77051. /**
  77052. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  77053. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  77054. */
  77055. transformationMatrix: Matrix;
  77056. /**
  77057. * the native xr-plane object
  77058. */
  77059. xrPlane: XRPlane;
  77060. }
  77061. /**
  77062. * The plane detector is used to detect planes in the real world when in AR
  77063. * For more information see https://github.com/immersive-web/real-world-geometry/
  77064. */
  77065. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  77066. private _options;
  77067. private _detectedPlanes;
  77068. private _enabled;
  77069. private _lastFrameDetected;
  77070. /**
  77071. * The module's name
  77072. */
  77073. static readonly Name: string;
  77074. /**
  77075. * The (Babylon) version of this module.
  77076. * This is an integer representing the implementation version.
  77077. * This number does not correspond to the WebXR specs version
  77078. */
  77079. static readonly Version: number;
  77080. /**
  77081. * Observers registered here will be executed when a new plane was added to the session
  77082. */
  77083. onPlaneAddedObservable: Observable<IWebXRPlane>;
  77084. /**
  77085. * Observers registered here will be executed when a plane is no longer detected in the session
  77086. */
  77087. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  77088. /**
  77089. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  77090. * This can execute N times every frame
  77091. */
  77092. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  77093. /**
  77094. * construct a new Plane Detector
  77095. * @param _xrSessionManager an instance of xr Session manager
  77096. * @param _options configuration to use when constructing this feature
  77097. */
  77098. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  77099. /**
  77100. * detach this feature.
  77101. * Will usually be called by the features manager
  77102. *
  77103. * @returns true if successful.
  77104. */
  77105. detach(): boolean;
  77106. /**
  77107. * Dispose this feature and all of the resources attached
  77108. */
  77109. dispose(): void;
  77110. protected _onXRFrame(frame: XRFrame): void;
  77111. private _init;
  77112. private _updatePlaneWithXRPlane;
  77113. /**
  77114. * avoiding using Array.find for global support.
  77115. * @param xrPlane the plane to find in the array
  77116. */
  77117. private findIndexInPlaneArray;
  77118. }
  77119. }
  77120. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  77121. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77123. import { Observable } from "babylonjs/Misc/observable";
  77124. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77125. /**
  77126. * Options interface for the background remover plugin
  77127. */
  77128. export interface IWebXRBackgroundRemoverOptions {
  77129. /**
  77130. * Further background meshes to disable when entering AR
  77131. */
  77132. backgroundMeshes?: AbstractMesh[];
  77133. /**
  77134. * flags to configure the removal of the environment helper.
  77135. * If not set, the entire background will be removed. If set, flags should be set as well.
  77136. */
  77137. environmentHelperRemovalFlags?: {
  77138. /**
  77139. * Should the skybox be removed (default false)
  77140. */
  77141. skyBox?: boolean;
  77142. /**
  77143. * Should the ground be removed (default false)
  77144. */
  77145. ground?: boolean;
  77146. };
  77147. /**
  77148. * don't disable the environment helper
  77149. */
  77150. ignoreEnvironmentHelper?: boolean;
  77151. }
  77152. /**
  77153. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  77154. */
  77155. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  77156. /**
  77157. * read-only options to be used in this module
  77158. */
  77159. readonly options: IWebXRBackgroundRemoverOptions;
  77160. /**
  77161. * The module's name
  77162. */
  77163. static readonly Name: string;
  77164. /**
  77165. * The (Babylon) version of this module.
  77166. * This is an integer representing the implementation version.
  77167. * This number does not correspond to the WebXR specs version
  77168. */
  77169. static readonly Version: number;
  77170. /**
  77171. * registered observers will be triggered when the background state changes
  77172. */
  77173. onBackgroundStateChangedObservable: Observable<boolean>;
  77174. /**
  77175. * constructs a new background remover module
  77176. * @param _xrSessionManager the session manager for this module
  77177. * @param options read-only options to be used in this module
  77178. */
  77179. constructor(_xrSessionManager: WebXRSessionManager,
  77180. /**
  77181. * read-only options to be used in this module
  77182. */
  77183. options?: IWebXRBackgroundRemoverOptions);
  77184. /**
  77185. * attach this feature
  77186. * Will usually be called by the features manager
  77187. *
  77188. * @returns true if successful.
  77189. */
  77190. attach(): boolean;
  77191. /**
  77192. * detach this feature.
  77193. * Will usually be called by the features manager
  77194. *
  77195. * @returns true if successful.
  77196. */
  77197. detach(): boolean;
  77198. /**
  77199. * Dispose this feature and all of the resources attached
  77200. */
  77201. dispose(): void;
  77202. protected _onXRFrame(_xrFrame: XRFrame): void;
  77203. private _setBackgroundState;
  77204. }
  77205. }
  77206. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  77207. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77208. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  77209. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  77210. import { WebXRInput } from "babylonjs/XR/webXRInput";
  77211. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77212. import { Nullable } from "babylonjs/types";
  77213. /**
  77214. * Options for the controller physics feature
  77215. */
  77216. export class IWebXRControllerPhysicsOptions {
  77217. /**
  77218. * Should the headset get its own impostor
  77219. */
  77220. enableHeadsetImpostor?: boolean;
  77221. /**
  77222. * Optional parameters for the headset impostor
  77223. */
  77224. headsetImpostorParams?: {
  77225. /**
  77226. * The type of impostor to create. Default is sphere
  77227. */
  77228. impostorType: number;
  77229. /**
  77230. * the size of the impostor. Defaults to 10cm
  77231. */
  77232. impostorSize?: number | {
  77233. width: number;
  77234. height: number;
  77235. depth: number;
  77236. };
  77237. /**
  77238. * Friction definitions
  77239. */
  77240. friction?: number;
  77241. /**
  77242. * Restitution
  77243. */
  77244. restitution?: number;
  77245. };
  77246. /**
  77247. * The physics properties of the future impostors
  77248. */
  77249. physicsProperties?: {
  77250. /**
  77251. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  77252. * Note that this requires a physics engine that supports mesh impostors!
  77253. */
  77254. useControllerMesh?: boolean;
  77255. /**
  77256. * The type of impostor to create. Default is sphere
  77257. */
  77258. impostorType?: number;
  77259. /**
  77260. * the size of the impostor. Defaults to 10cm
  77261. */
  77262. impostorSize?: number | {
  77263. width: number;
  77264. height: number;
  77265. depth: number;
  77266. };
  77267. /**
  77268. * Friction definitions
  77269. */
  77270. friction?: number;
  77271. /**
  77272. * Restitution
  77273. */
  77274. restitution?: number;
  77275. };
  77276. /**
  77277. * the xr input to use with this pointer selection
  77278. */
  77279. xrInput: WebXRInput;
  77280. }
  77281. /**
  77282. * Add physics impostor to your webxr controllers,
  77283. * including naive calculation of their linear and angular velocity
  77284. */
  77285. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  77286. private readonly _options;
  77287. private _attachController;
  77288. private _controllers;
  77289. private _debugMode;
  77290. private _delta;
  77291. private _headsetImpostor?;
  77292. private _headsetMesh?;
  77293. private _lastTimestamp;
  77294. private _tmpQuaternion;
  77295. private _tmpVector;
  77296. /**
  77297. * The module's name
  77298. */
  77299. static readonly Name: string;
  77300. /**
  77301. * The (Babylon) version of this module.
  77302. * This is an integer representing the implementation version.
  77303. * This number does not correspond to the webxr specs version
  77304. */
  77305. static readonly Version: number;
  77306. /**
  77307. * Construct a new Controller Physics Feature
  77308. * @param _xrSessionManager the corresponding xr session manager
  77309. * @param _options options to create this feature with
  77310. */
  77311. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  77312. /**
  77313. * @hidden
  77314. * enable debugging - will show console outputs and the impostor mesh
  77315. */
  77316. _enablePhysicsDebug(): void;
  77317. /**
  77318. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  77319. * @param xrController the controller to add
  77320. */
  77321. addController(xrController: WebXRInputSource): void;
  77322. /**
  77323. * attach this feature
  77324. * Will usually be called by the features manager
  77325. *
  77326. * @returns true if successful.
  77327. */
  77328. attach(): boolean;
  77329. /**
  77330. * detach this feature.
  77331. * Will usually be called by the features manager
  77332. *
  77333. * @returns true if successful.
  77334. */
  77335. detach(): boolean;
  77336. /**
  77337. * Get the headset impostor, if enabled
  77338. * @returns the impostor
  77339. */
  77340. getHeadsetImpostor(): PhysicsImpostor | undefined;
  77341. /**
  77342. * Get the physics impostor of a specific controller.
  77343. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  77344. * @param controller the controller or the controller id of which to get the impostor
  77345. * @returns the impostor or null
  77346. */
  77347. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  77348. /**
  77349. * Update the physics properties provided in the constructor
  77350. * @param newProperties the new properties object
  77351. */
  77352. setPhysicsProperties(newProperties: {
  77353. impostorType?: number;
  77354. impostorSize?: number | {
  77355. width: number;
  77356. height: number;
  77357. depth: number;
  77358. };
  77359. friction?: number;
  77360. restitution?: number;
  77361. }): void;
  77362. protected _onXRFrame(_xrFrame: any): void;
  77363. private _detachController;
  77364. }
  77365. }
  77366. declare module "babylonjs/XR/features/index" {
  77367. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  77368. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  77369. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  77370. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  77371. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  77372. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  77373. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  77374. export * from "babylonjs/XR/features/WebXRHitTest";
  77375. }
  77376. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  77377. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77379. import { Scene } from "babylonjs/scene";
  77380. /**
  77381. * The motion controller class for all microsoft mixed reality controllers
  77382. */
  77383. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  77384. protected readonly _mapping: {
  77385. defaultButton: {
  77386. valueNodeName: string;
  77387. unpressedNodeName: string;
  77388. pressedNodeName: string;
  77389. };
  77390. defaultAxis: {
  77391. valueNodeName: string;
  77392. minNodeName: string;
  77393. maxNodeName: string;
  77394. };
  77395. buttons: {
  77396. "xr-standard-trigger": {
  77397. rootNodeName: string;
  77398. componentProperty: string;
  77399. states: string[];
  77400. };
  77401. "xr-standard-squeeze": {
  77402. rootNodeName: string;
  77403. componentProperty: string;
  77404. states: string[];
  77405. };
  77406. "xr-standard-touchpad": {
  77407. rootNodeName: string;
  77408. labelAnchorNodeName: string;
  77409. touchPointNodeName: string;
  77410. };
  77411. "xr-standard-thumbstick": {
  77412. rootNodeName: string;
  77413. componentProperty: string;
  77414. states: string[];
  77415. };
  77416. };
  77417. axes: {
  77418. "xr-standard-touchpad": {
  77419. "x-axis": {
  77420. rootNodeName: string;
  77421. };
  77422. "y-axis": {
  77423. rootNodeName: string;
  77424. };
  77425. };
  77426. "xr-standard-thumbstick": {
  77427. "x-axis": {
  77428. rootNodeName: string;
  77429. };
  77430. "y-axis": {
  77431. rootNodeName: string;
  77432. };
  77433. };
  77434. };
  77435. };
  77436. /**
  77437. * The base url used to load the left and right controller models
  77438. */
  77439. static MODEL_BASE_URL: string;
  77440. /**
  77441. * The name of the left controller model file
  77442. */
  77443. static MODEL_LEFT_FILENAME: string;
  77444. /**
  77445. * The name of the right controller model file
  77446. */
  77447. static MODEL_RIGHT_FILENAME: string;
  77448. profileId: string;
  77449. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77450. protected _getFilenameAndPath(): {
  77451. filename: string;
  77452. path: string;
  77453. };
  77454. protected _getModelLoadingConstraints(): boolean;
  77455. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77456. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77457. protected _updateModel(): void;
  77458. }
  77459. }
  77460. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  77461. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77463. import { Scene } from "babylonjs/scene";
  77464. /**
  77465. * The motion controller class for oculus touch (quest, rift).
  77466. * This class supports legacy mapping as well the standard xr mapping
  77467. */
  77468. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  77469. private _forceLegacyControllers;
  77470. private _modelRootNode;
  77471. /**
  77472. * The base url used to load the left and right controller models
  77473. */
  77474. static MODEL_BASE_URL: string;
  77475. /**
  77476. * The name of the left controller model file
  77477. */
  77478. static MODEL_LEFT_FILENAME: string;
  77479. /**
  77480. * The name of the right controller model file
  77481. */
  77482. static MODEL_RIGHT_FILENAME: string;
  77483. /**
  77484. * Base Url for the Quest controller model.
  77485. */
  77486. static QUEST_MODEL_BASE_URL: string;
  77487. profileId: string;
  77488. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  77489. protected _getFilenameAndPath(): {
  77490. filename: string;
  77491. path: string;
  77492. };
  77493. protected _getModelLoadingConstraints(): boolean;
  77494. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77495. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77496. protected _updateModel(): void;
  77497. /**
  77498. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  77499. * between the touch and touch 2.
  77500. */
  77501. private _isQuest;
  77502. }
  77503. }
  77504. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  77505. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77506. import { Scene } from "babylonjs/scene";
  77507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77508. /**
  77509. * The motion controller class for the standard HTC-Vive controllers
  77510. */
  77511. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  77512. private _modelRootNode;
  77513. /**
  77514. * The base url used to load the left and right controller models
  77515. */
  77516. static MODEL_BASE_URL: string;
  77517. /**
  77518. * File name for the controller model.
  77519. */
  77520. static MODEL_FILENAME: string;
  77521. profileId: string;
  77522. /**
  77523. * Create a new Vive motion controller object
  77524. * @param scene the scene to use to create this controller
  77525. * @param gamepadObject the corresponding gamepad object
  77526. * @param handedness the handedness of the controller
  77527. */
  77528. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77529. protected _getFilenameAndPath(): {
  77530. filename: string;
  77531. path: string;
  77532. };
  77533. protected _getModelLoadingConstraints(): boolean;
  77534. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77535. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77536. protected _updateModel(): void;
  77537. }
  77538. }
  77539. declare module "babylonjs/XR/motionController/index" {
  77540. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77541. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  77542. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  77543. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  77544. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  77545. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  77546. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  77547. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  77548. }
  77549. declare module "babylonjs/XR/index" {
  77550. export * from "babylonjs/XR/webXRCamera";
  77551. export * from "babylonjs/XR/webXREnterExitUI";
  77552. export * from "babylonjs/XR/webXRExperienceHelper";
  77553. export * from "babylonjs/XR/webXRInput";
  77554. export * from "babylonjs/XR/webXRInputSource";
  77555. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  77556. export * from "babylonjs/XR/webXRTypes";
  77557. export * from "babylonjs/XR/webXRSessionManager";
  77558. export * from "babylonjs/XR/webXRDefaultExperience";
  77559. export * from "babylonjs/XR/webXRFeaturesManager";
  77560. export * from "babylonjs/XR/features/index";
  77561. export * from "babylonjs/XR/motionController/index";
  77562. }
  77563. declare module "babylonjs/index" {
  77564. export * from "babylonjs/abstractScene";
  77565. export * from "babylonjs/Actions/index";
  77566. export * from "babylonjs/Animations/index";
  77567. export * from "babylonjs/assetContainer";
  77568. export * from "babylonjs/Audio/index";
  77569. export * from "babylonjs/Behaviors/index";
  77570. export * from "babylonjs/Bones/index";
  77571. export * from "babylonjs/Cameras/index";
  77572. export * from "babylonjs/Collisions/index";
  77573. export * from "babylonjs/Culling/index";
  77574. export * from "babylonjs/Debug/index";
  77575. export * from "babylonjs/DeviceInput/index";
  77576. export * from "babylonjs/Engines/index";
  77577. export * from "babylonjs/Events/index";
  77578. export * from "babylonjs/Gamepads/index";
  77579. export * from "babylonjs/Gizmos/index";
  77580. export * from "babylonjs/Helpers/index";
  77581. export * from "babylonjs/Instrumentation/index";
  77582. export * from "babylonjs/Layers/index";
  77583. export * from "babylonjs/LensFlares/index";
  77584. export * from "babylonjs/Lights/index";
  77585. export * from "babylonjs/Loading/index";
  77586. export * from "babylonjs/Materials/index";
  77587. export * from "babylonjs/Maths/index";
  77588. export * from "babylonjs/Meshes/index";
  77589. export * from "babylonjs/Morph/index";
  77590. export * from "babylonjs/Navigation/index";
  77591. export * from "babylonjs/node";
  77592. export * from "babylonjs/Offline/index";
  77593. export * from "babylonjs/Particles/index";
  77594. export * from "babylonjs/Physics/index";
  77595. export * from "babylonjs/PostProcesses/index";
  77596. export * from "babylonjs/Probes/index";
  77597. export * from "babylonjs/Rendering/index";
  77598. export * from "babylonjs/scene";
  77599. export * from "babylonjs/sceneComponent";
  77600. export * from "babylonjs/Sprites/index";
  77601. export * from "babylonjs/States/index";
  77602. export * from "babylonjs/Misc/index";
  77603. export * from "babylonjs/XR/index";
  77604. export * from "babylonjs/types";
  77605. }
  77606. declare module "babylonjs/Animations/pathCursor" {
  77607. import { Vector3 } from "babylonjs/Maths/math.vector";
  77608. import { Path2 } from "babylonjs/Maths/math.path";
  77609. /**
  77610. * A cursor which tracks a point on a path
  77611. */
  77612. export class PathCursor {
  77613. private path;
  77614. /**
  77615. * Stores path cursor callbacks for when an onchange event is triggered
  77616. */
  77617. private _onchange;
  77618. /**
  77619. * The value of the path cursor
  77620. */
  77621. value: number;
  77622. /**
  77623. * The animation array of the path cursor
  77624. */
  77625. animations: Animation[];
  77626. /**
  77627. * Initializes the path cursor
  77628. * @param path The path to track
  77629. */
  77630. constructor(path: Path2);
  77631. /**
  77632. * Gets the cursor point on the path
  77633. * @returns A point on the path cursor at the cursor location
  77634. */
  77635. getPoint(): Vector3;
  77636. /**
  77637. * Moves the cursor ahead by the step amount
  77638. * @param step The amount to move the cursor forward
  77639. * @returns This path cursor
  77640. */
  77641. moveAhead(step?: number): PathCursor;
  77642. /**
  77643. * Moves the cursor behind by the step amount
  77644. * @param step The amount to move the cursor back
  77645. * @returns This path cursor
  77646. */
  77647. moveBack(step?: number): PathCursor;
  77648. /**
  77649. * Moves the cursor by the step amount
  77650. * If the step amount is greater than one, an exception is thrown
  77651. * @param step The amount to move the cursor
  77652. * @returns This path cursor
  77653. */
  77654. move(step: number): PathCursor;
  77655. /**
  77656. * Ensures that the value is limited between zero and one
  77657. * @returns This path cursor
  77658. */
  77659. private ensureLimits;
  77660. /**
  77661. * Runs onchange callbacks on change (used by the animation engine)
  77662. * @returns This path cursor
  77663. */
  77664. private raiseOnChange;
  77665. /**
  77666. * Executes a function on change
  77667. * @param f A path cursor onchange callback
  77668. * @returns This path cursor
  77669. */
  77670. onchange(f: (cursor: PathCursor) => void): PathCursor;
  77671. }
  77672. }
  77673. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  77674. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  77675. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  77676. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  77677. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  77678. }
  77679. declare module "babylonjs/Engines/Processors/Expressions/index" {
  77680. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  77681. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  77682. }
  77683. declare module "babylonjs/Engines/Processors/index" {
  77684. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  77685. export * from "babylonjs/Engines/Processors/Expressions/index";
  77686. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  77687. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  77688. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  77689. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  77690. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  77691. export * from "babylonjs/Engines/Processors/shaderProcessor";
  77692. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  77693. }
  77694. declare module "babylonjs/Legacy/legacy" {
  77695. import * as Babylon from "babylonjs/index";
  77696. export * from "babylonjs/index";
  77697. }
  77698. declare module "babylonjs/Shaders/blur.fragment" {
  77699. /** @hidden */
  77700. export var blurPixelShader: {
  77701. name: string;
  77702. shader: string;
  77703. };
  77704. }
  77705. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  77706. /** @hidden */
  77707. export var pointCloudVertexDeclaration: {
  77708. name: string;
  77709. shader: string;
  77710. };
  77711. }
  77712. declare module "babylonjs" {
  77713. export * from "babylonjs/Legacy/legacy";
  77714. }
  77715. declare module BABYLON {
  77716. /** Alias type for value that can be null */
  77717. export type Nullable<T> = T | null;
  77718. /**
  77719. * Alias type for number that are floats
  77720. * @ignorenaming
  77721. */
  77722. export type float = number;
  77723. /**
  77724. * Alias type for number that are doubles.
  77725. * @ignorenaming
  77726. */
  77727. export type double = number;
  77728. /**
  77729. * Alias type for number that are integer
  77730. * @ignorenaming
  77731. */
  77732. export type int = number;
  77733. /** Alias type for number array or Float32Array */
  77734. export type FloatArray = number[] | Float32Array;
  77735. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  77736. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  77737. /**
  77738. * Alias for types that can be used by a Buffer or VertexBuffer.
  77739. */
  77740. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  77741. /**
  77742. * Alias type for primitive types
  77743. * @ignorenaming
  77744. */
  77745. type Primitive = undefined | null | boolean | string | number | Function;
  77746. /**
  77747. * Type modifier to make all the properties of an object Readonly
  77748. */
  77749. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  77750. /**
  77751. * Type modifier to make all the properties of an object Readonly recursively
  77752. */
  77753. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  77754. /**
  77755. * Type modifier to make object properties readonly.
  77756. */
  77757. export type DeepImmutableObject<T> = {
  77758. readonly [K in keyof T]: DeepImmutable<T[K]>;
  77759. };
  77760. /** @hidden */
  77761. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  77762. }
  77763. }
  77764. declare module BABYLON {
  77765. /**
  77766. * A class serves as a medium between the observable and its observers
  77767. */
  77768. export class EventState {
  77769. /**
  77770. * Create a new EventState
  77771. * @param mask defines the mask associated with this state
  77772. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  77773. * @param target defines the original target of the state
  77774. * @param currentTarget defines the current target of the state
  77775. */
  77776. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  77777. /**
  77778. * Initialize the current event state
  77779. * @param mask defines the mask associated with this state
  77780. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  77781. * @param target defines the original target of the state
  77782. * @param currentTarget defines the current target of the state
  77783. * @returns the current event state
  77784. */
  77785. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  77786. /**
  77787. * An Observer can set this property to true to prevent subsequent observers of being notified
  77788. */
  77789. skipNextObservers: boolean;
  77790. /**
  77791. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77792. */
  77793. mask: number;
  77794. /**
  77795. * The object that originally notified the event
  77796. */
  77797. target?: any;
  77798. /**
  77799. * The current object in the bubbling phase
  77800. */
  77801. currentTarget?: any;
  77802. /**
  77803. * This will be populated with the return value of the last function that was executed.
  77804. * If it is the first function in the callback chain it will be the event data.
  77805. */
  77806. lastReturnValue?: any;
  77807. }
  77808. /**
  77809. * Represent an Observer registered to a given Observable object.
  77810. */
  77811. export class Observer<T> {
  77812. /**
  77813. * Defines the callback to call when the observer is notified
  77814. */
  77815. callback: (eventData: T, eventState: EventState) => void;
  77816. /**
  77817. * Defines the mask of the observer (used to filter notifications)
  77818. */
  77819. mask: number;
  77820. /**
  77821. * Defines the current scope used to restore the JS context
  77822. */
  77823. scope: any;
  77824. /** @hidden */
  77825. _willBeUnregistered: boolean;
  77826. /**
  77827. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  77828. */
  77829. unregisterOnNextCall: boolean;
  77830. /**
  77831. * Creates a new observer
  77832. * @param callback defines the callback to call when the observer is notified
  77833. * @param mask defines the mask of the observer (used to filter notifications)
  77834. * @param scope defines the current scope used to restore the JS context
  77835. */
  77836. constructor(
  77837. /**
  77838. * Defines the callback to call when the observer is notified
  77839. */
  77840. callback: (eventData: T, eventState: EventState) => void,
  77841. /**
  77842. * Defines the mask of the observer (used to filter notifications)
  77843. */
  77844. mask: number,
  77845. /**
  77846. * Defines the current scope used to restore the JS context
  77847. */
  77848. scope?: any);
  77849. }
  77850. /**
  77851. * Represent a list of observers registered to multiple Observables object.
  77852. */
  77853. export class MultiObserver<T> {
  77854. private _observers;
  77855. private _observables;
  77856. /**
  77857. * Release associated resources
  77858. */
  77859. dispose(): void;
  77860. /**
  77861. * Raise a callback when one of the observable will notify
  77862. * @param observables defines a list of observables to watch
  77863. * @param callback defines the callback to call on notification
  77864. * @param mask defines the mask used to filter notifications
  77865. * @param scope defines the current scope used to restore the JS context
  77866. * @returns the new MultiObserver
  77867. */
  77868. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  77869. }
  77870. /**
  77871. * The Observable class is a simple implementation of the Observable pattern.
  77872. *
  77873. * 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.
  77874. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  77875. * 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).
  77876. * 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.
  77877. */
  77878. export class Observable<T> {
  77879. private _observers;
  77880. private _eventState;
  77881. private _onObserverAdded;
  77882. /**
  77883. * Gets the list of observers
  77884. */
  77885. get observers(): Array<Observer<T>>;
  77886. /**
  77887. * Creates a new observable
  77888. * @param onObserverAdded defines a callback to call when a new observer is added
  77889. */
  77890. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  77891. /**
  77892. * Create a new Observer with the specified callback
  77893. * @param callback the callback that will be executed for that Observer
  77894. * @param mask the mask used to filter observers
  77895. * @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.
  77896. * @param scope optional scope for the callback to be called from
  77897. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  77898. * @returns the new observer created for the callback
  77899. */
  77900. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  77901. /**
  77902. * Create a new Observer with the specified callback and unregisters after the next notification
  77903. * @param callback the callback that will be executed for that Observer
  77904. * @returns the new observer created for the callback
  77905. */
  77906. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  77907. /**
  77908. * Remove an Observer from the Observable object
  77909. * @param observer the instance of the Observer to remove
  77910. * @returns false if it doesn't belong to this Observable
  77911. */
  77912. remove(observer: Nullable<Observer<T>>): boolean;
  77913. /**
  77914. * Remove a callback from the Observable object
  77915. * @param callback the callback to remove
  77916. * @param scope optional scope. If used only the callbacks with this scope will be removed
  77917. * @returns false if it doesn't belong to this Observable
  77918. */
  77919. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  77920. private _deferUnregister;
  77921. private _remove;
  77922. /**
  77923. * Moves the observable to the top of the observer list making it get called first when notified
  77924. * @param observer the observer to move
  77925. */
  77926. makeObserverTopPriority(observer: Observer<T>): void;
  77927. /**
  77928. * Moves the observable to the bottom of the observer list making it get called last when notified
  77929. * @param observer the observer to move
  77930. */
  77931. makeObserverBottomPriority(observer: Observer<T>): void;
  77932. /**
  77933. * Notify all Observers by calling their respective callback with the given data
  77934. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  77935. * @param eventData defines the data to send to all observers
  77936. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  77937. * @param target defines the original target of the state
  77938. * @param currentTarget defines the current target of the state
  77939. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  77940. */
  77941. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  77942. /**
  77943. * Calling this will execute each callback, expecting it to be a promise or return a value.
  77944. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  77945. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  77946. * and it is crucial that all callbacks will be executed.
  77947. * The order of the callbacks is kept, callbacks are not executed parallel.
  77948. *
  77949. * @param eventData The data to be sent to each callback
  77950. * @param mask is used to filter observers defaults to -1
  77951. * @param target defines the callback target (see EventState)
  77952. * @param currentTarget defines he current object in the bubbling phase
  77953. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  77954. */
  77955. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  77956. /**
  77957. * Notify a specific observer
  77958. * @param observer defines the observer to notify
  77959. * @param eventData defines the data to be sent to each callback
  77960. * @param mask is used to filter observers defaults to -1
  77961. */
  77962. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  77963. /**
  77964. * Gets a boolean indicating if the observable has at least one observer
  77965. * @returns true is the Observable has at least one Observer registered
  77966. */
  77967. hasObservers(): boolean;
  77968. /**
  77969. * Clear the list of observers
  77970. */
  77971. clear(): void;
  77972. /**
  77973. * Clone the current observable
  77974. * @returns a new observable
  77975. */
  77976. clone(): Observable<T>;
  77977. /**
  77978. * Does this observable handles observer registered with a given mask
  77979. * @param mask defines the mask to be tested
  77980. * @return whether or not one observer registered with the given mask is handeled
  77981. **/
  77982. hasSpecificMask(mask?: number): boolean;
  77983. }
  77984. }
  77985. declare module BABYLON {
  77986. /**
  77987. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  77988. * Babylon.js
  77989. */
  77990. export class DomManagement {
  77991. /**
  77992. * Checks if the window object exists
  77993. * @returns true if the window object exists
  77994. */
  77995. static IsWindowObjectExist(): boolean;
  77996. /**
  77997. * Checks if the navigator object exists
  77998. * @returns true if the navigator object exists
  77999. */
  78000. static IsNavigatorAvailable(): boolean;
  78001. /**
  78002. * Check if the document object exists
  78003. * @returns true if the document object exists
  78004. */
  78005. static IsDocumentAvailable(): boolean;
  78006. /**
  78007. * Extracts text content from a DOM element hierarchy
  78008. * @param element defines the root element
  78009. * @returns a string
  78010. */
  78011. static GetDOMTextContent(element: HTMLElement): string;
  78012. }
  78013. }
  78014. declare module BABYLON {
  78015. /**
  78016. * Logger used througouht the application to allow configuration of
  78017. * the log level required for the messages.
  78018. */
  78019. export class Logger {
  78020. /**
  78021. * No log
  78022. */
  78023. static readonly NoneLogLevel: number;
  78024. /**
  78025. * Only message logs
  78026. */
  78027. static readonly MessageLogLevel: number;
  78028. /**
  78029. * Only warning logs
  78030. */
  78031. static readonly WarningLogLevel: number;
  78032. /**
  78033. * Only error logs
  78034. */
  78035. static readonly ErrorLogLevel: number;
  78036. /**
  78037. * All logs
  78038. */
  78039. static readonly AllLogLevel: number;
  78040. private static _LogCache;
  78041. /**
  78042. * Gets a value indicating the number of loading errors
  78043. * @ignorenaming
  78044. */
  78045. static errorsCount: number;
  78046. /**
  78047. * Callback called when a new log is added
  78048. */
  78049. static OnNewCacheEntry: (entry: string) => void;
  78050. private static _AddLogEntry;
  78051. private static _FormatMessage;
  78052. private static _LogDisabled;
  78053. private static _LogEnabled;
  78054. private static _WarnDisabled;
  78055. private static _WarnEnabled;
  78056. private static _ErrorDisabled;
  78057. private static _ErrorEnabled;
  78058. /**
  78059. * Log a message to the console
  78060. */
  78061. static Log: (message: string) => void;
  78062. /**
  78063. * Write a warning message to the console
  78064. */
  78065. static Warn: (message: string) => void;
  78066. /**
  78067. * Write an error message to the console
  78068. */
  78069. static Error: (message: string) => void;
  78070. /**
  78071. * Gets current log cache (list of logs)
  78072. */
  78073. static get LogCache(): string;
  78074. /**
  78075. * Clears the log cache
  78076. */
  78077. static ClearLogCache(): void;
  78078. /**
  78079. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  78080. */
  78081. static set LogLevels(level: number);
  78082. }
  78083. }
  78084. declare module BABYLON {
  78085. /** @hidden */
  78086. export class _TypeStore {
  78087. /** @hidden */
  78088. static RegisteredTypes: {
  78089. [key: string]: Object;
  78090. };
  78091. /** @hidden */
  78092. static GetClass(fqdn: string): any;
  78093. }
  78094. }
  78095. declare module BABYLON {
  78096. /**
  78097. * Helper to manipulate strings
  78098. */
  78099. export class StringTools {
  78100. /**
  78101. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  78102. * @param str Source string
  78103. * @param suffix Suffix to search for in the source string
  78104. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78105. */
  78106. static EndsWith(str: string, suffix: string): boolean;
  78107. /**
  78108. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  78109. * @param str Source string
  78110. * @param suffix Suffix to search for in the source string
  78111. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78112. */
  78113. static StartsWith(str: string, suffix: string): boolean;
  78114. /**
  78115. * Decodes a buffer into a string
  78116. * @param buffer The buffer to decode
  78117. * @returns The decoded string
  78118. */
  78119. static Decode(buffer: Uint8Array | Uint16Array): string;
  78120. /**
  78121. * Encode a buffer to a base64 string
  78122. * @param buffer defines the buffer to encode
  78123. * @returns the encoded string
  78124. */
  78125. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  78126. /**
  78127. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  78128. * @param num the number to convert and pad
  78129. * @param length the expected length of the string
  78130. * @returns the padded string
  78131. */
  78132. static PadNumber(num: number, length: number): string;
  78133. }
  78134. }
  78135. declare module BABYLON {
  78136. /**
  78137. * Class containing a set of static utilities functions for deep copy.
  78138. */
  78139. export class DeepCopier {
  78140. /**
  78141. * Tries to copy an object by duplicating every property
  78142. * @param source defines the source object
  78143. * @param destination defines the target object
  78144. * @param doNotCopyList defines a list of properties to avoid
  78145. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  78146. */
  78147. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  78148. }
  78149. }
  78150. declare module BABYLON {
  78151. /**
  78152. * Class containing a set of static utilities functions for precision date
  78153. */
  78154. export class PrecisionDate {
  78155. /**
  78156. * Gets either window.performance.now() if supported or Date.now() else
  78157. */
  78158. static get Now(): number;
  78159. }
  78160. }
  78161. declare module BABYLON {
  78162. /** @hidden */
  78163. export class _DevTools {
  78164. static WarnImport(name: string): string;
  78165. }
  78166. }
  78167. declare module BABYLON {
  78168. /**
  78169. * Interface used to define the mechanism to get data from the network
  78170. */
  78171. export interface IWebRequest {
  78172. /**
  78173. * Returns client's response url
  78174. */
  78175. responseURL: string;
  78176. /**
  78177. * Returns client's status
  78178. */
  78179. status: number;
  78180. /**
  78181. * Returns client's status as a text
  78182. */
  78183. statusText: string;
  78184. }
  78185. }
  78186. declare module BABYLON {
  78187. /**
  78188. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  78189. */
  78190. export class WebRequest implements IWebRequest {
  78191. private _xhr;
  78192. /**
  78193. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  78194. * i.e. when loading files, where the server/service expects an Authorization header
  78195. */
  78196. static CustomRequestHeaders: {
  78197. [key: string]: string;
  78198. };
  78199. /**
  78200. * Add callback functions in this array to update all the requests before they get sent to the network
  78201. */
  78202. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  78203. private _injectCustomRequestHeaders;
  78204. /**
  78205. * Gets or sets a function to be called when loading progress changes
  78206. */
  78207. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  78208. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  78209. /**
  78210. * Returns client's state
  78211. */
  78212. get readyState(): number;
  78213. /**
  78214. * Returns client's status
  78215. */
  78216. get status(): number;
  78217. /**
  78218. * Returns client's status as a text
  78219. */
  78220. get statusText(): string;
  78221. /**
  78222. * Returns client's response
  78223. */
  78224. get response(): any;
  78225. /**
  78226. * Returns client's response url
  78227. */
  78228. get responseURL(): string;
  78229. /**
  78230. * Returns client's response as text
  78231. */
  78232. get responseText(): string;
  78233. /**
  78234. * Gets or sets the expected response type
  78235. */
  78236. get responseType(): XMLHttpRequestResponseType;
  78237. set responseType(value: XMLHttpRequestResponseType);
  78238. /** @hidden */
  78239. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  78240. /** @hidden */
  78241. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  78242. /**
  78243. * Cancels any network activity
  78244. */
  78245. abort(): void;
  78246. /**
  78247. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  78248. * @param body defines an optional request body
  78249. */
  78250. send(body?: Document | BodyInit | null): void;
  78251. /**
  78252. * Sets the request method, request URL
  78253. * @param method defines the method to use (GET, POST, etc..)
  78254. * @param url defines the url to connect with
  78255. */
  78256. open(method: string, url: string): void;
  78257. /**
  78258. * Sets the value of a request header.
  78259. * @param name The name of the header whose value is to be set
  78260. * @param value The value to set as the body of the header
  78261. */
  78262. setRequestHeader(name: string, value: string): void;
  78263. /**
  78264. * Get the string containing the text of a particular header's value.
  78265. * @param name The name of the header
  78266. * @returns The string containing the text of the given header name
  78267. */
  78268. getResponseHeader(name: string): Nullable<string>;
  78269. }
  78270. }
  78271. declare module BABYLON {
  78272. /**
  78273. * File request interface
  78274. */
  78275. export interface IFileRequest {
  78276. /**
  78277. * Raised when the request is complete (success or error).
  78278. */
  78279. onCompleteObservable: Observable<IFileRequest>;
  78280. /**
  78281. * Aborts the request for a file.
  78282. */
  78283. abort: () => void;
  78284. }
  78285. }
  78286. declare module BABYLON {
  78287. /**
  78288. * Define options used to create a render target texture
  78289. */
  78290. export class RenderTargetCreationOptions {
  78291. /**
  78292. * Specifies is mipmaps must be generated
  78293. */
  78294. generateMipMaps?: boolean;
  78295. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  78296. generateDepthBuffer?: boolean;
  78297. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  78298. generateStencilBuffer?: boolean;
  78299. /** Defines texture type (int by default) */
  78300. type?: number;
  78301. /** Defines sampling mode (trilinear by default) */
  78302. samplingMode?: number;
  78303. /** Defines format (RGBA by default) */
  78304. format?: number;
  78305. }
  78306. }
  78307. declare module BABYLON {
  78308. /** Defines the cross module used constants to avoid circular dependncies */
  78309. export class Constants {
  78310. /** Defines that alpha blending is disabled */
  78311. static readonly ALPHA_DISABLE: number;
  78312. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  78313. static readonly ALPHA_ADD: number;
  78314. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  78315. static readonly ALPHA_COMBINE: number;
  78316. /** Defines that alpha blending is DEST - SRC * DEST */
  78317. static readonly ALPHA_SUBTRACT: number;
  78318. /** Defines that alpha blending is SRC * DEST */
  78319. static readonly ALPHA_MULTIPLY: number;
  78320. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  78321. static readonly ALPHA_MAXIMIZED: number;
  78322. /** Defines that alpha blending is SRC + DEST */
  78323. static readonly ALPHA_ONEONE: number;
  78324. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  78325. static readonly ALPHA_PREMULTIPLIED: number;
  78326. /**
  78327. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  78328. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  78329. */
  78330. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  78331. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  78332. static readonly ALPHA_INTERPOLATE: number;
  78333. /**
  78334. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  78335. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  78336. */
  78337. static readonly ALPHA_SCREENMODE: number;
  78338. /**
  78339. * Defines that alpha blending is SRC + DST
  78340. * Alpha will be set to SRC ALPHA + DST ALPHA
  78341. */
  78342. static readonly ALPHA_ONEONE_ONEONE: number;
  78343. /**
  78344. * Defines that alpha blending is SRC * DST ALPHA + DST
  78345. * Alpha will be set to 0
  78346. */
  78347. static readonly ALPHA_ALPHATOCOLOR: number;
  78348. /**
  78349. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  78350. */
  78351. static readonly ALPHA_REVERSEONEMINUS: number;
  78352. /**
  78353. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  78354. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  78355. */
  78356. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  78357. /**
  78358. * Defines that alpha blending is SRC + DST
  78359. * Alpha will be set to SRC ALPHA
  78360. */
  78361. static readonly ALPHA_ONEONE_ONEZERO: number;
  78362. /**
  78363. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  78364. * Alpha will be set to DST ALPHA
  78365. */
  78366. static readonly ALPHA_EXCLUSION: number;
  78367. /** Defines that alpha blending equation a SUM */
  78368. static readonly ALPHA_EQUATION_ADD: number;
  78369. /** Defines that alpha blending equation a SUBSTRACTION */
  78370. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  78371. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  78372. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  78373. /** Defines that alpha blending equation a MAX operation */
  78374. static readonly ALPHA_EQUATION_MAX: number;
  78375. /** Defines that alpha blending equation a MIN operation */
  78376. static readonly ALPHA_EQUATION_MIN: number;
  78377. /**
  78378. * Defines that alpha blending equation a DARKEN operation:
  78379. * It takes the min of the src and sums the alpha channels.
  78380. */
  78381. static readonly ALPHA_EQUATION_DARKEN: number;
  78382. /** Defines that the ressource is not delayed*/
  78383. static readonly DELAYLOADSTATE_NONE: number;
  78384. /** Defines that the ressource was successfully delay loaded */
  78385. static readonly DELAYLOADSTATE_LOADED: number;
  78386. /** Defines that the ressource is currently delay loading */
  78387. static readonly DELAYLOADSTATE_LOADING: number;
  78388. /** Defines that the ressource is delayed and has not started loading */
  78389. static readonly DELAYLOADSTATE_NOTLOADED: number;
  78390. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  78391. static readonly NEVER: number;
  78392. /** 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 */
  78393. static readonly ALWAYS: number;
  78394. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  78395. static readonly LESS: number;
  78396. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  78397. static readonly EQUAL: number;
  78398. /** 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 */
  78399. static readonly LEQUAL: number;
  78400. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  78401. static readonly GREATER: number;
  78402. /** 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 */
  78403. static readonly GEQUAL: number;
  78404. /** 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 */
  78405. static readonly NOTEQUAL: number;
  78406. /** Passed to stencilOperation to specify that stencil value must be kept */
  78407. static readonly KEEP: number;
  78408. /** Passed to stencilOperation to specify that stencil value must be replaced */
  78409. static readonly REPLACE: number;
  78410. /** Passed to stencilOperation to specify that stencil value must be incremented */
  78411. static readonly INCR: number;
  78412. /** Passed to stencilOperation to specify that stencil value must be decremented */
  78413. static readonly DECR: number;
  78414. /** Passed to stencilOperation to specify that stencil value must be inverted */
  78415. static readonly INVERT: number;
  78416. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  78417. static readonly INCR_WRAP: number;
  78418. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  78419. static readonly DECR_WRAP: number;
  78420. /** Texture is not repeating outside of 0..1 UVs */
  78421. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  78422. /** Texture is repeating outside of 0..1 UVs */
  78423. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  78424. /** Texture is repeating and mirrored */
  78425. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  78426. /** ALPHA */
  78427. static readonly TEXTUREFORMAT_ALPHA: number;
  78428. /** LUMINANCE */
  78429. static readonly TEXTUREFORMAT_LUMINANCE: number;
  78430. /** LUMINANCE_ALPHA */
  78431. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  78432. /** RGB */
  78433. static readonly TEXTUREFORMAT_RGB: number;
  78434. /** RGBA */
  78435. static readonly TEXTUREFORMAT_RGBA: number;
  78436. /** RED */
  78437. static readonly TEXTUREFORMAT_RED: number;
  78438. /** RED (2nd reference) */
  78439. static readonly TEXTUREFORMAT_R: number;
  78440. /** RG */
  78441. static readonly TEXTUREFORMAT_RG: number;
  78442. /** RED_INTEGER */
  78443. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  78444. /** RED_INTEGER (2nd reference) */
  78445. static readonly TEXTUREFORMAT_R_INTEGER: number;
  78446. /** RG_INTEGER */
  78447. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  78448. /** RGB_INTEGER */
  78449. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  78450. /** RGBA_INTEGER */
  78451. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  78452. /** UNSIGNED_BYTE */
  78453. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  78454. /** UNSIGNED_BYTE (2nd reference) */
  78455. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  78456. /** FLOAT */
  78457. static readonly TEXTURETYPE_FLOAT: number;
  78458. /** HALF_FLOAT */
  78459. static readonly TEXTURETYPE_HALF_FLOAT: number;
  78460. /** BYTE */
  78461. static readonly TEXTURETYPE_BYTE: number;
  78462. /** SHORT */
  78463. static readonly TEXTURETYPE_SHORT: number;
  78464. /** UNSIGNED_SHORT */
  78465. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  78466. /** INT */
  78467. static readonly TEXTURETYPE_INT: number;
  78468. /** UNSIGNED_INT */
  78469. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  78470. /** UNSIGNED_SHORT_4_4_4_4 */
  78471. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  78472. /** UNSIGNED_SHORT_5_5_5_1 */
  78473. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  78474. /** UNSIGNED_SHORT_5_6_5 */
  78475. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  78476. /** UNSIGNED_INT_2_10_10_10_REV */
  78477. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  78478. /** UNSIGNED_INT_24_8 */
  78479. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  78480. /** UNSIGNED_INT_10F_11F_11F_REV */
  78481. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  78482. /** UNSIGNED_INT_5_9_9_9_REV */
  78483. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  78484. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  78485. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  78486. /** nearest is mag = nearest and min = nearest and no mip */
  78487. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  78488. /** mag = nearest and min = nearest and mip = none */
  78489. static readonly TEXTURE_NEAREST_NEAREST: number;
  78490. /** Bilinear is mag = linear and min = linear and no mip */
  78491. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  78492. /** mag = linear and min = linear and mip = none */
  78493. static readonly TEXTURE_LINEAR_LINEAR: number;
  78494. /** Trilinear is mag = linear and min = linear and mip = linear */
  78495. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  78496. /** Trilinear is mag = linear and min = linear and mip = linear */
  78497. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  78498. /** mag = nearest and min = nearest and mip = nearest */
  78499. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  78500. /** mag = nearest and min = linear and mip = nearest */
  78501. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  78502. /** mag = nearest and min = linear and mip = linear */
  78503. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  78504. /** mag = nearest and min = linear and mip = none */
  78505. static readonly TEXTURE_NEAREST_LINEAR: number;
  78506. /** nearest is mag = nearest and min = nearest and mip = linear */
  78507. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  78508. /** mag = linear and min = nearest and mip = nearest */
  78509. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  78510. /** mag = linear and min = nearest and mip = linear */
  78511. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  78512. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78513. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  78514. /** mag = linear and min = nearest and mip = none */
  78515. static readonly TEXTURE_LINEAR_NEAREST: number;
  78516. /** Explicit coordinates mode */
  78517. static readonly TEXTURE_EXPLICIT_MODE: number;
  78518. /** Spherical coordinates mode */
  78519. static readonly TEXTURE_SPHERICAL_MODE: number;
  78520. /** Planar coordinates mode */
  78521. static readonly TEXTURE_PLANAR_MODE: number;
  78522. /** Cubic coordinates mode */
  78523. static readonly TEXTURE_CUBIC_MODE: number;
  78524. /** Projection coordinates mode */
  78525. static readonly TEXTURE_PROJECTION_MODE: number;
  78526. /** Skybox coordinates mode */
  78527. static readonly TEXTURE_SKYBOX_MODE: number;
  78528. /** Inverse Cubic coordinates mode */
  78529. static readonly TEXTURE_INVCUBIC_MODE: number;
  78530. /** Equirectangular coordinates mode */
  78531. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  78532. /** Equirectangular Fixed coordinates mode */
  78533. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  78534. /** Equirectangular Fixed Mirrored coordinates mode */
  78535. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  78536. /** Offline (baking) quality for texture filtering */
  78537. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  78538. /** High quality for texture filtering */
  78539. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  78540. /** Medium quality for texture filtering */
  78541. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  78542. /** Low quality for texture filtering */
  78543. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  78544. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  78545. static readonly SCALEMODE_FLOOR: number;
  78546. /** Defines that texture rescaling will look for the nearest power of 2 size */
  78547. static readonly SCALEMODE_NEAREST: number;
  78548. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  78549. static readonly SCALEMODE_CEILING: number;
  78550. /**
  78551. * The dirty texture flag value
  78552. */
  78553. static readonly MATERIAL_TextureDirtyFlag: number;
  78554. /**
  78555. * The dirty light flag value
  78556. */
  78557. static readonly MATERIAL_LightDirtyFlag: number;
  78558. /**
  78559. * The dirty fresnel flag value
  78560. */
  78561. static readonly MATERIAL_FresnelDirtyFlag: number;
  78562. /**
  78563. * The dirty attribute flag value
  78564. */
  78565. static readonly MATERIAL_AttributesDirtyFlag: number;
  78566. /**
  78567. * The dirty misc flag value
  78568. */
  78569. static readonly MATERIAL_MiscDirtyFlag: number;
  78570. /**
  78571. * The all dirty flag value
  78572. */
  78573. static readonly MATERIAL_AllDirtyFlag: number;
  78574. /**
  78575. * Returns the triangle fill mode
  78576. */
  78577. static readonly MATERIAL_TriangleFillMode: number;
  78578. /**
  78579. * Returns the wireframe mode
  78580. */
  78581. static readonly MATERIAL_WireFrameFillMode: number;
  78582. /**
  78583. * Returns the point fill mode
  78584. */
  78585. static readonly MATERIAL_PointFillMode: number;
  78586. /**
  78587. * Returns the point list draw mode
  78588. */
  78589. static readonly MATERIAL_PointListDrawMode: number;
  78590. /**
  78591. * Returns the line list draw mode
  78592. */
  78593. static readonly MATERIAL_LineListDrawMode: number;
  78594. /**
  78595. * Returns the line loop draw mode
  78596. */
  78597. static readonly MATERIAL_LineLoopDrawMode: number;
  78598. /**
  78599. * Returns the line strip draw mode
  78600. */
  78601. static readonly MATERIAL_LineStripDrawMode: number;
  78602. /**
  78603. * Returns the triangle strip draw mode
  78604. */
  78605. static readonly MATERIAL_TriangleStripDrawMode: number;
  78606. /**
  78607. * Returns the triangle fan draw mode
  78608. */
  78609. static readonly MATERIAL_TriangleFanDrawMode: number;
  78610. /**
  78611. * Stores the clock-wise side orientation
  78612. */
  78613. static readonly MATERIAL_ClockWiseSideOrientation: number;
  78614. /**
  78615. * Stores the counter clock-wise side orientation
  78616. */
  78617. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  78618. /**
  78619. * Nothing
  78620. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78621. */
  78622. static readonly ACTION_NothingTrigger: number;
  78623. /**
  78624. * On pick
  78625. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78626. */
  78627. static readonly ACTION_OnPickTrigger: number;
  78628. /**
  78629. * On left pick
  78630. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78631. */
  78632. static readonly ACTION_OnLeftPickTrigger: number;
  78633. /**
  78634. * On right pick
  78635. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78636. */
  78637. static readonly ACTION_OnRightPickTrigger: number;
  78638. /**
  78639. * On center pick
  78640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78641. */
  78642. static readonly ACTION_OnCenterPickTrigger: number;
  78643. /**
  78644. * On pick down
  78645. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78646. */
  78647. static readonly ACTION_OnPickDownTrigger: number;
  78648. /**
  78649. * On double pick
  78650. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78651. */
  78652. static readonly ACTION_OnDoublePickTrigger: number;
  78653. /**
  78654. * On pick up
  78655. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78656. */
  78657. static readonly ACTION_OnPickUpTrigger: number;
  78658. /**
  78659. * On pick out.
  78660. * This trigger will only be raised if you also declared a OnPickDown
  78661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78662. */
  78663. static readonly ACTION_OnPickOutTrigger: number;
  78664. /**
  78665. * On long press
  78666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78667. */
  78668. static readonly ACTION_OnLongPressTrigger: number;
  78669. /**
  78670. * On pointer over
  78671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78672. */
  78673. static readonly ACTION_OnPointerOverTrigger: number;
  78674. /**
  78675. * On pointer out
  78676. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78677. */
  78678. static readonly ACTION_OnPointerOutTrigger: number;
  78679. /**
  78680. * On every frame
  78681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78682. */
  78683. static readonly ACTION_OnEveryFrameTrigger: number;
  78684. /**
  78685. * On intersection enter
  78686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78687. */
  78688. static readonly ACTION_OnIntersectionEnterTrigger: number;
  78689. /**
  78690. * On intersection exit
  78691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78692. */
  78693. static readonly ACTION_OnIntersectionExitTrigger: number;
  78694. /**
  78695. * On key down
  78696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78697. */
  78698. static readonly ACTION_OnKeyDownTrigger: number;
  78699. /**
  78700. * On key up
  78701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78702. */
  78703. static readonly ACTION_OnKeyUpTrigger: number;
  78704. /**
  78705. * Billboard mode will only apply to Y axis
  78706. */
  78707. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  78708. /**
  78709. * Billboard mode will apply to all axes
  78710. */
  78711. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  78712. /**
  78713. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  78714. */
  78715. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  78716. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  78717. * Test order :
  78718. * Is the bounding sphere outside the frustum ?
  78719. * If not, are the bounding box vertices outside the frustum ?
  78720. * It not, then the cullable object is in the frustum.
  78721. */
  78722. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  78723. /** Culling strategy : Bounding Sphere Only.
  78724. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  78725. * It's also less accurate than the standard because some not visible objects can still be selected.
  78726. * Test : is the bounding sphere outside the frustum ?
  78727. * If not, then the cullable object is in the frustum.
  78728. */
  78729. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  78730. /** Culling strategy : Optimistic Inclusion.
  78731. * This in an inclusion test first, then the standard exclusion test.
  78732. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  78733. * 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.
  78734. * Anyway, it's as accurate as the standard strategy.
  78735. * Test :
  78736. * Is the cullable object bounding sphere center in the frustum ?
  78737. * If not, apply the default culling strategy.
  78738. */
  78739. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  78740. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  78741. * This in an inclusion test first, then the bounding sphere only exclusion test.
  78742. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  78743. * 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.
  78744. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  78745. * Test :
  78746. * Is the cullable object bounding sphere center in the frustum ?
  78747. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  78748. */
  78749. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  78750. /**
  78751. * No logging while loading
  78752. */
  78753. static readonly SCENELOADER_NO_LOGGING: number;
  78754. /**
  78755. * Minimal logging while loading
  78756. */
  78757. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  78758. /**
  78759. * Summary logging while loading
  78760. */
  78761. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  78762. /**
  78763. * Detailled logging while loading
  78764. */
  78765. static readonly SCENELOADER_DETAILED_LOGGING: number;
  78766. }
  78767. }
  78768. declare module BABYLON {
  78769. /**
  78770. * This represents the required contract to create a new type of texture loader.
  78771. */
  78772. export interface IInternalTextureLoader {
  78773. /**
  78774. * Defines wether the loader supports cascade loading the different faces.
  78775. */
  78776. supportCascades: boolean;
  78777. /**
  78778. * This returns if the loader support the current file information.
  78779. * @param extension defines the file extension of the file being loaded
  78780. * @returns true if the loader can load the specified file
  78781. */
  78782. canLoad(extension: string): boolean;
  78783. /**
  78784. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  78785. * @param data contains the texture data
  78786. * @param texture defines the BabylonJS internal texture
  78787. * @param createPolynomials will be true if polynomials have been requested
  78788. * @param onLoad defines the callback to trigger once the texture is ready
  78789. * @param onError defines the callback to trigger in case of error
  78790. */
  78791. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  78792. /**
  78793. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  78794. * @param data contains the texture data
  78795. * @param texture defines the BabylonJS internal texture
  78796. * @param callback defines the method to call once ready to upload
  78797. */
  78798. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  78799. }
  78800. }
  78801. declare module BABYLON {
  78802. /**
  78803. * Class used to store and describe the pipeline context associated with an effect
  78804. */
  78805. export interface IPipelineContext {
  78806. /**
  78807. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  78808. */
  78809. isAsync: boolean;
  78810. /**
  78811. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  78812. */
  78813. isReady: boolean;
  78814. /** @hidden */
  78815. _getVertexShaderCode(): string | null;
  78816. /** @hidden */
  78817. _getFragmentShaderCode(): string | null;
  78818. /** @hidden */
  78819. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  78820. }
  78821. }
  78822. declare module BABYLON {
  78823. /**
  78824. * Class used to store gfx data (like WebGLBuffer)
  78825. */
  78826. export class DataBuffer {
  78827. /**
  78828. * Gets or sets the number of objects referencing this buffer
  78829. */
  78830. references: number;
  78831. /** Gets or sets the size of the underlying buffer */
  78832. capacity: number;
  78833. /**
  78834. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  78835. */
  78836. is32Bits: boolean;
  78837. /**
  78838. * Gets the underlying buffer
  78839. */
  78840. get underlyingResource(): any;
  78841. }
  78842. }
  78843. declare module BABYLON {
  78844. /** @hidden */
  78845. export interface IShaderProcessor {
  78846. attributeProcessor?: (attribute: string) => string;
  78847. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  78848. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  78849. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  78850. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  78851. lineProcessor?: (line: string, isFragment: boolean) => string;
  78852. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  78853. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  78854. }
  78855. }
  78856. declare module BABYLON {
  78857. /** @hidden */
  78858. export interface ProcessingOptions {
  78859. defines: string[];
  78860. indexParameters: any;
  78861. isFragment: boolean;
  78862. shouldUseHighPrecisionShader: boolean;
  78863. supportsUniformBuffers: boolean;
  78864. shadersRepository: string;
  78865. includesShadersStore: {
  78866. [key: string]: string;
  78867. };
  78868. processor?: IShaderProcessor;
  78869. version: string;
  78870. platformName: string;
  78871. lookForClosingBracketForUniformBuffer?: boolean;
  78872. }
  78873. }
  78874. declare module BABYLON {
  78875. /** @hidden */
  78876. export class ShaderCodeNode {
  78877. line: string;
  78878. children: ShaderCodeNode[];
  78879. additionalDefineKey?: string;
  78880. additionalDefineValue?: string;
  78881. isValid(preprocessors: {
  78882. [key: string]: string;
  78883. }): boolean;
  78884. process(preprocessors: {
  78885. [key: string]: string;
  78886. }, options: ProcessingOptions): string;
  78887. }
  78888. }
  78889. declare module BABYLON {
  78890. /** @hidden */
  78891. export class ShaderCodeCursor {
  78892. private _lines;
  78893. lineIndex: number;
  78894. get currentLine(): string;
  78895. get canRead(): boolean;
  78896. set lines(value: string[]);
  78897. }
  78898. }
  78899. declare module BABYLON {
  78900. /** @hidden */
  78901. export class ShaderCodeConditionNode extends ShaderCodeNode {
  78902. process(preprocessors: {
  78903. [key: string]: string;
  78904. }, options: ProcessingOptions): string;
  78905. }
  78906. }
  78907. declare module BABYLON {
  78908. /** @hidden */
  78909. export class ShaderDefineExpression {
  78910. isTrue(preprocessors: {
  78911. [key: string]: string;
  78912. }): boolean;
  78913. private static _OperatorPriority;
  78914. private static _Stack;
  78915. static postfixToInfix(postfix: string[]): string;
  78916. static infixToPostfix(infix: string): string[];
  78917. }
  78918. }
  78919. declare module BABYLON {
  78920. /** @hidden */
  78921. export class ShaderCodeTestNode extends ShaderCodeNode {
  78922. testExpression: ShaderDefineExpression;
  78923. isValid(preprocessors: {
  78924. [key: string]: string;
  78925. }): boolean;
  78926. }
  78927. }
  78928. declare module BABYLON {
  78929. /** @hidden */
  78930. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  78931. define: string;
  78932. not: boolean;
  78933. constructor(define: string, not?: boolean);
  78934. isTrue(preprocessors: {
  78935. [key: string]: string;
  78936. }): boolean;
  78937. }
  78938. }
  78939. declare module BABYLON {
  78940. /** @hidden */
  78941. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  78942. leftOperand: ShaderDefineExpression;
  78943. rightOperand: ShaderDefineExpression;
  78944. isTrue(preprocessors: {
  78945. [key: string]: string;
  78946. }): boolean;
  78947. }
  78948. }
  78949. declare module BABYLON {
  78950. /** @hidden */
  78951. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  78952. leftOperand: ShaderDefineExpression;
  78953. rightOperand: ShaderDefineExpression;
  78954. isTrue(preprocessors: {
  78955. [key: string]: string;
  78956. }): boolean;
  78957. }
  78958. }
  78959. declare module BABYLON {
  78960. /** @hidden */
  78961. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  78962. define: string;
  78963. operand: string;
  78964. testValue: string;
  78965. constructor(define: string, operand: string, testValue: string);
  78966. isTrue(preprocessors: {
  78967. [key: string]: string;
  78968. }): boolean;
  78969. }
  78970. }
  78971. declare module BABYLON {
  78972. /**
  78973. * Class used to enable access to offline support
  78974. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  78975. */
  78976. export interface IOfflineProvider {
  78977. /**
  78978. * Gets a boolean indicating if scene must be saved in the database
  78979. */
  78980. enableSceneOffline: boolean;
  78981. /**
  78982. * Gets a boolean indicating if textures must be saved in the database
  78983. */
  78984. enableTexturesOffline: boolean;
  78985. /**
  78986. * Open the offline support and make it available
  78987. * @param successCallback defines the callback to call on success
  78988. * @param errorCallback defines the callback to call on error
  78989. */
  78990. open(successCallback: () => void, errorCallback: () => void): void;
  78991. /**
  78992. * Loads an image from the offline support
  78993. * @param url defines the url to load from
  78994. * @param image defines the target DOM image
  78995. */
  78996. loadImage(url: string, image: HTMLImageElement): void;
  78997. /**
  78998. * Loads a file from offline support
  78999. * @param url defines the URL to load from
  79000. * @param sceneLoaded defines a callback to call on success
  79001. * @param progressCallBack defines a callback to call when progress changed
  79002. * @param errorCallback defines a callback to call on error
  79003. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  79004. */
  79005. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  79006. }
  79007. }
  79008. declare module BABYLON {
  79009. /**
  79010. * Class used to help managing file picking and drag'n'drop
  79011. * File Storage
  79012. */
  79013. export class FilesInputStore {
  79014. /**
  79015. * List of files ready to be loaded
  79016. */
  79017. static FilesToLoad: {
  79018. [key: string]: File;
  79019. };
  79020. }
  79021. }
  79022. declare module BABYLON {
  79023. /**
  79024. * Class used to define a retry strategy when error happens while loading assets
  79025. */
  79026. export class RetryStrategy {
  79027. /**
  79028. * Function used to defines an exponential back off strategy
  79029. * @param maxRetries defines the maximum number of retries (3 by default)
  79030. * @param baseInterval defines the interval between retries
  79031. * @returns the strategy function to use
  79032. */
  79033. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  79034. }
  79035. }
  79036. declare module BABYLON {
  79037. /**
  79038. * @ignore
  79039. * Application error to support additional information when loading a file
  79040. */
  79041. export abstract class BaseError extends Error {
  79042. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  79043. }
  79044. }
  79045. declare module BABYLON {
  79046. /** @ignore */
  79047. export class LoadFileError extends BaseError {
  79048. request?: WebRequest;
  79049. file?: File;
  79050. /**
  79051. * Creates a new LoadFileError
  79052. * @param message defines the message of the error
  79053. * @param request defines the optional web request
  79054. * @param file defines the optional file
  79055. */
  79056. constructor(message: string, object?: WebRequest | File);
  79057. }
  79058. /** @ignore */
  79059. export class RequestFileError extends BaseError {
  79060. request: WebRequest;
  79061. /**
  79062. * Creates a new LoadFileError
  79063. * @param message defines the message of the error
  79064. * @param request defines the optional web request
  79065. */
  79066. constructor(message: string, request: WebRequest);
  79067. }
  79068. /** @ignore */
  79069. export class ReadFileError extends BaseError {
  79070. file: File;
  79071. /**
  79072. * Creates a new ReadFileError
  79073. * @param message defines the message of the error
  79074. * @param file defines the optional file
  79075. */
  79076. constructor(message: string, file: File);
  79077. }
  79078. /**
  79079. * @hidden
  79080. */
  79081. export class FileTools {
  79082. /**
  79083. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  79084. */
  79085. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  79086. /**
  79087. * Gets or sets the base URL to use to load assets
  79088. */
  79089. static BaseUrl: string;
  79090. /**
  79091. * Default behaviour for cors in the application.
  79092. * It can be a string if the expected behavior is identical in the entire app.
  79093. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  79094. */
  79095. static CorsBehavior: string | ((url: string | string[]) => string);
  79096. /**
  79097. * Gets or sets a function used to pre-process url before using them to load assets
  79098. */
  79099. static PreprocessUrl: (url: string) => string;
  79100. /**
  79101. * Removes unwanted characters from an url
  79102. * @param url defines the url to clean
  79103. * @returns the cleaned url
  79104. */
  79105. private static _CleanUrl;
  79106. /**
  79107. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  79108. * @param url define the url we are trying
  79109. * @param element define the dom element where to configure the cors policy
  79110. */
  79111. static SetCorsBehavior(url: string | string[], element: {
  79112. crossOrigin: string | null;
  79113. }): void;
  79114. /**
  79115. * Loads an image as an HTMLImageElement.
  79116. * @param input url string, ArrayBuffer, or Blob to load
  79117. * @param onLoad callback called when the image successfully loads
  79118. * @param onError callback called when the image fails to load
  79119. * @param offlineProvider offline provider for caching
  79120. * @param mimeType optional mime type
  79121. * @returns the HTMLImageElement of the loaded image
  79122. */
  79123. 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>;
  79124. /**
  79125. * Reads a file from a File object
  79126. * @param file defines the file to load
  79127. * @param onSuccess defines the callback to call when data is loaded
  79128. * @param onProgress defines the callback to call during loading process
  79129. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  79130. * @param onError defines the callback to call when an error occurs
  79131. * @returns a file request object
  79132. */
  79133. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  79134. /**
  79135. * Loads a file from a url
  79136. * @param url url to load
  79137. * @param onSuccess callback called when the file successfully loads
  79138. * @param onProgress callback called while file is loading (if the server supports this mode)
  79139. * @param offlineProvider defines the offline provider for caching
  79140. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79141. * @param onError callback called when the file fails to load
  79142. * @returns a file request object
  79143. */
  79144. 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;
  79145. /**
  79146. * Loads a file
  79147. * @param url url to load
  79148. * @param onSuccess callback called when the file successfully loads
  79149. * @param onProgress callback called while file is loading (if the server supports this mode)
  79150. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79151. * @param onError callback called when the file fails to load
  79152. * @param onOpened callback called when the web request is opened
  79153. * @returns a file request object
  79154. */
  79155. 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;
  79156. /**
  79157. * Checks if the loaded document was accessed via `file:`-Protocol.
  79158. * @returns boolean
  79159. */
  79160. static IsFileURL(): boolean;
  79161. }
  79162. }
  79163. declare module BABYLON {
  79164. /** @hidden */
  79165. export class ShaderProcessor {
  79166. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  79167. private static _ProcessPrecision;
  79168. private static _ExtractOperation;
  79169. private static _BuildSubExpression;
  79170. private static _BuildExpression;
  79171. private static _MoveCursorWithinIf;
  79172. private static _MoveCursor;
  79173. private static _EvaluatePreProcessors;
  79174. private static _PreparePreProcessors;
  79175. private static _ProcessShaderConversion;
  79176. private static _ProcessIncludes;
  79177. /**
  79178. * Loads a file from a url
  79179. * @param url url to load
  79180. * @param onSuccess callback called when the file successfully loads
  79181. * @param onProgress callback called while file is loading (if the server supports this mode)
  79182. * @param offlineProvider defines the offline provider for caching
  79183. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79184. * @param onError callback called when the file fails to load
  79185. * @returns a file request object
  79186. * @hidden
  79187. */
  79188. 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;
  79189. }
  79190. }
  79191. declare module BABYLON {
  79192. /**
  79193. * @hidden
  79194. */
  79195. export interface IColor4Like {
  79196. r: float;
  79197. g: float;
  79198. b: float;
  79199. a: float;
  79200. }
  79201. /**
  79202. * @hidden
  79203. */
  79204. export interface IColor3Like {
  79205. r: float;
  79206. g: float;
  79207. b: float;
  79208. }
  79209. /**
  79210. * @hidden
  79211. */
  79212. export interface IVector4Like {
  79213. x: float;
  79214. y: float;
  79215. z: float;
  79216. w: float;
  79217. }
  79218. /**
  79219. * @hidden
  79220. */
  79221. export interface IVector3Like {
  79222. x: float;
  79223. y: float;
  79224. z: float;
  79225. }
  79226. /**
  79227. * @hidden
  79228. */
  79229. export interface IVector2Like {
  79230. x: float;
  79231. y: float;
  79232. }
  79233. /**
  79234. * @hidden
  79235. */
  79236. export interface IMatrixLike {
  79237. toArray(): DeepImmutable<Float32Array>;
  79238. updateFlag: int;
  79239. }
  79240. /**
  79241. * @hidden
  79242. */
  79243. export interface IViewportLike {
  79244. x: float;
  79245. y: float;
  79246. width: float;
  79247. height: float;
  79248. }
  79249. /**
  79250. * @hidden
  79251. */
  79252. export interface IPlaneLike {
  79253. normal: IVector3Like;
  79254. d: float;
  79255. normalize(): void;
  79256. }
  79257. }
  79258. declare module BABYLON {
  79259. /**
  79260. * Interface used to define common properties for effect fallbacks
  79261. */
  79262. export interface IEffectFallbacks {
  79263. /**
  79264. * Removes the defines that should be removed when falling back.
  79265. * @param currentDefines defines the current define statements for the shader.
  79266. * @param effect defines the current effect we try to compile
  79267. * @returns The resulting defines with defines of the current rank removed.
  79268. */
  79269. reduce(currentDefines: string, effect: Effect): string;
  79270. /**
  79271. * Removes the fallback from the bound mesh.
  79272. */
  79273. unBindMesh(): void;
  79274. /**
  79275. * Checks to see if more fallbacks are still availible.
  79276. */
  79277. hasMoreFallbacks: boolean;
  79278. }
  79279. }
  79280. declare module BABYLON {
  79281. /**
  79282. * Class used to evalaute queries containing `and` and `or` operators
  79283. */
  79284. export class AndOrNotEvaluator {
  79285. /**
  79286. * Evaluate a query
  79287. * @param query defines the query to evaluate
  79288. * @param evaluateCallback defines the callback used to filter result
  79289. * @returns true if the query matches
  79290. */
  79291. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  79292. private static _HandleParenthesisContent;
  79293. private static _SimplifyNegation;
  79294. }
  79295. }
  79296. declare module BABYLON {
  79297. /**
  79298. * Class used to store custom tags
  79299. */
  79300. export class Tags {
  79301. /**
  79302. * Adds support for tags on the given object
  79303. * @param obj defines the object to use
  79304. */
  79305. static EnableFor(obj: any): void;
  79306. /**
  79307. * Removes tags support
  79308. * @param obj defines the object to use
  79309. */
  79310. static DisableFor(obj: any): void;
  79311. /**
  79312. * Gets a boolean indicating if the given object has tags
  79313. * @param obj defines the object to use
  79314. * @returns a boolean
  79315. */
  79316. static HasTags(obj: any): boolean;
  79317. /**
  79318. * Gets the tags available on a given object
  79319. * @param obj defines the object to use
  79320. * @param asString defines if the tags must be returned as a string instead of an array of strings
  79321. * @returns the tags
  79322. */
  79323. static GetTags(obj: any, asString?: boolean): any;
  79324. /**
  79325. * Adds tags to an object
  79326. * @param obj defines the object to use
  79327. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  79328. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  79329. */
  79330. static AddTagsTo(obj: any, tagsString: string): void;
  79331. /**
  79332. * @hidden
  79333. */
  79334. static _AddTagTo(obj: any, tag: string): void;
  79335. /**
  79336. * Removes specific tags from a specific object
  79337. * @param obj defines the object to use
  79338. * @param tagsString defines the tags to remove
  79339. */
  79340. static RemoveTagsFrom(obj: any, tagsString: string): void;
  79341. /**
  79342. * @hidden
  79343. */
  79344. static _RemoveTagFrom(obj: any, tag: string): void;
  79345. /**
  79346. * Defines if tags hosted on an object match a given query
  79347. * @param obj defines the object to use
  79348. * @param tagsQuery defines the tag query
  79349. * @returns a boolean
  79350. */
  79351. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  79352. }
  79353. }
  79354. declare module BABYLON {
  79355. /**
  79356. * Scalar computation library
  79357. */
  79358. export class Scalar {
  79359. /**
  79360. * Two pi constants convenient for computation.
  79361. */
  79362. static TwoPi: number;
  79363. /**
  79364. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  79365. * @param a number
  79366. * @param b number
  79367. * @param epsilon (default = 1.401298E-45)
  79368. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  79369. */
  79370. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  79371. /**
  79372. * Returns a string : the upper case translation of the number i to hexadecimal.
  79373. * @param i number
  79374. * @returns the upper case translation of the number i to hexadecimal.
  79375. */
  79376. static ToHex(i: number): string;
  79377. /**
  79378. * Returns -1 if value is negative and +1 is value is positive.
  79379. * @param value the value
  79380. * @returns the value itself if it's equal to zero.
  79381. */
  79382. static Sign(value: number): number;
  79383. /**
  79384. * Returns the value itself if it's between min and max.
  79385. * Returns min if the value is lower than min.
  79386. * Returns max if the value is greater than max.
  79387. * @param value the value to clmap
  79388. * @param min the min value to clamp to (default: 0)
  79389. * @param max the max value to clamp to (default: 1)
  79390. * @returns the clamped value
  79391. */
  79392. static Clamp(value: number, min?: number, max?: number): number;
  79393. /**
  79394. * the log2 of value.
  79395. * @param value the value to compute log2 of
  79396. * @returns the log2 of value.
  79397. */
  79398. static Log2(value: number): number;
  79399. /**
  79400. * Loops the value, so that it is never larger than length and never smaller than 0.
  79401. *
  79402. * This is similar to the modulo operator but it works with floating point numbers.
  79403. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  79404. * With t = 5 and length = 2.5, the result would be 0.0.
  79405. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  79406. * @param value the value
  79407. * @param length the length
  79408. * @returns the looped value
  79409. */
  79410. static Repeat(value: number, length: number): number;
  79411. /**
  79412. * Normalize the value between 0.0 and 1.0 using min and max values
  79413. * @param value value to normalize
  79414. * @param min max to normalize between
  79415. * @param max min to normalize between
  79416. * @returns the normalized value
  79417. */
  79418. static Normalize(value: number, min: number, max: number): number;
  79419. /**
  79420. * Denormalize the value from 0.0 and 1.0 using min and max values
  79421. * @param normalized value to denormalize
  79422. * @param min max to denormalize between
  79423. * @param max min to denormalize between
  79424. * @returns the denormalized value
  79425. */
  79426. static Denormalize(normalized: number, min: number, max: number): number;
  79427. /**
  79428. * Calculates the shortest difference between two given angles given in degrees.
  79429. * @param current current angle in degrees
  79430. * @param target target angle in degrees
  79431. * @returns the delta
  79432. */
  79433. static DeltaAngle(current: number, target: number): number;
  79434. /**
  79435. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  79436. * @param tx value
  79437. * @param length length
  79438. * @returns The returned value will move back and forth between 0 and length
  79439. */
  79440. static PingPong(tx: number, length: number): number;
  79441. /**
  79442. * Interpolates between min and max with smoothing at the limits.
  79443. *
  79444. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  79445. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  79446. * @param from from
  79447. * @param to to
  79448. * @param tx value
  79449. * @returns the smooth stepped value
  79450. */
  79451. static SmoothStep(from: number, to: number, tx: number): number;
  79452. /**
  79453. * Moves a value current towards target.
  79454. *
  79455. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  79456. * Negative values of maxDelta pushes the value away from target.
  79457. * @param current current value
  79458. * @param target target value
  79459. * @param maxDelta max distance to move
  79460. * @returns resulting value
  79461. */
  79462. static MoveTowards(current: number, target: number, maxDelta: number): number;
  79463. /**
  79464. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  79465. *
  79466. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  79467. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  79468. * @param current current value
  79469. * @param target target value
  79470. * @param maxDelta max distance to move
  79471. * @returns resulting angle
  79472. */
  79473. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  79474. /**
  79475. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  79476. * @param start start value
  79477. * @param end target value
  79478. * @param amount amount to lerp between
  79479. * @returns the lerped value
  79480. */
  79481. static Lerp(start: number, end: number, amount: number): number;
  79482. /**
  79483. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  79484. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  79485. * @param start start value
  79486. * @param end target value
  79487. * @param amount amount to lerp between
  79488. * @returns the lerped value
  79489. */
  79490. static LerpAngle(start: number, end: number, amount: number): number;
  79491. /**
  79492. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  79493. * @param a start value
  79494. * @param b target value
  79495. * @param value value between a and b
  79496. * @returns the inverseLerp value
  79497. */
  79498. static InverseLerp(a: number, b: number, value: number): number;
  79499. /**
  79500. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  79501. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  79502. * @param value1 spline value
  79503. * @param tangent1 spline value
  79504. * @param value2 spline value
  79505. * @param tangent2 spline value
  79506. * @param amount input value
  79507. * @returns hermite result
  79508. */
  79509. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  79510. /**
  79511. * Returns a random float number between and min and max values
  79512. * @param min min value of random
  79513. * @param max max value of random
  79514. * @returns random value
  79515. */
  79516. static RandomRange(min: number, max: number): number;
  79517. /**
  79518. * This function returns percentage of a number in a given range.
  79519. *
  79520. * RangeToPercent(40,20,60) will return 0.5 (50%)
  79521. * RangeToPercent(34,0,100) will return 0.34 (34%)
  79522. * @param number to convert to percentage
  79523. * @param min min range
  79524. * @param max max range
  79525. * @returns the percentage
  79526. */
  79527. static RangeToPercent(number: number, min: number, max: number): number;
  79528. /**
  79529. * This function returns number that corresponds to the percentage in a given range.
  79530. *
  79531. * PercentToRange(0.34,0,100) will return 34.
  79532. * @param percent to convert to number
  79533. * @param min min range
  79534. * @param max max range
  79535. * @returns the number
  79536. */
  79537. static PercentToRange(percent: number, min: number, max: number): number;
  79538. /**
  79539. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  79540. * @param angle The angle to normalize in radian.
  79541. * @return The converted angle.
  79542. */
  79543. static NormalizeRadians(angle: number): number;
  79544. }
  79545. }
  79546. declare module BABYLON {
  79547. /**
  79548. * Constant used to convert a value to gamma space
  79549. * @ignorenaming
  79550. */
  79551. export const ToGammaSpace: number;
  79552. /**
  79553. * Constant used to convert a value to linear space
  79554. * @ignorenaming
  79555. */
  79556. export const ToLinearSpace = 2.2;
  79557. /**
  79558. * Constant used to define the minimal number value in Babylon.js
  79559. * @ignorenaming
  79560. */
  79561. let Epsilon: number;
  79562. }
  79563. declare module BABYLON {
  79564. /**
  79565. * Class used to represent a viewport on screen
  79566. */
  79567. export class Viewport {
  79568. /** viewport left coordinate */
  79569. x: number;
  79570. /** viewport top coordinate */
  79571. y: number;
  79572. /**viewport width */
  79573. width: number;
  79574. /** viewport height */
  79575. height: number;
  79576. /**
  79577. * Creates a Viewport object located at (x, y) and sized (width, height)
  79578. * @param x defines viewport left coordinate
  79579. * @param y defines viewport top coordinate
  79580. * @param width defines the viewport width
  79581. * @param height defines the viewport height
  79582. */
  79583. constructor(
  79584. /** viewport left coordinate */
  79585. x: number,
  79586. /** viewport top coordinate */
  79587. y: number,
  79588. /**viewport width */
  79589. width: number,
  79590. /** viewport height */
  79591. height: number);
  79592. /**
  79593. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  79594. * @param renderWidth defines the rendering width
  79595. * @param renderHeight defines the rendering height
  79596. * @returns a new Viewport
  79597. */
  79598. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  79599. /**
  79600. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  79601. * @param renderWidth defines the rendering width
  79602. * @param renderHeight defines the rendering height
  79603. * @param ref defines the target viewport
  79604. * @returns the current viewport
  79605. */
  79606. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  79607. /**
  79608. * Returns a new Viewport copied from the current one
  79609. * @returns a new Viewport
  79610. */
  79611. clone(): Viewport;
  79612. }
  79613. }
  79614. declare module BABYLON {
  79615. /**
  79616. * Class containing a set of static utilities functions for arrays.
  79617. */
  79618. export class ArrayTools {
  79619. /**
  79620. * Returns an array of the given size filled with element built from the given constructor and the paramters
  79621. * @param size the number of element to construct and put in the array
  79622. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  79623. * @returns a new array filled with new objects
  79624. */
  79625. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  79626. }
  79627. }
  79628. declare module BABYLON {
  79629. /**
  79630. * Represents a plane by the equation ax + by + cz + d = 0
  79631. */
  79632. export class Plane {
  79633. private static _TmpMatrix;
  79634. /**
  79635. * Normal of the plane (a,b,c)
  79636. */
  79637. normal: Vector3;
  79638. /**
  79639. * d component of the plane
  79640. */
  79641. d: number;
  79642. /**
  79643. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79644. * @param a a component of the plane
  79645. * @param b b component of the plane
  79646. * @param c c component of the plane
  79647. * @param d d component of the plane
  79648. */
  79649. constructor(a: number, b: number, c: number, d: number);
  79650. /**
  79651. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79652. */
  79653. asArray(): number[];
  79654. /**
  79655. * @returns a new plane copied from the current Plane.
  79656. */
  79657. clone(): Plane;
  79658. /**
  79659. * @returns the string "Plane".
  79660. */
  79661. getClassName(): string;
  79662. /**
  79663. * @returns the Plane hash code.
  79664. */
  79665. getHashCode(): number;
  79666. /**
  79667. * Normalize the current Plane in place.
  79668. * @returns the updated Plane.
  79669. */
  79670. normalize(): Plane;
  79671. /**
  79672. * Applies a transformation the plane and returns the result
  79673. * @param transformation the transformation matrix to be applied to the plane
  79674. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79675. */
  79676. transform(transformation: DeepImmutable<Matrix>): Plane;
  79677. /**
  79678. * Compute the dot product between the point and the plane normal
  79679. * @param point point to calculate the dot product with
  79680. * @returns the dot product (float) of the point coordinates and the plane normal.
  79681. */
  79682. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79683. /**
  79684. * Updates the current Plane from the plane defined by the three given points.
  79685. * @param point1 one of the points used to contruct the plane
  79686. * @param point2 one of the points used to contruct the plane
  79687. * @param point3 one of the points used to contruct the plane
  79688. * @returns the updated Plane.
  79689. */
  79690. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79691. /**
  79692. * Checks if the plane is facing a given direction
  79693. * @param direction the direction to check if the plane is facing
  79694. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79695. * @returns True is the vector "direction" is the same side than the plane normal.
  79696. */
  79697. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79698. /**
  79699. * Calculates the distance to a point
  79700. * @param point point to calculate distance to
  79701. * @returns the signed distance (float) from the given point to the Plane.
  79702. */
  79703. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79704. /**
  79705. * Creates a plane from an array
  79706. * @param array the array to create a plane from
  79707. * @returns a new Plane from the given array.
  79708. */
  79709. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79710. /**
  79711. * Creates a plane from three points
  79712. * @param point1 point used to create the plane
  79713. * @param point2 point used to create the plane
  79714. * @param point3 point used to create the plane
  79715. * @returns a new Plane defined by the three given points.
  79716. */
  79717. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79718. /**
  79719. * Creates a plane from an origin point and a normal
  79720. * @param origin origin of the plane to be constructed
  79721. * @param normal normal of the plane to be constructed
  79722. * @returns a new Plane the normal vector to this plane at the given origin point.
  79723. * Note : the vector "normal" is updated because normalized.
  79724. */
  79725. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  79726. /**
  79727. * Calculates the distance from a plane and a point
  79728. * @param origin origin of the plane to be constructed
  79729. * @param normal normal of the plane to be constructed
  79730. * @param point point to calculate distance to
  79731. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79732. */
  79733. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79734. }
  79735. }
  79736. declare module BABYLON {
  79737. /**
  79738. * Class representing a vector containing 2 coordinates
  79739. */
  79740. export class Vector2 {
  79741. /** defines the first coordinate */
  79742. x: number;
  79743. /** defines the second coordinate */
  79744. y: number;
  79745. /**
  79746. * Creates a new Vector2 from the given x and y coordinates
  79747. * @param x defines the first coordinate
  79748. * @param y defines the second coordinate
  79749. */
  79750. constructor(
  79751. /** defines the first coordinate */
  79752. x?: number,
  79753. /** defines the second coordinate */
  79754. y?: number);
  79755. /**
  79756. * Gets a string with the Vector2 coordinates
  79757. * @returns a string with the Vector2 coordinates
  79758. */
  79759. toString(): string;
  79760. /**
  79761. * Gets class name
  79762. * @returns the string "Vector2"
  79763. */
  79764. getClassName(): string;
  79765. /**
  79766. * Gets current vector hash code
  79767. * @returns the Vector2 hash code as a number
  79768. */
  79769. getHashCode(): number;
  79770. /**
  79771. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  79772. * @param array defines the source array
  79773. * @param index defines the offset in source array
  79774. * @returns the current Vector2
  79775. */
  79776. toArray(array: FloatArray, index?: number): Vector2;
  79777. /**
  79778. * Copy the current vector to an array
  79779. * @returns a new array with 2 elements: the Vector2 coordinates.
  79780. */
  79781. asArray(): number[];
  79782. /**
  79783. * Sets the Vector2 coordinates with the given Vector2 coordinates
  79784. * @param source defines the source Vector2
  79785. * @returns the current updated Vector2
  79786. */
  79787. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  79788. /**
  79789. * Sets the Vector2 coordinates with the given floats
  79790. * @param x defines the first coordinate
  79791. * @param y defines the second coordinate
  79792. * @returns the current updated Vector2
  79793. */
  79794. copyFromFloats(x: number, y: number): Vector2;
  79795. /**
  79796. * Sets the Vector2 coordinates with the given floats
  79797. * @param x defines the first coordinate
  79798. * @param y defines the second coordinate
  79799. * @returns the current updated Vector2
  79800. */
  79801. set(x: number, y: number): Vector2;
  79802. /**
  79803. * Add another vector with the current one
  79804. * @param otherVector defines the other vector
  79805. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  79806. */
  79807. add(otherVector: DeepImmutable<Vector2>): Vector2;
  79808. /**
  79809. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  79810. * @param otherVector defines the other vector
  79811. * @param result defines the target vector
  79812. * @returns the unmodified current Vector2
  79813. */
  79814. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79815. /**
  79816. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  79817. * @param otherVector defines the other vector
  79818. * @returns the current updated Vector2
  79819. */
  79820. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79821. /**
  79822. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  79823. * @param otherVector defines the other vector
  79824. * @returns a new Vector2
  79825. */
  79826. addVector3(otherVector: Vector3): Vector2;
  79827. /**
  79828. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  79829. * @param otherVector defines the other vector
  79830. * @returns a new Vector2
  79831. */
  79832. subtract(otherVector: Vector2): Vector2;
  79833. /**
  79834. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  79835. * @param otherVector defines the other vector
  79836. * @param result defines the target vector
  79837. * @returns the unmodified current Vector2
  79838. */
  79839. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79840. /**
  79841. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  79842. * @param otherVector defines the other vector
  79843. * @returns the current updated Vector2
  79844. */
  79845. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79846. /**
  79847. * Multiplies in place the current Vector2 coordinates by the given ones
  79848. * @param otherVector defines the other vector
  79849. * @returns the current updated Vector2
  79850. */
  79851. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79852. /**
  79853. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  79854. * @param otherVector defines the other vector
  79855. * @returns a new Vector2
  79856. */
  79857. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  79858. /**
  79859. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  79860. * @param otherVector defines the other vector
  79861. * @param result defines the target vector
  79862. * @returns the unmodified current Vector2
  79863. */
  79864. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79865. /**
  79866. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  79867. * @param x defines the first coordinate
  79868. * @param y defines the second coordinate
  79869. * @returns a new Vector2
  79870. */
  79871. multiplyByFloats(x: number, y: number): Vector2;
  79872. /**
  79873. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  79874. * @param otherVector defines the other vector
  79875. * @returns a new Vector2
  79876. */
  79877. divide(otherVector: Vector2): Vector2;
  79878. /**
  79879. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  79880. * @param otherVector defines the other vector
  79881. * @param result defines the target vector
  79882. * @returns the unmodified current Vector2
  79883. */
  79884. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79885. /**
  79886. * Divides the current Vector2 coordinates by the given ones
  79887. * @param otherVector defines the other vector
  79888. * @returns the current updated Vector2
  79889. */
  79890. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79891. /**
  79892. * Gets a new Vector2 with current Vector2 negated coordinates
  79893. * @returns a new Vector2
  79894. */
  79895. negate(): Vector2;
  79896. /**
  79897. * Negate this vector in place
  79898. * @returns this
  79899. */
  79900. negateInPlace(): Vector2;
  79901. /**
  79902. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  79903. * @param result defines the Vector3 object where to store the result
  79904. * @returns the current Vector2
  79905. */
  79906. negateToRef(result: Vector2): Vector2;
  79907. /**
  79908. * Multiply the Vector2 coordinates by scale
  79909. * @param scale defines the scaling factor
  79910. * @returns the current updated Vector2
  79911. */
  79912. scaleInPlace(scale: number): Vector2;
  79913. /**
  79914. * Returns a new Vector2 scaled by "scale" from the current Vector2
  79915. * @param scale defines the scaling factor
  79916. * @returns a new Vector2
  79917. */
  79918. scale(scale: number): Vector2;
  79919. /**
  79920. * Scale the current Vector2 values by a factor to a given Vector2
  79921. * @param scale defines the scale factor
  79922. * @param result defines the Vector2 object where to store the result
  79923. * @returns the unmodified current Vector2
  79924. */
  79925. scaleToRef(scale: number, result: Vector2): Vector2;
  79926. /**
  79927. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  79928. * @param scale defines the scale factor
  79929. * @param result defines the Vector2 object where to store the result
  79930. * @returns the unmodified current Vector2
  79931. */
  79932. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  79933. /**
  79934. * Gets a boolean if two vectors are equals
  79935. * @param otherVector defines the other vector
  79936. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  79937. */
  79938. equals(otherVector: DeepImmutable<Vector2>): boolean;
  79939. /**
  79940. * Gets a boolean if two vectors are equals (using an epsilon value)
  79941. * @param otherVector defines the other vector
  79942. * @param epsilon defines the minimal distance to consider equality
  79943. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  79944. */
  79945. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  79946. /**
  79947. * Gets a new Vector2 from current Vector2 floored values
  79948. * @returns a new Vector2
  79949. */
  79950. floor(): Vector2;
  79951. /**
  79952. * Gets a new Vector2 from current Vector2 floored values
  79953. * @returns a new Vector2
  79954. */
  79955. fract(): Vector2;
  79956. /**
  79957. * Gets the length of the vector
  79958. * @returns the vector length (float)
  79959. */
  79960. length(): number;
  79961. /**
  79962. * Gets the vector squared length
  79963. * @returns the vector squared length (float)
  79964. */
  79965. lengthSquared(): number;
  79966. /**
  79967. * Normalize the vector
  79968. * @returns the current updated Vector2
  79969. */
  79970. normalize(): Vector2;
  79971. /**
  79972. * Gets a new Vector2 copied from the Vector2
  79973. * @returns a new Vector2
  79974. */
  79975. clone(): Vector2;
  79976. /**
  79977. * Gets a new Vector2(0, 0)
  79978. * @returns a new Vector2
  79979. */
  79980. static Zero(): Vector2;
  79981. /**
  79982. * Gets a new Vector2(1, 1)
  79983. * @returns a new Vector2
  79984. */
  79985. static One(): Vector2;
  79986. /**
  79987. * Gets a new Vector2 set from the given index element of the given array
  79988. * @param array defines the data source
  79989. * @param offset defines the offset in the data source
  79990. * @returns a new Vector2
  79991. */
  79992. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  79993. /**
  79994. * Sets "result" from the given index element of the given array
  79995. * @param array defines the data source
  79996. * @param offset defines the offset in the data source
  79997. * @param result defines the target vector
  79998. */
  79999. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  80000. /**
  80001. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  80002. * @param value1 defines 1st point of control
  80003. * @param value2 defines 2nd point of control
  80004. * @param value3 defines 3rd point of control
  80005. * @param value4 defines 4th point of control
  80006. * @param amount defines the interpolation factor
  80007. * @returns a new Vector2
  80008. */
  80009. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  80010. /**
  80011. * 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".
  80012. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  80013. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  80014. * @param value defines the value to clamp
  80015. * @param min defines the lower limit
  80016. * @param max defines the upper limit
  80017. * @returns a new Vector2
  80018. */
  80019. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  80020. /**
  80021. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  80022. * @param value1 defines the 1st control point
  80023. * @param tangent1 defines the outgoing tangent
  80024. * @param value2 defines the 2nd control point
  80025. * @param tangent2 defines the incoming tangent
  80026. * @param amount defines the interpolation factor
  80027. * @returns a new Vector2
  80028. */
  80029. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  80030. /**
  80031. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  80032. * @param start defines the start vector
  80033. * @param end defines the end vector
  80034. * @param amount defines the interpolation factor
  80035. * @returns a new Vector2
  80036. */
  80037. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  80038. /**
  80039. * Gets the dot product of the vector "left" and the vector "right"
  80040. * @param left defines first vector
  80041. * @param right defines second vector
  80042. * @returns the dot product (float)
  80043. */
  80044. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  80045. /**
  80046. * Returns a new Vector2 equal to the normalized given vector
  80047. * @param vector defines the vector to normalize
  80048. * @returns a new Vector2
  80049. */
  80050. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  80051. /**
  80052. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  80053. * @param left defines 1st vector
  80054. * @param right defines 2nd vector
  80055. * @returns a new Vector2
  80056. */
  80057. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80058. /**
  80059. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  80060. * @param left defines 1st vector
  80061. * @param right defines 2nd vector
  80062. * @returns a new Vector2
  80063. */
  80064. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80065. /**
  80066. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  80067. * @param vector defines the vector to transform
  80068. * @param transformation defines the matrix to apply
  80069. * @returns a new Vector2
  80070. */
  80071. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  80072. /**
  80073. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  80074. * @param vector defines the vector to transform
  80075. * @param transformation defines the matrix to apply
  80076. * @param result defines the target vector
  80077. */
  80078. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  80079. /**
  80080. * Determines if a given vector is included in a triangle
  80081. * @param p defines the vector to test
  80082. * @param p0 defines 1st triangle point
  80083. * @param p1 defines 2nd triangle point
  80084. * @param p2 defines 3rd triangle point
  80085. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  80086. */
  80087. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  80088. /**
  80089. * Gets the distance between the vectors "value1" and "value2"
  80090. * @param value1 defines first vector
  80091. * @param value2 defines second vector
  80092. * @returns the distance between vectors
  80093. */
  80094. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80095. /**
  80096. * Returns the squared distance between the vectors "value1" and "value2"
  80097. * @param value1 defines first vector
  80098. * @param value2 defines second vector
  80099. * @returns the squared distance between vectors
  80100. */
  80101. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80102. /**
  80103. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  80104. * @param value1 defines first vector
  80105. * @param value2 defines second vector
  80106. * @returns a new Vector2
  80107. */
  80108. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  80109. /**
  80110. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  80111. * @param p defines the middle point
  80112. * @param segA defines one point of the segment
  80113. * @param segB defines the other point of the segment
  80114. * @returns the shortest distance
  80115. */
  80116. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  80117. }
  80118. /**
  80119. * Class used to store (x,y,z) vector representation
  80120. * A Vector3 is the main object used in 3D geometry
  80121. * It can represent etiher the coordinates of a point the space, either a direction
  80122. * Reminder: js uses a left handed forward facing system
  80123. */
  80124. export class Vector3 {
  80125. /**
  80126. * Defines the first coordinates (on X axis)
  80127. */
  80128. x: number;
  80129. /**
  80130. * Defines the second coordinates (on Y axis)
  80131. */
  80132. y: number;
  80133. /**
  80134. * Defines the third coordinates (on Z axis)
  80135. */
  80136. z: number;
  80137. private static _UpReadOnly;
  80138. private static _ZeroReadOnly;
  80139. /**
  80140. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  80141. * @param x defines the first coordinates (on X axis)
  80142. * @param y defines the second coordinates (on Y axis)
  80143. * @param z defines the third coordinates (on Z axis)
  80144. */
  80145. constructor(
  80146. /**
  80147. * Defines the first coordinates (on X axis)
  80148. */
  80149. x?: number,
  80150. /**
  80151. * Defines the second coordinates (on Y axis)
  80152. */
  80153. y?: number,
  80154. /**
  80155. * Defines the third coordinates (on Z axis)
  80156. */
  80157. z?: number);
  80158. /**
  80159. * Creates a string representation of the Vector3
  80160. * @returns a string with the Vector3 coordinates.
  80161. */
  80162. toString(): string;
  80163. /**
  80164. * Gets the class name
  80165. * @returns the string "Vector3"
  80166. */
  80167. getClassName(): string;
  80168. /**
  80169. * Creates the Vector3 hash code
  80170. * @returns a number which tends to be unique between Vector3 instances
  80171. */
  80172. getHashCode(): number;
  80173. /**
  80174. * Creates an array containing three elements : the coordinates of the Vector3
  80175. * @returns a new array of numbers
  80176. */
  80177. asArray(): number[];
  80178. /**
  80179. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  80180. * @param array defines the destination array
  80181. * @param index defines the offset in the destination array
  80182. * @returns the current Vector3
  80183. */
  80184. toArray(array: FloatArray, index?: number): Vector3;
  80185. /**
  80186. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  80187. * @returns a new Quaternion object, computed from the Vector3 coordinates
  80188. */
  80189. toQuaternion(): Quaternion;
  80190. /**
  80191. * Adds the given vector to the current Vector3
  80192. * @param otherVector defines the second operand
  80193. * @returns the current updated Vector3
  80194. */
  80195. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80196. /**
  80197. * Adds the given coordinates to the current Vector3
  80198. * @param x defines the x coordinate of the operand
  80199. * @param y defines the y coordinate of the operand
  80200. * @param z defines the z coordinate of the operand
  80201. * @returns the current updated Vector3
  80202. */
  80203. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80204. /**
  80205. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  80206. * @param otherVector defines the second operand
  80207. * @returns the resulting Vector3
  80208. */
  80209. add(otherVector: DeepImmutable<Vector3>): Vector3;
  80210. /**
  80211. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  80212. * @param otherVector defines the second operand
  80213. * @param result defines the Vector3 object where to store the result
  80214. * @returns the current Vector3
  80215. */
  80216. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80217. /**
  80218. * Subtract the given vector from the current Vector3
  80219. * @param otherVector defines the second operand
  80220. * @returns the current updated Vector3
  80221. */
  80222. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80223. /**
  80224. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  80225. * @param otherVector defines the second operand
  80226. * @returns the resulting Vector3
  80227. */
  80228. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  80229. /**
  80230. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  80231. * @param otherVector defines the second operand
  80232. * @param result defines the Vector3 object where to store the result
  80233. * @returns the current Vector3
  80234. */
  80235. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80236. /**
  80237. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  80238. * @param x defines the x coordinate of the operand
  80239. * @param y defines the y coordinate of the operand
  80240. * @param z defines the z coordinate of the operand
  80241. * @returns the resulting Vector3
  80242. */
  80243. subtractFromFloats(x: number, y: number, z: number): Vector3;
  80244. /**
  80245. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  80246. * @param x defines the x coordinate of the operand
  80247. * @param y defines the y coordinate of the operand
  80248. * @param z defines the z coordinate of the operand
  80249. * @param result defines the Vector3 object where to store the result
  80250. * @returns the current Vector3
  80251. */
  80252. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  80253. /**
  80254. * Gets a new Vector3 set with the current Vector3 negated coordinates
  80255. * @returns a new Vector3
  80256. */
  80257. negate(): Vector3;
  80258. /**
  80259. * Negate this vector in place
  80260. * @returns this
  80261. */
  80262. negateInPlace(): Vector3;
  80263. /**
  80264. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  80265. * @param result defines the Vector3 object where to store the result
  80266. * @returns the current Vector3
  80267. */
  80268. negateToRef(result: Vector3): Vector3;
  80269. /**
  80270. * Multiplies the Vector3 coordinates by the float "scale"
  80271. * @param scale defines the multiplier factor
  80272. * @returns the current updated Vector3
  80273. */
  80274. scaleInPlace(scale: number): Vector3;
  80275. /**
  80276. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  80277. * @param scale defines the multiplier factor
  80278. * @returns a new Vector3
  80279. */
  80280. scale(scale: number): Vector3;
  80281. /**
  80282. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  80283. * @param scale defines the multiplier factor
  80284. * @param result defines the Vector3 object where to store the result
  80285. * @returns the current Vector3
  80286. */
  80287. scaleToRef(scale: number, result: Vector3): Vector3;
  80288. /**
  80289. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  80290. * @param scale defines the scale factor
  80291. * @param result defines the Vector3 object where to store the result
  80292. * @returns the unmodified current Vector3
  80293. */
  80294. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  80295. /**
  80296. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  80297. * @param origin defines the origin of the projection ray
  80298. * @param plane defines the plane to project to
  80299. * @returns the projected vector3
  80300. */
  80301. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  80302. /**
  80303. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  80304. * @param origin defines the origin of the projection ray
  80305. * @param plane defines the plane to project to
  80306. * @param result defines the Vector3 where to store the result
  80307. */
  80308. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  80309. /**
  80310. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  80311. * @param otherVector defines the second operand
  80312. * @returns true if both vectors are equals
  80313. */
  80314. equals(otherVector: DeepImmutable<Vector3>): boolean;
  80315. /**
  80316. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  80317. * @param otherVector defines the second operand
  80318. * @param epsilon defines the minimal distance to define values as equals
  80319. * @returns true if both vectors are distant less than epsilon
  80320. */
  80321. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  80322. /**
  80323. * Returns true if the current Vector3 coordinates equals the given floats
  80324. * @param x defines the x coordinate of the operand
  80325. * @param y defines the y coordinate of the operand
  80326. * @param z defines the z coordinate of the operand
  80327. * @returns true if both vectors are equals
  80328. */
  80329. equalsToFloats(x: number, y: number, z: number): boolean;
  80330. /**
  80331. * Multiplies the current Vector3 coordinates by the given ones
  80332. * @param otherVector defines the second operand
  80333. * @returns the current updated Vector3
  80334. */
  80335. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80336. /**
  80337. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  80338. * @param otherVector defines the second operand
  80339. * @returns the new Vector3
  80340. */
  80341. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  80342. /**
  80343. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  80344. * @param otherVector defines the second operand
  80345. * @param result defines the Vector3 object where to store the result
  80346. * @returns the current Vector3
  80347. */
  80348. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80349. /**
  80350. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  80351. * @param x defines the x coordinate of the operand
  80352. * @param y defines the y coordinate of the operand
  80353. * @param z defines the z coordinate of the operand
  80354. * @returns the new Vector3
  80355. */
  80356. multiplyByFloats(x: number, y: number, z: number): Vector3;
  80357. /**
  80358. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  80359. * @param otherVector defines the second operand
  80360. * @returns the new Vector3
  80361. */
  80362. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  80363. /**
  80364. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  80365. * @param otherVector defines the second operand
  80366. * @param result defines the Vector3 object where to store the result
  80367. * @returns the current Vector3
  80368. */
  80369. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80370. /**
  80371. * Divides the current Vector3 coordinates by the given ones.
  80372. * @param otherVector defines the second operand
  80373. * @returns the current updated Vector3
  80374. */
  80375. divideInPlace(otherVector: Vector3): Vector3;
  80376. /**
  80377. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  80378. * @param other defines the second operand
  80379. * @returns the current updated Vector3
  80380. */
  80381. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  80382. /**
  80383. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  80384. * @param other defines the second operand
  80385. * @returns the current updated Vector3
  80386. */
  80387. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  80388. /**
  80389. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  80390. * @param x defines the x coordinate of the operand
  80391. * @param y defines the y coordinate of the operand
  80392. * @param z defines the z coordinate of the operand
  80393. * @returns the current updated Vector3
  80394. */
  80395. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80396. /**
  80397. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  80398. * @param x defines the x coordinate of the operand
  80399. * @param y defines the y coordinate of the operand
  80400. * @param z defines the z coordinate of the operand
  80401. * @returns the current updated Vector3
  80402. */
  80403. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80404. /**
  80405. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  80406. * Check if is non uniform within a certain amount of decimal places to account for this
  80407. * @param epsilon the amount the values can differ
  80408. * @returns if the the vector is non uniform to a certain number of decimal places
  80409. */
  80410. isNonUniformWithinEpsilon(epsilon: number): boolean;
  80411. /**
  80412. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  80413. */
  80414. get isNonUniform(): boolean;
  80415. /**
  80416. * Gets a new Vector3 from current Vector3 floored values
  80417. * @returns a new Vector3
  80418. */
  80419. floor(): Vector3;
  80420. /**
  80421. * Gets a new Vector3 from current Vector3 floored values
  80422. * @returns a new Vector3
  80423. */
  80424. fract(): Vector3;
  80425. /**
  80426. * Gets the length of the Vector3
  80427. * @returns the length of the Vector3
  80428. */
  80429. length(): number;
  80430. /**
  80431. * Gets the squared length of the Vector3
  80432. * @returns squared length of the Vector3
  80433. */
  80434. lengthSquared(): number;
  80435. /**
  80436. * Normalize the current Vector3.
  80437. * Please note that this is an in place operation.
  80438. * @returns the current updated Vector3
  80439. */
  80440. normalize(): Vector3;
  80441. /**
  80442. * Reorders the x y z properties of the vector in place
  80443. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  80444. * @returns the current updated vector
  80445. */
  80446. reorderInPlace(order: string): this;
  80447. /**
  80448. * Rotates the vector around 0,0,0 by a quaternion
  80449. * @param quaternion the rotation quaternion
  80450. * @param result vector to store the result
  80451. * @returns the resulting vector
  80452. */
  80453. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  80454. /**
  80455. * Rotates a vector around a given point
  80456. * @param quaternion the rotation quaternion
  80457. * @param point the point to rotate around
  80458. * @param result vector to store the result
  80459. * @returns the resulting vector
  80460. */
  80461. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  80462. /**
  80463. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  80464. * The cross product is then orthogonal to both current and "other"
  80465. * @param other defines the right operand
  80466. * @returns the cross product
  80467. */
  80468. cross(other: Vector3): Vector3;
  80469. /**
  80470. * Normalize the current Vector3 with the given input length.
  80471. * Please note that this is an in place operation.
  80472. * @param len the length of the vector
  80473. * @returns the current updated Vector3
  80474. */
  80475. normalizeFromLength(len: number): Vector3;
  80476. /**
  80477. * Normalize the current Vector3 to a new vector
  80478. * @returns the new Vector3
  80479. */
  80480. normalizeToNew(): Vector3;
  80481. /**
  80482. * Normalize the current Vector3 to the reference
  80483. * @param reference define the Vector3 to update
  80484. * @returns the updated Vector3
  80485. */
  80486. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  80487. /**
  80488. * Creates a new Vector3 copied from the current Vector3
  80489. * @returns the new Vector3
  80490. */
  80491. clone(): Vector3;
  80492. /**
  80493. * Copies the given vector coordinates to the current Vector3 ones
  80494. * @param source defines the source Vector3
  80495. * @returns the current updated Vector3
  80496. */
  80497. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  80498. /**
  80499. * Copies the given floats to the current Vector3 coordinates
  80500. * @param x defines the x coordinate of the operand
  80501. * @param y defines the y coordinate of the operand
  80502. * @param z defines the z coordinate of the operand
  80503. * @returns the current updated Vector3
  80504. */
  80505. copyFromFloats(x: number, y: number, z: number): Vector3;
  80506. /**
  80507. * Copies the given floats to the current Vector3 coordinates
  80508. * @param x defines the x coordinate of the operand
  80509. * @param y defines the y coordinate of the operand
  80510. * @param z defines the z coordinate of the operand
  80511. * @returns the current updated Vector3
  80512. */
  80513. set(x: number, y: number, z: number): Vector3;
  80514. /**
  80515. * Copies the given float to the current Vector3 coordinates
  80516. * @param v defines the x, y and z coordinates of the operand
  80517. * @returns the current updated Vector3
  80518. */
  80519. setAll(v: number): Vector3;
  80520. /**
  80521. * Get the clip factor between two vectors
  80522. * @param vector0 defines the first operand
  80523. * @param vector1 defines the second operand
  80524. * @param axis defines the axis to use
  80525. * @param size defines the size along the axis
  80526. * @returns the clip factor
  80527. */
  80528. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  80529. /**
  80530. * Get angle between two vectors
  80531. * @param vector0 angle between vector0 and vector1
  80532. * @param vector1 angle between vector0 and vector1
  80533. * @param normal direction of the normal
  80534. * @return the angle between vector0 and vector1
  80535. */
  80536. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  80537. /**
  80538. * Returns a new Vector3 set from the index "offset" of the given array
  80539. * @param array defines the source array
  80540. * @param offset defines the offset in the source array
  80541. * @returns the new Vector3
  80542. */
  80543. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  80544. /**
  80545. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  80546. * @param array defines the source array
  80547. * @param offset defines the offset in the source array
  80548. * @returns the new Vector3
  80549. * @deprecated Please use FromArray instead.
  80550. */
  80551. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  80552. /**
  80553. * Sets the given vector "result" with the element values from the index "offset" of the given array
  80554. * @param array defines the source array
  80555. * @param offset defines the offset in the source array
  80556. * @param result defines the Vector3 where to store the result
  80557. */
  80558. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  80559. /**
  80560. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  80561. * @param array defines the source array
  80562. * @param offset defines the offset in the source array
  80563. * @param result defines the Vector3 where to store the result
  80564. * @deprecated Please use FromArrayToRef instead.
  80565. */
  80566. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  80567. /**
  80568. * Sets the given vector "result" with the given floats.
  80569. * @param x defines the x coordinate of the source
  80570. * @param y defines the y coordinate of the source
  80571. * @param z defines the z coordinate of the source
  80572. * @param result defines the Vector3 where to store the result
  80573. */
  80574. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  80575. /**
  80576. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  80577. * @returns a new empty Vector3
  80578. */
  80579. static Zero(): Vector3;
  80580. /**
  80581. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  80582. * @returns a new unit Vector3
  80583. */
  80584. static One(): Vector3;
  80585. /**
  80586. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  80587. * @returns a new up Vector3
  80588. */
  80589. static Up(): Vector3;
  80590. /**
  80591. * Gets a up Vector3 that must not be updated
  80592. */
  80593. static get UpReadOnly(): DeepImmutable<Vector3>;
  80594. /**
  80595. * Gets a zero Vector3 that must not be updated
  80596. */
  80597. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  80598. /**
  80599. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  80600. * @returns a new down Vector3
  80601. */
  80602. static Down(): Vector3;
  80603. /**
  80604. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  80605. * @param rightHandedSystem is the scene right-handed (negative z)
  80606. * @returns a new forward Vector3
  80607. */
  80608. static Forward(rightHandedSystem?: boolean): Vector3;
  80609. /**
  80610. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  80611. * @param rightHandedSystem is the scene right-handed (negative-z)
  80612. * @returns a new forward Vector3
  80613. */
  80614. static Backward(rightHandedSystem?: boolean): Vector3;
  80615. /**
  80616. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  80617. * @returns a new right Vector3
  80618. */
  80619. static Right(): Vector3;
  80620. /**
  80621. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  80622. * @returns a new left Vector3
  80623. */
  80624. static Left(): Vector3;
  80625. /**
  80626. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  80627. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  80628. * @param vector defines the Vector3 to transform
  80629. * @param transformation defines the transformation matrix
  80630. * @returns the transformed Vector3
  80631. */
  80632. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  80633. /**
  80634. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  80635. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  80636. * @param vector defines the Vector3 to transform
  80637. * @param transformation defines the transformation matrix
  80638. * @param result defines the Vector3 where to store the result
  80639. */
  80640. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80641. /**
  80642. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  80643. * This method computes tranformed coordinates only, not transformed direction vectors
  80644. * @param x define the x coordinate of the source vector
  80645. * @param y define the y coordinate of the source vector
  80646. * @param z define the z coordinate of the source vector
  80647. * @param transformation defines the transformation matrix
  80648. * @param result defines the Vector3 where to store the result
  80649. */
  80650. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80651. /**
  80652. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  80653. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80654. * @param vector defines the Vector3 to transform
  80655. * @param transformation defines the transformation matrix
  80656. * @returns the new Vector3
  80657. */
  80658. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  80659. /**
  80660. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  80661. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80662. * @param vector defines the Vector3 to transform
  80663. * @param transformation defines the transformation matrix
  80664. * @param result defines the Vector3 where to store the result
  80665. */
  80666. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80667. /**
  80668. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  80669. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80670. * @param x define the x coordinate of the source vector
  80671. * @param y define the y coordinate of the source vector
  80672. * @param z define the z coordinate of the source vector
  80673. * @param transformation defines the transformation matrix
  80674. * @param result defines the Vector3 where to store the result
  80675. */
  80676. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80677. /**
  80678. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  80679. * @param value1 defines the first control point
  80680. * @param value2 defines the second control point
  80681. * @param value3 defines the third control point
  80682. * @param value4 defines the fourth control point
  80683. * @param amount defines the amount on the spline to use
  80684. * @returns the new Vector3
  80685. */
  80686. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  80687. /**
  80688. * 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"
  80689. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  80690. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  80691. * @param value defines the current value
  80692. * @param min defines the lower range value
  80693. * @param max defines the upper range value
  80694. * @returns the new Vector3
  80695. */
  80696. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  80697. /**
  80698. * 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"
  80699. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  80700. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  80701. * @param value defines the current value
  80702. * @param min defines the lower range value
  80703. * @param max defines the upper range value
  80704. * @param result defines the Vector3 where to store the result
  80705. */
  80706. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  80707. /**
  80708. * Checks if a given vector is inside a specific range
  80709. * @param v defines the vector to test
  80710. * @param min defines the minimum range
  80711. * @param max defines the maximum range
  80712. */
  80713. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  80714. /**
  80715. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  80716. * @param value1 defines the first control point
  80717. * @param tangent1 defines the first tangent vector
  80718. * @param value2 defines the second control point
  80719. * @param tangent2 defines the second tangent vector
  80720. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  80721. * @returns the new Vector3
  80722. */
  80723. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  80724. /**
  80725. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  80726. * @param start defines the start value
  80727. * @param end defines the end value
  80728. * @param amount max defines amount between both (between 0 and 1)
  80729. * @returns the new Vector3
  80730. */
  80731. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  80732. /**
  80733. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  80734. * @param start defines the start value
  80735. * @param end defines the end value
  80736. * @param amount max defines amount between both (between 0 and 1)
  80737. * @param result defines the Vector3 where to store the result
  80738. */
  80739. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  80740. /**
  80741. * Returns the dot product (float) between the vectors "left" and "right"
  80742. * @param left defines the left operand
  80743. * @param right defines the right operand
  80744. * @returns the dot product
  80745. */
  80746. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  80747. /**
  80748. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  80749. * The cross product is then orthogonal to both "left" and "right"
  80750. * @param left defines the left operand
  80751. * @param right defines the right operand
  80752. * @returns the cross product
  80753. */
  80754. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80755. /**
  80756. * Sets the given vector "result" with the cross product of "left" and "right"
  80757. * The cross product is then orthogonal to both "left" and "right"
  80758. * @param left defines the left operand
  80759. * @param right defines the right operand
  80760. * @param result defines the Vector3 where to store the result
  80761. */
  80762. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  80763. /**
  80764. * Returns a new Vector3 as the normalization of the given vector
  80765. * @param vector defines the Vector3 to normalize
  80766. * @returns the new Vector3
  80767. */
  80768. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  80769. /**
  80770. * Sets the given vector "result" with the normalization of the given first vector
  80771. * @param vector defines the Vector3 to normalize
  80772. * @param result defines the Vector3 where to store the result
  80773. */
  80774. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  80775. /**
  80776. * Project a Vector3 onto screen space
  80777. * @param vector defines the Vector3 to project
  80778. * @param world defines the world matrix to use
  80779. * @param transform defines the transform (view x projection) matrix to use
  80780. * @param viewport defines the screen viewport to use
  80781. * @returns the new Vector3
  80782. */
  80783. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  80784. /** @hidden */
  80785. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  80786. /**
  80787. * Unproject from screen space to object space
  80788. * @param source defines the screen space Vector3 to use
  80789. * @param viewportWidth defines the current width of the viewport
  80790. * @param viewportHeight defines the current height of the viewport
  80791. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80792. * @param transform defines the transform (view x projection) matrix to use
  80793. * @returns the new Vector3
  80794. */
  80795. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  80796. /**
  80797. * Unproject from screen space to object space
  80798. * @param source defines the screen space Vector3 to use
  80799. * @param viewportWidth defines the current width of the viewport
  80800. * @param viewportHeight defines the current height of the viewport
  80801. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80802. * @param view defines the view matrix to use
  80803. * @param projection defines the projection matrix to use
  80804. * @returns the new Vector3
  80805. */
  80806. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  80807. /**
  80808. * Unproject from screen space to object space
  80809. * @param source defines the screen space Vector3 to use
  80810. * @param viewportWidth defines the current width of the viewport
  80811. * @param viewportHeight defines the current height of the viewport
  80812. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80813. * @param view defines the view matrix to use
  80814. * @param projection defines the projection matrix to use
  80815. * @param result defines the Vector3 where to store the result
  80816. */
  80817. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  80818. /**
  80819. * Unproject from screen space to object space
  80820. * @param sourceX defines the screen space x coordinate to use
  80821. * @param sourceY defines the screen space y coordinate to use
  80822. * @param sourceZ defines the screen space z coordinate to use
  80823. * @param viewportWidth defines the current width of the viewport
  80824. * @param viewportHeight defines the current height of the viewport
  80825. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80826. * @param view defines the view matrix to use
  80827. * @param projection defines the projection matrix to use
  80828. * @param result defines the Vector3 where to store the result
  80829. */
  80830. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  80831. /**
  80832. * Gets the minimal coordinate values between two Vector3
  80833. * @param left defines the first operand
  80834. * @param right defines the second operand
  80835. * @returns the new Vector3
  80836. */
  80837. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80838. /**
  80839. * Gets the maximal coordinate values between two Vector3
  80840. * @param left defines the first operand
  80841. * @param right defines the second operand
  80842. * @returns the new Vector3
  80843. */
  80844. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80845. /**
  80846. * Returns the distance between the vectors "value1" and "value2"
  80847. * @param value1 defines the first operand
  80848. * @param value2 defines the second operand
  80849. * @returns the distance
  80850. */
  80851. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  80852. /**
  80853. * Returns the squared distance between the vectors "value1" and "value2"
  80854. * @param value1 defines the first operand
  80855. * @param value2 defines the second operand
  80856. * @returns the squared distance
  80857. */
  80858. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  80859. /**
  80860. * Returns a new Vector3 located at the center between "value1" and "value2"
  80861. * @param value1 defines the first operand
  80862. * @param value2 defines the second operand
  80863. * @returns the new Vector3
  80864. */
  80865. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  80866. /**
  80867. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  80868. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  80869. * to something in order to rotate it from its local system to the given target system
  80870. * Note: axis1, axis2 and axis3 are normalized during this operation
  80871. * @param axis1 defines the first axis
  80872. * @param axis2 defines the second axis
  80873. * @param axis3 defines the third axis
  80874. * @returns a new Vector3
  80875. */
  80876. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  80877. /**
  80878. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  80879. * @param axis1 defines the first axis
  80880. * @param axis2 defines the second axis
  80881. * @param axis3 defines the third axis
  80882. * @param ref defines the Vector3 where to store the result
  80883. */
  80884. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  80885. }
  80886. /**
  80887. * Vector4 class created for EulerAngle class conversion to Quaternion
  80888. */
  80889. export class Vector4 {
  80890. /** x value of the vector */
  80891. x: number;
  80892. /** y value of the vector */
  80893. y: number;
  80894. /** z value of the vector */
  80895. z: number;
  80896. /** w value of the vector */
  80897. w: number;
  80898. /**
  80899. * Creates a Vector4 object from the given floats.
  80900. * @param x x value of the vector
  80901. * @param y y value of the vector
  80902. * @param z z value of the vector
  80903. * @param w w value of the vector
  80904. */
  80905. constructor(
  80906. /** x value of the vector */
  80907. x: number,
  80908. /** y value of the vector */
  80909. y: number,
  80910. /** z value of the vector */
  80911. z: number,
  80912. /** w value of the vector */
  80913. w: number);
  80914. /**
  80915. * Returns the string with the Vector4 coordinates.
  80916. * @returns a string containing all the vector values
  80917. */
  80918. toString(): string;
  80919. /**
  80920. * Returns the string "Vector4".
  80921. * @returns "Vector4"
  80922. */
  80923. getClassName(): string;
  80924. /**
  80925. * Returns the Vector4 hash code.
  80926. * @returns a unique hash code
  80927. */
  80928. getHashCode(): number;
  80929. /**
  80930. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  80931. * @returns the resulting array
  80932. */
  80933. asArray(): number[];
  80934. /**
  80935. * Populates the given array from the given index with the Vector4 coordinates.
  80936. * @param array array to populate
  80937. * @param index index of the array to start at (default: 0)
  80938. * @returns the Vector4.
  80939. */
  80940. toArray(array: FloatArray, index?: number): Vector4;
  80941. /**
  80942. * Adds the given vector to the current Vector4.
  80943. * @param otherVector the vector to add
  80944. * @returns the updated Vector4.
  80945. */
  80946. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80947. /**
  80948. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  80949. * @param otherVector the vector to add
  80950. * @returns the resulting vector
  80951. */
  80952. add(otherVector: DeepImmutable<Vector4>): Vector4;
  80953. /**
  80954. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  80955. * @param otherVector the vector to add
  80956. * @param result the vector to store the result
  80957. * @returns the current Vector4.
  80958. */
  80959. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80960. /**
  80961. * Subtract in place the given vector from the current Vector4.
  80962. * @param otherVector the vector to subtract
  80963. * @returns the updated Vector4.
  80964. */
  80965. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80966. /**
  80967. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  80968. * @param otherVector the vector to add
  80969. * @returns the new vector with the result
  80970. */
  80971. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  80972. /**
  80973. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  80974. * @param otherVector the vector to subtract
  80975. * @param result the vector to store the result
  80976. * @returns the current Vector4.
  80977. */
  80978. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80979. /**
  80980. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80981. */
  80982. /**
  80983. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80984. * @param x value to subtract
  80985. * @param y value to subtract
  80986. * @param z value to subtract
  80987. * @param w value to subtract
  80988. * @returns new vector containing the result
  80989. */
  80990. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  80991. /**
  80992. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80993. * @param x value to subtract
  80994. * @param y value to subtract
  80995. * @param z value to subtract
  80996. * @param w value to subtract
  80997. * @param result the vector to store the result in
  80998. * @returns the current Vector4.
  80999. */
  81000. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  81001. /**
  81002. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  81003. * @returns a new vector with the negated values
  81004. */
  81005. negate(): Vector4;
  81006. /**
  81007. * Negate this vector in place
  81008. * @returns this
  81009. */
  81010. negateInPlace(): Vector4;
  81011. /**
  81012. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  81013. * @param result defines the Vector3 object where to store the result
  81014. * @returns the current Vector4
  81015. */
  81016. negateToRef(result: Vector4): Vector4;
  81017. /**
  81018. * Multiplies the current Vector4 coordinates by scale (float).
  81019. * @param scale the number to scale with
  81020. * @returns the updated Vector4.
  81021. */
  81022. scaleInPlace(scale: number): Vector4;
  81023. /**
  81024. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  81025. * @param scale the number to scale with
  81026. * @returns a new vector with the result
  81027. */
  81028. scale(scale: number): Vector4;
  81029. /**
  81030. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  81031. * @param scale the number to scale with
  81032. * @param result a vector to store the result in
  81033. * @returns the current Vector4.
  81034. */
  81035. scaleToRef(scale: number, result: Vector4): Vector4;
  81036. /**
  81037. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  81038. * @param scale defines the scale factor
  81039. * @param result defines the Vector4 object where to store the result
  81040. * @returns the unmodified current Vector4
  81041. */
  81042. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  81043. /**
  81044. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  81045. * @param otherVector the vector to compare against
  81046. * @returns true if they are equal
  81047. */
  81048. equals(otherVector: DeepImmutable<Vector4>): boolean;
  81049. /**
  81050. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  81051. * @param otherVector vector to compare against
  81052. * @param epsilon (Default: very small number)
  81053. * @returns true if they are equal
  81054. */
  81055. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  81056. /**
  81057. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  81058. * @param x x value to compare against
  81059. * @param y y value to compare against
  81060. * @param z z value to compare against
  81061. * @param w w value to compare against
  81062. * @returns true if equal
  81063. */
  81064. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  81065. /**
  81066. * Multiplies in place the current Vector4 by the given one.
  81067. * @param otherVector vector to multiple with
  81068. * @returns the updated Vector4.
  81069. */
  81070. multiplyInPlace(otherVector: Vector4): Vector4;
  81071. /**
  81072. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  81073. * @param otherVector vector to multiple with
  81074. * @returns resulting new vector
  81075. */
  81076. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  81077. /**
  81078. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  81079. * @param otherVector vector to multiple with
  81080. * @param result vector to store the result
  81081. * @returns the current Vector4.
  81082. */
  81083. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81084. /**
  81085. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  81086. * @param x x value multiply with
  81087. * @param y y value multiply with
  81088. * @param z z value multiply with
  81089. * @param w w value multiply with
  81090. * @returns resulting new vector
  81091. */
  81092. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  81093. /**
  81094. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  81095. * @param otherVector vector to devide with
  81096. * @returns resulting new vector
  81097. */
  81098. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  81099. /**
  81100. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  81101. * @param otherVector vector to devide with
  81102. * @param result vector to store the result
  81103. * @returns the current Vector4.
  81104. */
  81105. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81106. /**
  81107. * Divides the current Vector3 coordinates by the given ones.
  81108. * @param otherVector vector to devide with
  81109. * @returns the updated Vector3.
  81110. */
  81111. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81112. /**
  81113. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  81114. * @param other defines the second operand
  81115. * @returns the current updated Vector4
  81116. */
  81117. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81118. /**
  81119. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  81120. * @param other defines the second operand
  81121. * @returns the current updated Vector4
  81122. */
  81123. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81124. /**
  81125. * Gets a new Vector4 from current Vector4 floored values
  81126. * @returns a new Vector4
  81127. */
  81128. floor(): Vector4;
  81129. /**
  81130. * Gets a new Vector4 from current Vector3 floored values
  81131. * @returns a new Vector4
  81132. */
  81133. fract(): Vector4;
  81134. /**
  81135. * Returns the Vector4 length (float).
  81136. * @returns the length
  81137. */
  81138. length(): number;
  81139. /**
  81140. * Returns the Vector4 squared length (float).
  81141. * @returns the length squared
  81142. */
  81143. lengthSquared(): number;
  81144. /**
  81145. * Normalizes in place the Vector4.
  81146. * @returns the updated Vector4.
  81147. */
  81148. normalize(): Vector4;
  81149. /**
  81150. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  81151. * @returns this converted to a new vector3
  81152. */
  81153. toVector3(): Vector3;
  81154. /**
  81155. * Returns a new Vector4 copied from the current one.
  81156. * @returns the new cloned vector
  81157. */
  81158. clone(): Vector4;
  81159. /**
  81160. * Updates the current Vector4 with the given one coordinates.
  81161. * @param source the source vector to copy from
  81162. * @returns the updated Vector4.
  81163. */
  81164. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  81165. /**
  81166. * Updates the current Vector4 coordinates with the given floats.
  81167. * @param x float to copy from
  81168. * @param y float to copy from
  81169. * @param z float to copy from
  81170. * @param w float to copy from
  81171. * @returns the updated Vector4.
  81172. */
  81173. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  81174. /**
  81175. * Updates the current Vector4 coordinates with the given floats.
  81176. * @param x float to set from
  81177. * @param y float to set from
  81178. * @param z float to set from
  81179. * @param w float to set from
  81180. * @returns the updated Vector4.
  81181. */
  81182. set(x: number, y: number, z: number, w: number): Vector4;
  81183. /**
  81184. * Copies the given float to the current Vector3 coordinates
  81185. * @param v defines the x, y, z and w coordinates of the operand
  81186. * @returns the current updated Vector3
  81187. */
  81188. setAll(v: number): Vector4;
  81189. /**
  81190. * Returns a new Vector4 set from the starting index of the given array.
  81191. * @param array the array to pull values from
  81192. * @param offset the offset into the array to start at
  81193. * @returns the new vector
  81194. */
  81195. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  81196. /**
  81197. * Updates the given vector "result" from the starting index of the given array.
  81198. * @param array the array to pull values from
  81199. * @param offset the offset into the array to start at
  81200. * @param result the vector to store the result in
  81201. */
  81202. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  81203. /**
  81204. * Updates the given vector "result" from the starting index of the given Float32Array.
  81205. * @param array the array to pull values from
  81206. * @param offset the offset into the array to start at
  81207. * @param result the vector to store the result in
  81208. */
  81209. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  81210. /**
  81211. * Updates the given vector "result" coordinates from the given floats.
  81212. * @param x float to set from
  81213. * @param y float to set from
  81214. * @param z float to set from
  81215. * @param w float to set from
  81216. * @param result the vector to the floats in
  81217. */
  81218. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  81219. /**
  81220. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  81221. * @returns the new vector
  81222. */
  81223. static Zero(): Vector4;
  81224. /**
  81225. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  81226. * @returns the new vector
  81227. */
  81228. static One(): Vector4;
  81229. /**
  81230. * Returns a new normalized Vector4 from the given one.
  81231. * @param vector the vector to normalize
  81232. * @returns the vector
  81233. */
  81234. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  81235. /**
  81236. * Updates the given vector "result" from the normalization of the given one.
  81237. * @param vector the vector to normalize
  81238. * @param result the vector to store the result in
  81239. */
  81240. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  81241. /**
  81242. * Returns a vector with the minimum values from the left and right vectors
  81243. * @param left left vector to minimize
  81244. * @param right right vector to minimize
  81245. * @returns a new vector with the minimum of the left and right vector values
  81246. */
  81247. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81248. /**
  81249. * Returns a vector with the maximum values from the left and right vectors
  81250. * @param left left vector to maximize
  81251. * @param right right vector to maximize
  81252. * @returns a new vector with the maximum of the left and right vector values
  81253. */
  81254. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81255. /**
  81256. * Returns the distance (float) between the vectors "value1" and "value2".
  81257. * @param value1 value to calulate the distance between
  81258. * @param value2 value to calulate the distance between
  81259. * @return the distance between the two vectors
  81260. */
  81261. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  81262. /**
  81263. * Returns the squared distance (float) between the vectors "value1" and "value2".
  81264. * @param value1 value to calulate the distance between
  81265. * @param value2 value to calulate the distance between
  81266. * @return the distance between the two vectors squared
  81267. */
  81268. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  81269. /**
  81270. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  81271. * @param value1 value to calulate the center between
  81272. * @param value2 value to calulate the center between
  81273. * @return the center between the two vectors
  81274. */
  81275. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  81276. /**
  81277. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  81278. * This methods computes transformed normalized direction vectors only.
  81279. * @param vector the vector to transform
  81280. * @param transformation the transformation matrix to apply
  81281. * @returns the new vector
  81282. */
  81283. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  81284. /**
  81285. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  81286. * This methods computes transformed normalized direction vectors only.
  81287. * @param vector the vector to transform
  81288. * @param transformation the transformation matrix to apply
  81289. * @param result the vector to store the result in
  81290. */
  81291. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  81292. /**
  81293. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  81294. * This methods computes transformed normalized direction vectors only.
  81295. * @param x value to transform
  81296. * @param y value to transform
  81297. * @param z value to transform
  81298. * @param w value to transform
  81299. * @param transformation the transformation matrix to apply
  81300. * @param result the vector to store the results in
  81301. */
  81302. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  81303. /**
  81304. * Creates a new Vector4 from a Vector3
  81305. * @param source defines the source data
  81306. * @param w defines the 4th component (default is 0)
  81307. * @returns a new Vector4
  81308. */
  81309. static FromVector3(source: Vector3, w?: number): Vector4;
  81310. }
  81311. /**
  81312. * Class used to store quaternion data
  81313. * @see https://en.wikipedia.org/wiki/Quaternion
  81314. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  81315. */
  81316. export class Quaternion {
  81317. /** defines the first component (0 by default) */
  81318. x: number;
  81319. /** defines the second component (0 by default) */
  81320. y: number;
  81321. /** defines the third component (0 by default) */
  81322. z: number;
  81323. /** defines the fourth component (1.0 by default) */
  81324. w: number;
  81325. /**
  81326. * Creates a new Quaternion from the given floats
  81327. * @param x defines the first component (0 by default)
  81328. * @param y defines the second component (0 by default)
  81329. * @param z defines the third component (0 by default)
  81330. * @param w defines the fourth component (1.0 by default)
  81331. */
  81332. constructor(
  81333. /** defines the first component (0 by default) */
  81334. x?: number,
  81335. /** defines the second component (0 by default) */
  81336. y?: number,
  81337. /** defines the third component (0 by default) */
  81338. z?: number,
  81339. /** defines the fourth component (1.0 by default) */
  81340. w?: number);
  81341. /**
  81342. * Gets a string representation for the current quaternion
  81343. * @returns a string with the Quaternion coordinates
  81344. */
  81345. toString(): string;
  81346. /**
  81347. * Gets the class name of the quaternion
  81348. * @returns the string "Quaternion"
  81349. */
  81350. getClassName(): string;
  81351. /**
  81352. * Gets a hash code for this quaternion
  81353. * @returns the quaternion hash code
  81354. */
  81355. getHashCode(): number;
  81356. /**
  81357. * Copy the quaternion to an array
  81358. * @returns a new array populated with 4 elements from the quaternion coordinates
  81359. */
  81360. asArray(): number[];
  81361. /**
  81362. * Check if two quaternions are equals
  81363. * @param otherQuaternion defines the second operand
  81364. * @return true if the current quaternion and the given one coordinates are strictly equals
  81365. */
  81366. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  81367. /**
  81368. * Gets a boolean if two quaternions are equals (using an epsilon value)
  81369. * @param otherQuaternion defines the other quaternion
  81370. * @param epsilon defines the minimal distance to consider equality
  81371. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  81372. */
  81373. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  81374. /**
  81375. * Clone the current quaternion
  81376. * @returns a new quaternion copied from the current one
  81377. */
  81378. clone(): Quaternion;
  81379. /**
  81380. * Copy a quaternion to the current one
  81381. * @param other defines the other quaternion
  81382. * @returns the updated current quaternion
  81383. */
  81384. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  81385. /**
  81386. * Updates the current quaternion with the given float coordinates
  81387. * @param x defines the x coordinate
  81388. * @param y defines the y coordinate
  81389. * @param z defines the z coordinate
  81390. * @param w defines the w coordinate
  81391. * @returns the updated current quaternion
  81392. */
  81393. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  81394. /**
  81395. * Updates the current quaternion from the given float coordinates
  81396. * @param x defines the x coordinate
  81397. * @param y defines the y coordinate
  81398. * @param z defines the z coordinate
  81399. * @param w defines the w coordinate
  81400. * @returns the updated current quaternion
  81401. */
  81402. set(x: number, y: number, z: number, w: number): Quaternion;
  81403. /**
  81404. * Adds two quaternions
  81405. * @param other defines the second operand
  81406. * @returns a new quaternion as the addition result of the given one and the current quaternion
  81407. */
  81408. add(other: DeepImmutable<Quaternion>): Quaternion;
  81409. /**
  81410. * Add a quaternion to the current one
  81411. * @param other defines the quaternion to add
  81412. * @returns the current quaternion
  81413. */
  81414. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  81415. /**
  81416. * Subtract two quaternions
  81417. * @param other defines the second operand
  81418. * @returns a new quaternion as the subtraction result of the given one from the current one
  81419. */
  81420. subtract(other: Quaternion): Quaternion;
  81421. /**
  81422. * Multiplies the current quaternion by a scale factor
  81423. * @param value defines the scale factor
  81424. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  81425. */
  81426. scale(value: number): Quaternion;
  81427. /**
  81428. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  81429. * @param scale defines the scale factor
  81430. * @param result defines the Quaternion object where to store the result
  81431. * @returns the unmodified current quaternion
  81432. */
  81433. scaleToRef(scale: number, result: Quaternion): Quaternion;
  81434. /**
  81435. * Multiplies in place the current quaternion by a scale factor
  81436. * @param value defines the scale factor
  81437. * @returns the current modified quaternion
  81438. */
  81439. scaleInPlace(value: number): Quaternion;
  81440. /**
  81441. * Scale the current quaternion values by a factor and add the result to a given quaternion
  81442. * @param scale defines the scale factor
  81443. * @param result defines the Quaternion object where to store the result
  81444. * @returns the unmodified current quaternion
  81445. */
  81446. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  81447. /**
  81448. * Multiplies two quaternions
  81449. * @param q1 defines the second operand
  81450. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  81451. */
  81452. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  81453. /**
  81454. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  81455. * @param q1 defines the second operand
  81456. * @param result defines the target quaternion
  81457. * @returns the current quaternion
  81458. */
  81459. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  81460. /**
  81461. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  81462. * @param q1 defines the second operand
  81463. * @returns the currentupdated quaternion
  81464. */
  81465. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  81466. /**
  81467. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  81468. * @param ref defines the target quaternion
  81469. * @returns the current quaternion
  81470. */
  81471. conjugateToRef(ref: Quaternion): Quaternion;
  81472. /**
  81473. * Conjugates in place (1-q) the current quaternion
  81474. * @returns the current updated quaternion
  81475. */
  81476. conjugateInPlace(): Quaternion;
  81477. /**
  81478. * Conjugates in place (1-q) the current quaternion
  81479. * @returns a new quaternion
  81480. */
  81481. conjugate(): Quaternion;
  81482. /**
  81483. * Gets length of current quaternion
  81484. * @returns the quaternion length (float)
  81485. */
  81486. length(): number;
  81487. /**
  81488. * Normalize in place the current quaternion
  81489. * @returns the current updated quaternion
  81490. */
  81491. normalize(): Quaternion;
  81492. /**
  81493. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  81494. * @param order is a reserved parameter and is ignore for now
  81495. * @returns a new Vector3 containing the Euler angles
  81496. */
  81497. toEulerAngles(order?: string): Vector3;
  81498. /**
  81499. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  81500. * @param result defines the vector which will be filled with the Euler angles
  81501. * @param order is a reserved parameter and is ignore for now
  81502. * @returns the current unchanged quaternion
  81503. */
  81504. toEulerAnglesToRef(result: Vector3): Quaternion;
  81505. /**
  81506. * Updates the given rotation matrix with the current quaternion values
  81507. * @param result defines the target matrix
  81508. * @returns the current unchanged quaternion
  81509. */
  81510. toRotationMatrix(result: Matrix): Quaternion;
  81511. /**
  81512. * Updates the current quaternion from the given rotation matrix values
  81513. * @param matrix defines the source matrix
  81514. * @returns the current updated quaternion
  81515. */
  81516. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  81517. /**
  81518. * Creates a new quaternion from a rotation matrix
  81519. * @param matrix defines the source matrix
  81520. * @returns a new quaternion created from the given rotation matrix values
  81521. */
  81522. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  81523. /**
  81524. * Updates the given quaternion with the given rotation matrix values
  81525. * @param matrix defines the source matrix
  81526. * @param result defines the target quaternion
  81527. */
  81528. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  81529. /**
  81530. * Returns the dot product (float) between the quaternions "left" and "right"
  81531. * @param left defines the left operand
  81532. * @param right defines the right operand
  81533. * @returns the dot product
  81534. */
  81535. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  81536. /**
  81537. * Checks if the two quaternions are close to each other
  81538. * @param quat0 defines the first quaternion to check
  81539. * @param quat1 defines the second quaternion to check
  81540. * @returns true if the two quaternions are close to each other
  81541. */
  81542. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  81543. /**
  81544. * Creates an empty quaternion
  81545. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  81546. */
  81547. static Zero(): Quaternion;
  81548. /**
  81549. * Inverse a given quaternion
  81550. * @param q defines the source quaternion
  81551. * @returns a new quaternion as the inverted current quaternion
  81552. */
  81553. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  81554. /**
  81555. * Inverse a given quaternion
  81556. * @param q defines the source quaternion
  81557. * @param result the quaternion the result will be stored in
  81558. * @returns the result quaternion
  81559. */
  81560. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  81561. /**
  81562. * Creates an identity quaternion
  81563. * @returns the identity quaternion
  81564. */
  81565. static Identity(): Quaternion;
  81566. /**
  81567. * Gets a boolean indicating if the given quaternion is identity
  81568. * @param quaternion defines the quaternion to check
  81569. * @returns true if the quaternion is identity
  81570. */
  81571. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  81572. /**
  81573. * Creates a quaternion from a rotation around an axis
  81574. * @param axis defines the axis to use
  81575. * @param angle defines the angle to use
  81576. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  81577. */
  81578. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  81579. /**
  81580. * Creates a rotation around an axis and stores it into the given quaternion
  81581. * @param axis defines the axis to use
  81582. * @param angle defines the angle to use
  81583. * @param result defines the target quaternion
  81584. * @returns the target quaternion
  81585. */
  81586. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  81587. /**
  81588. * Creates a new quaternion from data stored into an array
  81589. * @param array defines the data source
  81590. * @param offset defines the offset in the source array where the data starts
  81591. * @returns a new quaternion
  81592. */
  81593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  81594. /**
  81595. * Updates the given quaternion "result" from the starting index of the given array.
  81596. * @param array the array to pull values from
  81597. * @param offset the offset into the array to start at
  81598. * @param result the quaternion to store the result in
  81599. */
  81600. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  81601. /**
  81602. * Create a quaternion from Euler rotation angles
  81603. * @param x Pitch
  81604. * @param y Yaw
  81605. * @param z Roll
  81606. * @returns the new Quaternion
  81607. */
  81608. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  81609. /**
  81610. * Updates a quaternion from Euler rotation angles
  81611. * @param x Pitch
  81612. * @param y Yaw
  81613. * @param z Roll
  81614. * @param result the quaternion to store the result
  81615. * @returns the updated quaternion
  81616. */
  81617. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  81618. /**
  81619. * Create a quaternion from Euler rotation vector
  81620. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  81621. * @returns the new Quaternion
  81622. */
  81623. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  81624. /**
  81625. * Updates a quaternion from Euler rotation vector
  81626. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  81627. * @param result the quaternion to store the result
  81628. * @returns the updated quaternion
  81629. */
  81630. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  81631. /**
  81632. * Creates a new quaternion from the given Euler float angles (y, x, z)
  81633. * @param yaw defines the rotation around Y axis
  81634. * @param pitch defines the rotation around X axis
  81635. * @param roll defines the rotation around Z axis
  81636. * @returns the new quaternion
  81637. */
  81638. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  81639. /**
  81640. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  81641. * @param yaw defines the rotation around Y axis
  81642. * @param pitch defines the rotation around X axis
  81643. * @param roll defines the rotation around Z axis
  81644. * @param result defines the target quaternion
  81645. */
  81646. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  81647. /**
  81648. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  81649. * @param alpha defines the rotation around first axis
  81650. * @param beta defines the rotation around second axis
  81651. * @param gamma defines the rotation around third axis
  81652. * @returns the new quaternion
  81653. */
  81654. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  81655. /**
  81656. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  81657. * @param alpha defines the rotation around first axis
  81658. * @param beta defines the rotation around second axis
  81659. * @param gamma defines the rotation around third axis
  81660. * @param result defines the target quaternion
  81661. */
  81662. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  81663. /**
  81664. * 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)
  81665. * @param axis1 defines the first axis
  81666. * @param axis2 defines the second axis
  81667. * @param axis3 defines the third axis
  81668. * @returns the new quaternion
  81669. */
  81670. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  81671. /**
  81672. * 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
  81673. * @param axis1 defines the first axis
  81674. * @param axis2 defines the second axis
  81675. * @param axis3 defines the third axis
  81676. * @param ref defines the target quaternion
  81677. */
  81678. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  81679. /**
  81680. * Interpolates between two quaternions
  81681. * @param left defines first quaternion
  81682. * @param right defines second quaternion
  81683. * @param amount defines the gradient to use
  81684. * @returns the new interpolated quaternion
  81685. */
  81686. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  81687. /**
  81688. * Interpolates between two quaternions and stores it into a target quaternion
  81689. * @param left defines first quaternion
  81690. * @param right defines second quaternion
  81691. * @param amount defines the gradient to use
  81692. * @param result defines the target quaternion
  81693. */
  81694. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  81695. /**
  81696. * Interpolate between two quaternions using Hermite interpolation
  81697. * @param value1 defines first quaternion
  81698. * @param tangent1 defines the incoming tangent
  81699. * @param value2 defines second quaternion
  81700. * @param tangent2 defines the outgoing tangent
  81701. * @param amount defines the target quaternion
  81702. * @returns the new interpolated quaternion
  81703. */
  81704. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  81705. }
  81706. /**
  81707. * Class used to store matrix data (4x4)
  81708. */
  81709. export class Matrix {
  81710. private static _updateFlagSeed;
  81711. private static _identityReadOnly;
  81712. private _isIdentity;
  81713. private _isIdentityDirty;
  81714. private _isIdentity3x2;
  81715. private _isIdentity3x2Dirty;
  81716. /**
  81717. * Gets the update flag of the matrix which is an unique number for the matrix.
  81718. * It will be incremented every time the matrix data change.
  81719. * You can use it to speed the comparison between two versions of the same matrix.
  81720. */
  81721. updateFlag: number;
  81722. private readonly _m;
  81723. /**
  81724. * Gets the internal data of the matrix
  81725. */
  81726. get m(): DeepImmutable<Float32Array>;
  81727. /** @hidden */
  81728. _markAsUpdated(): void;
  81729. /** @hidden */
  81730. private _updateIdentityStatus;
  81731. /**
  81732. * Creates an empty matrix (filled with zeros)
  81733. */
  81734. constructor();
  81735. /**
  81736. * Check if the current matrix is identity
  81737. * @returns true is the matrix is the identity matrix
  81738. */
  81739. isIdentity(): boolean;
  81740. /**
  81741. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  81742. * @returns true is the matrix is the identity matrix
  81743. */
  81744. isIdentityAs3x2(): boolean;
  81745. /**
  81746. * Gets the determinant of the matrix
  81747. * @returns the matrix determinant
  81748. */
  81749. determinant(): number;
  81750. /**
  81751. * Returns the matrix as a Float32Array
  81752. * @returns the matrix underlying array
  81753. */
  81754. toArray(): DeepImmutable<Float32Array>;
  81755. /**
  81756. * Returns the matrix as a Float32Array
  81757. * @returns the matrix underlying array.
  81758. */
  81759. asArray(): DeepImmutable<Float32Array>;
  81760. /**
  81761. * Inverts the current matrix in place
  81762. * @returns the current inverted matrix
  81763. */
  81764. invert(): Matrix;
  81765. /**
  81766. * Sets all the matrix elements to zero
  81767. * @returns the current matrix
  81768. */
  81769. reset(): Matrix;
  81770. /**
  81771. * Adds the current matrix with a second one
  81772. * @param other defines the matrix to add
  81773. * @returns a new matrix as the addition of the current matrix and the given one
  81774. */
  81775. add(other: DeepImmutable<Matrix>): Matrix;
  81776. /**
  81777. * Sets the given matrix "result" to the addition of the current matrix and the given one
  81778. * @param other defines the matrix to add
  81779. * @param result defines the target matrix
  81780. * @returns the current matrix
  81781. */
  81782. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  81783. /**
  81784. * Adds in place the given matrix to the current matrix
  81785. * @param other defines the second operand
  81786. * @returns the current updated matrix
  81787. */
  81788. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  81789. /**
  81790. * Sets the given matrix to the current inverted Matrix
  81791. * @param other defines the target matrix
  81792. * @returns the unmodified current matrix
  81793. */
  81794. invertToRef(other: Matrix): Matrix;
  81795. /**
  81796. * add a value at the specified position in the current Matrix
  81797. * @param index the index of the value within the matrix. between 0 and 15.
  81798. * @param value the value to be added
  81799. * @returns the current updated matrix
  81800. */
  81801. addAtIndex(index: number, value: number): Matrix;
  81802. /**
  81803. * mutiply the specified position in the current Matrix by a value
  81804. * @param index the index of the value within the matrix. between 0 and 15.
  81805. * @param value the value to be added
  81806. * @returns the current updated matrix
  81807. */
  81808. multiplyAtIndex(index: number, value: number): Matrix;
  81809. /**
  81810. * Inserts the translation vector (using 3 floats) in the current matrix
  81811. * @param x defines the 1st component of the translation
  81812. * @param y defines the 2nd component of the translation
  81813. * @param z defines the 3rd component of the translation
  81814. * @returns the current updated matrix
  81815. */
  81816. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  81817. /**
  81818. * Adds the translation vector (using 3 floats) in the current matrix
  81819. * @param x defines the 1st component of the translation
  81820. * @param y defines the 2nd component of the translation
  81821. * @param z defines the 3rd component of the translation
  81822. * @returns the current updated matrix
  81823. */
  81824. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  81825. /**
  81826. * Inserts the translation vector in the current matrix
  81827. * @param vector3 defines the translation to insert
  81828. * @returns the current updated matrix
  81829. */
  81830. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  81831. /**
  81832. * Gets the translation value of the current matrix
  81833. * @returns a new Vector3 as the extracted translation from the matrix
  81834. */
  81835. getTranslation(): Vector3;
  81836. /**
  81837. * Fill a Vector3 with the extracted translation from the matrix
  81838. * @param result defines the Vector3 where to store the translation
  81839. * @returns the current matrix
  81840. */
  81841. getTranslationToRef(result: Vector3): Matrix;
  81842. /**
  81843. * Remove rotation and scaling part from the matrix
  81844. * @returns the updated matrix
  81845. */
  81846. removeRotationAndScaling(): Matrix;
  81847. /**
  81848. * Multiply two matrices
  81849. * @param other defines the second operand
  81850. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  81851. */
  81852. multiply(other: DeepImmutable<Matrix>): Matrix;
  81853. /**
  81854. * Copy the current matrix from the given one
  81855. * @param other defines the source matrix
  81856. * @returns the current updated matrix
  81857. */
  81858. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  81859. /**
  81860. * Populates the given array from the starting index with the current matrix values
  81861. * @param array defines the target array
  81862. * @param offset defines the offset in the target array where to start storing values
  81863. * @returns the current matrix
  81864. */
  81865. copyToArray(array: Float32Array, offset?: number): Matrix;
  81866. /**
  81867. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  81868. * @param other defines the second operand
  81869. * @param result defines the matrix where to store the multiplication
  81870. * @returns the current matrix
  81871. */
  81872. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  81873. /**
  81874. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  81875. * @param other defines the second operand
  81876. * @param result defines the array where to store the multiplication
  81877. * @param offset defines the offset in the target array where to start storing values
  81878. * @returns the current matrix
  81879. */
  81880. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  81881. /**
  81882. * Check equality between this matrix and a second one
  81883. * @param value defines the second matrix to compare
  81884. * @returns true is the current matrix and the given one values are strictly equal
  81885. */
  81886. equals(value: DeepImmutable<Matrix>): boolean;
  81887. /**
  81888. * Clone the current matrix
  81889. * @returns a new matrix from the current matrix
  81890. */
  81891. clone(): Matrix;
  81892. /**
  81893. * Returns the name of the current matrix class
  81894. * @returns the string "Matrix"
  81895. */
  81896. getClassName(): string;
  81897. /**
  81898. * Gets the hash code of the current matrix
  81899. * @returns the hash code
  81900. */
  81901. getHashCode(): number;
  81902. /**
  81903. * Decomposes the current Matrix into a translation, rotation and scaling components
  81904. * @param scale defines the scale vector3 given as a reference to update
  81905. * @param rotation defines the rotation quaternion given as a reference to update
  81906. * @param translation defines the translation vector3 given as a reference to update
  81907. * @returns true if operation was successful
  81908. */
  81909. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  81910. /**
  81911. * Gets specific row of the matrix
  81912. * @param index defines the number of the row to get
  81913. * @returns the index-th row of the current matrix as a new Vector4
  81914. */
  81915. getRow(index: number): Nullable<Vector4>;
  81916. /**
  81917. * Sets the index-th row of the current matrix to the vector4 values
  81918. * @param index defines the number of the row to set
  81919. * @param row defines the target vector4
  81920. * @returns the updated current matrix
  81921. */
  81922. setRow(index: number, row: Vector4): Matrix;
  81923. /**
  81924. * Compute the transpose of the matrix
  81925. * @returns the new transposed matrix
  81926. */
  81927. transpose(): Matrix;
  81928. /**
  81929. * Compute the transpose of the matrix and store it in a given matrix
  81930. * @param result defines the target matrix
  81931. * @returns the current matrix
  81932. */
  81933. transposeToRef(result: Matrix): Matrix;
  81934. /**
  81935. * Sets the index-th row of the current matrix with the given 4 x float values
  81936. * @param index defines the row index
  81937. * @param x defines the x component to set
  81938. * @param y defines the y component to set
  81939. * @param z defines the z component to set
  81940. * @param w defines the w component to set
  81941. * @returns the updated current matrix
  81942. */
  81943. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  81944. /**
  81945. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  81946. * @param scale defines the scale factor
  81947. * @returns a new matrix
  81948. */
  81949. scale(scale: number): Matrix;
  81950. /**
  81951. * Scale the current matrix values by a factor to a given result matrix
  81952. * @param scale defines the scale factor
  81953. * @param result defines the matrix to store the result
  81954. * @returns the current matrix
  81955. */
  81956. scaleToRef(scale: number, result: Matrix): Matrix;
  81957. /**
  81958. * Scale the current matrix values by a factor and add the result to a given matrix
  81959. * @param scale defines the scale factor
  81960. * @param result defines the Matrix to store the result
  81961. * @returns the current matrix
  81962. */
  81963. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  81964. /**
  81965. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  81966. * @param ref matrix to store the result
  81967. */
  81968. toNormalMatrix(ref: Matrix): void;
  81969. /**
  81970. * Gets only rotation part of the current matrix
  81971. * @returns a new matrix sets to the extracted rotation matrix from the current one
  81972. */
  81973. getRotationMatrix(): Matrix;
  81974. /**
  81975. * Extracts the rotation matrix from the current one and sets it as the given "result"
  81976. * @param result defines the target matrix to store data to
  81977. * @returns the current matrix
  81978. */
  81979. getRotationMatrixToRef(result: Matrix): Matrix;
  81980. /**
  81981. * Toggles model matrix from being right handed to left handed in place and vice versa
  81982. */
  81983. toggleModelMatrixHandInPlace(): void;
  81984. /**
  81985. * Toggles projection matrix from being right handed to left handed in place and vice versa
  81986. */
  81987. toggleProjectionMatrixHandInPlace(): void;
  81988. /**
  81989. * Creates a matrix from an array
  81990. * @param array defines the source array
  81991. * @param offset defines an offset in the source array
  81992. * @returns a new Matrix set from the starting index of the given array
  81993. */
  81994. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  81995. /**
  81996. * Copy the content of an array into a given matrix
  81997. * @param array defines the source array
  81998. * @param offset defines an offset in the source array
  81999. * @param result defines the target matrix
  82000. */
  82001. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  82002. /**
  82003. * Stores an array into a matrix after having multiplied each component by a given factor
  82004. * @param array defines the source array
  82005. * @param offset defines the offset in the source array
  82006. * @param scale defines the scaling factor
  82007. * @param result defines the target matrix
  82008. */
  82009. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  82010. /**
  82011. * Gets an identity matrix that must not be updated
  82012. */
  82013. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  82014. /**
  82015. * Stores a list of values (16) inside a given matrix
  82016. * @param initialM11 defines 1st value of 1st row
  82017. * @param initialM12 defines 2nd value of 1st row
  82018. * @param initialM13 defines 3rd value of 1st row
  82019. * @param initialM14 defines 4th value of 1st row
  82020. * @param initialM21 defines 1st value of 2nd row
  82021. * @param initialM22 defines 2nd value of 2nd row
  82022. * @param initialM23 defines 3rd value of 2nd row
  82023. * @param initialM24 defines 4th value of 2nd row
  82024. * @param initialM31 defines 1st value of 3rd row
  82025. * @param initialM32 defines 2nd value of 3rd row
  82026. * @param initialM33 defines 3rd value of 3rd row
  82027. * @param initialM34 defines 4th value of 3rd row
  82028. * @param initialM41 defines 1st value of 4th row
  82029. * @param initialM42 defines 2nd value of 4th row
  82030. * @param initialM43 defines 3rd value of 4th row
  82031. * @param initialM44 defines 4th value of 4th row
  82032. * @param result defines the target matrix
  82033. */
  82034. 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;
  82035. /**
  82036. * Creates new matrix from a list of values (16)
  82037. * @param initialM11 defines 1st value of 1st row
  82038. * @param initialM12 defines 2nd value of 1st row
  82039. * @param initialM13 defines 3rd value of 1st row
  82040. * @param initialM14 defines 4th value of 1st row
  82041. * @param initialM21 defines 1st value of 2nd row
  82042. * @param initialM22 defines 2nd value of 2nd row
  82043. * @param initialM23 defines 3rd value of 2nd row
  82044. * @param initialM24 defines 4th value of 2nd row
  82045. * @param initialM31 defines 1st value of 3rd row
  82046. * @param initialM32 defines 2nd value of 3rd row
  82047. * @param initialM33 defines 3rd value of 3rd row
  82048. * @param initialM34 defines 4th value of 3rd row
  82049. * @param initialM41 defines 1st value of 4th row
  82050. * @param initialM42 defines 2nd value of 4th row
  82051. * @param initialM43 defines 3rd value of 4th row
  82052. * @param initialM44 defines 4th value of 4th row
  82053. * @returns the new matrix
  82054. */
  82055. 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;
  82056. /**
  82057. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82058. * @param scale defines the scale vector3
  82059. * @param rotation defines the rotation quaternion
  82060. * @param translation defines the translation vector3
  82061. * @returns a new matrix
  82062. */
  82063. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  82064. /**
  82065. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82066. * @param scale defines the scale vector3
  82067. * @param rotation defines the rotation quaternion
  82068. * @param translation defines the translation vector3
  82069. * @param result defines the target matrix
  82070. */
  82071. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  82072. /**
  82073. * Creates a new identity matrix
  82074. * @returns a new identity matrix
  82075. */
  82076. static Identity(): Matrix;
  82077. /**
  82078. * Creates a new identity matrix and stores the result in a given matrix
  82079. * @param result defines the target matrix
  82080. */
  82081. static IdentityToRef(result: Matrix): void;
  82082. /**
  82083. * Creates a new zero matrix
  82084. * @returns a new zero matrix
  82085. */
  82086. static Zero(): Matrix;
  82087. /**
  82088. * Creates a new rotation matrix for "angle" radians around the X axis
  82089. * @param angle defines the angle (in radians) to use
  82090. * @return the new matrix
  82091. */
  82092. static RotationX(angle: number): Matrix;
  82093. /**
  82094. * Creates a new matrix as the invert of a given matrix
  82095. * @param source defines the source matrix
  82096. * @returns the new matrix
  82097. */
  82098. static Invert(source: DeepImmutable<Matrix>): Matrix;
  82099. /**
  82100. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  82101. * @param angle defines the angle (in radians) to use
  82102. * @param result defines the target matrix
  82103. */
  82104. static RotationXToRef(angle: number, result: Matrix): void;
  82105. /**
  82106. * Creates a new rotation matrix for "angle" radians around the Y axis
  82107. * @param angle defines the angle (in radians) to use
  82108. * @return the new matrix
  82109. */
  82110. static RotationY(angle: number): Matrix;
  82111. /**
  82112. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  82113. * @param angle defines the angle (in radians) to use
  82114. * @param result defines the target matrix
  82115. */
  82116. static RotationYToRef(angle: number, result: Matrix): void;
  82117. /**
  82118. * Creates a new rotation matrix for "angle" radians around the Z axis
  82119. * @param angle defines the angle (in radians) to use
  82120. * @return the new matrix
  82121. */
  82122. static RotationZ(angle: number): Matrix;
  82123. /**
  82124. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  82125. * @param angle defines the angle (in radians) to use
  82126. * @param result defines the target matrix
  82127. */
  82128. static RotationZToRef(angle: number, result: Matrix): void;
  82129. /**
  82130. * Creates a new rotation matrix for "angle" radians around the given axis
  82131. * @param axis defines the axis to use
  82132. * @param angle defines the angle (in radians) to use
  82133. * @return the new matrix
  82134. */
  82135. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  82136. /**
  82137. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  82138. * @param axis defines the axis to use
  82139. * @param angle defines the angle (in radians) to use
  82140. * @param result defines the target matrix
  82141. */
  82142. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  82143. /**
  82144. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  82145. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  82146. * @param from defines the vector to align
  82147. * @param to defines the vector to align to
  82148. * @param result defines the target matrix
  82149. */
  82150. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  82151. /**
  82152. * Creates a rotation matrix
  82153. * @param yaw defines the yaw angle in radians (Y axis)
  82154. * @param pitch defines the pitch angle in radians (X axis)
  82155. * @param roll defines the roll angle in radians (X axis)
  82156. * @returns the new rotation matrix
  82157. */
  82158. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  82159. /**
  82160. * Creates a rotation matrix and stores it in a given matrix
  82161. * @param yaw defines the yaw angle in radians (Y axis)
  82162. * @param pitch defines the pitch angle in radians (X axis)
  82163. * @param roll defines the roll angle in radians (X axis)
  82164. * @param result defines the target matrix
  82165. */
  82166. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  82167. /**
  82168. * Creates a scaling matrix
  82169. * @param x defines the scale factor on X axis
  82170. * @param y defines the scale factor on Y axis
  82171. * @param z defines the scale factor on Z axis
  82172. * @returns the new matrix
  82173. */
  82174. static Scaling(x: number, y: number, z: number): Matrix;
  82175. /**
  82176. * Creates a scaling matrix and stores it in a given matrix
  82177. * @param x defines the scale factor on X axis
  82178. * @param y defines the scale factor on Y axis
  82179. * @param z defines the scale factor on Z axis
  82180. * @param result defines the target matrix
  82181. */
  82182. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  82183. /**
  82184. * Creates a translation matrix
  82185. * @param x defines the translation on X axis
  82186. * @param y defines the translation on Y axis
  82187. * @param z defines the translationon Z axis
  82188. * @returns the new matrix
  82189. */
  82190. static Translation(x: number, y: number, z: number): Matrix;
  82191. /**
  82192. * Creates a translation matrix and stores it in a given matrix
  82193. * @param x defines the translation on X axis
  82194. * @param y defines the translation on Y axis
  82195. * @param z defines the translationon Z axis
  82196. * @param result defines the target matrix
  82197. */
  82198. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  82199. /**
  82200. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82201. * @param startValue defines the start value
  82202. * @param endValue defines the end value
  82203. * @param gradient defines the gradient factor
  82204. * @returns the new matrix
  82205. */
  82206. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82207. /**
  82208. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82209. * @param startValue defines the start value
  82210. * @param endValue defines the end value
  82211. * @param gradient defines the gradient factor
  82212. * @param result defines the Matrix object where to store data
  82213. */
  82214. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82215. /**
  82216. * Builds a new matrix whose values are computed by:
  82217. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82218. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82219. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82220. * @param startValue defines the first matrix
  82221. * @param endValue defines the second matrix
  82222. * @param gradient defines the gradient between the two matrices
  82223. * @returns the new matrix
  82224. */
  82225. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82226. /**
  82227. * Update a matrix to values which are computed by:
  82228. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82229. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82230. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82231. * @param startValue defines the first matrix
  82232. * @param endValue defines the second matrix
  82233. * @param gradient defines the gradient between the two matrices
  82234. * @param result defines the target matrix
  82235. */
  82236. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82237. /**
  82238. * 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"
  82239. * This function works in left handed mode
  82240. * @param eye defines the final position of the entity
  82241. * @param target defines where the entity should look at
  82242. * @param up defines the up vector for the entity
  82243. * @returns the new matrix
  82244. */
  82245. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82246. /**
  82247. * 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".
  82248. * This function works in left handed mode
  82249. * @param eye defines the final position of the entity
  82250. * @param target defines where the entity should look at
  82251. * @param up defines the up vector for the entity
  82252. * @param result defines the target matrix
  82253. */
  82254. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  82255. /**
  82256. * 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"
  82257. * This function works in right handed mode
  82258. * @param eye defines the final position of the entity
  82259. * @param target defines where the entity should look at
  82260. * @param up defines the up vector for the entity
  82261. * @returns the new matrix
  82262. */
  82263. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82264. /**
  82265. * 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".
  82266. * This function works in right handed mode
  82267. * @param eye defines the final position of the entity
  82268. * @param target defines where the entity should look at
  82269. * @param up defines the up vector for the entity
  82270. * @param result defines the target matrix
  82271. */
  82272. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  82273. /**
  82274. * Create a left-handed orthographic projection matrix
  82275. * @param width defines the viewport width
  82276. * @param height defines the viewport height
  82277. * @param znear defines the near clip plane
  82278. * @param zfar defines the far clip plane
  82279. * @returns a new matrix as a left-handed orthographic projection matrix
  82280. */
  82281. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  82282. /**
  82283. * Store a left-handed orthographic projection to a given matrix
  82284. * @param width defines the viewport width
  82285. * @param height defines the viewport height
  82286. * @param znear defines the near clip plane
  82287. * @param zfar defines the far clip plane
  82288. * @param result defines the target matrix
  82289. */
  82290. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  82291. /**
  82292. * Create a left-handed orthographic projection matrix
  82293. * @param left defines the viewport left coordinate
  82294. * @param right defines the viewport right coordinate
  82295. * @param bottom defines the viewport bottom coordinate
  82296. * @param top defines the viewport top coordinate
  82297. * @param znear defines the near clip plane
  82298. * @param zfar defines the far clip plane
  82299. * @returns a new matrix as a left-handed orthographic projection matrix
  82300. */
  82301. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  82302. /**
  82303. * Stores a left-handed orthographic projection into a given matrix
  82304. * @param left defines the viewport left coordinate
  82305. * @param right defines the viewport right coordinate
  82306. * @param bottom defines the viewport bottom coordinate
  82307. * @param top defines the viewport top coordinate
  82308. * @param znear defines the near clip plane
  82309. * @param zfar defines the far clip plane
  82310. * @param result defines the target matrix
  82311. */
  82312. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  82313. /**
  82314. * Creates a right-handed orthographic projection matrix
  82315. * @param left defines the viewport left coordinate
  82316. * @param right defines the viewport right coordinate
  82317. * @param bottom defines the viewport bottom coordinate
  82318. * @param top defines the viewport top coordinate
  82319. * @param znear defines the near clip plane
  82320. * @param zfar defines the far clip plane
  82321. * @returns a new matrix as a right-handed orthographic projection matrix
  82322. */
  82323. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  82324. /**
  82325. * Stores a right-handed orthographic projection into a given matrix
  82326. * @param left defines the viewport left coordinate
  82327. * @param right defines the viewport right coordinate
  82328. * @param bottom defines the viewport bottom coordinate
  82329. * @param top defines the viewport top coordinate
  82330. * @param znear defines the near clip plane
  82331. * @param zfar defines the far clip plane
  82332. * @param result defines the target matrix
  82333. */
  82334. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  82335. /**
  82336. * Creates a left-handed perspective projection matrix
  82337. * @param width defines the viewport width
  82338. * @param height defines the viewport height
  82339. * @param znear defines the near clip plane
  82340. * @param zfar defines the far clip plane
  82341. * @returns a new matrix as a left-handed perspective projection matrix
  82342. */
  82343. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  82344. /**
  82345. * Creates a left-handed perspective projection matrix
  82346. * @param fov defines the horizontal field of view
  82347. * @param aspect defines the aspect ratio
  82348. * @param znear defines the near clip plane
  82349. * @param zfar defines the far clip plane
  82350. * @returns a new matrix as a left-handed perspective projection matrix
  82351. */
  82352. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  82353. /**
  82354. * Stores a left-handed perspective projection into a given matrix
  82355. * @param fov defines the horizontal field of view
  82356. * @param aspect defines the aspect ratio
  82357. * @param znear defines the near clip plane
  82358. * @param zfar defines the far clip plane
  82359. * @param result defines the target matrix
  82360. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82361. */
  82362. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82363. /**
  82364. * Stores a left-handed perspective projection into a given matrix with depth reversed
  82365. * @param fov defines the horizontal field of view
  82366. * @param aspect defines the aspect ratio
  82367. * @param znear defines the near clip plane
  82368. * @param zfar not used as infinity is used as far clip
  82369. * @param result defines the target matrix
  82370. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82371. */
  82372. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82373. /**
  82374. * Creates a right-handed perspective projection matrix
  82375. * @param fov defines the horizontal field of view
  82376. * @param aspect defines the aspect ratio
  82377. * @param znear defines the near clip plane
  82378. * @param zfar defines the far clip plane
  82379. * @returns a new matrix as a right-handed perspective projection matrix
  82380. */
  82381. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  82382. /**
  82383. * Stores a right-handed perspective projection into a given matrix
  82384. * @param fov defines the horizontal field of view
  82385. * @param aspect defines the aspect ratio
  82386. * @param znear defines the near clip plane
  82387. * @param zfar defines the far clip plane
  82388. * @param result defines the target matrix
  82389. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82390. */
  82391. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82392. /**
  82393. * Stores a right-handed perspective projection into a given matrix
  82394. * @param fov defines the horizontal field of view
  82395. * @param aspect defines the aspect ratio
  82396. * @param znear defines the near clip plane
  82397. * @param zfar not used as infinity is used as far clip
  82398. * @param result defines the target matrix
  82399. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82400. */
  82401. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82402. /**
  82403. * Stores a perspective projection for WebVR info a given matrix
  82404. * @param fov defines the field of view
  82405. * @param znear defines the near clip plane
  82406. * @param zfar defines the far clip plane
  82407. * @param result defines the target matrix
  82408. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  82409. */
  82410. static PerspectiveFovWebVRToRef(fov: {
  82411. upDegrees: number;
  82412. downDegrees: number;
  82413. leftDegrees: number;
  82414. rightDegrees: number;
  82415. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  82416. /**
  82417. * Computes a complete transformation matrix
  82418. * @param viewport defines the viewport to use
  82419. * @param world defines the world matrix
  82420. * @param view defines the view matrix
  82421. * @param projection defines the projection matrix
  82422. * @param zmin defines the near clip plane
  82423. * @param zmax defines the far clip plane
  82424. * @returns the transformation matrix
  82425. */
  82426. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  82427. /**
  82428. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  82429. * @param matrix defines the matrix to use
  82430. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  82431. */
  82432. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  82433. /**
  82434. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  82435. * @param matrix defines the matrix to use
  82436. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  82437. */
  82438. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  82439. /**
  82440. * Compute the transpose of a given matrix
  82441. * @param matrix defines the matrix to transpose
  82442. * @returns the new matrix
  82443. */
  82444. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  82445. /**
  82446. * Compute the transpose of a matrix and store it in a target matrix
  82447. * @param matrix defines the matrix to transpose
  82448. * @param result defines the target matrix
  82449. */
  82450. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  82451. /**
  82452. * Computes a reflection matrix from a plane
  82453. * @param plane defines the reflection plane
  82454. * @returns a new matrix
  82455. */
  82456. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  82457. /**
  82458. * Computes a reflection matrix from a plane
  82459. * @param plane defines the reflection plane
  82460. * @param result defines the target matrix
  82461. */
  82462. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  82463. /**
  82464. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  82465. * @param xaxis defines the value of the 1st axis
  82466. * @param yaxis defines the value of the 2nd axis
  82467. * @param zaxis defines the value of the 3rd axis
  82468. * @param result defines the target matrix
  82469. */
  82470. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  82471. /**
  82472. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  82473. * @param quat defines the quaternion to use
  82474. * @param result defines the target matrix
  82475. */
  82476. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  82477. }
  82478. /**
  82479. * @hidden
  82480. */
  82481. export class TmpVectors {
  82482. static Vector2: Vector2[];
  82483. static Vector3: Vector3[];
  82484. static Vector4: Vector4[];
  82485. static Quaternion: Quaternion[];
  82486. static Matrix: Matrix[];
  82487. }
  82488. }
  82489. declare module BABYLON {
  82490. /**
  82491. * Defines potential orientation for back face culling
  82492. */
  82493. export enum Orientation {
  82494. /**
  82495. * Clockwise
  82496. */
  82497. CW = 0,
  82498. /** Counter clockwise */
  82499. CCW = 1
  82500. }
  82501. /** Class used to represent a Bezier curve */
  82502. export class BezierCurve {
  82503. /**
  82504. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  82505. * @param t defines the time
  82506. * @param x1 defines the left coordinate on X axis
  82507. * @param y1 defines the left coordinate on Y axis
  82508. * @param x2 defines the right coordinate on X axis
  82509. * @param y2 defines the right coordinate on Y axis
  82510. * @returns the interpolated value
  82511. */
  82512. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  82513. }
  82514. /**
  82515. * Defines angle representation
  82516. */
  82517. export class Angle {
  82518. private _radians;
  82519. /**
  82520. * Creates an Angle object of "radians" radians (float).
  82521. * @param radians the angle in radians
  82522. */
  82523. constructor(radians: number);
  82524. /**
  82525. * Get value in degrees
  82526. * @returns the Angle value in degrees (float)
  82527. */
  82528. degrees(): number;
  82529. /**
  82530. * Get value in radians
  82531. * @returns the Angle value in radians (float)
  82532. */
  82533. radians(): number;
  82534. /**
  82535. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  82536. * @param a defines first vector
  82537. * @param b defines second vector
  82538. * @returns a new Angle
  82539. */
  82540. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  82541. /**
  82542. * Gets a new Angle object from the given float in radians
  82543. * @param radians defines the angle value in radians
  82544. * @returns a new Angle
  82545. */
  82546. static FromRadians(radians: number): Angle;
  82547. /**
  82548. * Gets a new Angle object from the given float in degrees
  82549. * @param degrees defines the angle value in degrees
  82550. * @returns a new Angle
  82551. */
  82552. static FromDegrees(degrees: number): Angle;
  82553. }
  82554. /**
  82555. * This represents an arc in a 2d space.
  82556. */
  82557. export class Arc2 {
  82558. /** Defines the start point of the arc */
  82559. startPoint: Vector2;
  82560. /** Defines the mid point of the arc */
  82561. midPoint: Vector2;
  82562. /** Defines the end point of the arc */
  82563. endPoint: Vector2;
  82564. /**
  82565. * Defines the center point of the arc.
  82566. */
  82567. centerPoint: Vector2;
  82568. /**
  82569. * Defines the radius of the arc.
  82570. */
  82571. radius: number;
  82572. /**
  82573. * Defines the angle of the arc (from mid point to end point).
  82574. */
  82575. angle: Angle;
  82576. /**
  82577. * Defines the start angle of the arc (from start point to middle point).
  82578. */
  82579. startAngle: Angle;
  82580. /**
  82581. * Defines the orientation of the arc (clock wise/counter clock wise).
  82582. */
  82583. orientation: Orientation;
  82584. /**
  82585. * Creates an Arc object from the three given points : start, middle and end.
  82586. * @param startPoint Defines the start point of the arc
  82587. * @param midPoint Defines the midlle point of the arc
  82588. * @param endPoint Defines the end point of the arc
  82589. */
  82590. constructor(
  82591. /** Defines the start point of the arc */
  82592. startPoint: Vector2,
  82593. /** Defines the mid point of the arc */
  82594. midPoint: Vector2,
  82595. /** Defines the end point of the arc */
  82596. endPoint: Vector2);
  82597. }
  82598. /**
  82599. * Represents a 2D path made up of multiple 2D points
  82600. */
  82601. export class Path2 {
  82602. private _points;
  82603. private _length;
  82604. /**
  82605. * If the path start and end point are the same
  82606. */
  82607. closed: boolean;
  82608. /**
  82609. * Creates a Path2 object from the starting 2D coordinates x and y.
  82610. * @param x the starting points x value
  82611. * @param y the starting points y value
  82612. */
  82613. constructor(x: number, y: number);
  82614. /**
  82615. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  82616. * @param x the added points x value
  82617. * @param y the added points y value
  82618. * @returns the updated Path2.
  82619. */
  82620. addLineTo(x: number, y: number): Path2;
  82621. /**
  82622. * 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.
  82623. * @param midX middle point x value
  82624. * @param midY middle point y value
  82625. * @param endX end point x value
  82626. * @param endY end point y value
  82627. * @param numberOfSegments (default: 36)
  82628. * @returns the updated Path2.
  82629. */
  82630. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  82631. /**
  82632. * Closes the Path2.
  82633. * @returns the Path2.
  82634. */
  82635. close(): Path2;
  82636. /**
  82637. * Gets the sum of the distance between each sequential point in the path
  82638. * @returns the Path2 total length (float).
  82639. */
  82640. length(): number;
  82641. /**
  82642. * Gets the points which construct the path
  82643. * @returns the Path2 internal array of points.
  82644. */
  82645. getPoints(): Vector2[];
  82646. /**
  82647. * Retreives the point at the distance aways from the starting point
  82648. * @param normalizedLengthPosition the length along the path to retreive the point from
  82649. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  82650. */
  82651. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  82652. /**
  82653. * Creates a new path starting from an x and y position
  82654. * @param x starting x value
  82655. * @param y starting y value
  82656. * @returns a new Path2 starting at the coordinates (x, y).
  82657. */
  82658. static StartingAt(x: number, y: number): Path2;
  82659. }
  82660. /**
  82661. * Represents a 3D path made up of multiple 3D points
  82662. */
  82663. export class Path3D {
  82664. /**
  82665. * an array of Vector3, the curve axis of the Path3D
  82666. */
  82667. path: Vector3[];
  82668. private _curve;
  82669. private _distances;
  82670. private _tangents;
  82671. private _normals;
  82672. private _binormals;
  82673. private _raw;
  82674. private _alignTangentsWithPath;
  82675. private readonly _pointAtData;
  82676. /**
  82677. * new Path3D(path, normal, raw)
  82678. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  82679. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  82680. * @param path an array of Vector3, the curve axis of the Path3D
  82681. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  82682. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  82683. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  82684. */
  82685. constructor(
  82686. /**
  82687. * an array of Vector3, the curve axis of the Path3D
  82688. */
  82689. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  82690. /**
  82691. * Returns the Path3D array of successive Vector3 designing its curve.
  82692. * @returns the Path3D array of successive Vector3 designing its curve.
  82693. */
  82694. getCurve(): Vector3[];
  82695. /**
  82696. * Returns the Path3D array of successive Vector3 designing its curve.
  82697. * @returns the Path3D array of successive Vector3 designing its curve.
  82698. */
  82699. getPoints(): Vector3[];
  82700. /**
  82701. * @returns the computed length (float) of the path.
  82702. */
  82703. length(): number;
  82704. /**
  82705. * Returns an array populated with tangent vectors on each Path3D curve point.
  82706. * @returns an array populated with tangent vectors on each Path3D curve point.
  82707. */
  82708. getTangents(): Vector3[];
  82709. /**
  82710. * Returns an array populated with normal vectors on each Path3D curve point.
  82711. * @returns an array populated with normal vectors on each Path3D curve point.
  82712. */
  82713. getNormals(): Vector3[];
  82714. /**
  82715. * Returns an array populated with binormal vectors on each Path3D curve point.
  82716. * @returns an array populated with binormal vectors on each Path3D curve point.
  82717. */
  82718. getBinormals(): Vector3[];
  82719. /**
  82720. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  82721. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  82722. */
  82723. getDistances(): number[];
  82724. /**
  82725. * Returns an interpolated point along this path
  82726. * @param position the position of the point along this path, from 0.0 to 1.0
  82727. * @returns a new Vector3 as the point
  82728. */
  82729. getPointAt(position: number): Vector3;
  82730. /**
  82731. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  82732. * @param position the position of the point along this path, from 0.0 to 1.0
  82733. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  82734. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  82735. */
  82736. getTangentAt(position: number, interpolated?: boolean): Vector3;
  82737. /**
  82738. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  82739. * @param position the position of the point along this path, from 0.0 to 1.0
  82740. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  82741. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  82742. */
  82743. getNormalAt(position: number, interpolated?: boolean): Vector3;
  82744. /**
  82745. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  82746. * @param position the position of the point along this path, from 0.0 to 1.0
  82747. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  82748. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  82749. */
  82750. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  82751. /**
  82752. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  82753. * @param position the position of the point along this path, from 0.0 to 1.0
  82754. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  82755. */
  82756. getDistanceAt(position: number): number;
  82757. /**
  82758. * Returns the array index of the previous point of an interpolated point along this path
  82759. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  82760. * @returns the array index
  82761. */
  82762. getPreviousPointIndexAt(position: number): number;
  82763. /**
  82764. * 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)
  82765. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  82766. * @returns the sub position
  82767. */
  82768. getSubPositionAt(position: number): number;
  82769. /**
  82770. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  82771. * @param target the vector of which to get the closest position to
  82772. * @returns the position of the closest virtual point on this path to the target vector
  82773. */
  82774. getClosestPositionTo(target: Vector3): number;
  82775. /**
  82776. * Returns a sub path (slice) of this path
  82777. * @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
  82778. * @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
  82779. * @returns a sub path (slice) of this path
  82780. */
  82781. slice(start?: number, end?: number): Path3D;
  82782. /**
  82783. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  82784. * @param path path which all values are copied into the curves points
  82785. * @param firstNormal which should be projected onto the curve
  82786. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  82787. * @returns the same object updated.
  82788. */
  82789. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  82790. private _compute;
  82791. private _getFirstNonNullVector;
  82792. private _getLastNonNullVector;
  82793. private _normalVector;
  82794. /**
  82795. * Updates the point at data for an interpolated point along this curve
  82796. * @param position the position of the point along this curve, from 0.0 to 1.0
  82797. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  82798. * @returns the (updated) point at data
  82799. */
  82800. private _updatePointAtData;
  82801. /**
  82802. * Updates the point at data from the specified parameters
  82803. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  82804. * @param point the interpolated point
  82805. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  82806. */
  82807. private _setPointAtData;
  82808. /**
  82809. * Updates the point at interpolation matrix for the tangents, normals and binormals
  82810. */
  82811. private _updateInterpolationMatrix;
  82812. }
  82813. /**
  82814. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  82815. * A Curve3 is designed from a series of successive Vector3.
  82816. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  82817. */
  82818. export class Curve3 {
  82819. private _points;
  82820. private _length;
  82821. /**
  82822. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  82823. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  82824. * @param v1 (Vector3) the control point
  82825. * @param v2 (Vector3) the end point of the Quadratic Bezier
  82826. * @param nbPoints (integer) the wanted number of points in the curve
  82827. * @returns the created Curve3
  82828. */
  82829. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82830. /**
  82831. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  82832. * @param v0 (Vector3) the origin point of the Cubic Bezier
  82833. * @param v1 (Vector3) the first control point
  82834. * @param v2 (Vector3) the second control point
  82835. * @param v3 (Vector3) the end point of the Cubic Bezier
  82836. * @param nbPoints (integer) the wanted number of points in the curve
  82837. * @returns the created Curve3
  82838. */
  82839. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82840. /**
  82841. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  82842. * @param p1 (Vector3) the origin point of the Hermite Spline
  82843. * @param t1 (Vector3) the tangent vector at the origin point
  82844. * @param p2 (Vector3) the end point of the Hermite Spline
  82845. * @param t2 (Vector3) the tangent vector at the end point
  82846. * @param nbPoints (integer) the wanted number of points in the curve
  82847. * @returns the created Curve3
  82848. */
  82849. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82850. /**
  82851. * Returns a Curve3 object along a CatmullRom Spline curve :
  82852. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  82853. * @param nbPoints (integer) the wanted number of points between each curve control points
  82854. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  82855. * @returns the created Curve3
  82856. */
  82857. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  82858. /**
  82859. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  82860. * A Curve3 is designed from a series of successive Vector3.
  82861. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  82862. * @param points points which make up the curve
  82863. */
  82864. constructor(points: Vector3[]);
  82865. /**
  82866. * @returns the Curve3 stored array of successive Vector3
  82867. */
  82868. getPoints(): Vector3[];
  82869. /**
  82870. * @returns the computed length (float) of the curve.
  82871. */
  82872. length(): number;
  82873. /**
  82874. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  82875. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  82876. * curveA and curveB keep unchanged.
  82877. * @param curve the curve to continue from this curve
  82878. * @returns the newly constructed curve
  82879. */
  82880. continue(curve: DeepImmutable<Curve3>): Curve3;
  82881. private _computeLength;
  82882. }
  82883. }
  82884. declare module BABYLON {
  82885. /**
  82886. * This represents the main contract an easing function should follow.
  82887. * Easing functions are used throughout the animation system.
  82888. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82889. */
  82890. export interface IEasingFunction {
  82891. /**
  82892. * Given an input gradient between 0 and 1, this returns the corrseponding value
  82893. * of the easing function.
  82894. * The link below provides some of the most common examples of easing functions.
  82895. * @see https://easings.net/
  82896. * @param gradient Defines the value between 0 and 1 we want the easing value for
  82897. * @returns the corresponding value on the curve defined by the easing function
  82898. */
  82899. ease(gradient: number): number;
  82900. }
  82901. /**
  82902. * Base class used for every default easing function.
  82903. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82904. */
  82905. export class EasingFunction implements IEasingFunction {
  82906. /**
  82907. * Interpolation follows the mathematical formula associated with the easing function.
  82908. */
  82909. static readonly EASINGMODE_EASEIN: number;
  82910. /**
  82911. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  82912. */
  82913. static readonly EASINGMODE_EASEOUT: number;
  82914. /**
  82915. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  82916. */
  82917. static readonly EASINGMODE_EASEINOUT: number;
  82918. private _easingMode;
  82919. /**
  82920. * Sets the easing mode of the current function.
  82921. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  82922. */
  82923. setEasingMode(easingMode: number): void;
  82924. /**
  82925. * Gets the current easing mode.
  82926. * @returns the easing mode
  82927. */
  82928. getEasingMode(): number;
  82929. /**
  82930. * @hidden
  82931. */
  82932. easeInCore(gradient: number): number;
  82933. /**
  82934. * Given an input gradient between 0 and 1, this returns the corresponding value
  82935. * of the easing function.
  82936. * @param gradient Defines the value between 0 and 1 we want the easing value for
  82937. * @returns the corresponding value on the curve defined by the easing function
  82938. */
  82939. ease(gradient: number): number;
  82940. }
  82941. /**
  82942. * Easing function with a circle shape (see link below).
  82943. * @see https://easings.net/#easeInCirc
  82944. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82945. */
  82946. export class CircleEase extends EasingFunction implements IEasingFunction {
  82947. /** @hidden */
  82948. easeInCore(gradient: number): number;
  82949. }
  82950. /**
  82951. * Easing function with a ease back shape (see link below).
  82952. * @see https://easings.net/#easeInBack
  82953. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82954. */
  82955. export class BackEase extends EasingFunction implements IEasingFunction {
  82956. /** Defines the amplitude of the function */
  82957. amplitude: number;
  82958. /**
  82959. * Instantiates a back ease easing
  82960. * @see https://easings.net/#easeInBack
  82961. * @param amplitude Defines the amplitude of the function
  82962. */
  82963. constructor(
  82964. /** Defines the amplitude of the function */
  82965. amplitude?: number);
  82966. /** @hidden */
  82967. easeInCore(gradient: number): number;
  82968. }
  82969. /**
  82970. * Easing function with a bouncing shape (see link below).
  82971. * @see https://easings.net/#easeInBounce
  82972. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82973. */
  82974. export class BounceEase extends EasingFunction implements IEasingFunction {
  82975. /** Defines the number of bounces */
  82976. bounces: number;
  82977. /** Defines the amplitude of the bounce */
  82978. bounciness: number;
  82979. /**
  82980. * Instantiates a bounce easing
  82981. * @see https://easings.net/#easeInBounce
  82982. * @param bounces Defines the number of bounces
  82983. * @param bounciness Defines the amplitude of the bounce
  82984. */
  82985. constructor(
  82986. /** Defines the number of bounces */
  82987. bounces?: number,
  82988. /** Defines the amplitude of the bounce */
  82989. bounciness?: number);
  82990. /** @hidden */
  82991. easeInCore(gradient: number): number;
  82992. }
  82993. /**
  82994. * Easing function with a power of 3 shape (see link below).
  82995. * @see https://easings.net/#easeInCubic
  82996. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82997. */
  82998. export class CubicEase extends EasingFunction implements IEasingFunction {
  82999. /** @hidden */
  83000. easeInCore(gradient: number): number;
  83001. }
  83002. /**
  83003. * Easing function with an elastic shape (see link below).
  83004. * @see https://easings.net/#easeInElastic
  83005. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83006. */
  83007. export class ElasticEase extends EasingFunction implements IEasingFunction {
  83008. /** Defines the number of oscillations*/
  83009. oscillations: number;
  83010. /** Defines the amplitude of the oscillations*/
  83011. springiness: number;
  83012. /**
  83013. * Instantiates an elastic easing function
  83014. * @see https://easings.net/#easeInElastic
  83015. * @param oscillations Defines the number of oscillations
  83016. * @param springiness Defines the amplitude of the oscillations
  83017. */
  83018. constructor(
  83019. /** Defines the number of oscillations*/
  83020. oscillations?: number,
  83021. /** Defines the amplitude of the oscillations*/
  83022. springiness?: number);
  83023. /** @hidden */
  83024. easeInCore(gradient: number): number;
  83025. }
  83026. /**
  83027. * Easing function with an exponential shape (see link below).
  83028. * @see https://easings.net/#easeInExpo
  83029. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83030. */
  83031. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  83032. /** Defines the exponent of the function */
  83033. exponent: number;
  83034. /**
  83035. * Instantiates an exponential easing function
  83036. * @see https://easings.net/#easeInExpo
  83037. * @param exponent Defines the exponent of the function
  83038. */
  83039. constructor(
  83040. /** Defines the exponent of the function */
  83041. exponent?: number);
  83042. /** @hidden */
  83043. easeInCore(gradient: number): number;
  83044. }
  83045. /**
  83046. * Easing function with a power shape (see link below).
  83047. * @see https://easings.net/#easeInQuad
  83048. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83049. */
  83050. export class PowerEase extends EasingFunction implements IEasingFunction {
  83051. /** Defines the power of the function */
  83052. power: number;
  83053. /**
  83054. * Instantiates an power base easing function
  83055. * @see https://easings.net/#easeInQuad
  83056. * @param power Defines the power of the function
  83057. */
  83058. constructor(
  83059. /** Defines the power of the function */
  83060. power?: number);
  83061. /** @hidden */
  83062. easeInCore(gradient: number): number;
  83063. }
  83064. /**
  83065. * Easing function with a power of 2 shape (see link below).
  83066. * @see https://easings.net/#easeInQuad
  83067. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83068. */
  83069. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  83070. /** @hidden */
  83071. easeInCore(gradient: number): number;
  83072. }
  83073. /**
  83074. * Easing function with a power of 4 shape (see link below).
  83075. * @see https://easings.net/#easeInQuart
  83076. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83077. */
  83078. export class QuarticEase extends EasingFunction implements IEasingFunction {
  83079. /** @hidden */
  83080. easeInCore(gradient: number): number;
  83081. }
  83082. /**
  83083. * Easing function with a power of 5 shape (see link below).
  83084. * @see https://easings.net/#easeInQuint
  83085. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83086. */
  83087. export class QuinticEase extends EasingFunction implements IEasingFunction {
  83088. /** @hidden */
  83089. easeInCore(gradient: number): number;
  83090. }
  83091. /**
  83092. * Easing function with a sin shape (see link below).
  83093. * @see https://easings.net/#easeInSine
  83094. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83095. */
  83096. export class SineEase extends EasingFunction implements IEasingFunction {
  83097. /** @hidden */
  83098. easeInCore(gradient: number): number;
  83099. }
  83100. /**
  83101. * Easing function with a bezier shape (see link below).
  83102. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83103. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83104. */
  83105. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  83106. /** Defines the x component of the start tangent in the bezier curve */
  83107. x1: number;
  83108. /** Defines the y component of the start tangent in the bezier curve */
  83109. y1: number;
  83110. /** Defines the x component of the end tangent in the bezier curve */
  83111. x2: number;
  83112. /** Defines the y component of the end tangent in the bezier curve */
  83113. y2: number;
  83114. /**
  83115. * Instantiates a bezier function
  83116. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83117. * @param x1 Defines the x component of the start tangent in the bezier curve
  83118. * @param y1 Defines the y component of the start tangent in the bezier curve
  83119. * @param x2 Defines the x component of the end tangent in the bezier curve
  83120. * @param y2 Defines the y component of the end tangent in the bezier curve
  83121. */
  83122. constructor(
  83123. /** Defines the x component of the start tangent in the bezier curve */
  83124. x1?: number,
  83125. /** Defines the y component of the start tangent in the bezier curve */
  83126. y1?: number,
  83127. /** Defines the x component of the end tangent in the bezier curve */
  83128. x2?: number,
  83129. /** Defines the y component of the end tangent in the bezier curve */
  83130. y2?: number);
  83131. /** @hidden */
  83132. easeInCore(gradient: number): number;
  83133. }
  83134. }
  83135. declare module BABYLON {
  83136. /**
  83137. * Class used to hold a RBG color
  83138. */
  83139. export class Color3 {
  83140. /**
  83141. * Defines the red component (between 0 and 1, default is 0)
  83142. */
  83143. r: number;
  83144. /**
  83145. * Defines the green component (between 0 and 1, default is 0)
  83146. */
  83147. g: number;
  83148. /**
  83149. * Defines the blue component (between 0 and 1, default is 0)
  83150. */
  83151. b: number;
  83152. /**
  83153. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  83154. * @param r defines the red component (between 0 and 1, default is 0)
  83155. * @param g defines the green component (between 0 and 1, default is 0)
  83156. * @param b defines the blue component (between 0 and 1, default is 0)
  83157. */
  83158. constructor(
  83159. /**
  83160. * Defines the red component (between 0 and 1, default is 0)
  83161. */
  83162. r?: number,
  83163. /**
  83164. * Defines the green component (between 0 and 1, default is 0)
  83165. */
  83166. g?: number,
  83167. /**
  83168. * Defines the blue component (between 0 and 1, default is 0)
  83169. */
  83170. b?: number);
  83171. /**
  83172. * Creates a string with the Color3 current values
  83173. * @returns the string representation of the Color3 object
  83174. */
  83175. toString(): string;
  83176. /**
  83177. * Returns the string "Color3"
  83178. * @returns "Color3"
  83179. */
  83180. getClassName(): string;
  83181. /**
  83182. * Compute the Color3 hash code
  83183. * @returns an unique number that can be used to hash Color3 objects
  83184. */
  83185. getHashCode(): number;
  83186. /**
  83187. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  83188. * @param array defines the array where to store the r,g,b components
  83189. * @param index defines an optional index in the target array to define where to start storing values
  83190. * @returns the current Color3 object
  83191. */
  83192. toArray(array: FloatArray, index?: number): Color3;
  83193. /**
  83194. * Returns a new Color4 object from the current Color3 and the given alpha
  83195. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  83196. * @returns a new Color4 object
  83197. */
  83198. toColor4(alpha?: number): Color4;
  83199. /**
  83200. * Returns a new array populated with 3 numeric elements : red, green and blue values
  83201. * @returns the new array
  83202. */
  83203. asArray(): number[];
  83204. /**
  83205. * Returns the luminance value
  83206. * @returns a float value
  83207. */
  83208. toLuminance(): number;
  83209. /**
  83210. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  83211. * @param otherColor defines the second operand
  83212. * @returns the new Color3 object
  83213. */
  83214. multiply(otherColor: DeepImmutable<Color3>): Color3;
  83215. /**
  83216. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  83217. * @param otherColor defines the second operand
  83218. * @param result defines the Color3 object where to store the result
  83219. * @returns the current Color3
  83220. */
  83221. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83222. /**
  83223. * Determines equality between Color3 objects
  83224. * @param otherColor defines the second operand
  83225. * @returns true if the rgb values are equal to the given ones
  83226. */
  83227. equals(otherColor: DeepImmutable<Color3>): boolean;
  83228. /**
  83229. * Determines equality between the current Color3 object and a set of r,b,g values
  83230. * @param r defines the red component to check
  83231. * @param g defines the green component to check
  83232. * @param b defines the blue component to check
  83233. * @returns true if the rgb values are equal to the given ones
  83234. */
  83235. equalsFloats(r: number, g: number, b: number): boolean;
  83236. /**
  83237. * Multiplies in place each rgb value by scale
  83238. * @param scale defines the scaling factor
  83239. * @returns the updated Color3
  83240. */
  83241. scale(scale: number): Color3;
  83242. /**
  83243. * Multiplies the rgb values by scale and stores the result into "result"
  83244. * @param scale defines the scaling factor
  83245. * @param result defines the Color3 object where to store the result
  83246. * @returns the unmodified current Color3
  83247. */
  83248. scaleToRef(scale: number, result: Color3): Color3;
  83249. /**
  83250. * Scale the current Color3 values by a factor and add the result to a given Color3
  83251. * @param scale defines the scale factor
  83252. * @param result defines color to store the result into
  83253. * @returns the unmodified current Color3
  83254. */
  83255. scaleAndAddToRef(scale: number, result: Color3): Color3;
  83256. /**
  83257. * Clamps the rgb values by the min and max values and stores the result into "result"
  83258. * @param min defines minimum clamping value (default is 0)
  83259. * @param max defines maximum clamping value (default is 1)
  83260. * @param result defines color to store the result into
  83261. * @returns the original Color3
  83262. */
  83263. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  83264. /**
  83265. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  83266. * @param otherColor defines the second operand
  83267. * @returns the new Color3
  83268. */
  83269. add(otherColor: DeepImmutable<Color3>): Color3;
  83270. /**
  83271. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  83272. * @param otherColor defines the second operand
  83273. * @param result defines Color3 object to store the result into
  83274. * @returns the unmodified current Color3
  83275. */
  83276. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83277. /**
  83278. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  83279. * @param otherColor defines the second operand
  83280. * @returns the new Color3
  83281. */
  83282. subtract(otherColor: DeepImmutable<Color3>): Color3;
  83283. /**
  83284. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  83285. * @param otherColor defines the second operand
  83286. * @param result defines Color3 object to store the result into
  83287. * @returns the unmodified current Color3
  83288. */
  83289. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83290. /**
  83291. * Copy the current object
  83292. * @returns a new Color3 copied the current one
  83293. */
  83294. clone(): Color3;
  83295. /**
  83296. * Copies the rgb values from the source in the current Color3
  83297. * @param source defines the source Color3 object
  83298. * @returns the updated Color3 object
  83299. */
  83300. copyFrom(source: DeepImmutable<Color3>): Color3;
  83301. /**
  83302. * Updates the Color3 rgb values from the given floats
  83303. * @param r defines the red component to read from
  83304. * @param g defines the green component to read from
  83305. * @param b defines the blue component to read from
  83306. * @returns the current Color3 object
  83307. */
  83308. copyFromFloats(r: number, g: number, b: number): Color3;
  83309. /**
  83310. * Updates the Color3 rgb values from the given floats
  83311. * @param r defines the red component to read from
  83312. * @param g defines the green component to read from
  83313. * @param b defines the blue component to read from
  83314. * @returns the current Color3 object
  83315. */
  83316. set(r: number, g: number, b: number): Color3;
  83317. /**
  83318. * Compute the Color3 hexadecimal code as a string
  83319. * @returns a string containing the hexadecimal representation of the Color3 object
  83320. */
  83321. toHexString(): string;
  83322. /**
  83323. * Computes a new Color3 converted from the current one to linear space
  83324. * @returns a new Color3 object
  83325. */
  83326. toLinearSpace(): Color3;
  83327. /**
  83328. * Converts current color in rgb space to HSV values
  83329. * @returns a new color3 representing the HSV values
  83330. */
  83331. toHSV(): Color3;
  83332. /**
  83333. * Converts current color in rgb space to HSV values
  83334. * @param result defines the Color3 where to store the HSV values
  83335. */
  83336. toHSVToRef(result: Color3): void;
  83337. /**
  83338. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  83339. * @param convertedColor defines the Color3 object where to store the linear space version
  83340. * @returns the unmodified Color3
  83341. */
  83342. toLinearSpaceToRef(convertedColor: Color3): Color3;
  83343. /**
  83344. * Computes a new Color3 converted from the current one to gamma space
  83345. * @returns a new Color3 object
  83346. */
  83347. toGammaSpace(): Color3;
  83348. /**
  83349. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  83350. * @param convertedColor defines the Color3 object where to store the gamma space version
  83351. * @returns the unmodified Color3
  83352. */
  83353. toGammaSpaceToRef(convertedColor: Color3): Color3;
  83354. private static _BlackReadOnly;
  83355. /**
  83356. * Convert Hue, saturation and value to a Color3 (RGB)
  83357. * @param hue defines the hue
  83358. * @param saturation defines the saturation
  83359. * @param value defines the value
  83360. * @param result defines the Color3 where to store the RGB values
  83361. */
  83362. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  83363. /**
  83364. * Creates a new Color3 from the string containing valid hexadecimal values
  83365. * @param hex defines a string containing valid hexadecimal values
  83366. * @returns a new Color3 object
  83367. */
  83368. static FromHexString(hex: string): Color3;
  83369. /**
  83370. * Creates a new Color3 from the starting index of the given array
  83371. * @param array defines the source array
  83372. * @param offset defines an offset in the source array
  83373. * @returns a new Color3 object
  83374. */
  83375. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  83376. /**
  83377. * Creates a new Color3 from integer values (< 256)
  83378. * @param r defines the red component to read from (value between 0 and 255)
  83379. * @param g defines the green component to read from (value between 0 and 255)
  83380. * @param b defines the blue component to read from (value between 0 and 255)
  83381. * @returns a new Color3 object
  83382. */
  83383. static FromInts(r: number, g: number, b: number): Color3;
  83384. /**
  83385. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  83386. * @param start defines the start Color3 value
  83387. * @param end defines the end Color3 value
  83388. * @param amount defines the gradient value between start and end
  83389. * @returns a new Color3 object
  83390. */
  83391. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  83392. /**
  83393. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  83394. * @param left defines the start value
  83395. * @param right defines the end value
  83396. * @param amount defines the gradient factor
  83397. * @param result defines the Color3 object where to store the result
  83398. */
  83399. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  83400. /**
  83401. * Returns a Color3 value containing a red color
  83402. * @returns a new Color3 object
  83403. */
  83404. static Red(): Color3;
  83405. /**
  83406. * Returns a Color3 value containing a green color
  83407. * @returns a new Color3 object
  83408. */
  83409. static Green(): Color3;
  83410. /**
  83411. * Returns a Color3 value containing a blue color
  83412. * @returns a new Color3 object
  83413. */
  83414. static Blue(): Color3;
  83415. /**
  83416. * Returns a Color3 value containing a black color
  83417. * @returns a new Color3 object
  83418. */
  83419. static Black(): Color3;
  83420. /**
  83421. * Gets a Color3 value containing a black color that must not be updated
  83422. */
  83423. static get BlackReadOnly(): DeepImmutable<Color3>;
  83424. /**
  83425. * Returns a Color3 value containing a white color
  83426. * @returns a new Color3 object
  83427. */
  83428. static White(): Color3;
  83429. /**
  83430. * Returns a Color3 value containing a purple color
  83431. * @returns a new Color3 object
  83432. */
  83433. static Purple(): Color3;
  83434. /**
  83435. * Returns a Color3 value containing a magenta color
  83436. * @returns a new Color3 object
  83437. */
  83438. static Magenta(): Color3;
  83439. /**
  83440. * Returns a Color3 value containing a yellow color
  83441. * @returns a new Color3 object
  83442. */
  83443. static Yellow(): Color3;
  83444. /**
  83445. * Returns a Color3 value containing a gray color
  83446. * @returns a new Color3 object
  83447. */
  83448. static Gray(): Color3;
  83449. /**
  83450. * Returns a Color3 value containing a teal color
  83451. * @returns a new Color3 object
  83452. */
  83453. static Teal(): Color3;
  83454. /**
  83455. * Returns a Color3 value containing a random color
  83456. * @returns a new Color3 object
  83457. */
  83458. static Random(): Color3;
  83459. }
  83460. /**
  83461. * Class used to hold a RBGA color
  83462. */
  83463. export class Color4 {
  83464. /**
  83465. * Defines the red component (between 0 and 1, default is 0)
  83466. */
  83467. r: number;
  83468. /**
  83469. * Defines the green component (between 0 and 1, default is 0)
  83470. */
  83471. g: number;
  83472. /**
  83473. * Defines the blue component (between 0 and 1, default is 0)
  83474. */
  83475. b: number;
  83476. /**
  83477. * Defines the alpha component (between 0 and 1, default is 1)
  83478. */
  83479. a: number;
  83480. /**
  83481. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  83482. * @param r defines the red component (between 0 and 1, default is 0)
  83483. * @param g defines the green component (between 0 and 1, default is 0)
  83484. * @param b defines the blue component (between 0 and 1, default is 0)
  83485. * @param a defines the alpha component (between 0 and 1, default is 1)
  83486. */
  83487. constructor(
  83488. /**
  83489. * Defines the red component (between 0 and 1, default is 0)
  83490. */
  83491. r?: number,
  83492. /**
  83493. * Defines the green component (between 0 and 1, default is 0)
  83494. */
  83495. g?: number,
  83496. /**
  83497. * Defines the blue component (between 0 and 1, default is 0)
  83498. */
  83499. b?: number,
  83500. /**
  83501. * Defines the alpha component (between 0 and 1, default is 1)
  83502. */
  83503. a?: number);
  83504. /**
  83505. * Adds in place the given Color4 values to the current Color4 object
  83506. * @param right defines the second operand
  83507. * @returns the current updated Color4 object
  83508. */
  83509. addInPlace(right: DeepImmutable<Color4>): Color4;
  83510. /**
  83511. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  83512. * @returns the new array
  83513. */
  83514. asArray(): number[];
  83515. /**
  83516. * Stores from the starting index in the given array the Color4 successive values
  83517. * @param array defines the array where to store the r,g,b components
  83518. * @param index defines an optional index in the target array to define where to start storing values
  83519. * @returns the current Color4 object
  83520. */
  83521. toArray(array: number[], index?: number): Color4;
  83522. /**
  83523. * Determines equality between Color4 objects
  83524. * @param otherColor defines the second operand
  83525. * @returns true if the rgba values are equal to the given ones
  83526. */
  83527. equals(otherColor: DeepImmutable<Color4>): boolean;
  83528. /**
  83529. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  83530. * @param right defines the second operand
  83531. * @returns a new Color4 object
  83532. */
  83533. add(right: DeepImmutable<Color4>): Color4;
  83534. /**
  83535. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  83536. * @param right defines the second operand
  83537. * @returns a new Color4 object
  83538. */
  83539. subtract(right: DeepImmutable<Color4>): Color4;
  83540. /**
  83541. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  83542. * @param right defines the second operand
  83543. * @param result defines the Color4 object where to store the result
  83544. * @returns the current Color4 object
  83545. */
  83546. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  83547. /**
  83548. * Creates a new Color4 with the current Color4 values multiplied by scale
  83549. * @param scale defines the scaling factor to apply
  83550. * @returns a new Color4 object
  83551. */
  83552. scale(scale: number): Color4;
  83553. /**
  83554. * Multiplies the current Color4 values by scale and stores the result in "result"
  83555. * @param scale defines the scaling factor to apply
  83556. * @param result defines the Color4 object where to store the result
  83557. * @returns the current unmodified Color4
  83558. */
  83559. scaleToRef(scale: number, result: Color4): Color4;
  83560. /**
  83561. * Scale the current Color4 values by a factor and add the result to a given Color4
  83562. * @param scale defines the scale factor
  83563. * @param result defines the Color4 object where to store the result
  83564. * @returns the unmodified current Color4
  83565. */
  83566. scaleAndAddToRef(scale: number, result: Color4): Color4;
  83567. /**
  83568. * Clamps the rgb values by the min and max values and stores the result into "result"
  83569. * @param min defines minimum clamping value (default is 0)
  83570. * @param max defines maximum clamping value (default is 1)
  83571. * @param result defines color to store the result into.
  83572. * @returns the cuurent Color4
  83573. */
  83574. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  83575. /**
  83576. * Multipy an Color4 value by another and return a new Color4 object
  83577. * @param color defines the Color4 value to multiply by
  83578. * @returns a new Color4 object
  83579. */
  83580. multiply(color: Color4): Color4;
  83581. /**
  83582. * Multipy a Color4 value by another and push the result in a reference value
  83583. * @param color defines the Color4 value to multiply by
  83584. * @param result defines the Color4 to fill the result in
  83585. * @returns the result Color4
  83586. */
  83587. multiplyToRef(color: Color4, result: Color4): Color4;
  83588. /**
  83589. * Creates a string with the Color4 current values
  83590. * @returns the string representation of the Color4 object
  83591. */
  83592. toString(): string;
  83593. /**
  83594. * Returns the string "Color4"
  83595. * @returns "Color4"
  83596. */
  83597. getClassName(): string;
  83598. /**
  83599. * Compute the Color4 hash code
  83600. * @returns an unique number that can be used to hash Color4 objects
  83601. */
  83602. getHashCode(): number;
  83603. /**
  83604. * Creates a new Color4 copied from the current one
  83605. * @returns a new Color4 object
  83606. */
  83607. clone(): Color4;
  83608. /**
  83609. * Copies the given Color4 values into the current one
  83610. * @param source defines the source Color4 object
  83611. * @returns the current updated Color4 object
  83612. */
  83613. copyFrom(source: Color4): Color4;
  83614. /**
  83615. * Copies the given float values into the current one
  83616. * @param r defines the red component to read from
  83617. * @param g defines the green component to read from
  83618. * @param b defines the blue component to read from
  83619. * @param a defines the alpha component to read from
  83620. * @returns the current updated Color4 object
  83621. */
  83622. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  83623. /**
  83624. * Copies the given float values into the current one
  83625. * @param r defines the red component to read from
  83626. * @param g defines the green component to read from
  83627. * @param b defines the blue component to read from
  83628. * @param a defines the alpha component to read from
  83629. * @returns the current updated Color4 object
  83630. */
  83631. set(r: number, g: number, b: number, a: number): Color4;
  83632. /**
  83633. * Compute the Color4 hexadecimal code as a string
  83634. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  83635. * @returns a string containing the hexadecimal representation of the Color4 object
  83636. */
  83637. toHexString(returnAsColor3?: boolean): string;
  83638. /**
  83639. * Computes a new Color4 converted from the current one to linear space
  83640. * @returns a new Color4 object
  83641. */
  83642. toLinearSpace(): Color4;
  83643. /**
  83644. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  83645. * @param convertedColor defines the Color4 object where to store the linear space version
  83646. * @returns the unmodified Color4
  83647. */
  83648. toLinearSpaceToRef(convertedColor: Color4): Color4;
  83649. /**
  83650. * Computes a new Color4 converted from the current one to gamma space
  83651. * @returns a new Color4 object
  83652. */
  83653. toGammaSpace(): Color4;
  83654. /**
  83655. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  83656. * @param convertedColor defines the Color4 object where to store the gamma space version
  83657. * @returns the unmodified Color4
  83658. */
  83659. toGammaSpaceToRef(convertedColor: Color4): Color4;
  83660. /**
  83661. * Creates a new Color4 from the string containing valid hexadecimal values
  83662. * @param hex defines a string containing valid hexadecimal values
  83663. * @returns a new Color4 object
  83664. */
  83665. static FromHexString(hex: string): Color4;
  83666. /**
  83667. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  83668. * @param left defines the start value
  83669. * @param right defines the end value
  83670. * @param amount defines the gradient factor
  83671. * @returns a new Color4 object
  83672. */
  83673. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  83674. /**
  83675. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  83676. * @param left defines the start value
  83677. * @param right defines the end value
  83678. * @param amount defines the gradient factor
  83679. * @param result defines the Color4 object where to store data
  83680. */
  83681. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  83682. /**
  83683. * Creates a new Color4 from a Color3 and an alpha value
  83684. * @param color3 defines the source Color3 to read from
  83685. * @param alpha defines the alpha component (1.0 by default)
  83686. * @returns a new Color4 object
  83687. */
  83688. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  83689. /**
  83690. * Creates a new Color4 from the starting index element of the given array
  83691. * @param array defines the source array to read from
  83692. * @param offset defines the offset in the source array
  83693. * @returns a new Color4 object
  83694. */
  83695. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  83696. /**
  83697. * Creates a new Color3 from integer values (< 256)
  83698. * @param r defines the red component to read from (value between 0 and 255)
  83699. * @param g defines the green component to read from (value between 0 and 255)
  83700. * @param b defines the blue component to read from (value between 0 and 255)
  83701. * @param a defines the alpha component to read from (value between 0 and 255)
  83702. * @returns a new Color3 object
  83703. */
  83704. static FromInts(r: number, g: number, b: number, a: number): Color4;
  83705. /**
  83706. * Check the content of a given array and convert it to an array containing RGBA data
  83707. * If the original array was already containing count * 4 values then it is returned directly
  83708. * @param colors defines the array to check
  83709. * @param count defines the number of RGBA data to expect
  83710. * @returns an array containing count * 4 values (RGBA)
  83711. */
  83712. static CheckColors4(colors: number[], count: number): number[];
  83713. }
  83714. /**
  83715. * @hidden
  83716. */
  83717. export class TmpColors {
  83718. static Color3: Color3[];
  83719. static Color4: Color4[];
  83720. }
  83721. }
  83722. declare module BABYLON {
  83723. /**
  83724. * Defines an interface which represents an animation key frame
  83725. */
  83726. export interface IAnimationKey {
  83727. /**
  83728. * Frame of the key frame
  83729. */
  83730. frame: number;
  83731. /**
  83732. * Value at the specifies key frame
  83733. */
  83734. value: any;
  83735. /**
  83736. * The input tangent for the cubic hermite spline
  83737. */
  83738. inTangent?: any;
  83739. /**
  83740. * The output tangent for the cubic hermite spline
  83741. */
  83742. outTangent?: any;
  83743. /**
  83744. * The animation interpolation type
  83745. */
  83746. interpolation?: AnimationKeyInterpolation;
  83747. }
  83748. /**
  83749. * Enum for the animation key frame interpolation type
  83750. */
  83751. export enum AnimationKeyInterpolation {
  83752. /**
  83753. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  83754. */
  83755. STEP = 1
  83756. }
  83757. }
  83758. declare module BABYLON {
  83759. /**
  83760. * Represents the range of an animation
  83761. */
  83762. export class AnimationRange {
  83763. /**The name of the animation range**/
  83764. name: string;
  83765. /**The starting frame of the animation */
  83766. from: number;
  83767. /**The ending frame of the animation*/
  83768. to: number;
  83769. /**
  83770. * Initializes the range of an animation
  83771. * @param name The name of the animation range
  83772. * @param from The starting frame of the animation
  83773. * @param to The ending frame of the animation
  83774. */
  83775. constructor(
  83776. /**The name of the animation range**/
  83777. name: string,
  83778. /**The starting frame of the animation */
  83779. from: number,
  83780. /**The ending frame of the animation*/
  83781. to: number);
  83782. /**
  83783. * Makes a copy of the animation range
  83784. * @returns A copy of the animation range
  83785. */
  83786. clone(): AnimationRange;
  83787. }
  83788. }
  83789. declare module BABYLON {
  83790. /**
  83791. * Composed of a frame, and an action function
  83792. */
  83793. export class AnimationEvent {
  83794. /** The frame for which the event is triggered **/
  83795. frame: number;
  83796. /** The event to perform when triggered **/
  83797. action: (currentFrame: number) => void;
  83798. /** Specifies if the event should be triggered only once**/
  83799. onlyOnce?: boolean | undefined;
  83800. /**
  83801. * Specifies if the animation event is done
  83802. */
  83803. isDone: boolean;
  83804. /**
  83805. * Initializes the animation event
  83806. * @param frame The frame for which the event is triggered
  83807. * @param action The event to perform when triggered
  83808. * @param onlyOnce Specifies if the event should be triggered only once
  83809. */
  83810. constructor(
  83811. /** The frame for which the event is triggered **/
  83812. frame: number,
  83813. /** The event to perform when triggered **/
  83814. action: (currentFrame: number) => void,
  83815. /** Specifies if the event should be triggered only once**/
  83816. onlyOnce?: boolean | undefined);
  83817. /** @hidden */
  83818. _clone(): AnimationEvent;
  83819. }
  83820. }
  83821. declare module BABYLON {
  83822. /**
  83823. * Interface used to define a behavior
  83824. */
  83825. export interface Behavior<T> {
  83826. /** gets or sets behavior's name */
  83827. name: string;
  83828. /**
  83829. * Function called when the behavior needs to be initialized (after attaching it to a target)
  83830. */
  83831. init(): void;
  83832. /**
  83833. * Called when the behavior is attached to a target
  83834. * @param target defines the target where the behavior is attached to
  83835. */
  83836. attach(target: T): void;
  83837. /**
  83838. * Called when the behavior is detached from its target
  83839. */
  83840. detach(): void;
  83841. }
  83842. /**
  83843. * Interface implemented by classes supporting behaviors
  83844. */
  83845. export interface IBehaviorAware<T> {
  83846. /**
  83847. * Attach a behavior
  83848. * @param behavior defines the behavior to attach
  83849. * @returns the current host
  83850. */
  83851. addBehavior(behavior: Behavior<T>): T;
  83852. /**
  83853. * Remove a behavior from the current object
  83854. * @param behavior defines the behavior to detach
  83855. * @returns the current host
  83856. */
  83857. removeBehavior(behavior: Behavior<T>): T;
  83858. /**
  83859. * Gets a behavior using its name to search
  83860. * @param name defines the name to search
  83861. * @returns the behavior or null if not found
  83862. */
  83863. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  83864. }
  83865. }
  83866. declare module BABYLON {
  83867. /**
  83868. * Defines an array and its length.
  83869. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  83870. */
  83871. export interface ISmartArrayLike<T> {
  83872. /**
  83873. * The data of the array.
  83874. */
  83875. data: Array<T>;
  83876. /**
  83877. * The active length of the array.
  83878. */
  83879. length: number;
  83880. }
  83881. /**
  83882. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83883. */
  83884. export class SmartArray<T> implements ISmartArrayLike<T> {
  83885. /**
  83886. * The full set of data from the array.
  83887. */
  83888. data: Array<T>;
  83889. /**
  83890. * The active length of the array.
  83891. */
  83892. length: number;
  83893. protected _id: number;
  83894. /**
  83895. * Instantiates a Smart Array.
  83896. * @param capacity defines the default capacity of the array.
  83897. */
  83898. constructor(capacity: number);
  83899. /**
  83900. * Pushes a value at the end of the active data.
  83901. * @param value defines the object to push in the array.
  83902. */
  83903. push(value: T): void;
  83904. /**
  83905. * Iterates over the active data and apply the lambda to them.
  83906. * @param func defines the action to apply on each value.
  83907. */
  83908. forEach(func: (content: T) => void): void;
  83909. /**
  83910. * Sorts the full sets of data.
  83911. * @param compareFn defines the comparison function to apply.
  83912. */
  83913. sort(compareFn: (a: T, b: T) => number): void;
  83914. /**
  83915. * Resets the active data to an empty array.
  83916. */
  83917. reset(): void;
  83918. /**
  83919. * Releases all the data from the array as well as the array.
  83920. */
  83921. dispose(): void;
  83922. /**
  83923. * Concats the active data with a given array.
  83924. * @param array defines the data to concatenate with.
  83925. */
  83926. concat(array: any): void;
  83927. /**
  83928. * Returns the position of a value in the active data.
  83929. * @param value defines the value to find the index for
  83930. * @returns the index if found in the active data otherwise -1
  83931. */
  83932. indexOf(value: T): number;
  83933. /**
  83934. * Returns whether an element is part of the active data.
  83935. * @param value defines the value to look for
  83936. * @returns true if found in the active data otherwise false
  83937. */
  83938. contains(value: T): boolean;
  83939. private static _GlobalId;
  83940. }
  83941. /**
  83942. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83943. * The data in this array can only be present once
  83944. */
  83945. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  83946. private _duplicateId;
  83947. /**
  83948. * Pushes a value at the end of the active data.
  83949. * THIS DOES NOT PREVENT DUPPLICATE DATA
  83950. * @param value defines the object to push in the array.
  83951. */
  83952. push(value: T): void;
  83953. /**
  83954. * Pushes a value at the end of the active data.
  83955. * If the data is already present, it won t be added again
  83956. * @param value defines the object to push in the array.
  83957. * @returns true if added false if it was already present
  83958. */
  83959. pushNoDuplicate(value: T): boolean;
  83960. /**
  83961. * Resets the active data to an empty array.
  83962. */
  83963. reset(): void;
  83964. /**
  83965. * Concats the active data with a given array.
  83966. * This ensures no dupplicate will be present in the result.
  83967. * @param array defines the data to concatenate with.
  83968. */
  83969. concatWithNoDuplicate(array: any): void;
  83970. }
  83971. }
  83972. declare module BABYLON {
  83973. /**
  83974. * @ignore
  83975. * This is a list of all the different input types that are available in the application.
  83976. * Fo instance: ArcRotateCameraGamepadInput...
  83977. */
  83978. export var CameraInputTypes: {};
  83979. /**
  83980. * This is the contract to implement in order to create a new input class.
  83981. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  83982. */
  83983. export interface ICameraInput<TCamera extends Camera> {
  83984. /**
  83985. * Defines the camera the input is attached to.
  83986. */
  83987. camera: Nullable<TCamera>;
  83988. /**
  83989. * Gets the class name of the current intput.
  83990. * @returns the class name
  83991. */
  83992. getClassName(): string;
  83993. /**
  83994. * Get the friendly name associated with the input class.
  83995. * @returns the input friendly name
  83996. */
  83997. getSimpleName(): string;
  83998. /**
  83999. * Attach the input controls to a specific dom element to get the input from.
  84000. * @param element Defines the element the controls should be listened from
  84001. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84002. */
  84003. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84004. /**
  84005. * Detach the current controls from the specified dom element.
  84006. * @param element Defines the element to stop listening the inputs from
  84007. */
  84008. detachControl(element: Nullable<HTMLElement>): void;
  84009. /**
  84010. * Update the current camera state depending on the inputs that have been used this frame.
  84011. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84012. */
  84013. checkInputs?: () => void;
  84014. }
  84015. /**
  84016. * Represents a map of input types to input instance or input index to input instance.
  84017. */
  84018. export interface CameraInputsMap<TCamera extends Camera> {
  84019. /**
  84020. * Accessor to the input by input type.
  84021. */
  84022. [name: string]: ICameraInput<TCamera>;
  84023. /**
  84024. * Accessor to the input by input index.
  84025. */
  84026. [idx: number]: ICameraInput<TCamera>;
  84027. }
  84028. /**
  84029. * This represents the input manager used within a camera.
  84030. * It helps dealing with all the different kind of input attached to a camera.
  84031. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84032. */
  84033. export class CameraInputsManager<TCamera extends Camera> {
  84034. /**
  84035. * Defines the list of inputs attahed to the camera.
  84036. */
  84037. attached: CameraInputsMap<TCamera>;
  84038. /**
  84039. * Defines the dom element the camera is collecting inputs from.
  84040. * This is null if the controls have not been attached.
  84041. */
  84042. attachedElement: Nullable<HTMLElement>;
  84043. /**
  84044. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84045. */
  84046. noPreventDefault: boolean;
  84047. /**
  84048. * Defined the camera the input manager belongs to.
  84049. */
  84050. camera: TCamera;
  84051. /**
  84052. * Update the current camera state depending on the inputs that have been used this frame.
  84053. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84054. */
  84055. checkInputs: () => void;
  84056. /**
  84057. * Instantiate a new Camera Input Manager.
  84058. * @param camera Defines the camera the input manager blongs to
  84059. */
  84060. constructor(camera: TCamera);
  84061. /**
  84062. * Add an input method to a camera
  84063. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84064. * @param input camera input method
  84065. */
  84066. add(input: ICameraInput<TCamera>): void;
  84067. /**
  84068. * Remove a specific input method from a camera
  84069. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  84070. * @param inputToRemove camera input method
  84071. */
  84072. remove(inputToRemove: ICameraInput<TCamera>): void;
  84073. /**
  84074. * Remove a specific input type from a camera
  84075. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  84076. * @param inputType the type of the input to remove
  84077. */
  84078. removeByType(inputType: string): void;
  84079. private _addCheckInputs;
  84080. /**
  84081. * Attach the input controls to the currently attached dom element to listen the events from.
  84082. * @param input Defines the input to attach
  84083. */
  84084. attachInput(input: ICameraInput<TCamera>): void;
  84085. /**
  84086. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  84087. * @param element Defines the dom element to collect the events from
  84088. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84089. */
  84090. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  84091. /**
  84092. * Detach the current manager inputs controls from a specific dom element.
  84093. * @param element Defines the dom element to collect the events from
  84094. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  84095. */
  84096. detachElement(element: HTMLElement, disconnect?: boolean): void;
  84097. /**
  84098. * Rebuild the dynamic inputCheck function from the current list of
  84099. * defined inputs in the manager.
  84100. */
  84101. rebuildInputCheck(): void;
  84102. /**
  84103. * Remove all attached input methods from a camera
  84104. */
  84105. clear(): void;
  84106. /**
  84107. * Serialize the current input manager attached to a camera.
  84108. * This ensures than once parsed,
  84109. * the input associated to the camera will be identical to the current ones
  84110. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  84111. */
  84112. serialize(serializedCamera: any): void;
  84113. /**
  84114. * Parses an input manager serialized JSON to restore the previous list of inputs
  84115. * and states associated to a camera.
  84116. * @param parsedCamera Defines the JSON to parse
  84117. */
  84118. parse(parsedCamera: any): void;
  84119. }
  84120. }
  84121. declare module BABYLON {
  84122. /**
  84123. * Class used to store data that will be store in GPU memory
  84124. */
  84125. export class Buffer {
  84126. private _engine;
  84127. private _buffer;
  84128. /** @hidden */
  84129. _data: Nullable<DataArray>;
  84130. private _updatable;
  84131. private _instanced;
  84132. private _divisor;
  84133. /**
  84134. * Gets the byte stride.
  84135. */
  84136. readonly byteStride: number;
  84137. /**
  84138. * Constructor
  84139. * @param engine the engine
  84140. * @param data the data to use for this buffer
  84141. * @param updatable whether the data is updatable
  84142. * @param stride the stride (optional)
  84143. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84144. * @param instanced whether the buffer is instanced (optional)
  84145. * @param useBytes set to true if the stride in in bytes (optional)
  84146. * @param divisor sets an optional divisor for instances (1 by default)
  84147. */
  84148. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  84149. /**
  84150. * Create a new VertexBuffer based on the current buffer
  84151. * @param kind defines the vertex buffer kind (position, normal, etc.)
  84152. * @param offset defines offset in the buffer (0 by default)
  84153. * @param size defines the size in floats of attributes (position is 3 for instance)
  84154. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  84155. * @param instanced defines if the vertex buffer contains indexed data
  84156. * @param useBytes defines if the offset and stride are in bytes *
  84157. * @param divisor sets an optional divisor for instances (1 by default)
  84158. * @returns the new vertex buffer
  84159. */
  84160. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  84161. /**
  84162. * Gets a boolean indicating if the Buffer is updatable?
  84163. * @returns true if the buffer is updatable
  84164. */
  84165. isUpdatable(): boolean;
  84166. /**
  84167. * Gets current buffer's data
  84168. * @returns a DataArray or null
  84169. */
  84170. getData(): Nullable<DataArray>;
  84171. /**
  84172. * Gets underlying native buffer
  84173. * @returns underlying native buffer
  84174. */
  84175. getBuffer(): Nullable<DataBuffer>;
  84176. /**
  84177. * Gets the stride in float32 units (i.e. byte stride / 4).
  84178. * May not be an integer if the byte stride is not divisible by 4.
  84179. * @returns the stride in float32 units
  84180. * @deprecated Please use byteStride instead.
  84181. */
  84182. getStrideSize(): number;
  84183. /**
  84184. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84185. * @param data defines the data to store
  84186. */
  84187. create(data?: Nullable<DataArray>): void;
  84188. /** @hidden */
  84189. _rebuild(): void;
  84190. /**
  84191. * Update current buffer data
  84192. * @param data defines the data to store
  84193. */
  84194. update(data: DataArray): void;
  84195. /**
  84196. * Updates the data directly.
  84197. * @param data the new data
  84198. * @param offset the new offset
  84199. * @param vertexCount the vertex count (optional)
  84200. * @param useBytes set to true if the offset is in bytes
  84201. */
  84202. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  84203. /**
  84204. * Release all resources
  84205. */
  84206. dispose(): void;
  84207. }
  84208. /**
  84209. * Specialized buffer used to store vertex data
  84210. */
  84211. export class VertexBuffer {
  84212. /** @hidden */
  84213. _buffer: Buffer;
  84214. private _kind;
  84215. private _size;
  84216. private _ownsBuffer;
  84217. private _instanced;
  84218. private _instanceDivisor;
  84219. /**
  84220. * The byte type.
  84221. */
  84222. static readonly BYTE: number;
  84223. /**
  84224. * The unsigned byte type.
  84225. */
  84226. static readonly UNSIGNED_BYTE: number;
  84227. /**
  84228. * The short type.
  84229. */
  84230. static readonly SHORT: number;
  84231. /**
  84232. * The unsigned short type.
  84233. */
  84234. static readonly UNSIGNED_SHORT: number;
  84235. /**
  84236. * The integer type.
  84237. */
  84238. static readonly INT: number;
  84239. /**
  84240. * The unsigned integer type.
  84241. */
  84242. static readonly UNSIGNED_INT: number;
  84243. /**
  84244. * The float type.
  84245. */
  84246. static readonly FLOAT: number;
  84247. /**
  84248. * Gets or sets the instance divisor when in instanced mode
  84249. */
  84250. get instanceDivisor(): number;
  84251. set instanceDivisor(value: number);
  84252. /**
  84253. * Gets the byte stride.
  84254. */
  84255. readonly byteStride: number;
  84256. /**
  84257. * Gets the byte offset.
  84258. */
  84259. readonly byteOffset: number;
  84260. /**
  84261. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  84262. */
  84263. readonly normalized: boolean;
  84264. /**
  84265. * Gets the data type of each component in the array.
  84266. */
  84267. readonly type: number;
  84268. /**
  84269. * Constructor
  84270. * @param engine the engine
  84271. * @param data the data to use for this vertex buffer
  84272. * @param kind the vertex buffer kind
  84273. * @param updatable whether the data is updatable
  84274. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84275. * @param stride the stride (optional)
  84276. * @param instanced whether the buffer is instanced (optional)
  84277. * @param offset the offset of the data (optional)
  84278. * @param size the number of components (optional)
  84279. * @param type the type of the component (optional)
  84280. * @param normalized whether the data contains normalized data (optional)
  84281. * @param useBytes set to true if stride and offset are in bytes (optional)
  84282. * @param divisor defines the instance divisor to use (1 by default)
  84283. */
  84284. 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);
  84285. /** @hidden */
  84286. _rebuild(): void;
  84287. /**
  84288. * Returns the kind of the VertexBuffer (string)
  84289. * @returns a string
  84290. */
  84291. getKind(): string;
  84292. /**
  84293. * Gets a boolean indicating if the VertexBuffer is updatable?
  84294. * @returns true if the buffer is updatable
  84295. */
  84296. isUpdatable(): boolean;
  84297. /**
  84298. * Gets current buffer's data
  84299. * @returns a DataArray or null
  84300. */
  84301. getData(): Nullable<DataArray>;
  84302. /**
  84303. * Gets underlying native buffer
  84304. * @returns underlying native buffer
  84305. */
  84306. getBuffer(): Nullable<DataBuffer>;
  84307. /**
  84308. * Gets the stride in float32 units (i.e. byte stride / 4).
  84309. * May not be an integer if the byte stride is not divisible by 4.
  84310. * @returns the stride in float32 units
  84311. * @deprecated Please use byteStride instead.
  84312. */
  84313. getStrideSize(): number;
  84314. /**
  84315. * Returns the offset as a multiple of the type byte length.
  84316. * @returns the offset in bytes
  84317. * @deprecated Please use byteOffset instead.
  84318. */
  84319. getOffset(): number;
  84320. /**
  84321. * Returns the number of components per vertex attribute (integer)
  84322. * @returns the size in float
  84323. */
  84324. getSize(): number;
  84325. /**
  84326. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  84327. * @returns true if this buffer is instanced
  84328. */
  84329. getIsInstanced(): boolean;
  84330. /**
  84331. * Returns the instancing divisor, zero for non-instanced (integer).
  84332. * @returns a number
  84333. */
  84334. getInstanceDivisor(): number;
  84335. /**
  84336. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84337. * @param data defines the data to store
  84338. */
  84339. create(data?: DataArray): void;
  84340. /**
  84341. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  84342. * This function will create a new buffer if the current one is not updatable
  84343. * @param data defines the data to store
  84344. */
  84345. update(data: DataArray): void;
  84346. /**
  84347. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  84348. * Returns the directly updated WebGLBuffer.
  84349. * @param data the new data
  84350. * @param offset the new offset
  84351. * @param useBytes set to true if the offset is in bytes
  84352. */
  84353. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  84354. /**
  84355. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  84356. */
  84357. dispose(): void;
  84358. /**
  84359. * Enumerates each value of this vertex buffer as numbers.
  84360. * @param count the number of values to enumerate
  84361. * @param callback the callback function called for each value
  84362. */
  84363. forEach(count: number, callback: (value: number, index: number) => void): void;
  84364. /**
  84365. * Positions
  84366. */
  84367. static readonly PositionKind: string;
  84368. /**
  84369. * Normals
  84370. */
  84371. static readonly NormalKind: string;
  84372. /**
  84373. * Tangents
  84374. */
  84375. static readonly TangentKind: string;
  84376. /**
  84377. * Texture coordinates
  84378. */
  84379. static readonly UVKind: string;
  84380. /**
  84381. * Texture coordinates 2
  84382. */
  84383. static readonly UV2Kind: string;
  84384. /**
  84385. * Texture coordinates 3
  84386. */
  84387. static readonly UV3Kind: string;
  84388. /**
  84389. * Texture coordinates 4
  84390. */
  84391. static readonly UV4Kind: string;
  84392. /**
  84393. * Texture coordinates 5
  84394. */
  84395. static readonly UV5Kind: string;
  84396. /**
  84397. * Texture coordinates 6
  84398. */
  84399. static readonly UV6Kind: string;
  84400. /**
  84401. * Colors
  84402. */
  84403. static readonly ColorKind: string;
  84404. /**
  84405. * Matrix indices (for bones)
  84406. */
  84407. static readonly MatricesIndicesKind: string;
  84408. /**
  84409. * Matrix weights (for bones)
  84410. */
  84411. static readonly MatricesWeightsKind: string;
  84412. /**
  84413. * Additional matrix indices (for bones)
  84414. */
  84415. static readonly MatricesIndicesExtraKind: string;
  84416. /**
  84417. * Additional matrix weights (for bones)
  84418. */
  84419. static readonly MatricesWeightsExtraKind: string;
  84420. /**
  84421. * Deduces the stride given a kind.
  84422. * @param kind The kind string to deduce
  84423. * @returns The deduced stride
  84424. */
  84425. static DeduceStride(kind: string): number;
  84426. /**
  84427. * Gets the byte length of the given type.
  84428. * @param type the type
  84429. * @returns the number of bytes
  84430. */
  84431. static GetTypeByteLength(type: number): number;
  84432. /**
  84433. * Enumerates each value of the given parameters as numbers.
  84434. * @param data the data to enumerate
  84435. * @param byteOffset the byte offset of the data
  84436. * @param byteStride the byte stride of the data
  84437. * @param componentCount the number of components per element
  84438. * @param componentType the type of the component
  84439. * @param count the number of values to enumerate
  84440. * @param normalized whether the data is normalized
  84441. * @param callback the callback function called for each value
  84442. */
  84443. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  84444. private static _GetFloatValue;
  84445. }
  84446. }
  84447. declare module BABYLON {
  84448. /**
  84449. * @hidden
  84450. */
  84451. export class IntersectionInfo {
  84452. bu: Nullable<number>;
  84453. bv: Nullable<number>;
  84454. distance: number;
  84455. faceId: number;
  84456. subMeshId: number;
  84457. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  84458. }
  84459. }
  84460. declare module BABYLON {
  84461. /**
  84462. * Class used to store bounding sphere information
  84463. */
  84464. export class BoundingSphere {
  84465. /**
  84466. * Gets the center of the bounding sphere in local space
  84467. */
  84468. readonly center: Vector3;
  84469. /**
  84470. * Radius of the bounding sphere in local space
  84471. */
  84472. radius: number;
  84473. /**
  84474. * Gets the center of the bounding sphere in world space
  84475. */
  84476. readonly centerWorld: Vector3;
  84477. /**
  84478. * Radius of the bounding sphere in world space
  84479. */
  84480. radiusWorld: number;
  84481. /**
  84482. * Gets the minimum vector in local space
  84483. */
  84484. readonly minimum: Vector3;
  84485. /**
  84486. * Gets the maximum vector in local space
  84487. */
  84488. readonly maximum: Vector3;
  84489. private _worldMatrix;
  84490. private static readonly TmpVector3;
  84491. /**
  84492. * Creates a new bounding sphere
  84493. * @param min defines the minimum vector (in local space)
  84494. * @param max defines the maximum vector (in local space)
  84495. * @param worldMatrix defines the new world matrix
  84496. */
  84497. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84498. /**
  84499. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  84500. * @param min defines the new minimum vector (in local space)
  84501. * @param max defines the new maximum vector (in local space)
  84502. * @param worldMatrix defines the new world matrix
  84503. */
  84504. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84505. /**
  84506. * Scale the current bounding sphere by applying a scale factor
  84507. * @param factor defines the scale factor to apply
  84508. * @returns the current bounding box
  84509. */
  84510. scale(factor: number): BoundingSphere;
  84511. /**
  84512. * Gets the world matrix of the bounding box
  84513. * @returns a matrix
  84514. */
  84515. getWorldMatrix(): DeepImmutable<Matrix>;
  84516. /** @hidden */
  84517. _update(worldMatrix: DeepImmutable<Matrix>): void;
  84518. /**
  84519. * Tests if the bounding sphere is intersecting the frustum planes
  84520. * @param frustumPlanes defines the frustum planes to test
  84521. * @returns true if there is an intersection
  84522. */
  84523. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84524. /**
  84525. * Tests if the bounding sphere center is in between the frustum planes.
  84526. * Used for optimistic fast inclusion.
  84527. * @param frustumPlanes defines the frustum planes to test
  84528. * @returns true if the sphere center is in between the frustum planes
  84529. */
  84530. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84531. /**
  84532. * Tests if a point is inside the bounding sphere
  84533. * @param point defines the point to test
  84534. * @returns true if the point is inside the bounding sphere
  84535. */
  84536. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84537. /**
  84538. * Checks if two sphere intersct
  84539. * @param sphere0 sphere 0
  84540. * @param sphere1 sphere 1
  84541. * @returns true if the speres intersect
  84542. */
  84543. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  84544. }
  84545. }
  84546. declare module BABYLON {
  84547. /**
  84548. * Class used to store bounding box information
  84549. */
  84550. export class BoundingBox implements ICullable {
  84551. /**
  84552. * Gets the 8 vectors representing the bounding box in local space
  84553. */
  84554. readonly vectors: Vector3[];
  84555. /**
  84556. * Gets the center of the bounding box in local space
  84557. */
  84558. readonly center: Vector3;
  84559. /**
  84560. * Gets the center of the bounding box in world space
  84561. */
  84562. readonly centerWorld: Vector3;
  84563. /**
  84564. * Gets the extend size in local space
  84565. */
  84566. readonly extendSize: Vector3;
  84567. /**
  84568. * Gets the extend size in world space
  84569. */
  84570. readonly extendSizeWorld: Vector3;
  84571. /**
  84572. * Gets the OBB (object bounding box) directions
  84573. */
  84574. readonly directions: Vector3[];
  84575. /**
  84576. * Gets the 8 vectors representing the bounding box in world space
  84577. */
  84578. readonly vectorsWorld: Vector3[];
  84579. /**
  84580. * Gets the minimum vector in world space
  84581. */
  84582. readonly minimumWorld: Vector3;
  84583. /**
  84584. * Gets the maximum vector in world space
  84585. */
  84586. readonly maximumWorld: Vector3;
  84587. /**
  84588. * Gets the minimum vector in local space
  84589. */
  84590. readonly minimum: Vector3;
  84591. /**
  84592. * Gets the maximum vector in local space
  84593. */
  84594. readonly maximum: Vector3;
  84595. private _worldMatrix;
  84596. private static readonly TmpVector3;
  84597. /**
  84598. * @hidden
  84599. */
  84600. _tag: number;
  84601. /**
  84602. * Creates a new bounding box
  84603. * @param min defines the minimum vector (in local space)
  84604. * @param max defines the maximum vector (in local space)
  84605. * @param worldMatrix defines the new world matrix
  84606. */
  84607. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84608. /**
  84609. * Recreates the entire bounding box from scratch as if we call the constructor in place
  84610. * @param min defines the new minimum vector (in local space)
  84611. * @param max defines the new maximum vector (in local space)
  84612. * @param worldMatrix defines the new world matrix
  84613. */
  84614. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84615. /**
  84616. * Scale the current bounding box by applying a scale factor
  84617. * @param factor defines the scale factor to apply
  84618. * @returns the current bounding box
  84619. */
  84620. scale(factor: number): BoundingBox;
  84621. /**
  84622. * Gets the world matrix of the bounding box
  84623. * @returns a matrix
  84624. */
  84625. getWorldMatrix(): DeepImmutable<Matrix>;
  84626. /** @hidden */
  84627. _update(world: DeepImmutable<Matrix>): void;
  84628. /**
  84629. * Tests if the bounding box is intersecting the frustum planes
  84630. * @param frustumPlanes defines the frustum planes to test
  84631. * @returns true if there is an intersection
  84632. */
  84633. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84634. /**
  84635. * Tests if the bounding box is entirely inside the frustum planes
  84636. * @param frustumPlanes defines the frustum planes to test
  84637. * @returns true if there is an inclusion
  84638. */
  84639. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84640. /**
  84641. * Tests if a point is inside the bounding box
  84642. * @param point defines the point to test
  84643. * @returns true if the point is inside the bounding box
  84644. */
  84645. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84646. /**
  84647. * Tests if the bounding box intersects with a bounding sphere
  84648. * @param sphere defines the sphere to test
  84649. * @returns true if there is an intersection
  84650. */
  84651. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  84652. /**
  84653. * Tests if the bounding box intersects with a box defined by a min and max vectors
  84654. * @param min defines the min vector to use
  84655. * @param max defines the max vector to use
  84656. * @returns true if there is an intersection
  84657. */
  84658. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  84659. /**
  84660. * Tests if two bounding boxes are intersections
  84661. * @param box0 defines the first box to test
  84662. * @param box1 defines the second box to test
  84663. * @returns true if there is an intersection
  84664. */
  84665. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  84666. /**
  84667. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  84668. * @param minPoint defines the minimum vector of the bounding box
  84669. * @param maxPoint defines the maximum vector of the bounding box
  84670. * @param sphereCenter defines the sphere center
  84671. * @param sphereRadius defines the sphere radius
  84672. * @returns true if there is an intersection
  84673. */
  84674. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  84675. /**
  84676. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  84677. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  84678. * @param frustumPlanes defines the frustum planes to test
  84679. * @return true if there is an inclusion
  84680. */
  84681. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84682. /**
  84683. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  84684. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  84685. * @param frustumPlanes defines the frustum planes to test
  84686. * @return true if there is an intersection
  84687. */
  84688. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84689. }
  84690. }
  84691. declare module BABYLON {
  84692. /** @hidden */
  84693. export class Collider {
  84694. /** Define if a collision was found */
  84695. collisionFound: boolean;
  84696. /**
  84697. * Define last intersection point in local space
  84698. */
  84699. intersectionPoint: Vector3;
  84700. /**
  84701. * Define last collided mesh
  84702. */
  84703. collidedMesh: Nullable<AbstractMesh>;
  84704. private _collisionPoint;
  84705. private _planeIntersectionPoint;
  84706. private _tempVector;
  84707. private _tempVector2;
  84708. private _tempVector3;
  84709. private _tempVector4;
  84710. private _edge;
  84711. private _baseToVertex;
  84712. private _destinationPoint;
  84713. private _slidePlaneNormal;
  84714. private _displacementVector;
  84715. /** @hidden */
  84716. _radius: Vector3;
  84717. /** @hidden */
  84718. _retry: number;
  84719. private _velocity;
  84720. private _basePoint;
  84721. private _epsilon;
  84722. /** @hidden */
  84723. _velocityWorldLength: number;
  84724. /** @hidden */
  84725. _basePointWorld: Vector3;
  84726. private _velocityWorld;
  84727. private _normalizedVelocity;
  84728. /** @hidden */
  84729. _initialVelocity: Vector3;
  84730. /** @hidden */
  84731. _initialPosition: Vector3;
  84732. private _nearestDistance;
  84733. private _collisionMask;
  84734. get collisionMask(): number;
  84735. set collisionMask(mask: number);
  84736. /**
  84737. * Gets the plane normal used to compute the sliding response (in local space)
  84738. */
  84739. get slidePlaneNormal(): Vector3;
  84740. /** @hidden */
  84741. _initialize(source: Vector3, dir: Vector3, e: number): void;
  84742. /** @hidden */
  84743. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  84744. /** @hidden */
  84745. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  84746. /** @hidden */
  84747. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  84748. /** @hidden */
  84749. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  84750. /** @hidden */
  84751. _getResponse(pos: Vector3, vel: Vector3): void;
  84752. }
  84753. }
  84754. declare module BABYLON {
  84755. /**
  84756. * Interface for cullable objects
  84757. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  84758. */
  84759. export interface ICullable {
  84760. /**
  84761. * Checks if the object or part of the object is in the frustum
  84762. * @param frustumPlanes Camera near/planes
  84763. * @returns true if the object is in frustum otherwise false
  84764. */
  84765. isInFrustum(frustumPlanes: Plane[]): boolean;
  84766. /**
  84767. * Checks if a cullable object (mesh...) is in the camera frustum
  84768. * Unlike isInFrustum this cheks the full bounding box
  84769. * @param frustumPlanes Camera near/planes
  84770. * @returns true if the object is in frustum otherwise false
  84771. */
  84772. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84773. }
  84774. /**
  84775. * Info for a bounding data of a mesh
  84776. */
  84777. export class BoundingInfo implements ICullable {
  84778. /**
  84779. * Bounding box for the mesh
  84780. */
  84781. readonly boundingBox: BoundingBox;
  84782. /**
  84783. * Bounding sphere for the mesh
  84784. */
  84785. readonly boundingSphere: BoundingSphere;
  84786. private _isLocked;
  84787. private static readonly TmpVector3;
  84788. /**
  84789. * Constructs bounding info
  84790. * @param minimum min vector of the bounding box/sphere
  84791. * @param maximum max vector of the bounding box/sphere
  84792. * @param worldMatrix defines the new world matrix
  84793. */
  84794. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84795. /**
  84796. * Recreates the entire bounding info from scratch as if we call the constructor in place
  84797. * @param min defines the new minimum vector (in local space)
  84798. * @param max defines the new maximum vector (in local space)
  84799. * @param worldMatrix defines the new world matrix
  84800. */
  84801. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84802. /**
  84803. * min vector of the bounding box/sphere
  84804. */
  84805. get minimum(): Vector3;
  84806. /**
  84807. * max vector of the bounding box/sphere
  84808. */
  84809. get maximum(): Vector3;
  84810. /**
  84811. * If the info is locked and won't be updated to avoid perf overhead
  84812. */
  84813. get isLocked(): boolean;
  84814. set isLocked(value: boolean);
  84815. /**
  84816. * Updates the bounding sphere and box
  84817. * @param world world matrix to be used to update
  84818. */
  84819. update(world: DeepImmutable<Matrix>): void;
  84820. /**
  84821. * Recreate the bounding info to be centered around a specific point given a specific extend.
  84822. * @param center New center of the bounding info
  84823. * @param extend New extend of the bounding info
  84824. * @returns the current bounding info
  84825. */
  84826. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  84827. /**
  84828. * Scale the current bounding info by applying a scale factor
  84829. * @param factor defines the scale factor to apply
  84830. * @returns the current bounding info
  84831. */
  84832. scale(factor: number): BoundingInfo;
  84833. /**
  84834. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  84835. * @param frustumPlanes defines the frustum to test
  84836. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  84837. * @returns true if the bounding info is in the frustum planes
  84838. */
  84839. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  84840. /**
  84841. * Gets the world distance between the min and max points of the bounding box
  84842. */
  84843. get diagonalLength(): number;
  84844. /**
  84845. * Checks if a cullable object (mesh...) is in the camera frustum
  84846. * Unlike isInFrustum this cheks the full bounding box
  84847. * @param frustumPlanes Camera near/planes
  84848. * @returns true if the object is in frustum otherwise false
  84849. */
  84850. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84851. /** @hidden */
  84852. _checkCollision(collider: Collider): boolean;
  84853. /**
  84854. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  84855. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84856. * @param point the point to check intersection with
  84857. * @returns if the point intersects
  84858. */
  84859. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84860. /**
  84861. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  84862. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84863. * @param boundingInfo the bounding info to check intersection with
  84864. * @param precise if the intersection should be done using OBB
  84865. * @returns if the bounding info intersects
  84866. */
  84867. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  84868. }
  84869. }
  84870. declare module BABYLON {
  84871. /**
  84872. * Extracts minimum and maximum values from a list of indexed positions
  84873. * @param positions defines the positions to use
  84874. * @param indices defines the indices to the positions
  84875. * @param indexStart defines the start index
  84876. * @param indexCount defines the end index
  84877. * @param bias defines bias value to add to the result
  84878. * @return minimum and maximum values
  84879. */
  84880. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  84881. minimum: Vector3;
  84882. maximum: Vector3;
  84883. };
  84884. /**
  84885. * Extracts minimum and maximum values from a list of positions
  84886. * @param positions defines the positions to use
  84887. * @param start defines the start index in the positions array
  84888. * @param count defines the number of positions to handle
  84889. * @param bias defines bias value to add to the result
  84890. * @param stride defines the stride size to use (distance between two positions in the positions array)
  84891. * @return minimum and maximum values
  84892. */
  84893. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  84894. minimum: Vector3;
  84895. maximum: Vector3;
  84896. };
  84897. }
  84898. declare module BABYLON {
  84899. /** @hidden */
  84900. export class WebGLDataBuffer extends DataBuffer {
  84901. private _buffer;
  84902. constructor(resource: WebGLBuffer);
  84903. get underlyingResource(): any;
  84904. }
  84905. }
  84906. declare module BABYLON {
  84907. /** @hidden */
  84908. export class WebGLPipelineContext implements IPipelineContext {
  84909. engine: ThinEngine;
  84910. program: Nullable<WebGLProgram>;
  84911. context?: WebGLRenderingContext;
  84912. vertexShader?: WebGLShader;
  84913. fragmentShader?: WebGLShader;
  84914. isParallelCompiled: boolean;
  84915. onCompiled?: () => void;
  84916. transformFeedback?: WebGLTransformFeedback | null;
  84917. vertexCompilationError: Nullable<string>;
  84918. fragmentCompilationError: Nullable<string>;
  84919. programLinkError: Nullable<string>;
  84920. programValidationError: Nullable<string>;
  84921. get isAsync(): boolean;
  84922. get isReady(): boolean;
  84923. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  84924. _getVertexShaderCode(): string | null;
  84925. _getFragmentShaderCode(): string | null;
  84926. }
  84927. }
  84928. declare module BABYLON {
  84929. interface ThinEngine {
  84930. /**
  84931. * Create an uniform buffer
  84932. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84933. * @param elements defines the content of the uniform buffer
  84934. * @returns the webGL uniform buffer
  84935. */
  84936. createUniformBuffer(elements: FloatArray): DataBuffer;
  84937. /**
  84938. * Create a dynamic uniform buffer
  84939. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84940. * @param elements defines the content of the uniform buffer
  84941. * @returns the webGL uniform buffer
  84942. */
  84943. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  84944. /**
  84945. * Update an existing uniform buffer
  84946. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84947. * @param uniformBuffer defines the target uniform buffer
  84948. * @param elements defines the content to update
  84949. * @param offset defines the offset in the uniform buffer where update should start
  84950. * @param count defines the size of the data to update
  84951. */
  84952. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84953. /**
  84954. * Bind an uniform buffer to the current webGL context
  84955. * @param buffer defines the buffer to bind
  84956. */
  84957. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  84958. /**
  84959. * Bind a buffer to the current webGL context at a given location
  84960. * @param buffer defines the buffer to bind
  84961. * @param location defines the index where to bind the buffer
  84962. */
  84963. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  84964. /**
  84965. * Bind a specific block at a given index in a specific shader program
  84966. * @param pipelineContext defines the pipeline context to use
  84967. * @param blockName defines the block name
  84968. * @param index defines the index where to bind the block
  84969. */
  84970. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  84971. }
  84972. }
  84973. declare module BABYLON {
  84974. /**
  84975. * Uniform buffer objects.
  84976. *
  84977. * Handles blocks of uniform on the GPU.
  84978. *
  84979. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84980. *
  84981. * For more information, please refer to :
  84982. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84983. */
  84984. export class UniformBuffer {
  84985. private _engine;
  84986. private _buffer;
  84987. private _data;
  84988. private _bufferData;
  84989. private _dynamic?;
  84990. private _uniformLocations;
  84991. private _uniformSizes;
  84992. private _uniformLocationPointer;
  84993. private _needSync;
  84994. private _noUBO;
  84995. private _currentEffect;
  84996. /** @hidden */
  84997. _alreadyBound: boolean;
  84998. private static _MAX_UNIFORM_SIZE;
  84999. private static _tempBuffer;
  85000. /**
  85001. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  85002. * This is dynamic to allow compat with webgl 1 and 2.
  85003. * You will need to pass the name of the uniform as well as the value.
  85004. */
  85005. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  85006. /**
  85007. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  85008. * This is dynamic to allow compat with webgl 1 and 2.
  85009. * You will need to pass the name of the uniform as well as the value.
  85010. */
  85011. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  85012. /**
  85013. * Lambda to Update a single float in a uniform buffer.
  85014. * This is dynamic to allow compat with webgl 1 and 2.
  85015. * You will need to pass the name of the uniform as well as the value.
  85016. */
  85017. updateFloat: (name: string, x: number) => void;
  85018. /**
  85019. * Lambda to Update a vec2 of float in a uniform buffer.
  85020. * This is dynamic to allow compat with webgl 1 and 2.
  85021. * You will need to pass the name of the uniform as well as the value.
  85022. */
  85023. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  85024. /**
  85025. * Lambda to Update a vec3 of float in a uniform buffer.
  85026. * This is dynamic to allow compat with webgl 1 and 2.
  85027. * You will need to pass the name of the uniform as well as the value.
  85028. */
  85029. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  85030. /**
  85031. * Lambda to Update a vec4 of float in a uniform buffer.
  85032. * This is dynamic to allow compat with webgl 1 and 2.
  85033. * You will need to pass the name of the uniform as well as the value.
  85034. */
  85035. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  85036. /**
  85037. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  85038. * This is dynamic to allow compat with webgl 1 and 2.
  85039. * You will need to pass the name of the uniform as well as the value.
  85040. */
  85041. updateMatrix: (name: string, mat: Matrix) => void;
  85042. /**
  85043. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  85044. * This is dynamic to allow compat with webgl 1 and 2.
  85045. * You will need to pass the name of the uniform as well as the value.
  85046. */
  85047. updateVector3: (name: string, vector: Vector3) => void;
  85048. /**
  85049. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  85050. * This is dynamic to allow compat with webgl 1 and 2.
  85051. * You will need to pass the name of the uniform as well as the value.
  85052. */
  85053. updateVector4: (name: string, vector: Vector4) => void;
  85054. /**
  85055. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  85056. * This is dynamic to allow compat with webgl 1 and 2.
  85057. * You will need to pass the name of the uniform as well as the value.
  85058. */
  85059. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  85060. /**
  85061. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85062. * This is dynamic to allow compat with webgl 1 and 2.
  85063. * You will need to pass the name of the uniform as well as the value.
  85064. */
  85065. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85066. /**
  85067. * Instantiates a new Uniform buffer objects.
  85068. *
  85069. * Handles blocks of uniform on the GPU.
  85070. *
  85071. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85072. *
  85073. * For more information, please refer to :
  85074. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85075. * @param engine Define the engine the buffer is associated with
  85076. * @param data Define the data contained in the buffer
  85077. * @param dynamic Define if the buffer is updatable
  85078. */
  85079. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85080. /**
  85081. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85082. * or just falling back on setUniformXXX calls.
  85083. */
  85084. get useUbo(): boolean;
  85085. /**
  85086. * Indicates if the WebGL underlying uniform buffer is in sync
  85087. * with the javascript cache data.
  85088. */
  85089. get isSync(): boolean;
  85090. /**
  85091. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85092. * Also, a dynamic UniformBuffer will disable cache verification and always
  85093. * update the underlying WebGL uniform buffer to the GPU.
  85094. * @returns if Dynamic, otherwise false
  85095. */
  85096. isDynamic(): boolean;
  85097. /**
  85098. * The data cache on JS side.
  85099. * @returns the underlying data as a float array
  85100. */
  85101. getData(): Float32Array;
  85102. /**
  85103. * The underlying WebGL Uniform buffer.
  85104. * @returns the webgl buffer
  85105. */
  85106. getBuffer(): Nullable<DataBuffer>;
  85107. /**
  85108. * std140 layout specifies how to align data within an UBO structure.
  85109. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85110. * for specs.
  85111. */
  85112. private _fillAlignment;
  85113. /**
  85114. * Adds an uniform in the buffer.
  85115. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85116. * for the layout to be correct !
  85117. * @param name Name of the uniform, as used in the uniform block in the shader.
  85118. * @param size Data size, or data directly.
  85119. */
  85120. addUniform(name: string, size: number | number[]): void;
  85121. /**
  85122. * Adds a Matrix 4x4 to the uniform buffer.
  85123. * @param name Name of the uniform, as used in the uniform block in the shader.
  85124. * @param mat A 4x4 matrix.
  85125. */
  85126. addMatrix(name: string, mat: Matrix): void;
  85127. /**
  85128. * Adds a vec2 to the uniform buffer.
  85129. * @param name Name of the uniform, as used in the uniform block in the shader.
  85130. * @param x Define the x component value of the vec2
  85131. * @param y Define the y component value of the vec2
  85132. */
  85133. addFloat2(name: string, x: number, y: number): void;
  85134. /**
  85135. * Adds a vec3 to the uniform buffer.
  85136. * @param name Name of the uniform, as used in the uniform block in the shader.
  85137. * @param x Define the x component value of the vec3
  85138. * @param y Define the y component value of the vec3
  85139. * @param z Define the z component value of the vec3
  85140. */
  85141. addFloat3(name: string, x: number, y: number, z: number): void;
  85142. /**
  85143. * Adds a vec3 to the uniform buffer.
  85144. * @param name Name of the uniform, as used in the uniform block in the shader.
  85145. * @param color Define the vec3 from a Color
  85146. */
  85147. addColor3(name: string, color: Color3): void;
  85148. /**
  85149. * Adds a vec4 to the uniform buffer.
  85150. * @param name Name of the uniform, as used in the uniform block in the shader.
  85151. * @param color Define the rgb components from a Color
  85152. * @param alpha Define the a component of the vec4
  85153. */
  85154. addColor4(name: string, color: Color3, alpha: number): void;
  85155. /**
  85156. * Adds a vec3 to the uniform buffer.
  85157. * @param name Name of the uniform, as used in the uniform block in the shader.
  85158. * @param vector Define the vec3 components from a Vector
  85159. */
  85160. addVector3(name: string, vector: Vector3): void;
  85161. /**
  85162. * Adds a Matrix 3x3 to the uniform buffer.
  85163. * @param name Name of the uniform, as used in the uniform block in the shader.
  85164. */
  85165. addMatrix3x3(name: string): void;
  85166. /**
  85167. * Adds a Matrix 2x2 to the uniform buffer.
  85168. * @param name Name of the uniform, as used in the uniform block in the shader.
  85169. */
  85170. addMatrix2x2(name: string): void;
  85171. /**
  85172. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  85173. */
  85174. create(): void;
  85175. /** @hidden */
  85176. _rebuild(): void;
  85177. /**
  85178. * Updates the WebGL Uniform Buffer on the GPU.
  85179. * If the `dynamic` flag is set to true, no cache comparison is done.
  85180. * Otherwise, the buffer will be updated only if the cache differs.
  85181. */
  85182. update(): void;
  85183. /**
  85184. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85185. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85186. * @param data Define the flattened data
  85187. * @param size Define the size of the data.
  85188. */
  85189. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85190. private _valueCache;
  85191. private _cacheMatrix;
  85192. private _updateMatrix3x3ForUniform;
  85193. private _updateMatrix3x3ForEffect;
  85194. private _updateMatrix2x2ForEffect;
  85195. private _updateMatrix2x2ForUniform;
  85196. private _updateFloatForEffect;
  85197. private _updateFloatForUniform;
  85198. private _updateFloat2ForEffect;
  85199. private _updateFloat2ForUniform;
  85200. private _updateFloat3ForEffect;
  85201. private _updateFloat3ForUniform;
  85202. private _updateFloat4ForEffect;
  85203. private _updateFloat4ForUniform;
  85204. private _updateMatrixForEffect;
  85205. private _updateMatrixForUniform;
  85206. private _updateVector3ForEffect;
  85207. private _updateVector3ForUniform;
  85208. private _updateVector4ForEffect;
  85209. private _updateVector4ForUniform;
  85210. private _updateColor3ForEffect;
  85211. private _updateColor3ForUniform;
  85212. private _updateColor4ForEffect;
  85213. private _updateColor4ForUniform;
  85214. /**
  85215. * Sets a sampler uniform on the effect.
  85216. * @param name Define the name of the sampler.
  85217. * @param texture Define the texture to set in the sampler
  85218. */
  85219. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  85220. /**
  85221. * Directly updates the value of the uniform in the cache AND on the GPU.
  85222. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85223. * @param data Define the flattened data
  85224. */
  85225. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  85226. /**
  85227. * Binds this uniform buffer to an effect.
  85228. * @param effect Define the effect to bind the buffer to
  85229. * @param name Name of the uniform block in the shader.
  85230. */
  85231. bindToEffect(effect: Effect, name: string): void;
  85232. /**
  85233. * Disposes the uniform buffer.
  85234. */
  85235. dispose(): void;
  85236. }
  85237. }
  85238. declare module BABYLON {
  85239. /**
  85240. * Enum that determines the text-wrapping mode to use.
  85241. */
  85242. export enum InspectableType {
  85243. /**
  85244. * Checkbox for booleans
  85245. */
  85246. Checkbox = 0,
  85247. /**
  85248. * Sliders for numbers
  85249. */
  85250. Slider = 1,
  85251. /**
  85252. * Vector3
  85253. */
  85254. Vector3 = 2,
  85255. /**
  85256. * Quaternions
  85257. */
  85258. Quaternion = 3,
  85259. /**
  85260. * Color3
  85261. */
  85262. Color3 = 4,
  85263. /**
  85264. * String
  85265. */
  85266. String = 5
  85267. }
  85268. /**
  85269. * Interface used to define custom inspectable properties.
  85270. * This interface is used by the inspector to display custom property grids
  85271. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85272. */
  85273. export interface IInspectable {
  85274. /**
  85275. * Gets the label to display
  85276. */
  85277. label: string;
  85278. /**
  85279. * Gets the name of the property to edit
  85280. */
  85281. propertyName: string;
  85282. /**
  85283. * Gets the type of the editor to use
  85284. */
  85285. type: InspectableType;
  85286. /**
  85287. * Gets the minimum value of the property when using in "slider" mode
  85288. */
  85289. min?: number;
  85290. /**
  85291. * Gets the maximum value of the property when using in "slider" mode
  85292. */
  85293. max?: number;
  85294. /**
  85295. * Gets the setp to use when using in "slider" mode
  85296. */
  85297. step?: number;
  85298. }
  85299. }
  85300. declare module BABYLON {
  85301. /**
  85302. * Class used to provide helper for timing
  85303. */
  85304. export class TimingTools {
  85305. /**
  85306. * Polyfill for setImmediate
  85307. * @param action defines the action to execute after the current execution block
  85308. */
  85309. static SetImmediate(action: () => void): void;
  85310. }
  85311. }
  85312. declare module BABYLON {
  85313. /**
  85314. * Class used to enable instatition of objects by class name
  85315. */
  85316. export class InstantiationTools {
  85317. /**
  85318. * Use this object to register external classes like custom textures or material
  85319. * to allow the laoders to instantiate them
  85320. */
  85321. static RegisteredExternalClasses: {
  85322. [key: string]: Object;
  85323. };
  85324. /**
  85325. * Tries to instantiate a new object from a given class name
  85326. * @param className defines the class name to instantiate
  85327. * @returns the new object or null if the system was not able to do the instantiation
  85328. */
  85329. static Instantiate(className: string): any;
  85330. }
  85331. }
  85332. declare module BABYLON {
  85333. /**
  85334. * Define options used to create a depth texture
  85335. */
  85336. export class DepthTextureCreationOptions {
  85337. /** Specifies whether or not a stencil should be allocated in the texture */
  85338. generateStencil?: boolean;
  85339. /** Specifies whether or not bilinear filtering is enable on the texture */
  85340. bilinearFiltering?: boolean;
  85341. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  85342. comparisonFunction?: number;
  85343. /** Specifies if the created texture is a cube texture */
  85344. isCube?: boolean;
  85345. }
  85346. }
  85347. declare module BABYLON {
  85348. interface ThinEngine {
  85349. /**
  85350. * Creates a depth stencil cube texture.
  85351. * This is only available in WebGL 2.
  85352. * @param size The size of face edge in the cube texture.
  85353. * @param options The options defining the cube texture.
  85354. * @returns The cube texture
  85355. */
  85356. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  85357. /**
  85358. * Creates a cube texture
  85359. * @param rootUrl defines the url where the files to load is located
  85360. * @param scene defines the current scene
  85361. * @param files defines the list of files to load (1 per face)
  85362. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85363. * @param onLoad defines an optional callback raised when the texture is loaded
  85364. * @param onError defines an optional callback raised if there is an issue to load the texture
  85365. * @param format defines the format of the data
  85366. * @param forcedExtension defines the extension to use to pick the right loader
  85367. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85368. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85369. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85370. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85371. * @returns the cube texture as an InternalTexture
  85372. */
  85373. 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;
  85374. /**
  85375. * Creates a cube texture
  85376. * @param rootUrl defines the url where the files to load is located
  85377. * @param scene defines the current scene
  85378. * @param files defines the list of files to load (1 per face)
  85379. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85380. * @param onLoad defines an optional callback raised when the texture is loaded
  85381. * @param onError defines an optional callback raised if there is an issue to load the texture
  85382. * @param format defines the format of the data
  85383. * @param forcedExtension defines the extension to use to pick the right loader
  85384. * @returns the cube texture as an InternalTexture
  85385. */
  85386. 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;
  85387. /**
  85388. * Creates a cube texture
  85389. * @param rootUrl defines the url where the files to load is located
  85390. * @param scene defines the current scene
  85391. * @param files defines the list of files to load (1 per face)
  85392. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85393. * @param onLoad defines an optional callback raised when the texture is loaded
  85394. * @param onError defines an optional callback raised if there is an issue to load the texture
  85395. * @param format defines the format of the data
  85396. * @param forcedExtension defines the extension to use to pick the right loader
  85397. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85398. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85399. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85400. * @returns the cube texture as an InternalTexture
  85401. */
  85402. 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;
  85403. /** @hidden */
  85404. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  85405. /** @hidden */
  85406. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  85407. /** @hidden */
  85408. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  85409. /** @hidden */
  85410. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  85411. /**
  85412. * @hidden
  85413. */
  85414. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85415. }
  85416. }
  85417. declare module BABYLON {
  85418. /**
  85419. * Class for creating a cube texture
  85420. */
  85421. export class CubeTexture extends BaseTexture {
  85422. private _delayedOnLoad;
  85423. /**
  85424. * Observable triggered once the texture has been loaded.
  85425. */
  85426. onLoadObservable: Observable<CubeTexture>;
  85427. /**
  85428. * The url of the texture
  85429. */
  85430. url: string;
  85431. /**
  85432. * Gets or sets the center of the bounding box associated with the cube texture.
  85433. * It must define where the camera used to render the texture was set
  85434. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  85435. */
  85436. boundingBoxPosition: Vector3;
  85437. private _boundingBoxSize;
  85438. /**
  85439. * Gets or sets the size of the bounding box associated with the cube texture
  85440. * When defined, the cubemap will switch to local mode
  85441. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85442. * @example https://www.babylonjs-playground.com/#RNASML
  85443. */
  85444. set boundingBoxSize(value: Vector3);
  85445. /**
  85446. * Returns the bounding box size
  85447. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  85448. */
  85449. get boundingBoxSize(): Vector3;
  85450. protected _rotationY: number;
  85451. /**
  85452. * Sets texture matrix rotation angle around Y axis in radians.
  85453. */
  85454. set rotationY(value: number);
  85455. /**
  85456. * Gets texture matrix rotation angle around Y axis radians.
  85457. */
  85458. get rotationY(): number;
  85459. /**
  85460. * Are mip maps generated for this texture or not.
  85461. */
  85462. get noMipmap(): boolean;
  85463. private _noMipmap;
  85464. private _files;
  85465. protected _forcedExtension: Nullable<string>;
  85466. private _extensions;
  85467. private _textureMatrix;
  85468. private _format;
  85469. private _createPolynomials;
  85470. /**
  85471. * Creates a cube texture from an array of image urls
  85472. * @param files defines an array of image urls
  85473. * @param scene defines the hosting scene
  85474. * @param noMipmap specifies if mip maps are not used
  85475. * @returns a cube texture
  85476. */
  85477. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  85478. /**
  85479. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  85480. * @param url defines the url of the prefiltered texture
  85481. * @param scene defines the scene the texture is attached to
  85482. * @param forcedExtension defines the extension of the file if different from the url
  85483. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  85484. * @return the prefiltered texture
  85485. */
  85486. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  85487. /**
  85488. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  85489. * as prefiltered data.
  85490. * @param rootUrl defines the url of the texture or the root name of the six images
  85491. * @param null defines the scene or engine the texture is attached to
  85492. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  85493. * @param noMipmap defines if mipmaps should be created or not
  85494. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  85495. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  85496. * @param onError defines a callback triggered in case of error during load
  85497. * @param format defines the internal format to use for the texture once loaded
  85498. * @param prefiltered defines whether or not the texture is created from prefiltered data
  85499. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  85500. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  85501. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85502. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85503. * @return the cube texture
  85504. */
  85505. 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);
  85506. /**
  85507. * Get the current class name of the texture useful for serialization or dynamic coding.
  85508. * @returns "CubeTexture"
  85509. */
  85510. getClassName(): string;
  85511. /**
  85512. * Update the url (and optional buffer) of this texture if url was null during construction.
  85513. * @param url the url of the texture
  85514. * @param forcedExtension defines the extension to use
  85515. * @param onLoad callback called when the texture is loaded (defaults to null)
  85516. * @param prefiltered Defines whether the updated texture is prefiltered or not
  85517. */
  85518. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  85519. /**
  85520. * Delays loading of the cube texture
  85521. * @param forcedExtension defines the extension to use
  85522. */
  85523. delayLoad(forcedExtension?: string): void;
  85524. /**
  85525. * Returns the reflection texture matrix
  85526. * @returns the reflection texture matrix
  85527. */
  85528. getReflectionTextureMatrix(): Matrix;
  85529. /**
  85530. * Sets the reflection texture matrix
  85531. * @param value Reflection texture matrix
  85532. */
  85533. setReflectionTextureMatrix(value: Matrix): void;
  85534. /**
  85535. * Parses text to create a cube texture
  85536. * @param parsedTexture define the serialized text to read from
  85537. * @param scene defines the hosting scene
  85538. * @param rootUrl defines the root url of the cube texture
  85539. * @returns a cube texture
  85540. */
  85541. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  85542. /**
  85543. * Makes a clone, or deep copy, of the cube texture
  85544. * @returns a new cube texture
  85545. */
  85546. clone(): CubeTexture;
  85547. }
  85548. }
  85549. declare module BABYLON {
  85550. /**
  85551. * Manages the defines for the Material
  85552. */
  85553. export class MaterialDefines {
  85554. /** @hidden */
  85555. protected _keys: string[];
  85556. private _isDirty;
  85557. /** @hidden */
  85558. _renderId: number;
  85559. /** @hidden */
  85560. _areLightsDirty: boolean;
  85561. /** @hidden */
  85562. _areLightsDisposed: boolean;
  85563. /** @hidden */
  85564. _areAttributesDirty: boolean;
  85565. /** @hidden */
  85566. _areTexturesDirty: boolean;
  85567. /** @hidden */
  85568. _areFresnelDirty: boolean;
  85569. /** @hidden */
  85570. _areMiscDirty: boolean;
  85571. /** @hidden */
  85572. _areImageProcessingDirty: boolean;
  85573. /** @hidden */
  85574. _normals: boolean;
  85575. /** @hidden */
  85576. _uvs: boolean;
  85577. /** @hidden */
  85578. _needNormals: boolean;
  85579. /** @hidden */
  85580. _needUVs: boolean;
  85581. [id: string]: any;
  85582. /**
  85583. * Specifies if the material needs to be re-calculated
  85584. */
  85585. get isDirty(): boolean;
  85586. /**
  85587. * Marks the material to indicate that it has been re-calculated
  85588. */
  85589. markAsProcessed(): void;
  85590. /**
  85591. * Marks the material to indicate that it needs to be re-calculated
  85592. */
  85593. markAsUnprocessed(): void;
  85594. /**
  85595. * Marks the material to indicate all of its defines need to be re-calculated
  85596. */
  85597. markAllAsDirty(): void;
  85598. /**
  85599. * Marks the material to indicate that image processing needs to be re-calculated
  85600. */
  85601. markAsImageProcessingDirty(): void;
  85602. /**
  85603. * Marks the material to indicate the lights need to be re-calculated
  85604. * @param disposed Defines whether the light is dirty due to dispose or not
  85605. */
  85606. markAsLightDirty(disposed?: boolean): void;
  85607. /**
  85608. * Marks the attribute state as changed
  85609. */
  85610. markAsAttributesDirty(): void;
  85611. /**
  85612. * Marks the texture state as changed
  85613. */
  85614. markAsTexturesDirty(): void;
  85615. /**
  85616. * Marks the fresnel state as changed
  85617. */
  85618. markAsFresnelDirty(): void;
  85619. /**
  85620. * Marks the misc state as changed
  85621. */
  85622. markAsMiscDirty(): void;
  85623. /**
  85624. * Rebuilds the material defines
  85625. */
  85626. rebuild(): void;
  85627. /**
  85628. * Specifies if two material defines are equal
  85629. * @param other - A material define instance to compare to
  85630. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  85631. */
  85632. isEqual(other: MaterialDefines): boolean;
  85633. /**
  85634. * Clones this instance's defines to another instance
  85635. * @param other - material defines to clone values to
  85636. */
  85637. cloneTo(other: MaterialDefines): void;
  85638. /**
  85639. * Resets the material define values
  85640. */
  85641. reset(): void;
  85642. /**
  85643. * Converts the material define values to a string
  85644. * @returns - String of material define information
  85645. */
  85646. toString(): string;
  85647. }
  85648. }
  85649. declare module BABYLON {
  85650. /**
  85651. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  85652. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  85653. * 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;
  85654. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  85655. */
  85656. export class ColorCurves {
  85657. private _dirty;
  85658. private _tempColor;
  85659. private _globalCurve;
  85660. private _highlightsCurve;
  85661. private _midtonesCurve;
  85662. private _shadowsCurve;
  85663. private _positiveCurve;
  85664. private _negativeCurve;
  85665. private _globalHue;
  85666. private _globalDensity;
  85667. private _globalSaturation;
  85668. private _globalExposure;
  85669. /**
  85670. * Gets the global Hue value.
  85671. * 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).
  85672. */
  85673. get globalHue(): number;
  85674. /**
  85675. * Sets the global Hue value.
  85676. * 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).
  85677. */
  85678. set globalHue(value: number);
  85679. /**
  85680. * Gets the global Density value.
  85681. * 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.
  85682. * Values less than zero provide a filter of opposite hue.
  85683. */
  85684. get globalDensity(): number;
  85685. /**
  85686. * Sets the global Density value.
  85687. * 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.
  85688. * Values less than zero provide a filter of opposite hue.
  85689. */
  85690. set globalDensity(value: number);
  85691. /**
  85692. * Gets the global Saturation value.
  85693. * 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.
  85694. */
  85695. get globalSaturation(): number;
  85696. /**
  85697. * Sets the global Saturation value.
  85698. * 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.
  85699. */
  85700. set globalSaturation(value: number);
  85701. /**
  85702. * Gets the global Exposure value.
  85703. * 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.
  85704. */
  85705. get globalExposure(): number;
  85706. /**
  85707. * Sets the global Exposure value.
  85708. * 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.
  85709. */
  85710. set globalExposure(value: number);
  85711. private _highlightsHue;
  85712. private _highlightsDensity;
  85713. private _highlightsSaturation;
  85714. private _highlightsExposure;
  85715. /**
  85716. * Gets the highlights Hue value.
  85717. * 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).
  85718. */
  85719. get highlightsHue(): number;
  85720. /**
  85721. * Sets the highlights Hue value.
  85722. * 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).
  85723. */
  85724. set highlightsHue(value: number);
  85725. /**
  85726. * Gets the highlights Density value.
  85727. * 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.
  85728. * Values less than zero provide a filter of opposite hue.
  85729. */
  85730. get highlightsDensity(): number;
  85731. /**
  85732. * Sets the highlights Density value.
  85733. * 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.
  85734. * Values less than zero provide a filter of opposite hue.
  85735. */
  85736. set highlightsDensity(value: number);
  85737. /**
  85738. * Gets the highlights Saturation value.
  85739. * 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.
  85740. */
  85741. get highlightsSaturation(): number;
  85742. /**
  85743. * Sets the highlights Saturation value.
  85744. * 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.
  85745. */
  85746. set highlightsSaturation(value: number);
  85747. /**
  85748. * Gets the highlights Exposure value.
  85749. * 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.
  85750. */
  85751. get highlightsExposure(): number;
  85752. /**
  85753. * Sets the highlights Exposure value.
  85754. * 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.
  85755. */
  85756. set highlightsExposure(value: number);
  85757. private _midtonesHue;
  85758. private _midtonesDensity;
  85759. private _midtonesSaturation;
  85760. private _midtonesExposure;
  85761. /**
  85762. * Gets the midtones Hue value.
  85763. * 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).
  85764. */
  85765. get midtonesHue(): number;
  85766. /**
  85767. * Sets the midtones Hue value.
  85768. * 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).
  85769. */
  85770. set midtonesHue(value: number);
  85771. /**
  85772. * Gets the midtones Density value.
  85773. * 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.
  85774. * Values less than zero provide a filter of opposite hue.
  85775. */
  85776. get midtonesDensity(): number;
  85777. /**
  85778. * Sets the midtones Density value.
  85779. * 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.
  85780. * Values less than zero provide a filter of opposite hue.
  85781. */
  85782. set midtonesDensity(value: number);
  85783. /**
  85784. * Gets the midtones Saturation value.
  85785. * 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.
  85786. */
  85787. get midtonesSaturation(): number;
  85788. /**
  85789. * Sets the midtones Saturation value.
  85790. * 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.
  85791. */
  85792. set midtonesSaturation(value: number);
  85793. /**
  85794. * Gets the midtones Exposure value.
  85795. * 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.
  85796. */
  85797. get midtonesExposure(): number;
  85798. /**
  85799. * Sets the midtones Exposure value.
  85800. * 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.
  85801. */
  85802. set midtonesExposure(value: number);
  85803. private _shadowsHue;
  85804. private _shadowsDensity;
  85805. private _shadowsSaturation;
  85806. private _shadowsExposure;
  85807. /**
  85808. * Gets the shadows Hue value.
  85809. * 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).
  85810. */
  85811. get shadowsHue(): number;
  85812. /**
  85813. * Sets the shadows Hue value.
  85814. * 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).
  85815. */
  85816. set shadowsHue(value: number);
  85817. /**
  85818. * Gets the shadows Density value.
  85819. * 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.
  85820. * Values less than zero provide a filter of opposite hue.
  85821. */
  85822. get shadowsDensity(): number;
  85823. /**
  85824. * Sets the shadows Density value.
  85825. * 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.
  85826. * Values less than zero provide a filter of opposite hue.
  85827. */
  85828. set shadowsDensity(value: number);
  85829. /**
  85830. * Gets the shadows Saturation value.
  85831. * 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.
  85832. */
  85833. get shadowsSaturation(): number;
  85834. /**
  85835. * Sets the shadows Saturation value.
  85836. * 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.
  85837. */
  85838. set shadowsSaturation(value: number);
  85839. /**
  85840. * Gets the shadows Exposure value.
  85841. * 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.
  85842. */
  85843. get shadowsExposure(): number;
  85844. /**
  85845. * Sets the shadows Exposure value.
  85846. * 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.
  85847. */
  85848. set shadowsExposure(value: number);
  85849. /**
  85850. * Returns the class name
  85851. * @returns The class name
  85852. */
  85853. getClassName(): string;
  85854. /**
  85855. * Binds the color curves to the shader.
  85856. * @param colorCurves The color curve to bind
  85857. * @param effect The effect to bind to
  85858. * @param positiveUniform The positive uniform shader parameter
  85859. * @param neutralUniform The neutral uniform shader parameter
  85860. * @param negativeUniform The negative uniform shader parameter
  85861. */
  85862. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  85863. /**
  85864. * Prepare the list of uniforms associated with the ColorCurves effects.
  85865. * @param uniformsList The list of uniforms used in the effect
  85866. */
  85867. static PrepareUniforms(uniformsList: string[]): void;
  85868. /**
  85869. * Returns color grading data based on a hue, density, saturation and exposure value.
  85870. * @param filterHue The hue of the color filter.
  85871. * @param filterDensity The density of the color filter.
  85872. * @param saturation The saturation.
  85873. * @param exposure The exposure.
  85874. * @param result The result data container.
  85875. */
  85876. private getColorGradingDataToRef;
  85877. /**
  85878. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  85879. * @param value The input slider value in range [-100,100].
  85880. * @returns Adjusted value.
  85881. */
  85882. private static applyColorGradingSliderNonlinear;
  85883. /**
  85884. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  85885. * @param hue The hue (H) input.
  85886. * @param saturation The saturation (S) input.
  85887. * @param brightness The brightness (B) input.
  85888. * @result An RGBA color represented as Vector4.
  85889. */
  85890. private static fromHSBToRef;
  85891. /**
  85892. * Returns a value clamped between min and max
  85893. * @param value The value to clamp
  85894. * @param min The minimum of value
  85895. * @param max The maximum of value
  85896. * @returns The clamped value.
  85897. */
  85898. private static clamp;
  85899. /**
  85900. * Clones the current color curve instance.
  85901. * @return The cloned curves
  85902. */
  85903. clone(): ColorCurves;
  85904. /**
  85905. * Serializes the current color curve instance to a json representation.
  85906. * @return a JSON representation
  85907. */
  85908. serialize(): any;
  85909. /**
  85910. * Parses the color curve from a json representation.
  85911. * @param source the JSON source to parse
  85912. * @return The parsed curves
  85913. */
  85914. static Parse(source: any): ColorCurves;
  85915. }
  85916. }
  85917. declare module BABYLON {
  85918. /**
  85919. * Interface to follow in your material defines to integrate easily the
  85920. * Image proccessing functions.
  85921. * @hidden
  85922. */
  85923. export interface IImageProcessingConfigurationDefines {
  85924. IMAGEPROCESSING: boolean;
  85925. VIGNETTE: boolean;
  85926. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85927. VIGNETTEBLENDMODEOPAQUE: boolean;
  85928. TONEMAPPING: boolean;
  85929. TONEMAPPING_ACES: boolean;
  85930. CONTRAST: boolean;
  85931. EXPOSURE: boolean;
  85932. COLORCURVES: boolean;
  85933. COLORGRADING: boolean;
  85934. COLORGRADING3D: boolean;
  85935. SAMPLER3DGREENDEPTH: boolean;
  85936. SAMPLER3DBGRMAP: boolean;
  85937. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85938. }
  85939. /**
  85940. * @hidden
  85941. */
  85942. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  85943. IMAGEPROCESSING: boolean;
  85944. VIGNETTE: boolean;
  85945. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85946. VIGNETTEBLENDMODEOPAQUE: boolean;
  85947. TONEMAPPING: boolean;
  85948. TONEMAPPING_ACES: boolean;
  85949. CONTRAST: boolean;
  85950. COLORCURVES: boolean;
  85951. COLORGRADING: boolean;
  85952. COLORGRADING3D: boolean;
  85953. SAMPLER3DGREENDEPTH: boolean;
  85954. SAMPLER3DBGRMAP: boolean;
  85955. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85956. EXPOSURE: boolean;
  85957. constructor();
  85958. }
  85959. /**
  85960. * This groups together the common properties used for image processing either in direct forward pass
  85961. * or through post processing effect depending on the use of the image processing pipeline in your scene
  85962. * or not.
  85963. */
  85964. export class ImageProcessingConfiguration {
  85965. /**
  85966. * Default tone mapping applied in BabylonJS.
  85967. */
  85968. static readonly TONEMAPPING_STANDARD: number;
  85969. /**
  85970. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  85971. * to other engines rendering to increase portability.
  85972. */
  85973. static readonly TONEMAPPING_ACES: number;
  85974. /**
  85975. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  85976. */
  85977. colorCurves: Nullable<ColorCurves>;
  85978. private _colorCurvesEnabled;
  85979. /**
  85980. * Gets wether the color curves effect is enabled.
  85981. */
  85982. get colorCurvesEnabled(): boolean;
  85983. /**
  85984. * Sets wether the color curves effect is enabled.
  85985. */
  85986. set colorCurvesEnabled(value: boolean);
  85987. private _colorGradingTexture;
  85988. /**
  85989. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85990. */
  85991. get colorGradingTexture(): Nullable<BaseTexture>;
  85992. /**
  85993. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85994. */
  85995. set colorGradingTexture(value: Nullable<BaseTexture>);
  85996. private _colorGradingEnabled;
  85997. /**
  85998. * Gets wether the color grading effect is enabled.
  85999. */
  86000. get colorGradingEnabled(): boolean;
  86001. /**
  86002. * Sets wether the color grading effect is enabled.
  86003. */
  86004. set colorGradingEnabled(value: boolean);
  86005. private _colorGradingWithGreenDepth;
  86006. /**
  86007. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86008. */
  86009. get colorGradingWithGreenDepth(): boolean;
  86010. /**
  86011. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86012. */
  86013. set colorGradingWithGreenDepth(value: boolean);
  86014. private _colorGradingBGR;
  86015. /**
  86016. * Gets wether the color grading texture contains BGR values.
  86017. */
  86018. get colorGradingBGR(): boolean;
  86019. /**
  86020. * Sets wether the color grading texture contains BGR values.
  86021. */
  86022. set colorGradingBGR(value: boolean);
  86023. /** @hidden */
  86024. _exposure: number;
  86025. /**
  86026. * Gets the Exposure used in the effect.
  86027. */
  86028. get exposure(): number;
  86029. /**
  86030. * Sets the Exposure used in the effect.
  86031. */
  86032. set exposure(value: number);
  86033. private _toneMappingEnabled;
  86034. /**
  86035. * Gets wether the tone mapping effect is enabled.
  86036. */
  86037. get toneMappingEnabled(): boolean;
  86038. /**
  86039. * Sets wether the tone mapping effect is enabled.
  86040. */
  86041. set toneMappingEnabled(value: boolean);
  86042. private _toneMappingType;
  86043. /**
  86044. * Gets the type of tone mapping effect.
  86045. */
  86046. get toneMappingType(): number;
  86047. /**
  86048. * Sets the type of tone mapping effect used in BabylonJS.
  86049. */
  86050. set toneMappingType(value: number);
  86051. protected _contrast: number;
  86052. /**
  86053. * Gets the contrast used in the effect.
  86054. */
  86055. get contrast(): number;
  86056. /**
  86057. * Sets the contrast used in the effect.
  86058. */
  86059. set contrast(value: number);
  86060. /**
  86061. * Vignette stretch size.
  86062. */
  86063. vignetteStretch: number;
  86064. /**
  86065. * Vignette centre X Offset.
  86066. */
  86067. vignetteCentreX: number;
  86068. /**
  86069. * Vignette centre Y Offset.
  86070. */
  86071. vignetteCentreY: number;
  86072. /**
  86073. * Vignette weight or intensity of the vignette effect.
  86074. */
  86075. vignetteWeight: number;
  86076. /**
  86077. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86078. * if vignetteEnabled is set to true.
  86079. */
  86080. vignetteColor: Color4;
  86081. /**
  86082. * Camera field of view used by the Vignette effect.
  86083. */
  86084. vignetteCameraFov: number;
  86085. private _vignetteBlendMode;
  86086. /**
  86087. * Gets the vignette blend mode allowing different kind of effect.
  86088. */
  86089. get vignetteBlendMode(): number;
  86090. /**
  86091. * Sets the vignette blend mode allowing different kind of effect.
  86092. */
  86093. set vignetteBlendMode(value: number);
  86094. private _vignetteEnabled;
  86095. /**
  86096. * Gets wether the vignette effect is enabled.
  86097. */
  86098. get vignetteEnabled(): boolean;
  86099. /**
  86100. * Sets wether the vignette effect is enabled.
  86101. */
  86102. set vignetteEnabled(value: boolean);
  86103. private _applyByPostProcess;
  86104. /**
  86105. * Gets wether the image processing is applied through a post process or not.
  86106. */
  86107. get applyByPostProcess(): boolean;
  86108. /**
  86109. * Sets wether the image processing is applied through a post process or not.
  86110. */
  86111. set applyByPostProcess(value: boolean);
  86112. private _isEnabled;
  86113. /**
  86114. * Gets wether the image processing is enabled or not.
  86115. */
  86116. get isEnabled(): boolean;
  86117. /**
  86118. * Sets wether the image processing is enabled or not.
  86119. */
  86120. set isEnabled(value: boolean);
  86121. /**
  86122. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86123. */
  86124. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86125. /**
  86126. * Method called each time the image processing information changes requires to recompile the effect.
  86127. */
  86128. protected _updateParameters(): void;
  86129. /**
  86130. * Gets the current class name.
  86131. * @return "ImageProcessingConfiguration"
  86132. */
  86133. getClassName(): string;
  86134. /**
  86135. * Prepare the list of uniforms associated with the Image Processing effects.
  86136. * @param uniforms The list of uniforms used in the effect
  86137. * @param defines the list of defines currently in use
  86138. */
  86139. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86140. /**
  86141. * Prepare the list of samplers associated with the Image Processing effects.
  86142. * @param samplersList The list of uniforms used in the effect
  86143. * @param defines the list of defines currently in use
  86144. */
  86145. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86146. /**
  86147. * Prepare the list of defines associated to the shader.
  86148. * @param defines the list of defines to complete
  86149. * @param forPostProcess Define if we are currently in post process mode or not
  86150. */
  86151. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86152. /**
  86153. * Returns true if all the image processing information are ready.
  86154. * @returns True if ready, otherwise, false
  86155. */
  86156. isReady(): boolean;
  86157. /**
  86158. * Binds the image processing to the shader.
  86159. * @param effect The effect to bind to
  86160. * @param overrideAspectRatio Override the aspect ratio of the effect
  86161. */
  86162. bind(effect: Effect, overrideAspectRatio?: number): void;
  86163. /**
  86164. * Clones the current image processing instance.
  86165. * @return The cloned image processing
  86166. */
  86167. clone(): ImageProcessingConfiguration;
  86168. /**
  86169. * Serializes the current image processing instance to a json representation.
  86170. * @return a JSON representation
  86171. */
  86172. serialize(): any;
  86173. /**
  86174. * Parses the image processing from a json representation.
  86175. * @param source the JSON source to parse
  86176. * @return The parsed image processing
  86177. */
  86178. static Parse(source: any): ImageProcessingConfiguration;
  86179. private static _VIGNETTEMODE_MULTIPLY;
  86180. private static _VIGNETTEMODE_OPAQUE;
  86181. /**
  86182. * Used to apply the vignette as a mix with the pixel color.
  86183. */
  86184. static get VIGNETTEMODE_MULTIPLY(): number;
  86185. /**
  86186. * Used to apply the vignette as a replacement of the pixel color.
  86187. */
  86188. static get VIGNETTEMODE_OPAQUE(): number;
  86189. }
  86190. }
  86191. declare module BABYLON {
  86192. /** @hidden */
  86193. export var postprocessVertexShader: {
  86194. name: string;
  86195. shader: string;
  86196. };
  86197. }
  86198. declare module BABYLON {
  86199. interface ThinEngine {
  86200. /**
  86201. * Creates a new render target texture
  86202. * @param size defines the size of the texture
  86203. * @param options defines the options used to create the texture
  86204. * @returns a new render target texture stored in an InternalTexture
  86205. */
  86206. createRenderTargetTexture(size: number | {
  86207. width: number;
  86208. height: number;
  86209. layers?: number;
  86210. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  86211. /**
  86212. * Creates a depth stencil texture.
  86213. * This is only available in WebGL 2 or with the depth texture extension available.
  86214. * @param size The size of face edge in the texture.
  86215. * @param options The options defining the texture.
  86216. * @returns The texture
  86217. */
  86218. createDepthStencilTexture(size: number | {
  86219. width: number;
  86220. height: number;
  86221. layers?: number;
  86222. }, options: DepthTextureCreationOptions): InternalTexture;
  86223. /** @hidden */
  86224. _createDepthStencilTexture(size: number | {
  86225. width: number;
  86226. height: number;
  86227. layers?: number;
  86228. }, options: DepthTextureCreationOptions): InternalTexture;
  86229. }
  86230. }
  86231. declare module BABYLON {
  86232. /**
  86233. * Defines the kind of connection point for node based material
  86234. */
  86235. export enum NodeMaterialBlockConnectionPointTypes {
  86236. /** Float */
  86237. Float = 1,
  86238. /** Int */
  86239. Int = 2,
  86240. /** Vector2 */
  86241. Vector2 = 4,
  86242. /** Vector3 */
  86243. Vector3 = 8,
  86244. /** Vector4 */
  86245. Vector4 = 16,
  86246. /** Color3 */
  86247. Color3 = 32,
  86248. /** Color4 */
  86249. Color4 = 64,
  86250. /** Matrix */
  86251. Matrix = 128,
  86252. /** Custom object */
  86253. Object = 256,
  86254. /** Detect type based on connection */
  86255. AutoDetect = 1024,
  86256. /** Output type that will be defined by input type */
  86257. BasedOnInput = 2048
  86258. }
  86259. }
  86260. declare module BABYLON {
  86261. /**
  86262. * Enum used to define the target of a block
  86263. */
  86264. export enum NodeMaterialBlockTargets {
  86265. /** Vertex shader */
  86266. Vertex = 1,
  86267. /** Fragment shader */
  86268. Fragment = 2,
  86269. /** Neutral */
  86270. Neutral = 4,
  86271. /** Vertex and Fragment */
  86272. VertexAndFragment = 3
  86273. }
  86274. }
  86275. declare module BABYLON {
  86276. /**
  86277. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  86278. */
  86279. export enum NodeMaterialBlockConnectionPointMode {
  86280. /** Value is an uniform */
  86281. Uniform = 0,
  86282. /** Value is a mesh attribute */
  86283. Attribute = 1,
  86284. /** Value is a varying between vertex and fragment shaders */
  86285. Varying = 2,
  86286. /** Mode is undefined */
  86287. Undefined = 3
  86288. }
  86289. }
  86290. declare module BABYLON {
  86291. /**
  86292. * Enum used to define system values e.g. values automatically provided by the system
  86293. */
  86294. export enum NodeMaterialSystemValues {
  86295. /** World */
  86296. World = 1,
  86297. /** View */
  86298. View = 2,
  86299. /** Projection */
  86300. Projection = 3,
  86301. /** ViewProjection */
  86302. ViewProjection = 4,
  86303. /** WorldView */
  86304. WorldView = 5,
  86305. /** WorldViewProjection */
  86306. WorldViewProjection = 6,
  86307. /** CameraPosition */
  86308. CameraPosition = 7,
  86309. /** Fog Color */
  86310. FogColor = 8,
  86311. /** Delta time */
  86312. DeltaTime = 9
  86313. }
  86314. }
  86315. declare module BABYLON {
  86316. /** Defines supported spaces */
  86317. export enum Space {
  86318. /** Local (object) space */
  86319. LOCAL = 0,
  86320. /** World space */
  86321. WORLD = 1,
  86322. /** Bone space */
  86323. BONE = 2
  86324. }
  86325. /** Defines the 3 main axes */
  86326. export class Axis {
  86327. /** X axis */
  86328. static X: Vector3;
  86329. /** Y axis */
  86330. static Y: Vector3;
  86331. /** Z axis */
  86332. static Z: Vector3;
  86333. }
  86334. }
  86335. declare module BABYLON {
  86336. /**
  86337. * Represents a camera frustum
  86338. */
  86339. export class Frustum {
  86340. /**
  86341. * Gets the planes representing the frustum
  86342. * @param transform matrix to be applied to the returned planes
  86343. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  86344. */
  86345. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  86346. /**
  86347. * Gets the near frustum plane transformed by the transform matrix
  86348. * @param transform transformation matrix to be applied to the resulting frustum plane
  86349. * @param frustumPlane the resuling frustum plane
  86350. */
  86351. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86352. /**
  86353. * Gets the far frustum plane transformed by the transform matrix
  86354. * @param transform transformation matrix to be applied to the resulting frustum plane
  86355. * @param frustumPlane the resuling frustum plane
  86356. */
  86357. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86358. /**
  86359. * Gets the left frustum plane transformed by the transform matrix
  86360. * @param transform transformation matrix to be applied to the resulting frustum plane
  86361. * @param frustumPlane the resuling frustum plane
  86362. */
  86363. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86364. /**
  86365. * Gets the right frustum plane transformed by the transform matrix
  86366. * @param transform transformation matrix to be applied to the resulting frustum plane
  86367. * @param frustumPlane the resuling frustum plane
  86368. */
  86369. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86370. /**
  86371. * Gets the top frustum plane transformed by the transform matrix
  86372. * @param transform transformation matrix to be applied to the resulting frustum plane
  86373. * @param frustumPlane the resuling frustum plane
  86374. */
  86375. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86376. /**
  86377. * Gets the bottom frustum plane transformed by the transform matrix
  86378. * @param transform transformation matrix to be applied to the resulting frustum plane
  86379. * @param frustumPlane the resuling frustum plane
  86380. */
  86381. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86382. /**
  86383. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  86384. * @param transform transformation matrix to be applied to the resulting frustum planes
  86385. * @param frustumPlanes the resuling frustum planes
  86386. */
  86387. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  86388. }
  86389. }
  86390. declare module BABYLON {
  86391. /**
  86392. * Interface for the size containing width and height
  86393. */
  86394. export interface ISize {
  86395. /**
  86396. * Width
  86397. */
  86398. width: number;
  86399. /**
  86400. * Heighht
  86401. */
  86402. height: number;
  86403. }
  86404. /**
  86405. * Size containing widht and height
  86406. */
  86407. export class Size implements ISize {
  86408. /**
  86409. * Width
  86410. */
  86411. width: number;
  86412. /**
  86413. * Height
  86414. */
  86415. height: number;
  86416. /**
  86417. * Creates a Size object from the given width and height (floats).
  86418. * @param width width of the new size
  86419. * @param height height of the new size
  86420. */
  86421. constructor(width: number, height: number);
  86422. /**
  86423. * Returns a string with the Size width and height
  86424. * @returns a string with the Size width and height
  86425. */
  86426. toString(): string;
  86427. /**
  86428. * "Size"
  86429. * @returns the string "Size"
  86430. */
  86431. getClassName(): string;
  86432. /**
  86433. * Returns the Size hash code.
  86434. * @returns a hash code for a unique width and height
  86435. */
  86436. getHashCode(): number;
  86437. /**
  86438. * Updates the current size from the given one.
  86439. * @param src the given size
  86440. */
  86441. copyFrom(src: Size): void;
  86442. /**
  86443. * Updates in place the current Size from the given floats.
  86444. * @param width width of the new size
  86445. * @param height height of the new size
  86446. * @returns the updated Size.
  86447. */
  86448. copyFromFloats(width: number, height: number): Size;
  86449. /**
  86450. * Updates in place the current Size from the given floats.
  86451. * @param width width to set
  86452. * @param height height to set
  86453. * @returns the updated Size.
  86454. */
  86455. set(width: number, height: number): Size;
  86456. /**
  86457. * Multiplies the width and height by numbers
  86458. * @param w factor to multiple the width by
  86459. * @param h factor to multiple the height by
  86460. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  86461. */
  86462. multiplyByFloats(w: number, h: number): Size;
  86463. /**
  86464. * Clones the size
  86465. * @returns a new Size copied from the given one.
  86466. */
  86467. clone(): Size;
  86468. /**
  86469. * True if the current Size and the given one width and height are strictly equal.
  86470. * @param other the other size to compare against
  86471. * @returns True if the current Size and the given one width and height are strictly equal.
  86472. */
  86473. equals(other: Size): boolean;
  86474. /**
  86475. * The surface of the Size : width * height (float).
  86476. */
  86477. get surface(): number;
  86478. /**
  86479. * Create a new size of zero
  86480. * @returns a new Size set to (0.0, 0.0)
  86481. */
  86482. static Zero(): Size;
  86483. /**
  86484. * Sums the width and height of two sizes
  86485. * @param otherSize size to add to this size
  86486. * @returns a new Size set as the addition result of the current Size and the given one.
  86487. */
  86488. add(otherSize: Size): Size;
  86489. /**
  86490. * Subtracts the width and height of two
  86491. * @param otherSize size to subtract to this size
  86492. * @returns a new Size set as the subtraction result of the given one from the current Size.
  86493. */
  86494. subtract(otherSize: Size): Size;
  86495. /**
  86496. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  86497. * @param start starting size to lerp between
  86498. * @param end end size to lerp between
  86499. * @param amount amount to lerp between the start and end values
  86500. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  86501. */
  86502. static Lerp(start: Size, end: Size, amount: number): Size;
  86503. }
  86504. }
  86505. declare module BABYLON {
  86506. /**
  86507. * Contains position and normal vectors for a vertex
  86508. */
  86509. export class PositionNormalVertex {
  86510. /** the position of the vertex (defaut: 0,0,0) */
  86511. position: Vector3;
  86512. /** the normal of the vertex (defaut: 0,1,0) */
  86513. normal: Vector3;
  86514. /**
  86515. * Creates a PositionNormalVertex
  86516. * @param position the position of the vertex (defaut: 0,0,0)
  86517. * @param normal the normal of the vertex (defaut: 0,1,0)
  86518. */
  86519. constructor(
  86520. /** the position of the vertex (defaut: 0,0,0) */
  86521. position?: Vector3,
  86522. /** the normal of the vertex (defaut: 0,1,0) */
  86523. normal?: Vector3);
  86524. /**
  86525. * Clones the PositionNormalVertex
  86526. * @returns the cloned PositionNormalVertex
  86527. */
  86528. clone(): PositionNormalVertex;
  86529. }
  86530. /**
  86531. * Contains position, normal and uv vectors for a vertex
  86532. */
  86533. export class PositionNormalTextureVertex {
  86534. /** the position of the vertex (defaut: 0,0,0) */
  86535. position: Vector3;
  86536. /** the normal of the vertex (defaut: 0,1,0) */
  86537. normal: Vector3;
  86538. /** the uv of the vertex (default: 0,0) */
  86539. uv: Vector2;
  86540. /**
  86541. * Creates a PositionNormalTextureVertex
  86542. * @param position the position of the vertex (defaut: 0,0,0)
  86543. * @param normal the normal of the vertex (defaut: 0,1,0)
  86544. * @param uv the uv of the vertex (default: 0,0)
  86545. */
  86546. constructor(
  86547. /** the position of the vertex (defaut: 0,0,0) */
  86548. position?: Vector3,
  86549. /** the normal of the vertex (defaut: 0,1,0) */
  86550. normal?: Vector3,
  86551. /** the uv of the vertex (default: 0,0) */
  86552. uv?: Vector2);
  86553. /**
  86554. * Clones the PositionNormalTextureVertex
  86555. * @returns the cloned PositionNormalTextureVertex
  86556. */
  86557. clone(): PositionNormalTextureVertex;
  86558. }
  86559. }
  86560. declare module BABYLON {
  86561. /**
  86562. * Enum defining the type of animations supported by InputBlock
  86563. */
  86564. export enum AnimatedInputBlockTypes {
  86565. /** No animation */
  86566. None = 0,
  86567. /** Time based animation. Will only work for floats */
  86568. Time = 1
  86569. }
  86570. }
  86571. declare module BABYLON {
  86572. /**
  86573. * Interface describing all the common properties and methods a shadow light needs to implement.
  86574. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  86575. * as well as binding the different shadow properties to the effects.
  86576. */
  86577. export interface IShadowLight extends Light {
  86578. /**
  86579. * The light id in the scene (used in scene.findLighById for instance)
  86580. */
  86581. id: string;
  86582. /**
  86583. * The position the shdow will be casted from.
  86584. */
  86585. position: Vector3;
  86586. /**
  86587. * In 2d mode (needCube being false), the direction used to cast the shadow.
  86588. */
  86589. direction: Vector3;
  86590. /**
  86591. * The transformed position. Position of the light in world space taking parenting in account.
  86592. */
  86593. transformedPosition: Vector3;
  86594. /**
  86595. * The transformed direction. Direction of the light in world space taking parenting in account.
  86596. */
  86597. transformedDirection: Vector3;
  86598. /**
  86599. * The friendly name of the light in the scene.
  86600. */
  86601. name: string;
  86602. /**
  86603. * Defines the shadow projection clipping minimum z value.
  86604. */
  86605. shadowMinZ: number;
  86606. /**
  86607. * Defines the shadow projection clipping maximum z value.
  86608. */
  86609. shadowMaxZ: number;
  86610. /**
  86611. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  86612. * @returns true if the information has been computed, false if it does not need to (no parenting)
  86613. */
  86614. computeTransformedInformation(): boolean;
  86615. /**
  86616. * Gets the scene the light belongs to.
  86617. * @returns The scene
  86618. */
  86619. getScene(): Scene;
  86620. /**
  86621. * Callback defining a custom Projection Matrix Builder.
  86622. * This can be used to override the default projection matrix computation.
  86623. */
  86624. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  86625. /**
  86626. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  86627. * @param matrix The materix to updated with the projection information
  86628. * @param viewMatrix The transform matrix of the light
  86629. * @param renderList The list of mesh to render in the map
  86630. * @returns The current light
  86631. */
  86632. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  86633. /**
  86634. * Gets the current depth scale used in ESM.
  86635. * @returns The scale
  86636. */
  86637. getDepthScale(): number;
  86638. /**
  86639. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  86640. * @returns true if a cube texture needs to be use
  86641. */
  86642. needCube(): boolean;
  86643. /**
  86644. * Detects if the projection matrix requires to be recomputed this frame.
  86645. * @returns true if it requires to be recomputed otherwise, false.
  86646. */
  86647. needProjectionMatrixCompute(): boolean;
  86648. /**
  86649. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  86650. */
  86651. forceProjectionMatrixCompute(): void;
  86652. /**
  86653. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  86654. * @param faceIndex The index of the face we are computed the direction to generate shadow
  86655. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  86656. */
  86657. getShadowDirection(faceIndex?: number): Vector3;
  86658. /**
  86659. * Gets the minZ used for shadow according to both the scene and the light.
  86660. * @param activeCamera The camera we are returning the min for
  86661. * @returns the depth min z
  86662. */
  86663. getDepthMinZ(activeCamera: Camera): number;
  86664. /**
  86665. * Gets the maxZ used for shadow according to both the scene and the light.
  86666. * @param activeCamera The camera we are returning the max for
  86667. * @returns the depth max z
  86668. */
  86669. getDepthMaxZ(activeCamera: Camera): number;
  86670. }
  86671. /**
  86672. * Base implementation IShadowLight
  86673. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  86674. */
  86675. export abstract class ShadowLight extends Light implements IShadowLight {
  86676. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  86677. protected _position: Vector3;
  86678. protected _setPosition(value: Vector3): void;
  86679. /**
  86680. * Sets the position the shadow will be casted from. Also use as the light position for both
  86681. * point and spot lights.
  86682. */
  86683. get position(): Vector3;
  86684. /**
  86685. * Sets the position the shadow will be casted from. Also use as the light position for both
  86686. * point and spot lights.
  86687. */
  86688. set position(value: Vector3);
  86689. protected _direction: Vector3;
  86690. protected _setDirection(value: Vector3): void;
  86691. /**
  86692. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  86693. * Also use as the light direction on spot and directional lights.
  86694. */
  86695. get direction(): Vector3;
  86696. /**
  86697. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  86698. * Also use as the light direction on spot and directional lights.
  86699. */
  86700. set direction(value: Vector3);
  86701. protected _shadowMinZ: number;
  86702. /**
  86703. * Gets the shadow projection clipping minimum z value.
  86704. */
  86705. get shadowMinZ(): number;
  86706. /**
  86707. * Sets the shadow projection clipping minimum z value.
  86708. */
  86709. set shadowMinZ(value: number);
  86710. protected _shadowMaxZ: number;
  86711. /**
  86712. * Sets the shadow projection clipping maximum z value.
  86713. */
  86714. get shadowMaxZ(): number;
  86715. /**
  86716. * Gets the shadow projection clipping maximum z value.
  86717. */
  86718. set shadowMaxZ(value: number);
  86719. /**
  86720. * Callback defining a custom Projection Matrix Builder.
  86721. * This can be used to override the default projection matrix computation.
  86722. */
  86723. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  86724. /**
  86725. * The transformed position. Position of the light in world space taking parenting in account.
  86726. */
  86727. transformedPosition: Vector3;
  86728. /**
  86729. * The transformed direction. Direction of the light in world space taking parenting in account.
  86730. */
  86731. transformedDirection: Vector3;
  86732. private _needProjectionMatrixCompute;
  86733. /**
  86734. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  86735. * @returns true if the information has been computed, false if it does not need to (no parenting)
  86736. */
  86737. computeTransformedInformation(): boolean;
  86738. /**
  86739. * Return the depth scale used for the shadow map.
  86740. * @returns the depth scale.
  86741. */
  86742. getDepthScale(): number;
  86743. /**
  86744. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  86745. * @param faceIndex The index of the face we are computed the direction to generate shadow
  86746. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  86747. */
  86748. getShadowDirection(faceIndex?: number): Vector3;
  86749. /**
  86750. * Returns the ShadowLight absolute position in the World.
  86751. * @returns the position vector in world space
  86752. */
  86753. getAbsolutePosition(): Vector3;
  86754. /**
  86755. * Sets the ShadowLight direction toward the passed target.
  86756. * @param target The point to target in local space
  86757. * @returns the updated ShadowLight direction
  86758. */
  86759. setDirectionToTarget(target: Vector3): Vector3;
  86760. /**
  86761. * Returns the light rotation in euler definition.
  86762. * @returns the x y z rotation in local space.
  86763. */
  86764. getRotation(): Vector3;
  86765. /**
  86766. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  86767. * @returns true if a cube texture needs to be use
  86768. */
  86769. needCube(): boolean;
  86770. /**
  86771. * Detects if the projection matrix requires to be recomputed this frame.
  86772. * @returns true if it requires to be recomputed otherwise, false.
  86773. */
  86774. needProjectionMatrixCompute(): boolean;
  86775. /**
  86776. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  86777. */
  86778. forceProjectionMatrixCompute(): void;
  86779. /** @hidden */
  86780. _initCache(): void;
  86781. /** @hidden */
  86782. _isSynchronized(): boolean;
  86783. /**
  86784. * Computes the world matrix of the node
  86785. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  86786. * @returns the world matrix
  86787. */
  86788. computeWorldMatrix(force?: boolean): Matrix;
  86789. /**
  86790. * Gets the minZ used for shadow according to both the scene and the light.
  86791. * @param activeCamera The camera we are returning the min for
  86792. * @returns the depth min z
  86793. */
  86794. getDepthMinZ(activeCamera: Camera): number;
  86795. /**
  86796. * Gets the maxZ used for shadow according to both the scene and the light.
  86797. * @param activeCamera The camera we are returning the max for
  86798. * @returns the depth max z
  86799. */
  86800. getDepthMaxZ(activeCamera: Camera): number;
  86801. /**
  86802. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  86803. * @param matrix The materix to updated with the projection information
  86804. * @param viewMatrix The transform matrix of the light
  86805. * @param renderList The list of mesh to render in the map
  86806. * @returns The current light
  86807. */
  86808. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  86809. }
  86810. }
  86811. declare module BABYLON {
  86812. /** @hidden */
  86813. export var packingFunctions: {
  86814. name: string;
  86815. shader: string;
  86816. };
  86817. }
  86818. declare module BABYLON {
  86819. /** @hidden */
  86820. export var bayerDitherFunctions: {
  86821. name: string;
  86822. shader: string;
  86823. };
  86824. }
  86825. declare module BABYLON {
  86826. /** @hidden */
  86827. export var shadowMapFragmentDeclaration: {
  86828. name: string;
  86829. shader: string;
  86830. };
  86831. }
  86832. declare module BABYLON {
  86833. /** @hidden */
  86834. export var clipPlaneFragmentDeclaration: {
  86835. name: string;
  86836. shader: string;
  86837. };
  86838. }
  86839. declare module BABYLON {
  86840. /** @hidden */
  86841. export var clipPlaneFragment: {
  86842. name: string;
  86843. shader: string;
  86844. };
  86845. }
  86846. declare module BABYLON {
  86847. /** @hidden */
  86848. export var shadowMapFragment: {
  86849. name: string;
  86850. shader: string;
  86851. };
  86852. }
  86853. declare module BABYLON {
  86854. /** @hidden */
  86855. export var shadowMapPixelShader: {
  86856. name: string;
  86857. shader: string;
  86858. };
  86859. }
  86860. declare module BABYLON {
  86861. /** @hidden */
  86862. export var bonesDeclaration: {
  86863. name: string;
  86864. shader: string;
  86865. };
  86866. }
  86867. declare module BABYLON {
  86868. /** @hidden */
  86869. export var morphTargetsVertexGlobalDeclaration: {
  86870. name: string;
  86871. shader: string;
  86872. };
  86873. }
  86874. declare module BABYLON {
  86875. /** @hidden */
  86876. export var morphTargetsVertexDeclaration: {
  86877. name: string;
  86878. shader: string;
  86879. };
  86880. }
  86881. declare module BABYLON {
  86882. /** @hidden */
  86883. export var instancesDeclaration: {
  86884. name: string;
  86885. shader: string;
  86886. };
  86887. }
  86888. declare module BABYLON {
  86889. /** @hidden */
  86890. export var helperFunctions: {
  86891. name: string;
  86892. shader: string;
  86893. };
  86894. }
  86895. declare module BABYLON {
  86896. /** @hidden */
  86897. export var shadowMapVertexDeclaration: {
  86898. name: string;
  86899. shader: string;
  86900. };
  86901. }
  86902. declare module BABYLON {
  86903. /** @hidden */
  86904. export var clipPlaneVertexDeclaration: {
  86905. name: string;
  86906. shader: string;
  86907. };
  86908. }
  86909. declare module BABYLON {
  86910. /** @hidden */
  86911. export var morphTargetsVertex: {
  86912. name: string;
  86913. shader: string;
  86914. };
  86915. }
  86916. declare module BABYLON {
  86917. /** @hidden */
  86918. export var instancesVertex: {
  86919. name: string;
  86920. shader: string;
  86921. };
  86922. }
  86923. declare module BABYLON {
  86924. /** @hidden */
  86925. export var bonesVertex: {
  86926. name: string;
  86927. shader: string;
  86928. };
  86929. }
  86930. declare module BABYLON {
  86931. /** @hidden */
  86932. export var shadowMapVertexNormalBias: {
  86933. name: string;
  86934. shader: string;
  86935. };
  86936. }
  86937. declare module BABYLON {
  86938. /** @hidden */
  86939. export var shadowMapVertexMetric: {
  86940. name: string;
  86941. shader: string;
  86942. };
  86943. }
  86944. declare module BABYLON {
  86945. /** @hidden */
  86946. export var clipPlaneVertex: {
  86947. name: string;
  86948. shader: string;
  86949. };
  86950. }
  86951. declare module BABYLON {
  86952. /** @hidden */
  86953. export var shadowMapVertexShader: {
  86954. name: string;
  86955. shader: string;
  86956. };
  86957. }
  86958. declare module BABYLON {
  86959. /** @hidden */
  86960. export var depthBoxBlurPixelShader: {
  86961. name: string;
  86962. shader: string;
  86963. };
  86964. }
  86965. declare module BABYLON {
  86966. /** @hidden */
  86967. export var shadowMapFragmentSoftTransparentShadow: {
  86968. name: string;
  86969. shader: string;
  86970. };
  86971. }
  86972. declare module BABYLON {
  86973. /**
  86974. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  86975. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  86976. */
  86977. export class EffectFallbacks implements IEffectFallbacks {
  86978. private _defines;
  86979. private _currentRank;
  86980. private _maxRank;
  86981. private _mesh;
  86982. /**
  86983. * Removes the fallback from the bound mesh.
  86984. */
  86985. unBindMesh(): void;
  86986. /**
  86987. * Adds a fallback on the specified property.
  86988. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86989. * @param define The name of the define in the shader
  86990. */
  86991. addFallback(rank: number, define: string): void;
  86992. /**
  86993. * Sets the mesh to use CPU skinning when needing to fallback.
  86994. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86995. * @param mesh The mesh to use the fallbacks.
  86996. */
  86997. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  86998. /**
  86999. * Checks to see if more fallbacks are still availible.
  87000. */
  87001. get hasMoreFallbacks(): boolean;
  87002. /**
  87003. * Removes the defines that should be removed when falling back.
  87004. * @param currentDefines defines the current define statements for the shader.
  87005. * @param effect defines the current effect we try to compile
  87006. * @returns The resulting defines with defines of the current rank removed.
  87007. */
  87008. reduce(currentDefines: string, effect: Effect): string;
  87009. }
  87010. }
  87011. declare module BABYLON {
  87012. /**
  87013. * Interface used to define Action
  87014. */
  87015. export interface IAction {
  87016. /**
  87017. * Trigger for the action
  87018. */
  87019. trigger: number;
  87020. /** Options of the trigger */
  87021. triggerOptions: any;
  87022. /**
  87023. * Gets the trigger parameters
  87024. * @returns the trigger parameters
  87025. */
  87026. getTriggerParameter(): any;
  87027. /**
  87028. * Internal only - executes current action event
  87029. * @hidden
  87030. */
  87031. _executeCurrent(evt?: ActionEvent): void;
  87032. /**
  87033. * Serialize placeholder for child classes
  87034. * @param parent of child
  87035. * @returns the serialized object
  87036. */
  87037. serialize(parent: any): any;
  87038. /**
  87039. * Internal only
  87040. * @hidden
  87041. */
  87042. _prepare(): void;
  87043. /**
  87044. * Internal only - manager for action
  87045. * @hidden
  87046. */
  87047. _actionManager: AbstractActionManager;
  87048. /**
  87049. * Adds action to chain of actions, may be a DoNothingAction
  87050. * @param action defines the next action to execute
  87051. * @returns The action passed in
  87052. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87053. */
  87054. then(action: IAction): IAction;
  87055. }
  87056. /**
  87057. * The action to be carried out following a trigger
  87058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  87059. */
  87060. export class Action implements IAction {
  87061. /** the trigger, with or without parameters, for the action */
  87062. triggerOptions: any;
  87063. /**
  87064. * Trigger for the action
  87065. */
  87066. trigger: number;
  87067. /**
  87068. * Internal only - manager for action
  87069. * @hidden
  87070. */
  87071. _actionManager: ActionManager;
  87072. private _nextActiveAction;
  87073. private _child;
  87074. private _condition?;
  87075. private _triggerParameter;
  87076. /**
  87077. * An event triggered prior to action being executed.
  87078. */
  87079. onBeforeExecuteObservable: Observable<Action>;
  87080. /**
  87081. * Creates a new Action
  87082. * @param triggerOptions the trigger, with or without parameters, for the action
  87083. * @param condition an optional determinant of action
  87084. */
  87085. constructor(
  87086. /** the trigger, with or without parameters, for the action */
  87087. triggerOptions: any, condition?: Condition);
  87088. /**
  87089. * Internal only
  87090. * @hidden
  87091. */
  87092. _prepare(): void;
  87093. /**
  87094. * Gets the trigger parameters
  87095. * @returns the trigger parameters
  87096. */
  87097. getTriggerParameter(): any;
  87098. /**
  87099. * Internal only - executes current action event
  87100. * @hidden
  87101. */
  87102. _executeCurrent(evt?: ActionEvent): void;
  87103. /**
  87104. * Execute placeholder for child classes
  87105. * @param evt optional action event
  87106. */
  87107. execute(evt?: ActionEvent): void;
  87108. /**
  87109. * Skips to next active action
  87110. */
  87111. skipToNextActiveAction(): void;
  87112. /**
  87113. * Adds action to chain of actions, may be a DoNothingAction
  87114. * @param action defines the next action to execute
  87115. * @returns The action passed in
  87116. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87117. */
  87118. then(action: Action): Action;
  87119. /**
  87120. * Internal only
  87121. * @hidden
  87122. */
  87123. _getProperty(propertyPath: string): string;
  87124. /**
  87125. * Internal only
  87126. * @hidden
  87127. */
  87128. _getEffectiveTarget(target: any, propertyPath: string): any;
  87129. /**
  87130. * Serialize placeholder for child classes
  87131. * @param parent of child
  87132. * @returns the serialized object
  87133. */
  87134. serialize(parent: any): any;
  87135. /**
  87136. * Internal only called by serialize
  87137. * @hidden
  87138. */
  87139. protected _serialize(serializedAction: any, parent?: any): any;
  87140. /**
  87141. * Internal only
  87142. * @hidden
  87143. */
  87144. static _SerializeValueAsString: (value: any) => string;
  87145. /**
  87146. * Internal only
  87147. * @hidden
  87148. */
  87149. static _GetTargetProperty: (target: Node | Scene) => {
  87150. name: string;
  87151. targetType: string;
  87152. value: string;
  87153. };
  87154. }
  87155. }
  87156. declare module BABYLON {
  87157. /**
  87158. * A Condition applied to an Action
  87159. */
  87160. export class Condition {
  87161. /**
  87162. * Internal only - manager for action
  87163. * @hidden
  87164. */
  87165. _actionManager: ActionManager;
  87166. /**
  87167. * Internal only
  87168. * @hidden
  87169. */
  87170. _evaluationId: number;
  87171. /**
  87172. * Internal only
  87173. * @hidden
  87174. */
  87175. _currentResult: boolean;
  87176. /**
  87177. * Creates a new Condition
  87178. * @param actionManager the manager of the action the condition is applied to
  87179. */
  87180. constructor(actionManager: ActionManager);
  87181. /**
  87182. * Check if the current condition is valid
  87183. * @returns a boolean
  87184. */
  87185. isValid(): boolean;
  87186. /**
  87187. * Internal only
  87188. * @hidden
  87189. */
  87190. _getProperty(propertyPath: string): string;
  87191. /**
  87192. * Internal only
  87193. * @hidden
  87194. */
  87195. _getEffectiveTarget(target: any, propertyPath: string): any;
  87196. /**
  87197. * Serialize placeholder for child classes
  87198. * @returns the serialized object
  87199. */
  87200. serialize(): any;
  87201. /**
  87202. * Internal only
  87203. * @hidden
  87204. */
  87205. protected _serialize(serializedCondition: any): any;
  87206. }
  87207. /**
  87208. * Defines specific conditional operators as extensions of Condition
  87209. */
  87210. export class ValueCondition extends Condition {
  87211. /** path to specify the property of the target the conditional operator uses */
  87212. propertyPath: string;
  87213. /** the value compared by the conditional operator against the current value of the property */
  87214. value: any;
  87215. /** the conditional operator, default ValueCondition.IsEqual */
  87216. operator: number;
  87217. /**
  87218. * Internal only
  87219. * @hidden
  87220. */
  87221. private static _IsEqual;
  87222. /**
  87223. * Internal only
  87224. * @hidden
  87225. */
  87226. private static _IsDifferent;
  87227. /**
  87228. * Internal only
  87229. * @hidden
  87230. */
  87231. private static _IsGreater;
  87232. /**
  87233. * Internal only
  87234. * @hidden
  87235. */
  87236. private static _IsLesser;
  87237. /**
  87238. * returns the number for IsEqual
  87239. */
  87240. static get IsEqual(): number;
  87241. /**
  87242. * Returns the number for IsDifferent
  87243. */
  87244. static get IsDifferent(): number;
  87245. /**
  87246. * Returns the number for IsGreater
  87247. */
  87248. static get IsGreater(): number;
  87249. /**
  87250. * Returns the number for IsLesser
  87251. */
  87252. static get IsLesser(): number;
  87253. /**
  87254. * Internal only The action manager for the condition
  87255. * @hidden
  87256. */
  87257. _actionManager: ActionManager;
  87258. /**
  87259. * Internal only
  87260. * @hidden
  87261. */
  87262. private _target;
  87263. /**
  87264. * Internal only
  87265. * @hidden
  87266. */
  87267. private _effectiveTarget;
  87268. /**
  87269. * Internal only
  87270. * @hidden
  87271. */
  87272. private _property;
  87273. /**
  87274. * Creates a new ValueCondition
  87275. * @param actionManager manager for the action the condition applies to
  87276. * @param target for the action
  87277. * @param propertyPath path to specify the property of the target the conditional operator uses
  87278. * @param value the value compared by the conditional operator against the current value of the property
  87279. * @param operator the conditional operator, default ValueCondition.IsEqual
  87280. */
  87281. constructor(actionManager: ActionManager, target: any,
  87282. /** path to specify the property of the target the conditional operator uses */
  87283. propertyPath: string,
  87284. /** the value compared by the conditional operator against the current value of the property */
  87285. value: any,
  87286. /** the conditional operator, default ValueCondition.IsEqual */
  87287. operator?: number);
  87288. /**
  87289. * Compares the given value with the property value for the specified conditional operator
  87290. * @returns the result of the comparison
  87291. */
  87292. isValid(): boolean;
  87293. /**
  87294. * Serialize the ValueCondition into a JSON compatible object
  87295. * @returns serialization object
  87296. */
  87297. serialize(): any;
  87298. /**
  87299. * Gets the name of the conditional operator for the ValueCondition
  87300. * @param operator the conditional operator
  87301. * @returns the name
  87302. */
  87303. static GetOperatorName(operator: number): string;
  87304. }
  87305. /**
  87306. * Defines a predicate condition as an extension of Condition
  87307. */
  87308. export class PredicateCondition extends Condition {
  87309. /** defines the predicate function used to validate the condition */
  87310. predicate: () => boolean;
  87311. /**
  87312. * Internal only - manager for action
  87313. * @hidden
  87314. */
  87315. _actionManager: ActionManager;
  87316. /**
  87317. * Creates a new PredicateCondition
  87318. * @param actionManager manager for the action the condition applies to
  87319. * @param predicate defines the predicate function used to validate the condition
  87320. */
  87321. constructor(actionManager: ActionManager,
  87322. /** defines the predicate function used to validate the condition */
  87323. predicate: () => boolean);
  87324. /**
  87325. * @returns the validity of the predicate condition
  87326. */
  87327. isValid(): boolean;
  87328. }
  87329. /**
  87330. * Defines a state condition as an extension of Condition
  87331. */
  87332. export class StateCondition extends Condition {
  87333. /** Value to compare with target state */
  87334. value: string;
  87335. /**
  87336. * Internal only - manager for action
  87337. * @hidden
  87338. */
  87339. _actionManager: ActionManager;
  87340. /**
  87341. * Internal only
  87342. * @hidden
  87343. */
  87344. private _target;
  87345. /**
  87346. * Creates a new StateCondition
  87347. * @param actionManager manager for the action the condition applies to
  87348. * @param target of the condition
  87349. * @param value to compare with target state
  87350. */
  87351. constructor(actionManager: ActionManager, target: any,
  87352. /** Value to compare with target state */
  87353. value: string);
  87354. /**
  87355. * Gets a boolean indicating if the current condition is met
  87356. * @returns the validity of the state
  87357. */
  87358. isValid(): boolean;
  87359. /**
  87360. * Serialize the StateCondition into a JSON compatible object
  87361. * @returns serialization object
  87362. */
  87363. serialize(): any;
  87364. }
  87365. }
  87366. declare module BABYLON {
  87367. /**
  87368. * This defines an action responsible to toggle a boolean once triggered.
  87369. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87370. */
  87371. export class SwitchBooleanAction extends Action {
  87372. /**
  87373. * The path to the boolean property in the target object
  87374. */
  87375. propertyPath: string;
  87376. private _target;
  87377. private _effectiveTarget;
  87378. private _property;
  87379. /**
  87380. * Instantiate the action
  87381. * @param triggerOptions defines the trigger options
  87382. * @param target defines the object containing the boolean
  87383. * @param propertyPath defines the path to the boolean property in the target object
  87384. * @param condition defines the trigger related conditions
  87385. */
  87386. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  87387. /** @hidden */
  87388. _prepare(): void;
  87389. /**
  87390. * Execute the action toggle the boolean value.
  87391. */
  87392. execute(): void;
  87393. /**
  87394. * Serializes the actions and its related information.
  87395. * @param parent defines the object to serialize in
  87396. * @returns the serialized object
  87397. */
  87398. serialize(parent: any): any;
  87399. }
  87400. /**
  87401. * This defines an action responsible to set a the state field of the target
  87402. * to a desired value once triggered.
  87403. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87404. */
  87405. export class SetStateAction extends Action {
  87406. /**
  87407. * The value to store in the state field.
  87408. */
  87409. value: string;
  87410. private _target;
  87411. /**
  87412. * Instantiate the action
  87413. * @param triggerOptions defines the trigger options
  87414. * @param target defines the object containing the state property
  87415. * @param value defines the value to store in the state field
  87416. * @param condition defines the trigger related conditions
  87417. */
  87418. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  87419. /**
  87420. * Execute the action and store the value on the target state property.
  87421. */
  87422. execute(): void;
  87423. /**
  87424. * Serializes the actions and its related information.
  87425. * @param parent defines the object to serialize in
  87426. * @returns the serialized object
  87427. */
  87428. serialize(parent: any): any;
  87429. }
  87430. /**
  87431. * This defines an action responsible to set a property of the target
  87432. * to a desired value once triggered.
  87433. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87434. */
  87435. export class SetValueAction extends Action {
  87436. /**
  87437. * The path of the property to set in the target.
  87438. */
  87439. propertyPath: string;
  87440. /**
  87441. * The value to set in the property
  87442. */
  87443. value: any;
  87444. private _target;
  87445. private _effectiveTarget;
  87446. private _property;
  87447. /**
  87448. * Instantiate the action
  87449. * @param triggerOptions defines the trigger options
  87450. * @param target defines the object containing the property
  87451. * @param propertyPath defines the path of the property to set in the target
  87452. * @param value defines the value to set in the property
  87453. * @param condition defines the trigger related conditions
  87454. */
  87455. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  87456. /** @hidden */
  87457. _prepare(): void;
  87458. /**
  87459. * Execute the action and set the targetted property to the desired value.
  87460. */
  87461. execute(): void;
  87462. /**
  87463. * Serializes the actions and its related information.
  87464. * @param parent defines the object to serialize in
  87465. * @returns the serialized object
  87466. */
  87467. serialize(parent: any): any;
  87468. }
  87469. /**
  87470. * This defines an action responsible to increment the target value
  87471. * to a desired value once triggered.
  87472. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87473. */
  87474. export class IncrementValueAction extends Action {
  87475. /**
  87476. * The path of the property to increment in the target.
  87477. */
  87478. propertyPath: string;
  87479. /**
  87480. * The value we should increment the property by.
  87481. */
  87482. value: any;
  87483. private _target;
  87484. private _effectiveTarget;
  87485. private _property;
  87486. /**
  87487. * Instantiate the action
  87488. * @param triggerOptions defines the trigger options
  87489. * @param target defines the object containing the property
  87490. * @param propertyPath defines the path of the property to increment in the target
  87491. * @param value defines the value value we should increment the property by
  87492. * @param condition defines the trigger related conditions
  87493. */
  87494. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  87495. /** @hidden */
  87496. _prepare(): void;
  87497. /**
  87498. * Execute the action and increment the target of the value amount.
  87499. */
  87500. execute(): void;
  87501. /**
  87502. * Serializes the actions and its related information.
  87503. * @param parent defines the object to serialize in
  87504. * @returns the serialized object
  87505. */
  87506. serialize(parent: any): any;
  87507. }
  87508. /**
  87509. * This defines an action responsible to start an animation once triggered.
  87510. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87511. */
  87512. export class PlayAnimationAction extends Action {
  87513. /**
  87514. * Where the animation should start (animation frame)
  87515. */
  87516. from: number;
  87517. /**
  87518. * Where the animation should stop (animation frame)
  87519. */
  87520. to: number;
  87521. /**
  87522. * Define if the animation should loop or stop after the first play.
  87523. */
  87524. loop?: boolean;
  87525. private _target;
  87526. /**
  87527. * Instantiate the action
  87528. * @param triggerOptions defines the trigger options
  87529. * @param target defines the target animation or animation name
  87530. * @param from defines from where the animation should start (animation frame)
  87531. * @param end defines where the animation should stop (animation frame)
  87532. * @param loop defines if the animation should loop or stop after the first play
  87533. * @param condition defines the trigger related conditions
  87534. */
  87535. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  87536. /** @hidden */
  87537. _prepare(): void;
  87538. /**
  87539. * Execute the action and play the animation.
  87540. */
  87541. execute(): void;
  87542. /**
  87543. * Serializes the actions and its related information.
  87544. * @param parent defines the object to serialize in
  87545. * @returns the serialized object
  87546. */
  87547. serialize(parent: any): any;
  87548. }
  87549. /**
  87550. * This defines an action responsible to stop an animation once triggered.
  87551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87552. */
  87553. export class StopAnimationAction extends Action {
  87554. private _target;
  87555. /**
  87556. * Instantiate the action
  87557. * @param triggerOptions defines the trigger options
  87558. * @param target defines the target animation or animation name
  87559. * @param condition defines the trigger related conditions
  87560. */
  87561. constructor(triggerOptions: any, target: any, condition?: Condition);
  87562. /** @hidden */
  87563. _prepare(): void;
  87564. /**
  87565. * Execute the action and stop the animation.
  87566. */
  87567. execute(): void;
  87568. /**
  87569. * Serializes the actions and its related information.
  87570. * @param parent defines the object to serialize in
  87571. * @returns the serialized object
  87572. */
  87573. serialize(parent: any): any;
  87574. }
  87575. /**
  87576. * This defines an action responsible that does nothing once triggered.
  87577. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87578. */
  87579. export class DoNothingAction extends Action {
  87580. /**
  87581. * Instantiate the action
  87582. * @param triggerOptions defines the trigger options
  87583. * @param condition defines the trigger related conditions
  87584. */
  87585. constructor(triggerOptions?: any, condition?: Condition);
  87586. /**
  87587. * Execute the action and do nothing.
  87588. */
  87589. execute(): void;
  87590. /**
  87591. * Serializes the actions and its related information.
  87592. * @param parent defines the object to serialize in
  87593. * @returns the serialized object
  87594. */
  87595. serialize(parent: any): any;
  87596. }
  87597. /**
  87598. * This defines an action responsible to trigger several actions once triggered.
  87599. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87600. */
  87601. export class CombineAction extends Action {
  87602. /**
  87603. * The list of aggregated animations to run.
  87604. */
  87605. children: Action[];
  87606. /**
  87607. * Instantiate the action
  87608. * @param triggerOptions defines the trigger options
  87609. * @param children defines the list of aggregated animations to run
  87610. * @param condition defines the trigger related conditions
  87611. */
  87612. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  87613. /** @hidden */
  87614. _prepare(): void;
  87615. /**
  87616. * Execute the action and executes all the aggregated actions.
  87617. */
  87618. execute(evt: ActionEvent): void;
  87619. /**
  87620. * Serializes the actions and its related information.
  87621. * @param parent defines the object to serialize in
  87622. * @returns the serialized object
  87623. */
  87624. serialize(parent: any): any;
  87625. }
  87626. /**
  87627. * This defines an action responsible to run code (external event) once triggered.
  87628. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87629. */
  87630. export class ExecuteCodeAction extends Action {
  87631. /**
  87632. * The callback function to run.
  87633. */
  87634. func: (evt: ActionEvent) => void;
  87635. /**
  87636. * Instantiate the action
  87637. * @param triggerOptions defines the trigger options
  87638. * @param func defines the callback function to run
  87639. * @param condition defines the trigger related conditions
  87640. */
  87641. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  87642. /**
  87643. * Execute the action and run the attached code.
  87644. */
  87645. execute(evt: ActionEvent): void;
  87646. }
  87647. /**
  87648. * This defines an action responsible to set the parent property of the target once triggered.
  87649. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87650. */
  87651. export class SetParentAction extends Action {
  87652. private _parent;
  87653. private _target;
  87654. /**
  87655. * Instantiate the action
  87656. * @param triggerOptions defines the trigger options
  87657. * @param target defines the target containing the parent property
  87658. * @param parent defines from where the animation should start (animation frame)
  87659. * @param condition defines the trigger related conditions
  87660. */
  87661. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  87662. /** @hidden */
  87663. _prepare(): void;
  87664. /**
  87665. * Execute the action and set the parent property.
  87666. */
  87667. execute(): void;
  87668. /**
  87669. * Serializes the actions and its related information.
  87670. * @param parent defines the object to serialize in
  87671. * @returns the serialized object
  87672. */
  87673. serialize(parent: any): any;
  87674. }
  87675. }
  87676. declare module BABYLON {
  87677. /**
  87678. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  87679. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  87680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87681. */
  87682. export class ActionManager extends AbstractActionManager {
  87683. /**
  87684. * Nothing
  87685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87686. */
  87687. static readonly NothingTrigger: number;
  87688. /**
  87689. * On pick
  87690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87691. */
  87692. static readonly OnPickTrigger: number;
  87693. /**
  87694. * On left pick
  87695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87696. */
  87697. static readonly OnLeftPickTrigger: number;
  87698. /**
  87699. * On right pick
  87700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87701. */
  87702. static readonly OnRightPickTrigger: number;
  87703. /**
  87704. * On center pick
  87705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87706. */
  87707. static readonly OnCenterPickTrigger: number;
  87708. /**
  87709. * On pick down
  87710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87711. */
  87712. static readonly OnPickDownTrigger: number;
  87713. /**
  87714. * On double pick
  87715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87716. */
  87717. static readonly OnDoublePickTrigger: number;
  87718. /**
  87719. * On pick up
  87720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87721. */
  87722. static readonly OnPickUpTrigger: number;
  87723. /**
  87724. * On pick out.
  87725. * This trigger will only be raised if you also declared a OnPickDown
  87726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87727. */
  87728. static readonly OnPickOutTrigger: number;
  87729. /**
  87730. * On long press
  87731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87732. */
  87733. static readonly OnLongPressTrigger: number;
  87734. /**
  87735. * On pointer over
  87736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87737. */
  87738. static readonly OnPointerOverTrigger: number;
  87739. /**
  87740. * On pointer out
  87741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87742. */
  87743. static readonly OnPointerOutTrigger: number;
  87744. /**
  87745. * On every frame
  87746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87747. */
  87748. static readonly OnEveryFrameTrigger: number;
  87749. /**
  87750. * On intersection enter
  87751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87752. */
  87753. static readonly OnIntersectionEnterTrigger: number;
  87754. /**
  87755. * On intersection exit
  87756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87757. */
  87758. static readonly OnIntersectionExitTrigger: number;
  87759. /**
  87760. * On key down
  87761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87762. */
  87763. static readonly OnKeyDownTrigger: number;
  87764. /**
  87765. * On key up
  87766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87767. */
  87768. static readonly OnKeyUpTrigger: number;
  87769. private _scene;
  87770. /**
  87771. * Creates a new action manager
  87772. * @param scene defines the hosting scene
  87773. */
  87774. constructor(scene: Scene);
  87775. /**
  87776. * Releases all associated resources
  87777. */
  87778. dispose(): void;
  87779. /**
  87780. * Gets hosting scene
  87781. * @returns the hosting scene
  87782. */
  87783. getScene(): Scene;
  87784. /**
  87785. * Does this action manager handles actions of any of the given triggers
  87786. * @param triggers defines the triggers to be tested
  87787. * @return a boolean indicating whether one (or more) of the triggers is handled
  87788. */
  87789. hasSpecificTriggers(triggers: number[]): boolean;
  87790. /**
  87791. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  87792. * speed.
  87793. * @param triggerA defines the trigger to be tested
  87794. * @param triggerB defines the trigger to be tested
  87795. * @return a boolean indicating whether one (or more) of the triggers is handled
  87796. */
  87797. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  87798. /**
  87799. * Does this action manager handles actions of a given trigger
  87800. * @param trigger defines the trigger to be tested
  87801. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  87802. * @return whether the trigger is handled
  87803. */
  87804. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  87805. /**
  87806. * Does this action manager has pointer triggers
  87807. */
  87808. get hasPointerTriggers(): boolean;
  87809. /**
  87810. * Does this action manager has pick triggers
  87811. */
  87812. get hasPickTriggers(): boolean;
  87813. /**
  87814. * Registers an action to this action manager
  87815. * @param action defines the action to be registered
  87816. * @return the action amended (prepared) after registration
  87817. */
  87818. registerAction(action: IAction): Nullable<IAction>;
  87819. /**
  87820. * Unregisters an action to this action manager
  87821. * @param action defines the action to be unregistered
  87822. * @return a boolean indicating whether the action has been unregistered
  87823. */
  87824. unregisterAction(action: IAction): Boolean;
  87825. /**
  87826. * Process a specific trigger
  87827. * @param trigger defines the trigger to process
  87828. * @param evt defines the event details to be processed
  87829. */
  87830. processTrigger(trigger: number, evt?: IActionEvent): void;
  87831. /** @hidden */
  87832. _getEffectiveTarget(target: any, propertyPath: string): any;
  87833. /** @hidden */
  87834. _getProperty(propertyPath: string): string;
  87835. /**
  87836. * Serialize this manager to a JSON object
  87837. * @param name defines the property name to store this manager
  87838. * @returns a JSON representation of this manager
  87839. */
  87840. serialize(name: string): any;
  87841. /**
  87842. * Creates a new ActionManager from a JSON data
  87843. * @param parsedActions defines the JSON data to read from
  87844. * @param object defines the hosting mesh
  87845. * @param scene defines the hosting scene
  87846. */
  87847. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  87848. /**
  87849. * Get a trigger name by index
  87850. * @param trigger defines the trigger index
  87851. * @returns a trigger name
  87852. */
  87853. static GetTriggerName(trigger: number): string;
  87854. }
  87855. }
  87856. declare module BABYLON {
  87857. /**
  87858. * Class used to represent a sprite
  87859. * @see http://doc.babylonjs.com/babylon101/sprites
  87860. */
  87861. export class Sprite implements IAnimatable {
  87862. /** defines the name */
  87863. name: string;
  87864. /** Gets or sets the current world position */
  87865. position: Vector3;
  87866. /** Gets or sets the main color */
  87867. color: Color4;
  87868. /** Gets or sets the width */
  87869. width: number;
  87870. /** Gets or sets the height */
  87871. height: number;
  87872. /** Gets or sets rotation angle */
  87873. angle: number;
  87874. /** Gets or sets the cell index in the sprite sheet */
  87875. cellIndex: number;
  87876. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  87877. cellRef: string;
  87878. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  87879. invertU: boolean;
  87880. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  87881. invertV: boolean;
  87882. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  87883. disposeWhenFinishedAnimating: boolean;
  87884. /** Gets the list of attached animations */
  87885. animations: Nullable<Array<Animation>>;
  87886. /** Gets or sets a boolean indicating if the sprite can be picked */
  87887. isPickable: boolean;
  87888. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  87889. useAlphaForPicking: boolean;
  87890. /** @hidden */
  87891. _xOffset: number;
  87892. /** @hidden */
  87893. _yOffset: number;
  87894. /** @hidden */
  87895. _xSize: number;
  87896. /** @hidden */
  87897. _ySize: number;
  87898. /**
  87899. * Gets or sets the associated action manager
  87900. */
  87901. actionManager: Nullable<ActionManager>;
  87902. /**
  87903. * An event triggered when the control has been disposed
  87904. */
  87905. onDisposeObservable: Observable<Sprite>;
  87906. private _animationStarted;
  87907. private _loopAnimation;
  87908. private _fromIndex;
  87909. private _toIndex;
  87910. private _delay;
  87911. private _direction;
  87912. private _manager;
  87913. private _time;
  87914. private _onAnimationEnd;
  87915. /**
  87916. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  87917. */
  87918. isVisible: boolean;
  87919. /**
  87920. * Gets or sets the sprite size
  87921. */
  87922. get size(): number;
  87923. set size(value: number);
  87924. /**
  87925. * Returns a boolean indicating if the animation is started
  87926. */
  87927. get animationStarted(): boolean;
  87928. /**
  87929. * Gets or sets the unique id of the sprite
  87930. */
  87931. uniqueId: number;
  87932. /**
  87933. * Gets the manager of this sprite
  87934. */
  87935. get manager(): ISpriteManager;
  87936. /**
  87937. * Creates a new Sprite
  87938. * @param name defines the name
  87939. * @param manager defines the manager
  87940. */
  87941. constructor(
  87942. /** defines the name */
  87943. name: string, manager: ISpriteManager);
  87944. /**
  87945. * Returns the string "Sprite"
  87946. * @returns "Sprite"
  87947. */
  87948. getClassName(): string;
  87949. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  87950. get fromIndex(): number;
  87951. set fromIndex(value: number);
  87952. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  87953. get toIndex(): number;
  87954. set toIndex(value: number);
  87955. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  87956. get loopAnimation(): boolean;
  87957. set loopAnimation(value: boolean);
  87958. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  87959. get delay(): number;
  87960. set delay(value: number);
  87961. /**
  87962. * Starts an animation
  87963. * @param from defines the initial key
  87964. * @param to defines the end key
  87965. * @param loop defines if the animation must loop
  87966. * @param delay defines the start delay (in ms)
  87967. * @param onAnimationEnd defines a callback to call when animation ends
  87968. */
  87969. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  87970. /** Stops current animation (if any) */
  87971. stopAnimation(): void;
  87972. /** @hidden */
  87973. _animate(deltaTime: number): void;
  87974. /** Release associated resources */
  87975. dispose(): void;
  87976. /**
  87977. * Serializes the sprite to a JSON object
  87978. * @returns the JSON object
  87979. */
  87980. serialize(): any;
  87981. /**
  87982. * Parses a JSON object to create a new sprite
  87983. * @param parsedSprite The JSON object to parse
  87984. * @param manager defines the hosting manager
  87985. * @returns the new sprite
  87986. */
  87987. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  87988. }
  87989. }
  87990. declare module BABYLON {
  87991. /**
  87992. * Information about the result of picking within a scene
  87993. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  87994. */
  87995. export class PickingInfo {
  87996. /** @hidden */
  87997. _pickingUnavailable: boolean;
  87998. /**
  87999. * If the pick collided with an object
  88000. */
  88001. hit: boolean;
  88002. /**
  88003. * Distance away where the pick collided
  88004. */
  88005. distance: number;
  88006. /**
  88007. * The location of pick collision
  88008. */
  88009. pickedPoint: Nullable<Vector3>;
  88010. /**
  88011. * The mesh corresponding the the pick collision
  88012. */
  88013. pickedMesh: Nullable<AbstractMesh>;
  88014. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  88015. bu: number;
  88016. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  88017. bv: number;
  88018. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88019. faceId: number;
  88020. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88021. subMeshFaceId: number;
  88022. /** Id of the the submesh that was picked */
  88023. subMeshId: number;
  88024. /** If a sprite was picked, this will be the sprite the pick collided with */
  88025. pickedSprite: Nullable<Sprite>;
  88026. /**
  88027. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  88028. */
  88029. originMesh: Nullable<AbstractMesh>;
  88030. /**
  88031. * The ray that was used to perform the picking.
  88032. */
  88033. ray: Nullable<Ray>;
  88034. /**
  88035. * Gets the normal correspodning to the face the pick collided with
  88036. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  88037. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  88038. * @returns The normal correspodning to the face the pick collided with
  88039. */
  88040. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  88041. /**
  88042. * Gets the texture coordinates of where the pick occured
  88043. * @returns the vector containing the coordnates of the texture
  88044. */
  88045. getTextureCoordinates(): Nullable<Vector2>;
  88046. }
  88047. }
  88048. declare module BABYLON {
  88049. /**
  88050. * Class representing a ray with position and direction
  88051. */
  88052. export class Ray {
  88053. /** origin point */
  88054. origin: Vector3;
  88055. /** direction */
  88056. direction: Vector3;
  88057. /** length of the ray */
  88058. length: number;
  88059. private static readonly TmpVector3;
  88060. private _tmpRay;
  88061. /**
  88062. * Creates a new ray
  88063. * @param origin origin point
  88064. * @param direction direction
  88065. * @param length length of the ray
  88066. */
  88067. constructor(
  88068. /** origin point */
  88069. origin: Vector3,
  88070. /** direction */
  88071. direction: Vector3,
  88072. /** length of the ray */
  88073. length?: number);
  88074. /**
  88075. * Checks if the ray intersects a box
  88076. * This does not account for the ray lenght by design to improve perfs.
  88077. * @param minimum bound of the box
  88078. * @param maximum bound of the box
  88079. * @param intersectionTreshold extra extend to be added to the box in all direction
  88080. * @returns if the box was hit
  88081. */
  88082. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  88083. /**
  88084. * Checks if the ray intersects a box
  88085. * This does not account for the ray lenght by design to improve perfs.
  88086. * @param box the bounding box to check
  88087. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  88088. * @returns if the box was hit
  88089. */
  88090. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  88091. /**
  88092. * If the ray hits a sphere
  88093. * @param sphere the bounding sphere to check
  88094. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  88095. * @returns true if it hits the sphere
  88096. */
  88097. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  88098. /**
  88099. * If the ray hits a triange
  88100. * @param vertex0 triangle vertex
  88101. * @param vertex1 triangle vertex
  88102. * @param vertex2 triangle vertex
  88103. * @returns intersection information if hit
  88104. */
  88105. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  88106. /**
  88107. * Checks if ray intersects a plane
  88108. * @param plane the plane to check
  88109. * @returns the distance away it was hit
  88110. */
  88111. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  88112. /**
  88113. * Calculate the intercept of a ray on a given axis
  88114. * @param axis to check 'x' | 'y' | 'z'
  88115. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  88116. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  88117. */
  88118. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  88119. /**
  88120. * Checks if ray intersects a mesh
  88121. * @param mesh the mesh to check
  88122. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88123. * @returns picking info of the intersecton
  88124. */
  88125. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  88126. /**
  88127. * Checks if ray intersects a mesh
  88128. * @param meshes the meshes to check
  88129. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88130. * @param results array to store result in
  88131. * @returns Array of picking infos
  88132. */
  88133. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  88134. private _comparePickingInfo;
  88135. private static smallnum;
  88136. private static rayl;
  88137. /**
  88138. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  88139. * @param sega the first point of the segment to test the intersection against
  88140. * @param segb the second point of the segment to test the intersection against
  88141. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  88142. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  88143. */
  88144. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  88145. /**
  88146. * Update the ray from viewport position
  88147. * @param x position
  88148. * @param y y position
  88149. * @param viewportWidth viewport width
  88150. * @param viewportHeight viewport height
  88151. * @param world world matrix
  88152. * @param view view matrix
  88153. * @param projection projection matrix
  88154. * @returns this ray updated
  88155. */
  88156. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  88157. /**
  88158. * Creates a ray with origin and direction of 0,0,0
  88159. * @returns the new ray
  88160. */
  88161. static Zero(): Ray;
  88162. /**
  88163. * Creates a new ray from screen space and viewport
  88164. * @param x position
  88165. * @param y y position
  88166. * @param viewportWidth viewport width
  88167. * @param viewportHeight viewport height
  88168. * @param world world matrix
  88169. * @param view view matrix
  88170. * @param projection projection matrix
  88171. * @returns new ray
  88172. */
  88173. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  88174. /**
  88175. * 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
  88176. * transformed to the given world matrix.
  88177. * @param origin The origin point
  88178. * @param end The end point
  88179. * @param world a matrix to transform the ray to. Default is the identity matrix.
  88180. * @returns the new ray
  88181. */
  88182. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  88183. /**
  88184. * Transforms a ray by a matrix
  88185. * @param ray ray to transform
  88186. * @param matrix matrix to apply
  88187. * @returns the resulting new ray
  88188. */
  88189. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  88190. /**
  88191. * Transforms a ray by a matrix
  88192. * @param ray ray to transform
  88193. * @param matrix matrix to apply
  88194. * @param result ray to store result in
  88195. */
  88196. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  88197. /**
  88198. * Unproject a ray from screen space to object space
  88199. * @param sourceX defines the screen space x coordinate to use
  88200. * @param sourceY defines the screen space y coordinate to use
  88201. * @param viewportWidth defines the current width of the viewport
  88202. * @param viewportHeight defines the current height of the viewport
  88203. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88204. * @param view defines the view matrix to use
  88205. * @param projection defines the projection matrix to use
  88206. */
  88207. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  88208. }
  88209. /**
  88210. * Type used to define predicate used to select faces when a mesh intersection is detected
  88211. */
  88212. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  88213. interface Scene {
  88214. /** @hidden */
  88215. _tempPickingRay: Nullable<Ray>;
  88216. /** @hidden */
  88217. _cachedRayForTransform: Ray;
  88218. /** @hidden */
  88219. _pickWithRayInverseMatrix: Matrix;
  88220. /** @hidden */
  88221. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  88222. /** @hidden */
  88223. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  88224. }
  88225. }
  88226. declare module BABYLON {
  88227. /**
  88228. * Groups all the scene component constants in one place to ease maintenance.
  88229. * @hidden
  88230. */
  88231. export class SceneComponentConstants {
  88232. static readonly NAME_EFFECTLAYER: string;
  88233. static readonly NAME_LAYER: string;
  88234. static readonly NAME_LENSFLARESYSTEM: string;
  88235. static readonly NAME_BOUNDINGBOXRENDERER: string;
  88236. static readonly NAME_PARTICLESYSTEM: string;
  88237. static readonly NAME_GAMEPAD: string;
  88238. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  88239. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  88240. static readonly NAME_DEPTHRENDERER: string;
  88241. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  88242. static readonly NAME_SPRITE: string;
  88243. static readonly NAME_OUTLINERENDERER: string;
  88244. static readonly NAME_PROCEDURALTEXTURE: string;
  88245. static readonly NAME_SHADOWGENERATOR: string;
  88246. static readonly NAME_OCTREE: string;
  88247. static readonly NAME_PHYSICSENGINE: string;
  88248. static readonly NAME_AUDIO: string;
  88249. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  88250. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  88251. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  88252. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  88253. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  88254. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  88255. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  88256. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  88257. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  88258. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  88259. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  88260. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  88261. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  88262. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  88263. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  88264. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  88265. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  88266. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  88267. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  88268. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  88269. static readonly STEP_AFTERRENDER_AUDIO: number;
  88270. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  88271. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  88272. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  88273. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  88274. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  88275. static readonly STEP_POINTERMOVE_SPRITE: number;
  88276. static readonly STEP_POINTERDOWN_SPRITE: number;
  88277. static readonly STEP_POINTERUP_SPRITE: number;
  88278. }
  88279. /**
  88280. * This represents a scene component.
  88281. *
  88282. * This is used to decouple the dependency the scene is having on the different workloads like
  88283. * layers, post processes...
  88284. */
  88285. export interface ISceneComponent {
  88286. /**
  88287. * The name of the component. Each component must have a unique name.
  88288. */
  88289. name: string;
  88290. /**
  88291. * The scene the component belongs to.
  88292. */
  88293. scene: Scene;
  88294. /**
  88295. * Register the component to one instance of a scene.
  88296. */
  88297. register(): void;
  88298. /**
  88299. * Rebuilds the elements related to this component in case of
  88300. * context lost for instance.
  88301. */
  88302. rebuild(): void;
  88303. /**
  88304. * Disposes the component and the associated ressources.
  88305. */
  88306. dispose(): void;
  88307. }
  88308. /**
  88309. * This represents a SERIALIZABLE scene component.
  88310. *
  88311. * This extends Scene Component to add Serialization methods on top.
  88312. */
  88313. export interface ISceneSerializableComponent extends ISceneComponent {
  88314. /**
  88315. * Adds all the elements from the container to the scene
  88316. * @param container the container holding the elements
  88317. */
  88318. addFromContainer(container: AbstractScene): void;
  88319. /**
  88320. * Removes all the elements in the container from the scene
  88321. * @param container contains the elements to remove
  88322. * @param dispose if the removed element should be disposed (default: false)
  88323. */
  88324. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  88325. /**
  88326. * Serializes the component data to the specified json object
  88327. * @param serializationObject The object to serialize to
  88328. */
  88329. serialize(serializationObject: any): void;
  88330. }
  88331. /**
  88332. * Strong typing of a Mesh related stage step action
  88333. */
  88334. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  88335. /**
  88336. * Strong typing of a Evaluate Sub Mesh related stage step action
  88337. */
  88338. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  88339. /**
  88340. * Strong typing of a Active Mesh related stage step action
  88341. */
  88342. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  88343. /**
  88344. * Strong typing of a Camera related stage step action
  88345. */
  88346. export type CameraStageAction = (camera: Camera) => void;
  88347. /**
  88348. * Strong typing of a Camera Frame buffer related stage step action
  88349. */
  88350. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  88351. /**
  88352. * Strong typing of a Render Target related stage step action
  88353. */
  88354. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  88355. /**
  88356. * Strong typing of a RenderingGroup related stage step action
  88357. */
  88358. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  88359. /**
  88360. * Strong typing of a Mesh Render related stage step action
  88361. */
  88362. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  88363. /**
  88364. * Strong typing of a simple stage step action
  88365. */
  88366. export type SimpleStageAction = () => void;
  88367. /**
  88368. * Strong typing of a render target action.
  88369. */
  88370. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  88371. /**
  88372. * Strong typing of a pointer move action.
  88373. */
  88374. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  88375. /**
  88376. * Strong typing of a pointer up/down action.
  88377. */
  88378. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  88379. /**
  88380. * Representation of a stage in the scene (Basically a list of ordered steps)
  88381. * @hidden
  88382. */
  88383. export class Stage<T extends Function> extends Array<{
  88384. index: number;
  88385. component: ISceneComponent;
  88386. action: T;
  88387. }> {
  88388. /**
  88389. * Hide ctor from the rest of the world.
  88390. * @param items The items to add.
  88391. */
  88392. private constructor();
  88393. /**
  88394. * Creates a new Stage.
  88395. * @returns A new instance of a Stage
  88396. */
  88397. static Create<T extends Function>(): Stage<T>;
  88398. /**
  88399. * Registers a step in an ordered way in the targeted stage.
  88400. * @param index Defines the position to register the step in
  88401. * @param component Defines the component attached to the step
  88402. * @param action Defines the action to launch during the step
  88403. */
  88404. registerStep(index: number, component: ISceneComponent, action: T): void;
  88405. /**
  88406. * Clears all the steps from the stage.
  88407. */
  88408. clear(): void;
  88409. }
  88410. }
  88411. declare module BABYLON {
  88412. interface Scene {
  88413. /** @hidden */
  88414. _pointerOverSprite: Nullable<Sprite>;
  88415. /** @hidden */
  88416. _pickedDownSprite: Nullable<Sprite>;
  88417. /** @hidden */
  88418. _tempSpritePickingRay: Nullable<Ray>;
  88419. /**
  88420. * All of the sprite managers added to this scene
  88421. * @see http://doc.babylonjs.com/babylon101/sprites
  88422. */
  88423. spriteManagers: Array<ISpriteManager>;
  88424. /**
  88425. * An event triggered when sprites rendering is about to start
  88426. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  88427. */
  88428. onBeforeSpritesRenderingObservable: Observable<Scene>;
  88429. /**
  88430. * An event triggered when sprites rendering is done
  88431. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  88432. */
  88433. onAfterSpritesRenderingObservable: Observable<Scene>;
  88434. /** @hidden */
  88435. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88436. /** Launch a ray to try to pick a sprite in the scene
  88437. * @param x position on screen
  88438. * @param y position on screen
  88439. * @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
  88440. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88441. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88442. * @returns a PickingInfo
  88443. */
  88444. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88445. /** Use the given ray to pick a sprite in the scene
  88446. * @param ray The ray (in world space) to use to pick meshes
  88447. * @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
  88448. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88449. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  88450. * @returns a PickingInfo
  88451. */
  88452. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88453. /** @hidden */
  88454. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88455. /** Launch a ray to try to pick sprites in the scene
  88456. * @param x position on screen
  88457. * @param y position on screen
  88458. * @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
  88459. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88460. * @returns a PickingInfo array
  88461. */
  88462. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88463. /** Use the given ray to pick sprites in the scene
  88464. * @param ray The ray (in world space) to use to pick meshes
  88465. * @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
  88466. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  88467. * @returns a PickingInfo array
  88468. */
  88469. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88470. /**
  88471. * Force the sprite under the pointer
  88472. * @param sprite defines the sprite to use
  88473. */
  88474. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  88475. /**
  88476. * Gets the sprite under the pointer
  88477. * @returns a Sprite or null if no sprite is under the pointer
  88478. */
  88479. getPointerOverSprite(): Nullable<Sprite>;
  88480. }
  88481. /**
  88482. * Defines the sprite scene component responsible to manage sprites
  88483. * in a given scene.
  88484. */
  88485. export class SpriteSceneComponent implements ISceneComponent {
  88486. /**
  88487. * The component name helpfull to identify the component in the list of scene components.
  88488. */
  88489. readonly name: string;
  88490. /**
  88491. * The scene the component belongs to.
  88492. */
  88493. scene: Scene;
  88494. /** @hidden */
  88495. private _spritePredicate;
  88496. /**
  88497. * Creates a new instance of the component for the given scene
  88498. * @param scene Defines the scene to register the component in
  88499. */
  88500. constructor(scene: Scene);
  88501. /**
  88502. * Registers the component in a given scene
  88503. */
  88504. register(): void;
  88505. /**
  88506. * Rebuilds the elements related to this component in case of
  88507. * context lost for instance.
  88508. */
  88509. rebuild(): void;
  88510. /**
  88511. * Disposes the component and the associated ressources.
  88512. */
  88513. dispose(): void;
  88514. private _pickSpriteButKeepRay;
  88515. private _pointerMove;
  88516. private _pointerDown;
  88517. private _pointerUp;
  88518. }
  88519. }
  88520. declare module BABYLON {
  88521. /** @hidden */
  88522. export var fogFragmentDeclaration: {
  88523. name: string;
  88524. shader: string;
  88525. };
  88526. }
  88527. declare module BABYLON {
  88528. /** @hidden */
  88529. export var fogFragment: {
  88530. name: string;
  88531. shader: string;
  88532. };
  88533. }
  88534. declare module BABYLON {
  88535. /** @hidden */
  88536. export var spritesPixelShader: {
  88537. name: string;
  88538. shader: string;
  88539. };
  88540. }
  88541. declare module BABYLON {
  88542. /** @hidden */
  88543. export var fogVertexDeclaration: {
  88544. name: string;
  88545. shader: string;
  88546. };
  88547. }
  88548. declare module BABYLON {
  88549. /** @hidden */
  88550. export var spritesVertexShader: {
  88551. name: string;
  88552. shader: string;
  88553. };
  88554. }
  88555. declare module BABYLON {
  88556. /**
  88557. * Defines the minimum interface to fullfil in order to be a sprite manager.
  88558. */
  88559. export interface ISpriteManager extends IDisposable {
  88560. /**
  88561. * Gets manager's name
  88562. */
  88563. name: string;
  88564. /**
  88565. * Restricts the camera to viewing objects with the same layerMask.
  88566. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  88567. */
  88568. layerMask: number;
  88569. /**
  88570. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  88571. */
  88572. isPickable: boolean;
  88573. /**
  88574. * Gets the hosting scene
  88575. */
  88576. scene: Scene;
  88577. /**
  88578. * Specifies the rendering group id for this mesh (0 by default)
  88579. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  88580. */
  88581. renderingGroupId: number;
  88582. /**
  88583. * Defines the list of sprites managed by the manager.
  88584. */
  88585. sprites: Array<Sprite>;
  88586. /**
  88587. * Gets or sets the spritesheet texture
  88588. */
  88589. texture: Texture;
  88590. /** Defines the default width of a cell in the spritesheet */
  88591. cellWidth: number;
  88592. /** Defines the default height of a cell in the spritesheet */
  88593. cellHeight: number;
  88594. /**
  88595. * Tests the intersection of a sprite with a specific ray.
  88596. * @param ray The ray we are sending to test the collision
  88597. * @param camera The camera space we are sending rays in
  88598. * @param predicate A predicate allowing excluding sprites from the list of object to test
  88599. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88600. * @returns picking info or null.
  88601. */
  88602. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88603. /**
  88604. * Intersects the sprites with a ray
  88605. * @param ray defines the ray to intersect with
  88606. * @param camera defines the current active camera
  88607. * @param predicate defines a predicate used to select candidate sprites
  88608. * @returns null if no hit or a PickingInfo array
  88609. */
  88610. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  88611. /**
  88612. * Renders the list of sprites on screen.
  88613. */
  88614. render(): void;
  88615. }
  88616. /**
  88617. * Class used to manage multiple sprites on the same spritesheet
  88618. * @see http://doc.babylonjs.com/babylon101/sprites
  88619. */
  88620. export class SpriteManager implements ISpriteManager {
  88621. /** defines the manager's name */
  88622. name: string;
  88623. /** Define the Url to load snippets */
  88624. static SnippetUrl: string;
  88625. /** Snippet ID if the manager was created from the snippet server */
  88626. snippetId: string;
  88627. /** Gets the list of sprites */
  88628. sprites: Sprite[];
  88629. /** Gets or sets the rendering group id (0 by default) */
  88630. renderingGroupId: number;
  88631. /** Gets or sets camera layer mask */
  88632. layerMask: number;
  88633. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  88634. fogEnabled: boolean;
  88635. /** Gets or sets a boolean indicating if the sprites are pickable */
  88636. isPickable: boolean;
  88637. /** Defines the default width of a cell in the spritesheet */
  88638. cellWidth: number;
  88639. /** Defines the default height of a cell in the spritesheet */
  88640. cellHeight: number;
  88641. /** Associative array from JSON sprite data file */
  88642. private _cellData;
  88643. /** Array of sprite names from JSON sprite data file */
  88644. private _spriteMap;
  88645. /** True when packed cell data from JSON file is ready*/
  88646. private _packedAndReady;
  88647. private _textureContent;
  88648. /**
  88649. * An event triggered when the manager is disposed.
  88650. */
  88651. onDisposeObservable: Observable<SpriteManager>;
  88652. private _onDisposeObserver;
  88653. /**
  88654. * Callback called when the manager is disposed
  88655. */
  88656. set onDispose(callback: () => void);
  88657. private _capacity;
  88658. private _fromPacked;
  88659. private _spriteTexture;
  88660. private _epsilon;
  88661. private _scene;
  88662. private _vertexData;
  88663. private _buffer;
  88664. private _vertexBuffers;
  88665. private _indexBuffer;
  88666. private _effectBase;
  88667. private _effectFog;
  88668. /**
  88669. * Gets or sets the unique id of the sprite
  88670. */
  88671. uniqueId: number;
  88672. /**
  88673. * Gets the array of sprites
  88674. */
  88675. get children(): Sprite[];
  88676. /**
  88677. * Gets the hosting scene
  88678. */
  88679. get scene(): Scene;
  88680. /**
  88681. * Gets the capacity of the manager
  88682. */
  88683. get capacity(): number;
  88684. /**
  88685. * Gets or sets the spritesheet texture
  88686. */
  88687. get texture(): Texture;
  88688. set texture(value: Texture);
  88689. private _blendMode;
  88690. /**
  88691. * Blend mode use to render the particle, it can be any of
  88692. * the static Constants.ALPHA_x properties provided in this class.
  88693. * Default value is Constants.ALPHA_COMBINE
  88694. */
  88695. get blendMode(): number;
  88696. set blendMode(blendMode: number);
  88697. /** Disables writing to the depth buffer when rendering the sprites.
  88698. * It can be handy to disable depth writing when using textures without alpha channel
  88699. * and setting some specific blend modes.
  88700. */
  88701. disableDepthWrite: boolean;
  88702. /**
  88703. * Creates a new sprite manager
  88704. * @param name defines the manager's name
  88705. * @param imgUrl defines the sprite sheet url
  88706. * @param capacity defines the maximum allowed number of sprites
  88707. * @param cellSize defines the size of a sprite cell
  88708. * @param scene defines the hosting scene
  88709. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  88710. * @param samplingMode defines the smapling mode to use with spritesheet
  88711. * @param fromPacked set to false; do not alter
  88712. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  88713. */
  88714. constructor(
  88715. /** defines the manager's name */
  88716. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  88717. /**
  88718. * Returns the string "SpriteManager"
  88719. * @returns "SpriteManager"
  88720. */
  88721. getClassName(): string;
  88722. private _makePacked;
  88723. private _appendSpriteVertex;
  88724. private _checkTextureAlpha;
  88725. /**
  88726. * Intersects the sprites with a ray
  88727. * @param ray defines the ray to intersect with
  88728. * @param camera defines the current active camera
  88729. * @param predicate defines a predicate used to select candidate sprites
  88730. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  88731. * @returns null if no hit or a PickingInfo
  88732. */
  88733. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88734. /**
  88735. * Intersects the sprites with a ray
  88736. * @param ray defines the ray to intersect with
  88737. * @param camera defines the current active camera
  88738. * @param predicate defines a predicate used to select candidate sprites
  88739. * @returns null if no hit or a PickingInfo array
  88740. */
  88741. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  88742. /**
  88743. * Render all child sprites
  88744. */
  88745. render(): void;
  88746. /**
  88747. * Release associated resources
  88748. */
  88749. dispose(): void;
  88750. /**
  88751. * Serializes the sprite manager to a JSON object
  88752. * @param serializeTexture defines if the texture must be serialized as well
  88753. * @returns the JSON object
  88754. */
  88755. serialize(serializeTexture?: boolean): any;
  88756. /**
  88757. * Parses a JSON object to create a new sprite manager.
  88758. * @param parsedManager The JSON object to parse
  88759. * @param scene The scene to create the sprite managerin
  88760. * @param rootUrl The root url to use to load external dependencies like texture
  88761. * @returns the new sprite manager
  88762. */
  88763. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  88764. /**
  88765. * Creates a sprite manager from a snippet saved in a remote file
  88766. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  88767. * @param url defines the url to load from
  88768. * @param scene defines the hosting scene
  88769. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88770. * @returns a promise that will resolve to the new sprite manager
  88771. */
  88772. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  88773. /**
  88774. * Creates a sprite manager from a snippet saved by the sprite editor
  88775. * @param snippetId defines the snippet to load
  88776. * @param scene defines the hosting scene
  88777. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88778. * @returns a promise that will resolve to the new sprite manager
  88779. */
  88780. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  88781. }
  88782. }
  88783. declare module BABYLON {
  88784. /** Interface used by value gradients (color, factor, ...) */
  88785. export interface IValueGradient {
  88786. /**
  88787. * Gets or sets the gradient value (between 0 and 1)
  88788. */
  88789. gradient: number;
  88790. }
  88791. /** Class used to store color4 gradient */
  88792. export class ColorGradient implements IValueGradient {
  88793. /**
  88794. * Gets or sets the gradient value (between 0 and 1)
  88795. */
  88796. gradient: number;
  88797. /**
  88798. * Gets or sets first associated color
  88799. */
  88800. color1: Color4;
  88801. /**
  88802. * Gets or sets second associated color
  88803. */
  88804. color2?: Color4 | undefined;
  88805. /**
  88806. * Creates a new color4 gradient
  88807. * @param gradient gets or sets the gradient value (between 0 and 1)
  88808. * @param color1 gets or sets first associated color
  88809. * @param color2 gets or sets first second color
  88810. */
  88811. constructor(
  88812. /**
  88813. * Gets or sets the gradient value (between 0 and 1)
  88814. */
  88815. gradient: number,
  88816. /**
  88817. * Gets or sets first associated color
  88818. */
  88819. color1: Color4,
  88820. /**
  88821. * Gets or sets second associated color
  88822. */
  88823. color2?: Color4 | undefined);
  88824. /**
  88825. * Will get a color picked randomly between color1 and color2.
  88826. * If color2 is undefined then color1 will be used
  88827. * @param result defines the target Color4 to store the result in
  88828. */
  88829. getColorToRef(result: Color4): void;
  88830. }
  88831. /** Class used to store color 3 gradient */
  88832. export class Color3Gradient implements IValueGradient {
  88833. /**
  88834. * Gets or sets the gradient value (between 0 and 1)
  88835. */
  88836. gradient: number;
  88837. /**
  88838. * Gets or sets the associated color
  88839. */
  88840. color: Color3;
  88841. /**
  88842. * Creates a new color3 gradient
  88843. * @param gradient gets or sets the gradient value (between 0 and 1)
  88844. * @param color gets or sets associated color
  88845. */
  88846. constructor(
  88847. /**
  88848. * Gets or sets the gradient value (between 0 and 1)
  88849. */
  88850. gradient: number,
  88851. /**
  88852. * Gets or sets the associated color
  88853. */
  88854. color: Color3);
  88855. }
  88856. /** Class used to store factor gradient */
  88857. export class FactorGradient implements IValueGradient {
  88858. /**
  88859. * Gets or sets the gradient value (between 0 and 1)
  88860. */
  88861. gradient: number;
  88862. /**
  88863. * Gets or sets first associated factor
  88864. */
  88865. factor1: number;
  88866. /**
  88867. * Gets or sets second associated factor
  88868. */
  88869. factor2?: number | undefined;
  88870. /**
  88871. * Creates a new factor gradient
  88872. * @param gradient gets or sets the gradient value (between 0 and 1)
  88873. * @param factor1 gets or sets first associated factor
  88874. * @param factor2 gets or sets second associated factor
  88875. */
  88876. constructor(
  88877. /**
  88878. * Gets or sets the gradient value (between 0 and 1)
  88879. */
  88880. gradient: number,
  88881. /**
  88882. * Gets or sets first associated factor
  88883. */
  88884. factor1: number,
  88885. /**
  88886. * Gets or sets second associated factor
  88887. */
  88888. factor2?: number | undefined);
  88889. /**
  88890. * Will get a number picked randomly between factor1 and factor2.
  88891. * If factor2 is undefined then factor1 will be used
  88892. * @returns the picked number
  88893. */
  88894. getFactor(): number;
  88895. }
  88896. /**
  88897. * Helper used to simplify some generic gradient tasks
  88898. */
  88899. export class GradientHelper {
  88900. /**
  88901. * Gets the current gradient from an array of IValueGradient
  88902. * @param ratio defines the current ratio to get
  88903. * @param gradients defines the array of IValueGradient
  88904. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88905. */
  88906. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88907. }
  88908. }
  88909. declare module BABYLON {
  88910. interface ThinEngine {
  88911. /**
  88912. * Creates a dynamic texture
  88913. * @param width defines the width of the texture
  88914. * @param height defines the height of the texture
  88915. * @param generateMipMaps defines if the engine should generate the mip levels
  88916. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88917. * @returns the dynamic texture inside an InternalTexture
  88918. */
  88919. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88920. /**
  88921. * Update the content of a dynamic texture
  88922. * @param texture defines the texture to update
  88923. * @param canvas defines the canvas containing the source
  88924. * @param invertY defines if data must be stored with Y axis inverted
  88925. * @param premulAlpha defines if alpha is stored as premultiplied
  88926. * @param format defines the format of the data
  88927. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88928. */
  88929. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88930. }
  88931. }
  88932. declare module BABYLON {
  88933. /**
  88934. * Helper class used to generate a canvas to manipulate images
  88935. */
  88936. export class CanvasGenerator {
  88937. /**
  88938. * Create a new canvas (or offscreen canvas depending on the context)
  88939. * @param width defines the expected width
  88940. * @param height defines the expected height
  88941. * @return a new canvas or offscreen canvas
  88942. */
  88943. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  88944. }
  88945. }
  88946. declare module BABYLON {
  88947. /**
  88948. * A class extending Texture allowing drawing on a texture
  88949. * @see http://doc.babylonjs.com/how_to/dynamictexture
  88950. */
  88951. export class DynamicTexture extends Texture {
  88952. private _generateMipMaps;
  88953. private _canvas;
  88954. private _context;
  88955. /**
  88956. * Creates a DynamicTexture
  88957. * @param name defines the name of the texture
  88958. * @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
  88959. * @param scene defines the scene where you want the texture
  88960. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  88961. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  88962. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  88963. */
  88964. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  88965. /**
  88966. * Get the current class name of the texture useful for serialization or dynamic coding.
  88967. * @returns "DynamicTexture"
  88968. */
  88969. getClassName(): string;
  88970. /**
  88971. * Gets the current state of canRescale
  88972. */
  88973. get canRescale(): boolean;
  88974. private _recreate;
  88975. /**
  88976. * Scales the texture
  88977. * @param ratio the scale factor to apply to both width and height
  88978. */
  88979. scale(ratio: number): void;
  88980. /**
  88981. * Resizes the texture
  88982. * @param width the new width
  88983. * @param height the new height
  88984. */
  88985. scaleTo(width: number, height: number): void;
  88986. /**
  88987. * Gets the context of the canvas used by the texture
  88988. * @returns the canvas context of the dynamic texture
  88989. */
  88990. getContext(): CanvasRenderingContext2D;
  88991. /**
  88992. * Clears the texture
  88993. */
  88994. clear(): void;
  88995. /**
  88996. * Updates the texture
  88997. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  88998. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  88999. */
  89000. update(invertY?: boolean, premulAlpha?: boolean): void;
  89001. /**
  89002. * Draws text onto the texture
  89003. * @param text defines the text to be drawn
  89004. * @param x defines the placement of the text from the left
  89005. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  89006. * @param font defines the font to be used with font-style, font-size, font-name
  89007. * @param color defines the color used for the text
  89008. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  89009. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  89010. * @param update defines whether texture is immediately update (default is true)
  89011. */
  89012. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  89013. /**
  89014. * Clones the texture
  89015. * @returns the clone of the texture.
  89016. */
  89017. clone(): DynamicTexture;
  89018. /**
  89019. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  89020. * @returns a serialized dynamic texture object
  89021. */
  89022. serialize(): any;
  89023. /** @hidden */
  89024. _rebuild(): void;
  89025. }
  89026. }
  89027. declare module BABYLON {
  89028. interface ThinEngine {
  89029. /**
  89030. * Creates a raw texture
  89031. * @param data defines the data to store in the texture
  89032. * @param width defines the width of the texture
  89033. * @param height defines the height of the texture
  89034. * @param format defines the format of the data
  89035. * @param generateMipMaps defines if the engine should generate the mip levels
  89036. * @param invertY defines if data must be stored with Y axis inverted
  89037. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  89038. * @param compression defines the compression used (null by default)
  89039. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89040. * @returns the raw texture inside an InternalTexture
  89041. */
  89042. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  89043. /**
  89044. * Update a raw texture
  89045. * @param texture defines the texture to update
  89046. * @param data defines the data to store in the texture
  89047. * @param format defines the format of the data
  89048. * @param invertY defines if data must be stored with Y axis inverted
  89049. */
  89050. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89051. /**
  89052. * Update a raw texture
  89053. * @param texture defines the texture to update
  89054. * @param data defines the data to store in the texture
  89055. * @param format defines the format of the data
  89056. * @param invertY defines if data must be stored with Y axis inverted
  89057. * @param compression defines the compression used (null by default)
  89058. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89059. */
  89060. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  89061. /**
  89062. * Creates a new raw cube texture
  89063. * @param data defines the array of data to use to create each face
  89064. * @param size defines the size of the textures
  89065. * @param format defines the format of the data
  89066. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89067. * @param generateMipMaps defines if the engine should generate the mip levels
  89068. * @param invertY defines if data must be stored with Y axis inverted
  89069. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89070. * @param compression defines the compression used (null by default)
  89071. * @returns the cube texture as an InternalTexture
  89072. */
  89073. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  89074. /**
  89075. * Update a raw cube texture
  89076. * @param texture defines the texture to udpdate
  89077. * @param data defines the data to store
  89078. * @param format defines the data format
  89079. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89080. * @param invertY defines if data must be stored with Y axis inverted
  89081. */
  89082. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  89083. /**
  89084. * Update a raw cube texture
  89085. * @param texture defines the texture to udpdate
  89086. * @param data defines the data to store
  89087. * @param format defines the data format
  89088. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89089. * @param invertY defines if data must be stored with Y axis inverted
  89090. * @param compression defines the compression used (null by default)
  89091. */
  89092. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  89093. /**
  89094. * Update a raw cube texture
  89095. * @param texture defines the texture to udpdate
  89096. * @param data defines the data to store
  89097. * @param format defines the data format
  89098. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89099. * @param invertY defines if data must be stored with Y axis inverted
  89100. * @param compression defines the compression used (null by default)
  89101. * @param level defines which level of the texture to update
  89102. */
  89103. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  89104. /**
  89105. * Creates a new raw cube texture from a specified url
  89106. * @param url defines the url where the data is located
  89107. * @param scene defines the current scene
  89108. * @param size defines the size of the textures
  89109. * @param format defines the format of the data
  89110. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89111. * @param noMipmap defines if the engine should avoid generating the mip levels
  89112. * @param callback defines a callback used to extract texture data from loaded data
  89113. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89114. * @param onLoad defines a callback called when texture is loaded
  89115. * @param onError defines a callback called if there is an error
  89116. * @returns the cube texture as an InternalTexture
  89117. */
  89118. 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;
  89119. /**
  89120. * Creates a new raw cube texture from a specified url
  89121. * @param url defines the url where the data is located
  89122. * @param scene defines the current scene
  89123. * @param size defines the size of the textures
  89124. * @param format defines the format of the data
  89125. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89126. * @param noMipmap defines if the engine should avoid generating the mip levels
  89127. * @param callback defines a callback used to extract texture data from loaded data
  89128. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89129. * @param onLoad defines a callback called when texture is loaded
  89130. * @param onError defines a callback called if there is an error
  89131. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89132. * @param invertY defines if data must be stored with Y axis inverted
  89133. * @returns the cube texture as an InternalTexture
  89134. */
  89135. 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;
  89136. /**
  89137. * Creates a new raw 3D texture
  89138. * @param data defines the data used to create the texture
  89139. * @param width defines the width of the texture
  89140. * @param height defines the height of the texture
  89141. * @param depth defines the depth of the texture
  89142. * @param format defines the format of the texture
  89143. * @param generateMipMaps defines if the engine must generate mip levels
  89144. * @param invertY defines if data must be stored with Y axis inverted
  89145. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89146. * @param compression defines the compressed used (can be null)
  89147. * @param textureType defines the compressed used (can be null)
  89148. * @returns a new raw 3D texture (stored in an InternalTexture)
  89149. */
  89150. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89151. /**
  89152. * Update a raw 3D texture
  89153. * @param texture defines the texture to update
  89154. * @param data defines the data to store
  89155. * @param format defines the data format
  89156. * @param invertY defines if data must be stored with Y axis inverted
  89157. */
  89158. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89159. /**
  89160. * Update a raw 3D texture
  89161. * @param texture defines the texture to update
  89162. * @param data defines the data to store
  89163. * @param format defines the data format
  89164. * @param invertY defines if data must be stored with Y axis inverted
  89165. * @param compression defines the used compression (can be null)
  89166. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89167. */
  89168. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89169. /**
  89170. * Creates a new raw 2D array texture
  89171. * @param data defines the data used to create the texture
  89172. * @param width defines the width of the texture
  89173. * @param height defines the height of the texture
  89174. * @param depth defines the number of layers of the texture
  89175. * @param format defines the format of the texture
  89176. * @param generateMipMaps defines if the engine must generate mip levels
  89177. * @param invertY defines if data must be stored with Y axis inverted
  89178. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89179. * @param compression defines the compressed used (can be null)
  89180. * @param textureType defines the compressed used (can be null)
  89181. * @returns a new raw 2D array texture (stored in an InternalTexture)
  89182. */
  89183. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89184. /**
  89185. * Update a raw 2D array texture
  89186. * @param texture defines the texture to update
  89187. * @param data defines the data to store
  89188. * @param format defines the data format
  89189. * @param invertY defines if data must be stored with Y axis inverted
  89190. */
  89191. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89192. /**
  89193. * Update a raw 2D array texture
  89194. * @param texture defines the texture to update
  89195. * @param data defines the data to store
  89196. * @param format defines the data format
  89197. * @param invertY defines if data must be stored with Y axis inverted
  89198. * @param compression defines the used compression (can be null)
  89199. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89200. */
  89201. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89202. }
  89203. }
  89204. declare module BABYLON {
  89205. /**
  89206. * Raw texture can help creating a texture directly from an array of data.
  89207. * This can be super useful if you either get the data from an uncompressed source or
  89208. * if you wish to create your texture pixel by pixel.
  89209. */
  89210. export class RawTexture extends Texture {
  89211. /**
  89212. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89213. */
  89214. format: number;
  89215. /**
  89216. * Instantiates a new RawTexture.
  89217. * Raw texture can help creating a texture directly from an array of data.
  89218. * This can be super useful if you either get the data from an uncompressed source or
  89219. * if you wish to create your texture pixel by pixel.
  89220. * @param data define the array of data to use to create the texture
  89221. * @param width define the width of the texture
  89222. * @param height define the height of the texture
  89223. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89224. * @param scene define the scene the texture belongs to
  89225. * @param generateMipMaps define whether mip maps should be generated or not
  89226. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89227. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89228. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89229. */
  89230. constructor(data: ArrayBufferView, width: number, height: number,
  89231. /**
  89232. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89233. */
  89234. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  89235. /**
  89236. * Updates the texture underlying data.
  89237. * @param data Define the new data of the texture
  89238. */
  89239. update(data: ArrayBufferView): void;
  89240. /**
  89241. * Creates a luminance texture from some data.
  89242. * @param data Define the texture data
  89243. * @param width Define the width of the texture
  89244. * @param height Define the height of the texture
  89245. * @param scene Define the scene the texture belongs to
  89246. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89247. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89248. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89249. * @returns the luminance texture
  89250. */
  89251. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89252. /**
  89253. * Creates a luminance alpha texture from some data.
  89254. * @param data Define the texture data
  89255. * @param width Define the width of the texture
  89256. * @param height Define the height of the texture
  89257. * @param scene Define the scene the texture belongs to
  89258. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89259. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89260. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89261. * @returns the luminance alpha texture
  89262. */
  89263. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89264. /**
  89265. * Creates an alpha texture from some data.
  89266. * @param data Define the texture data
  89267. * @param width Define the width of the texture
  89268. * @param height Define the height of the texture
  89269. * @param scene Define the scene the texture belongs to
  89270. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89271. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89272. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89273. * @returns the alpha texture
  89274. */
  89275. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89276. /**
  89277. * Creates a RGB texture from some data.
  89278. * @param data Define the texture data
  89279. * @param width Define the width of the texture
  89280. * @param height Define the height of the texture
  89281. * @param scene Define the scene the texture belongs to
  89282. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89283. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89284. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89285. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89286. * @returns the RGB alpha texture
  89287. */
  89288. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89289. /**
  89290. * Creates a RGBA texture from some data.
  89291. * @param data Define the texture data
  89292. * @param width Define the width of the texture
  89293. * @param height Define the height of the texture
  89294. * @param scene Define the scene the texture belongs to
  89295. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89296. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89297. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89298. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89299. * @returns the RGBA texture
  89300. */
  89301. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89302. /**
  89303. * Creates a R texture from some data.
  89304. * @param data Define the texture data
  89305. * @param width Define the width of the texture
  89306. * @param height Define the height of the texture
  89307. * @param scene Define the scene the texture belongs to
  89308. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89309. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89310. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89311. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89312. * @returns the R texture
  89313. */
  89314. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89315. }
  89316. }
  89317. declare module BABYLON {
  89318. interface AbstractScene {
  89319. /**
  89320. * The list of procedural textures added to the scene
  89321. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89322. */
  89323. proceduralTextures: Array<ProceduralTexture>;
  89324. }
  89325. /**
  89326. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  89327. * in a given scene.
  89328. */
  89329. export class ProceduralTextureSceneComponent implements ISceneComponent {
  89330. /**
  89331. * The component name helpfull to identify the component in the list of scene components.
  89332. */
  89333. readonly name: string;
  89334. /**
  89335. * The scene the component belongs to.
  89336. */
  89337. scene: Scene;
  89338. /**
  89339. * Creates a new instance of the component for the given scene
  89340. * @param scene Defines the scene to register the component in
  89341. */
  89342. constructor(scene: Scene);
  89343. /**
  89344. * Registers the component in a given scene
  89345. */
  89346. register(): void;
  89347. /**
  89348. * Rebuilds the elements related to this component in case of
  89349. * context lost for instance.
  89350. */
  89351. rebuild(): void;
  89352. /**
  89353. * Disposes the component and the associated ressources.
  89354. */
  89355. dispose(): void;
  89356. private _beforeClear;
  89357. }
  89358. }
  89359. declare module BABYLON {
  89360. interface ThinEngine {
  89361. /**
  89362. * Creates a new render target cube texture
  89363. * @param size defines the size of the texture
  89364. * @param options defines the options used to create the texture
  89365. * @returns a new render target cube texture stored in an InternalTexture
  89366. */
  89367. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  89368. }
  89369. }
  89370. declare module BABYLON {
  89371. /** @hidden */
  89372. export var proceduralVertexShader: {
  89373. name: string;
  89374. shader: string;
  89375. };
  89376. }
  89377. declare module BABYLON {
  89378. /**
  89379. * 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.
  89380. * This is the base class of any Procedural texture and contains most of the shareable code.
  89381. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89382. */
  89383. export class ProceduralTexture extends Texture {
  89384. isCube: boolean;
  89385. /**
  89386. * Define if the texture is enabled or not (disabled texture will not render)
  89387. */
  89388. isEnabled: boolean;
  89389. /**
  89390. * Define if the texture must be cleared before rendering (default is true)
  89391. */
  89392. autoClear: boolean;
  89393. /**
  89394. * Callback called when the texture is generated
  89395. */
  89396. onGenerated: () => void;
  89397. /**
  89398. * Event raised when the texture is generated
  89399. */
  89400. onGeneratedObservable: Observable<ProceduralTexture>;
  89401. /** @hidden */
  89402. _generateMipMaps: boolean;
  89403. /** @hidden **/
  89404. _effect: Effect;
  89405. /** @hidden */
  89406. _textures: {
  89407. [key: string]: Texture;
  89408. };
  89409. /** @hidden */
  89410. protected _fallbackTexture: Nullable<Texture>;
  89411. private _size;
  89412. private _currentRefreshId;
  89413. private _frameId;
  89414. private _refreshRate;
  89415. private _vertexBuffers;
  89416. private _indexBuffer;
  89417. private _uniforms;
  89418. private _samplers;
  89419. private _fragment;
  89420. private _floats;
  89421. private _ints;
  89422. private _floatsArrays;
  89423. private _colors3;
  89424. private _colors4;
  89425. private _vectors2;
  89426. private _vectors3;
  89427. private _matrices;
  89428. private _fallbackTextureUsed;
  89429. private _fullEngine;
  89430. private _cachedDefines;
  89431. private _contentUpdateId;
  89432. private _contentData;
  89433. /**
  89434. * Instantiates a new procedural texture.
  89435. * 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.
  89436. * This is the base class of any Procedural texture and contains most of the shareable code.
  89437. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89438. * @param name Define the name of the texture
  89439. * @param size Define the size of the texture to create
  89440. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  89441. * @param scene Define the scene the texture belongs to
  89442. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  89443. * @param generateMipMaps Define if the texture should creates mip maps or not
  89444. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  89445. */
  89446. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  89447. /**
  89448. * The effect that is created when initializing the post process.
  89449. * @returns The created effect corresponding the the postprocess.
  89450. */
  89451. getEffect(): Effect;
  89452. /**
  89453. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  89454. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  89455. */
  89456. getContent(): Nullable<ArrayBufferView>;
  89457. private _createIndexBuffer;
  89458. /** @hidden */
  89459. _rebuild(): void;
  89460. /**
  89461. * Resets the texture in order to recreate its associated resources.
  89462. * This can be called in case of context loss
  89463. */
  89464. reset(): void;
  89465. protected _getDefines(): string;
  89466. /**
  89467. * Is the texture ready to be used ? (rendered at least once)
  89468. * @returns true if ready, otherwise, false.
  89469. */
  89470. isReady(): boolean;
  89471. /**
  89472. * Resets the refresh counter of the texture and start bak from scratch.
  89473. * Could be useful to regenerate the texture if it is setup to render only once.
  89474. */
  89475. resetRefreshCounter(): void;
  89476. /**
  89477. * Set the fragment shader to use in order to render the texture.
  89478. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  89479. */
  89480. setFragment(fragment: any): void;
  89481. /**
  89482. * Define the refresh rate of the texture or the rendering frequency.
  89483. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89484. */
  89485. get refreshRate(): number;
  89486. set refreshRate(value: number);
  89487. /** @hidden */
  89488. _shouldRender(): boolean;
  89489. /**
  89490. * Get the size the texture is rendering at.
  89491. * @returns the size (texture is always squared)
  89492. */
  89493. getRenderSize(): number;
  89494. /**
  89495. * Resize the texture to new value.
  89496. * @param size Define the new size the texture should have
  89497. * @param generateMipMaps Define whether the new texture should create mip maps
  89498. */
  89499. resize(size: number, generateMipMaps: boolean): void;
  89500. private _checkUniform;
  89501. /**
  89502. * Set a texture in the shader program used to render.
  89503. * @param name Define the name of the uniform samplers as defined in the shader
  89504. * @param texture Define the texture to bind to this sampler
  89505. * @return the texture itself allowing "fluent" like uniform updates
  89506. */
  89507. setTexture(name: string, texture: Texture): ProceduralTexture;
  89508. /**
  89509. * Set a float in the shader.
  89510. * @param name Define the name of the uniform as defined in the shader
  89511. * @param value Define the value to give to the uniform
  89512. * @return the texture itself allowing "fluent" like uniform updates
  89513. */
  89514. setFloat(name: string, value: number): ProceduralTexture;
  89515. /**
  89516. * Set a int in the shader.
  89517. * @param name Define the name of the uniform as defined in the shader
  89518. * @param value Define the value to give to the uniform
  89519. * @return the texture itself allowing "fluent" like uniform updates
  89520. */
  89521. setInt(name: string, value: number): ProceduralTexture;
  89522. /**
  89523. * Set an array of floats in the shader.
  89524. * @param name Define the name of the uniform as defined in the shader
  89525. * @param value Define the value to give to the uniform
  89526. * @return the texture itself allowing "fluent" like uniform updates
  89527. */
  89528. setFloats(name: string, value: number[]): ProceduralTexture;
  89529. /**
  89530. * Set a vec3 in the shader from a Color3.
  89531. * @param name Define the name of the uniform as defined in the shader
  89532. * @param value Define the value to give to the uniform
  89533. * @return the texture itself allowing "fluent" like uniform updates
  89534. */
  89535. setColor3(name: string, value: Color3): ProceduralTexture;
  89536. /**
  89537. * Set a vec4 in the shader from a Color4.
  89538. * @param name Define the name of the uniform as defined in the shader
  89539. * @param value Define the value to give to the uniform
  89540. * @return the texture itself allowing "fluent" like uniform updates
  89541. */
  89542. setColor4(name: string, value: Color4): ProceduralTexture;
  89543. /**
  89544. * Set a vec2 in the shader from a Vector2.
  89545. * @param name Define the name of the uniform as defined in the shader
  89546. * @param value Define the value to give to the uniform
  89547. * @return the texture itself allowing "fluent" like uniform updates
  89548. */
  89549. setVector2(name: string, value: Vector2): ProceduralTexture;
  89550. /**
  89551. * Set a vec3 in the shader from a Vector3.
  89552. * @param name Define the name of the uniform as defined in the shader
  89553. * @param value Define the value to give to the uniform
  89554. * @return the texture itself allowing "fluent" like uniform updates
  89555. */
  89556. setVector3(name: string, value: Vector3): ProceduralTexture;
  89557. /**
  89558. * Set a mat4 in the shader from a MAtrix.
  89559. * @param name Define the name of the uniform as defined in the shader
  89560. * @param value Define the value to give to the uniform
  89561. * @return the texture itself allowing "fluent" like uniform updates
  89562. */
  89563. setMatrix(name: string, value: Matrix): ProceduralTexture;
  89564. /**
  89565. * Render the texture to its associated render target.
  89566. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  89567. */
  89568. render(useCameraPostProcess?: boolean): void;
  89569. /**
  89570. * Clone the texture.
  89571. * @returns the cloned texture
  89572. */
  89573. clone(): ProceduralTexture;
  89574. /**
  89575. * Dispose the texture and release its asoociated resources.
  89576. */
  89577. dispose(): void;
  89578. }
  89579. }
  89580. declare module BABYLON {
  89581. /**
  89582. * This represents the base class for particle system in Babylon.
  89583. * 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.
  89584. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89585. * @example https://doc.babylonjs.com/babylon101/particles
  89586. */
  89587. export class BaseParticleSystem {
  89588. /**
  89589. * Source color is added to the destination color without alpha affecting the result
  89590. */
  89591. static BLENDMODE_ONEONE: number;
  89592. /**
  89593. * Blend current color and particle color using particle’s alpha
  89594. */
  89595. static BLENDMODE_STANDARD: number;
  89596. /**
  89597. * Add current color and particle color multiplied by particle’s alpha
  89598. */
  89599. static BLENDMODE_ADD: number;
  89600. /**
  89601. * Multiply current color with particle color
  89602. */
  89603. static BLENDMODE_MULTIPLY: number;
  89604. /**
  89605. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  89606. */
  89607. static BLENDMODE_MULTIPLYADD: number;
  89608. /**
  89609. * List of animations used by the particle system.
  89610. */
  89611. animations: Animation[];
  89612. /**
  89613. * Gets or sets the unique id of the particle system
  89614. */
  89615. uniqueId: number;
  89616. /**
  89617. * The id of the Particle system.
  89618. */
  89619. id: string;
  89620. /**
  89621. * The friendly name of the Particle system.
  89622. */
  89623. name: string;
  89624. /**
  89625. * Snippet ID if the particle system was created from the snippet server
  89626. */
  89627. snippetId: string;
  89628. /**
  89629. * The rendering group used by the Particle system to chose when to render.
  89630. */
  89631. renderingGroupId: number;
  89632. /**
  89633. * The emitter represents the Mesh or position we are attaching the particle system to.
  89634. */
  89635. emitter: Nullable<AbstractMesh | Vector3>;
  89636. /**
  89637. * The maximum number of particles to emit per frame
  89638. */
  89639. emitRate: number;
  89640. /**
  89641. * If you want to launch only a few particles at once, that can be done, as well.
  89642. */
  89643. manualEmitCount: number;
  89644. /**
  89645. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89646. */
  89647. updateSpeed: number;
  89648. /**
  89649. * The amount of time the particle system is running (depends of the overall update speed).
  89650. */
  89651. targetStopDuration: number;
  89652. /**
  89653. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89654. */
  89655. disposeOnStop: boolean;
  89656. /**
  89657. * Minimum power of emitting particles.
  89658. */
  89659. minEmitPower: number;
  89660. /**
  89661. * Maximum power of emitting particles.
  89662. */
  89663. maxEmitPower: number;
  89664. /**
  89665. * Minimum life time of emitting particles.
  89666. */
  89667. minLifeTime: number;
  89668. /**
  89669. * Maximum life time of emitting particles.
  89670. */
  89671. maxLifeTime: number;
  89672. /**
  89673. * Minimum Size of emitting particles.
  89674. */
  89675. minSize: number;
  89676. /**
  89677. * Maximum Size of emitting particles.
  89678. */
  89679. maxSize: number;
  89680. /**
  89681. * Minimum scale of emitting particles on X axis.
  89682. */
  89683. minScaleX: number;
  89684. /**
  89685. * Maximum scale of emitting particles on X axis.
  89686. */
  89687. maxScaleX: number;
  89688. /**
  89689. * Minimum scale of emitting particles on Y axis.
  89690. */
  89691. minScaleY: number;
  89692. /**
  89693. * Maximum scale of emitting particles on Y axis.
  89694. */
  89695. maxScaleY: number;
  89696. /**
  89697. * Gets or sets the minimal initial rotation in radians.
  89698. */
  89699. minInitialRotation: number;
  89700. /**
  89701. * Gets or sets the maximal initial rotation in radians.
  89702. */
  89703. maxInitialRotation: number;
  89704. /**
  89705. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89706. */
  89707. minAngularSpeed: number;
  89708. /**
  89709. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89710. */
  89711. maxAngularSpeed: number;
  89712. /**
  89713. * The texture used to render each particle. (this can be a spritesheet)
  89714. */
  89715. particleTexture: Nullable<Texture>;
  89716. /**
  89717. * The layer mask we are rendering the particles through.
  89718. */
  89719. layerMask: number;
  89720. /**
  89721. * This can help using your own shader to render the particle system.
  89722. * The according effect will be created
  89723. */
  89724. customShader: any;
  89725. /**
  89726. * By default particle system starts as soon as they are created. This prevents the
  89727. * automatic start to happen and let you decide when to start emitting particles.
  89728. */
  89729. preventAutoStart: boolean;
  89730. private _noiseTexture;
  89731. /**
  89732. * Gets or sets a texture used to add random noise to particle positions
  89733. */
  89734. get noiseTexture(): Nullable<ProceduralTexture>;
  89735. set noiseTexture(value: Nullable<ProceduralTexture>);
  89736. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89737. noiseStrength: Vector3;
  89738. /**
  89739. * Callback triggered when the particle animation is ending.
  89740. */
  89741. onAnimationEnd: Nullable<() => void>;
  89742. /**
  89743. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  89744. */
  89745. blendMode: number;
  89746. /**
  89747. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  89748. * to override the particles.
  89749. */
  89750. forceDepthWrite: boolean;
  89751. /** 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 */
  89752. preWarmCycles: number;
  89753. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  89754. preWarmStepOffset: number;
  89755. /**
  89756. * 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)
  89757. */
  89758. spriteCellChangeSpeed: number;
  89759. /**
  89760. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89761. */
  89762. startSpriteCellID: number;
  89763. /**
  89764. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89765. */
  89766. endSpriteCellID: number;
  89767. /**
  89768. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89769. */
  89770. spriteCellWidth: number;
  89771. /**
  89772. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89773. */
  89774. spriteCellHeight: number;
  89775. /**
  89776. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89777. */
  89778. spriteRandomStartCell: boolean;
  89779. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89780. translationPivot: Vector2;
  89781. /** @hidden */
  89782. protected _isAnimationSheetEnabled: boolean;
  89783. /**
  89784. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89785. */
  89786. beginAnimationOnStart: boolean;
  89787. /**
  89788. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89789. */
  89790. beginAnimationFrom: number;
  89791. /**
  89792. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89793. */
  89794. beginAnimationTo: number;
  89795. /**
  89796. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89797. */
  89798. beginAnimationLoop: boolean;
  89799. /**
  89800. * Gets or sets a world offset applied to all particles
  89801. */
  89802. worldOffset: Vector3;
  89803. /**
  89804. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  89805. */
  89806. get isAnimationSheetEnabled(): boolean;
  89807. set isAnimationSheetEnabled(value: boolean);
  89808. /**
  89809. * Get hosting scene
  89810. * @returns the scene
  89811. */
  89812. getScene(): Scene;
  89813. /**
  89814. * You can use gravity if you want to give an orientation to your particles.
  89815. */
  89816. gravity: Vector3;
  89817. protected _colorGradients: Nullable<Array<ColorGradient>>;
  89818. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  89819. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  89820. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  89821. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  89822. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  89823. protected _dragGradients: Nullable<Array<FactorGradient>>;
  89824. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  89825. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  89826. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  89827. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  89828. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  89829. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  89830. /**
  89831. * Defines the delay in milliseconds before starting the system (0 by default)
  89832. */
  89833. startDelay: number;
  89834. /**
  89835. * Gets the current list of drag gradients.
  89836. * You must use addDragGradient and removeDragGradient to udpate this list
  89837. * @returns the list of drag gradients
  89838. */
  89839. getDragGradients(): Nullable<Array<FactorGradient>>;
  89840. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89841. limitVelocityDamping: number;
  89842. /**
  89843. * Gets the current list of limit velocity gradients.
  89844. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89845. * @returns the list of limit velocity gradients
  89846. */
  89847. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89848. /**
  89849. * Gets the current list of color gradients.
  89850. * You must use addColorGradient and removeColorGradient to udpate this list
  89851. * @returns the list of color gradients
  89852. */
  89853. getColorGradients(): Nullable<Array<ColorGradient>>;
  89854. /**
  89855. * Gets the current list of size gradients.
  89856. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89857. * @returns the list of size gradients
  89858. */
  89859. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89860. /**
  89861. * Gets the current list of color remap gradients.
  89862. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89863. * @returns the list of color remap gradients
  89864. */
  89865. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89866. /**
  89867. * Gets the current list of alpha remap gradients.
  89868. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89869. * @returns the list of alpha remap gradients
  89870. */
  89871. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89872. /**
  89873. * Gets the current list of life time gradients.
  89874. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89875. * @returns the list of life time gradients
  89876. */
  89877. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89878. /**
  89879. * Gets the current list of angular speed gradients.
  89880. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89881. * @returns the list of angular speed gradients
  89882. */
  89883. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89884. /**
  89885. * Gets the current list of velocity gradients.
  89886. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89887. * @returns the list of velocity gradients
  89888. */
  89889. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89890. /**
  89891. * Gets the current list of start size gradients.
  89892. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89893. * @returns the list of start size gradients
  89894. */
  89895. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89896. /**
  89897. * Gets the current list of emit rate gradients.
  89898. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89899. * @returns the list of emit rate gradients
  89900. */
  89901. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89902. /**
  89903. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89904. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89905. */
  89906. get direction1(): Vector3;
  89907. set direction1(value: Vector3);
  89908. /**
  89909. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89910. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89911. */
  89912. get direction2(): Vector3;
  89913. set direction2(value: Vector3);
  89914. /**
  89915. * 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.
  89916. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89917. */
  89918. get minEmitBox(): Vector3;
  89919. set minEmitBox(value: Vector3);
  89920. /**
  89921. * 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.
  89922. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89923. */
  89924. get maxEmitBox(): Vector3;
  89925. set maxEmitBox(value: Vector3);
  89926. /**
  89927. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89928. */
  89929. color1: Color4;
  89930. /**
  89931. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89932. */
  89933. color2: Color4;
  89934. /**
  89935. * Color the particle will have at the end of its lifetime
  89936. */
  89937. colorDead: Color4;
  89938. /**
  89939. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  89940. */
  89941. textureMask: Color4;
  89942. /**
  89943. * The particle emitter type defines the emitter used by the particle system.
  89944. * It can be for example box, sphere, or cone...
  89945. */
  89946. particleEmitterType: IParticleEmitterType;
  89947. /** @hidden */
  89948. _isSubEmitter: boolean;
  89949. /**
  89950. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89951. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89952. */
  89953. billboardMode: number;
  89954. protected _isBillboardBased: boolean;
  89955. /**
  89956. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89957. */
  89958. get isBillboardBased(): boolean;
  89959. set isBillboardBased(value: boolean);
  89960. /**
  89961. * The scene the particle system belongs to.
  89962. */
  89963. protected _scene: Scene;
  89964. /**
  89965. * Local cache of defines for image processing.
  89966. */
  89967. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  89968. /**
  89969. * Default configuration related to image processing available in the standard Material.
  89970. */
  89971. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  89972. /**
  89973. * Gets the image processing configuration used either in this material.
  89974. */
  89975. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  89976. /**
  89977. * Sets the Default image processing configuration used either in the this material.
  89978. *
  89979. * If sets to null, the scene one is in use.
  89980. */
  89981. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  89982. /**
  89983. * Attaches a new image processing configuration to the Standard Material.
  89984. * @param configuration
  89985. */
  89986. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  89987. /** @hidden */
  89988. protected _reset(): void;
  89989. /** @hidden */
  89990. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  89991. /**
  89992. * Instantiates a particle system.
  89993. * 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.
  89994. * @param name The name of the particle system
  89995. */
  89996. constructor(name: string);
  89997. /**
  89998. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89999. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90000. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90001. * @returns the emitter
  90002. */
  90003. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  90004. /**
  90005. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  90006. * @param radius The radius of the hemisphere to emit from
  90007. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90008. * @returns the emitter
  90009. */
  90010. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  90011. /**
  90012. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  90013. * @param radius The radius of the sphere to emit from
  90014. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90015. * @returns the emitter
  90016. */
  90017. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  90018. /**
  90019. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  90020. * @param radius The radius of the sphere to emit from
  90021. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  90022. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  90023. * @returns the emitter
  90024. */
  90025. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  90026. /**
  90027. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  90028. * @param radius The radius of the emission cylinder
  90029. * @param height The height of the emission cylinder
  90030. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  90031. * @param directionRandomizer How much to randomize the particle direction [0-1]
  90032. * @returns the emitter
  90033. */
  90034. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  90035. /**
  90036. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  90037. * @param radius The radius of the cylinder to emit from
  90038. * @param height The height of the emission cylinder
  90039. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90040. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  90041. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  90042. * @returns the emitter
  90043. */
  90044. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  90045. /**
  90046. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  90047. * @param radius The radius of the cone to emit from
  90048. * @param angle The base angle of the cone
  90049. * @returns the emitter
  90050. */
  90051. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  90052. /**
  90053. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  90054. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90055. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90056. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90057. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90058. * @returns the emitter
  90059. */
  90060. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  90061. }
  90062. }
  90063. declare module BABYLON {
  90064. /**
  90065. * Type of sub emitter
  90066. */
  90067. export enum SubEmitterType {
  90068. /**
  90069. * Attached to the particle over it's lifetime
  90070. */
  90071. ATTACHED = 0,
  90072. /**
  90073. * Created when the particle dies
  90074. */
  90075. END = 1
  90076. }
  90077. /**
  90078. * Sub emitter class used to emit particles from an existing particle
  90079. */
  90080. export class SubEmitter {
  90081. /**
  90082. * the particle system to be used by the sub emitter
  90083. */
  90084. particleSystem: ParticleSystem;
  90085. /**
  90086. * Type of the submitter (Default: END)
  90087. */
  90088. type: SubEmitterType;
  90089. /**
  90090. * 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)
  90091. * Note: This only is supported when using an emitter of type Mesh
  90092. */
  90093. inheritDirection: boolean;
  90094. /**
  90095. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  90096. */
  90097. inheritedVelocityAmount: number;
  90098. /**
  90099. * Creates a sub emitter
  90100. * @param particleSystem the particle system to be used by the sub emitter
  90101. */
  90102. constructor(
  90103. /**
  90104. * the particle system to be used by the sub emitter
  90105. */
  90106. particleSystem: ParticleSystem);
  90107. /**
  90108. * Clones the sub emitter
  90109. * @returns the cloned sub emitter
  90110. */
  90111. clone(): SubEmitter;
  90112. /**
  90113. * Serialize current object to a JSON object
  90114. * @returns the serialized object
  90115. */
  90116. serialize(): any;
  90117. /** @hidden */
  90118. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  90119. /**
  90120. * Creates a new SubEmitter from a serialized JSON version
  90121. * @param serializationObject defines the JSON object to read from
  90122. * @param scene defines the hosting scene
  90123. * @param rootUrl defines the rootUrl for data loading
  90124. * @returns a new SubEmitter
  90125. */
  90126. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  90127. /** Release associated resources */
  90128. dispose(): void;
  90129. }
  90130. }
  90131. declare module BABYLON {
  90132. /** @hidden */
  90133. export var imageProcessingDeclaration: {
  90134. name: string;
  90135. shader: string;
  90136. };
  90137. }
  90138. declare module BABYLON {
  90139. /** @hidden */
  90140. export var imageProcessingFunctions: {
  90141. name: string;
  90142. shader: string;
  90143. };
  90144. }
  90145. declare module BABYLON {
  90146. /** @hidden */
  90147. export var particlesPixelShader: {
  90148. name: string;
  90149. shader: string;
  90150. };
  90151. }
  90152. declare module BABYLON {
  90153. /** @hidden */
  90154. export var particlesVertexShader: {
  90155. name: string;
  90156. shader: string;
  90157. };
  90158. }
  90159. declare module BABYLON {
  90160. /**
  90161. * This represents a particle system in Babylon.
  90162. * 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.
  90163. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90164. * @example https://doc.babylonjs.com/babylon101/particles
  90165. */
  90166. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  90167. /**
  90168. * Billboard mode will only apply to Y axis
  90169. */
  90170. static readonly BILLBOARDMODE_Y: number;
  90171. /**
  90172. * Billboard mode will apply to all axes
  90173. */
  90174. static readonly BILLBOARDMODE_ALL: number;
  90175. /**
  90176. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  90177. */
  90178. static readonly BILLBOARDMODE_STRETCHED: number;
  90179. /**
  90180. * This function can be defined to provide custom update for active particles.
  90181. * This function will be called instead of regular update (age, position, color, etc.).
  90182. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  90183. */
  90184. updateFunction: (particles: Particle[]) => void;
  90185. private _emitterWorldMatrix;
  90186. /**
  90187. * This function can be defined to specify initial direction for every new particle.
  90188. * It by default use the emitterType defined function
  90189. */
  90190. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90191. /**
  90192. * This function can be defined to specify initial position for every new particle.
  90193. * It by default use the emitterType defined function
  90194. */
  90195. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90196. /**
  90197. * @hidden
  90198. */
  90199. _inheritedVelocityOffset: Vector3;
  90200. /**
  90201. * An event triggered when the system is disposed
  90202. */
  90203. onDisposeObservable: Observable<IParticleSystem>;
  90204. private _onDisposeObserver;
  90205. /**
  90206. * Sets a callback that will be triggered when the system is disposed
  90207. */
  90208. set onDispose(callback: () => void);
  90209. private _particles;
  90210. private _epsilon;
  90211. private _capacity;
  90212. private _stockParticles;
  90213. private _newPartsExcess;
  90214. private _vertexData;
  90215. private _vertexBuffer;
  90216. private _vertexBuffers;
  90217. private _spriteBuffer;
  90218. private _indexBuffer;
  90219. private _effect;
  90220. private _customEffect;
  90221. private _cachedDefines;
  90222. private _scaledColorStep;
  90223. private _colorDiff;
  90224. private _scaledDirection;
  90225. private _scaledGravity;
  90226. private _currentRenderId;
  90227. private _alive;
  90228. private _useInstancing;
  90229. private _started;
  90230. private _stopped;
  90231. private _actualFrame;
  90232. private _scaledUpdateSpeed;
  90233. private _vertexBufferSize;
  90234. /** @hidden */
  90235. _currentEmitRateGradient: Nullable<FactorGradient>;
  90236. /** @hidden */
  90237. _currentEmitRate1: number;
  90238. /** @hidden */
  90239. _currentEmitRate2: number;
  90240. /** @hidden */
  90241. _currentStartSizeGradient: Nullable<FactorGradient>;
  90242. /** @hidden */
  90243. _currentStartSize1: number;
  90244. /** @hidden */
  90245. _currentStartSize2: number;
  90246. private readonly _rawTextureWidth;
  90247. private _rampGradientsTexture;
  90248. private _useRampGradients;
  90249. /** Gets or sets a boolean indicating that ramp gradients must be used
  90250. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  90251. */
  90252. get useRampGradients(): boolean;
  90253. set useRampGradients(value: boolean);
  90254. /**
  90255. * 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.
  90256. * 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: [])
  90257. */
  90258. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  90259. private _subEmitters;
  90260. /**
  90261. * @hidden
  90262. * If the particle systems emitter should be disposed when the particle system is disposed
  90263. */
  90264. _disposeEmitterOnDispose: boolean;
  90265. /**
  90266. * The current active Sub-systems, this property is used by the root particle system only.
  90267. */
  90268. activeSubSystems: Array<ParticleSystem>;
  90269. /**
  90270. * Specifies if the particles are updated in emitter local space or world space
  90271. */
  90272. isLocal: boolean;
  90273. private _rootParticleSystem;
  90274. /**
  90275. * Gets the current list of active particles
  90276. */
  90277. get particles(): Particle[];
  90278. /**
  90279. * Gets the number of particles active at the same time.
  90280. * @returns The number of active particles.
  90281. */
  90282. getActiveCount(): number;
  90283. /**
  90284. * Returns the string "ParticleSystem"
  90285. * @returns a string containing the class name
  90286. */
  90287. getClassName(): string;
  90288. /**
  90289. * Gets a boolean indicating that the system is stopping
  90290. * @returns true if the system is currently stopping
  90291. */
  90292. isStopping(): boolean;
  90293. /**
  90294. * Gets the custom effect used to render the particles
  90295. * @param blendMode Blend mode for which the effect should be retrieved
  90296. * @returns The effect
  90297. */
  90298. getCustomEffect(blendMode?: number): Nullable<Effect>;
  90299. /**
  90300. * Sets the custom effect used to render the particles
  90301. * @param effect The effect to set
  90302. * @param blendMode Blend mode for which the effect should be set
  90303. */
  90304. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  90305. /** @hidden */
  90306. private _onBeforeDrawParticlesObservable;
  90307. /**
  90308. * Observable that will be called just before the particles are drawn
  90309. */
  90310. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  90311. /**
  90312. * Gets the name of the particle vertex shader
  90313. */
  90314. get vertexShaderName(): string;
  90315. /**
  90316. * Instantiates a particle system.
  90317. * 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.
  90318. * @param name The name of the particle system
  90319. * @param capacity The max number of particles alive at the same time
  90320. * @param scene The scene the particle system belongs to
  90321. * @param customEffect a custom effect used to change the way particles are rendered by default
  90322. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  90323. * @param epsilon Offset used to render the particles
  90324. */
  90325. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  90326. private _addFactorGradient;
  90327. private _removeFactorGradient;
  90328. /**
  90329. * Adds a new life time gradient
  90330. * @param gradient defines the gradient to use (between 0 and 1)
  90331. * @param factor defines the life time factor to affect to the specified gradient
  90332. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90333. * @returns the current particle system
  90334. */
  90335. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90336. /**
  90337. * Remove a specific life time gradient
  90338. * @param gradient defines the gradient to remove
  90339. * @returns the current particle system
  90340. */
  90341. removeLifeTimeGradient(gradient: number): IParticleSystem;
  90342. /**
  90343. * Adds a new size gradient
  90344. * @param gradient defines the gradient to use (between 0 and 1)
  90345. * @param factor defines the size factor to affect to the specified gradient
  90346. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90347. * @returns the current particle system
  90348. */
  90349. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90350. /**
  90351. * Remove a specific size gradient
  90352. * @param gradient defines the gradient to remove
  90353. * @returns the current particle system
  90354. */
  90355. removeSizeGradient(gradient: number): IParticleSystem;
  90356. /**
  90357. * Adds a new color remap gradient
  90358. * @param gradient defines the gradient to use (between 0 and 1)
  90359. * @param min defines the color remap minimal range
  90360. * @param max defines the color remap maximal range
  90361. * @returns the current particle system
  90362. */
  90363. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90364. /**
  90365. * Remove a specific color remap gradient
  90366. * @param gradient defines the gradient to remove
  90367. * @returns the current particle system
  90368. */
  90369. removeColorRemapGradient(gradient: number): IParticleSystem;
  90370. /**
  90371. * Adds a new alpha remap gradient
  90372. * @param gradient defines the gradient to use (between 0 and 1)
  90373. * @param min defines the alpha remap minimal range
  90374. * @param max defines the alpha remap maximal range
  90375. * @returns the current particle system
  90376. */
  90377. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90378. /**
  90379. * Remove a specific alpha remap gradient
  90380. * @param gradient defines the gradient to remove
  90381. * @returns the current particle system
  90382. */
  90383. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  90384. /**
  90385. * Adds a new angular speed gradient
  90386. * @param gradient defines the gradient to use (between 0 and 1)
  90387. * @param factor defines the angular speed to affect to the specified gradient
  90388. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90389. * @returns the current particle system
  90390. */
  90391. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90392. /**
  90393. * Remove a specific angular speed gradient
  90394. * @param gradient defines the gradient to remove
  90395. * @returns the current particle system
  90396. */
  90397. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  90398. /**
  90399. * Adds a new velocity gradient
  90400. * @param gradient defines the gradient to use (between 0 and 1)
  90401. * @param factor defines the velocity to affect to the specified gradient
  90402. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90403. * @returns the current particle system
  90404. */
  90405. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90406. /**
  90407. * Remove a specific velocity gradient
  90408. * @param gradient defines the gradient to remove
  90409. * @returns the current particle system
  90410. */
  90411. removeVelocityGradient(gradient: number): IParticleSystem;
  90412. /**
  90413. * Adds a new limit velocity gradient
  90414. * @param gradient defines the gradient to use (between 0 and 1)
  90415. * @param factor defines the limit velocity value to affect to the specified gradient
  90416. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90417. * @returns the current particle system
  90418. */
  90419. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90420. /**
  90421. * Remove a specific limit velocity gradient
  90422. * @param gradient defines the gradient to remove
  90423. * @returns the current particle system
  90424. */
  90425. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  90426. /**
  90427. * Adds a new drag gradient
  90428. * @param gradient defines the gradient to use (between 0 and 1)
  90429. * @param factor defines the drag value to affect to the specified gradient
  90430. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90431. * @returns the current particle system
  90432. */
  90433. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90434. /**
  90435. * Remove a specific drag gradient
  90436. * @param gradient defines the gradient to remove
  90437. * @returns the current particle system
  90438. */
  90439. removeDragGradient(gradient: number): IParticleSystem;
  90440. /**
  90441. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  90442. * @param gradient defines the gradient to use (between 0 and 1)
  90443. * @param factor defines the emit rate value to affect to the specified gradient
  90444. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90445. * @returns the current particle system
  90446. */
  90447. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90448. /**
  90449. * Remove a specific emit rate gradient
  90450. * @param gradient defines the gradient to remove
  90451. * @returns the current particle system
  90452. */
  90453. removeEmitRateGradient(gradient: number): IParticleSystem;
  90454. /**
  90455. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  90456. * @param gradient defines the gradient to use (between 0 and 1)
  90457. * @param factor defines the start size value to affect to the specified gradient
  90458. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90459. * @returns the current particle system
  90460. */
  90461. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90462. /**
  90463. * Remove a specific start size gradient
  90464. * @param gradient defines the gradient to remove
  90465. * @returns the current particle system
  90466. */
  90467. removeStartSizeGradient(gradient: number): IParticleSystem;
  90468. private _createRampGradientTexture;
  90469. /**
  90470. * Gets the current list of ramp gradients.
  90471. * You must use addRampGradient and removeRampGradient to udpate this list
  90472. * @returns the list of ramp gradients
  90473. */
  90474. getRampGradients(): Nullable<Array<Color3Gradient>>;
  90475. /** Force the system to rebuild all gradients that need to be resync */
  90476. forceRefreshGradients(): void;
  90477. private _syncRampGradientTexture;
  90478. /**
  90479. * Adds a new ramp gradient used to remap particle colors
  90480. * @param gradient defines the gradient to use (between 0 and 1)
  90481. * @param color defines the color to affect to the specified gradient
  90482. * @returns the current particle system
  90483. */
  90484. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  90485. /**
  90486. * Remove a specific ramp gradient
  90487. * @param gradient defines the gradient to remove
  90488. * @returns the current particle system
  90489. */
  90490. removeRampGradient(gradient: number): ParticleSystem;
  90491. /**
  90492. * Adds a new color gradient
  90493. * @param gradient defines the gradient to use (between 0 and 1)
  90494. * @param color1 defines the color to affect to the specified gradient
  90495. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  90496. * @returns this particle system
  90497. */
  90498. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  90499. /**
  90500. * Remove a specific color gradient
  90501. * @param gradient defines the gradient to remove
  90502. * @returns this particle system
  90503. */
  90504. removeColorGradient(gradient: number): IParticleSystem;
  90505. private _fetchR;
  90506. protected _reset(): void;
  90507. private _resetEffect;
  90508. private _createVertexBuffers;
  90509. private _createIndexBuffer;
  90510. /**
  90511. * Gets the maximum number of particles active at the same time.
  90512. * @returns The max number of active particles.
  90513. */
  90514. getCapacity(): number;
  90515. /**
  90516. * Gets whether there are still active particles in the system.
  90517. * @returns True if it is alive, otherwise false.
  90518. */
  90519. isAlive(): boolean;
  90520. /**
  90521. * Gets if the system has been started. (Note: this will still be true after stop is called)
  90522. * @returns True if it has been started, otherwise false.
  90523. */
  90524. isStarted(): boolean;
  90525. private _prepareSubEmitterInternalArray;
  90526. /**
  90527. * Starts the particle system and begins to emit
  90528. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  90529. */
  90530. start(delay?: number): void;
  90531. /**
  90532. * Stops the particle system.
  90533. * @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.
  90534. */
  90535. stop(stopSubEmitters?: boolean): void;
  90536. /**
  90537. * Remove all active particles
  90538. */
  90539. reset(): void;
  90540. /**
  90541. * @hidden (for internal use only)
  90542. */
  90543. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  90544. /**
  90545. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  90546. * Its lifetime will start back at 0.
  90547. */
  90548. recycleParticle: (particle: Particle) => void;
  90549. private _stopSubEmitters;
  90550. private _createParticle;
  90551. private _removeFromRoot;
  90552. private _emitFromParticle;
  90553. private _update;
  90554. /** @hidden */
  90555. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  90556. /** @hidden */
  90557. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  90558. /**
  90559. * Fill the defines array according to the current settings of the particle system
  90560. * @param defines Array to be updated
  90561. * @param blendMode blend mode to take into account when updating the array
  90562. */
  90563. fillDefines(defines: Array<string>, blendMode: number): void;
  90564. /**
  90565. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  90566. * @param uniforms Uniforms array to fill
  90567. * @param attributes Attributes array to fill
  90568. * @param samplers Samplers array to fill
  90569. */
  90570. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  90571. /** @hidden */
  90572. private _getEffect;
  90573. /**
  90574. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  90575. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  90576. */
  90577. animate(preWarmOnly?: boolean): void;
  90578. private _appendParticleVertices;
  90579. /**
  90580. * Rebuilds the particle system.
  90581. */
  90582. rebuild(): void;
  90583. /**
  90584. * Is this system ready to be used/rendered
  90585. * @return true if the system is ready
  90586. */
  90587. isReady(): boolean;
  90588. private _render;
  90589. /**
  90590. * Renders the particle system in its current state.
  90591. * @returns the current number of particles
  90592. */
  90593. render(): number;
  90594. /**
  90595. * Disposes the particle system and free the associated resources
  90596. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  90597. */
  90598. dispose(disposeTexture?: boolean): void;
  90599. /**
  90600. * Clones the particle system.
  90601. * @param name The name of the cloned object
  90602. * @param newEmitter The new emitter to use
  90603. * @returns the cloned particle system
  90604. */
  90605. clone(name: string, newEmitter: any): ParticleSystem;
  90606. /**
  90607. * Serializes the particle system to a JSON object
  90608. * @param serializeTexture defines if the texture must be serialized as well
  90609. * @returns the JSON object
  90610. */
  90611. serialize(serializeTexture?: boolean): any;
  90612. /** @hidden */
  90613. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  90614. /** @hidden */
  90615. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  90616. /**
  90617. * Parses a JSON object to create a particle system.
  90618. * @param parsedParticleSystem The JSON object to parse
  90619. * @param scene The scene to create the particle system in
  90620. * @param rootUrl The root url to use to load external dependencies like texture
  90621. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  90622. * @returns the Parsed particle system
  90623. */
  90624. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  90625. }
  90626. }
  90627. declare module BABYLON {
  90628. /**
  90629. * A particle represents one of the element emitted by a particle system.
  90630. * This is mainly define by its coordinates, direction, velocity and age.
  90631. */
  90632. export class Particle {
  90633. /**
  90634. * The particle system the particle belongs to.
  90635. */
  90636. particleSystem: ParticleSystem;
  90637. private static _Count;
  90638. /**
  90639. * Unique ID of the particle
  90640. */
  90641. id: number;
  90642. /**
  90643. * The world position of the particle in the scene.
  90644. */
  90645. position: Vector3;
  90646. /**
  90647. * The world direction of the particle in the scene.
  90648. */
  90649. direction: Vector3;
  90650. /**
  90651. * The color of the particle.
  90652. */
  90653. color: Color4;
  90654. /**
  90655. * The color change of the particle per step.
  90656. */
  90657. colorStep: Color4;
  90658. /**
  90659. * Defines how long will the life of the particle be.
  90660. */
  90661. lifeTime: number;
  90662. /**
  90663. * The current age of the particle.
  90664. */
  90665. age: number;
  90666. /**
  90667. * The current size of the particle.
  90668. */
  90669. size: number;
  90670. /**
  90671. * The current scale of the particle.
  90672. */
  90673. scale: Vector2;
  90674. /**
  90675. * The current angle of the particle.
  90676. */
  90677. angle: number;
  90678. /**
  90679. * Defines how fast is the angle changing.
  90680. */
  90681. angularSpeed: number;
  90682. /**
  90683. * Defines the cell index used by the particle to be rendered from a sprite.
  90684. */
  90685. cellIndex: number;
  90686. /**
  90687. * The information required to support color remapping
  90688. */
  90689. remapData: Vector4;
  90690. /** @hidden */
  90691. _randomCellOffset?: number;
  90692. /** @hidden */
  90693. _initialDirection: Nullable<Vector3>;
  90694. /** @hidden */
  90695. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  90696. /** @hidden */
  90697. _initialStartSpriteCellID: number;
  90698. /** @hidden */
  90699. _initialEndSpriteCellID: number;
  90700. /** @hidden */
  90701. _currentColorGradient: Nullable<ColorGradient>;
  90702. /** @hidden */
  90703. _currentColor1: Color4;
  90704. /** @hidden */
  90705. _currentColor2: Color4;
  90706. /** @hidden */
  90707. _currentSizeGradient: Nullable<FactorGradient>;
  90708. /** @hidden */
  90709. _currentSize1: number;
  90710. /** @hidden */
  90711. _currentSize2: number;
  90712. /** @hidden */
  90713. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  90714. /** @hidden */
  90715. _currentAngularSpeed1: number;
  90716. /** @hidden */
  90717. _currentAngularSpeed2: number;
  90718. /** @hidden */
  90719. _currentVelocityGradient: Nullable<FactorGradient>;
  90720. /** @hidden */
  90721. _currentVelocity1: number;
  90722. /** @hidden */
  90723. _currentVelocity2: number;
  90724. /** @hidden */
  90725. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  90726. /** @hidden */
  90727. _currentLimitVelocity1: number;
  90728. /** @hidden */
  90729. _currentLimitVelocity2: number;
  90730. /** @hidden */
  90731. _currentDragGradient: Nullable<FactorGradient>;
  90732. /** @hidden */
  90733. _currentDrag1: number;
  90734. /** @hidden */
  90735. _currentDrag2: number;
  90736. /** @hidden */
  90737. _randomNoiseCoordinates1: Vector3;
  90738. /** @hidden */
  90739. _randomNoiseCoordinates2: Vector3;
  90740. /** @hidden */
  90741. _localPosition?: Vector3;
  90742. /**
  90743. * Creates a new instance Particle
  90744. * @param particleSystem the particle system the particle belongs to
  90745. */
  90746. constructor(
  90747. /**
  90748. * The particle system the particle belongs to.
  90749. */
  90750. particleSystem: ParticleSystem);
  90751. private updateCellInfoFromSystem;
  90752. /**
  90753. * Defines how the sprite cell index is updated for the particle
  90754. */
  90755. updateCellIndex(): void;
  90756. /** @hidden */
  90757. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  90758. /** @hidden */
  90759. _inheritParticleInfoToSubEmitters(): void;
  90760. /** @hidden */
  90761. _reset(): void;
  90762. /**
  90763. * Copy the properties of particle to another one.
  90764. * @param other the particle to copy the information to.
  90765. */
  90766. copyTo(other: Particle): void;
  90767. }
  90768. }
  90769. declare module BABYLON {
  90770. /**
  90771. * Particle emitter represents a volume emitting particles.
  90772. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  90773. */
  90774. export interface IParticleEmitterType {
  90775. /**
  90776. * Called by the particle System when the direction is computed for the created particle.
  90777. * @param worldMatrix is the world matrix of the particle system
  90778. * @param directionToUpdate is the direction vector to update with the result
  90779. * @param particle is the particle we are computed the direction for
  90780. * @param isLocal defines if the direction should be set in local space
  90781. */
  90782. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90783. /**
  90784. * Called by the particle System when the position is computed for the created particle.
  90785. * @param worldMatrix is the world matrix of the particle system
  90786. * @param positionToUpdate is the position vector to update with the result
  90787. * @param particle is the particle we are computed the position for
  90788. * @param isLocal defines if the position should be set in local space
  90789. */
  90790. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90791. /**
  90792. * Clones the current emitter and returns a copy of it
  90793. * @returns the new emitter
  90794. */
  90795. clone(): IParticleEmitterType;
  90796. /**
  90797. * Called by the GPUParticleSystem to setup the update shader
  90798. * @param effect defines the update shader
  90799. */
  90800. applyToShader(effect: Effect): void;
  90801. /**
  90802. * Returns a string to use to update the GPU particles update shader
  90803. * @returns the effect defines string
  90804. */
  90805. getEffectDefines(): string;
  90806. /**
  90807. * Returns a string representing the class name
  90808. * @returns a string containing the class name
  90809. */
  90810. getClassName(): string;
  90811. /**
  90812. * Serializes the particle system to a JSON object.
  90813. * @returns the JSON object
  90814. */
  90815. serialize(): any;
  90816. /**
  90817. * Parse properties from a JSON object
  90818. * @param serializationObject defines the JSON object
  90819. * @param scene defines the hosting scene
  90820. */
  90821. parse(serializationObject: any, scene: Scene): void;
  90822. }
  90823. }
  90824. declare module BABYLON {
  90825. /**
  90826. * Particle emitter emitting particles from the inside of a box.
  90827. * It emits the particles randomly between 2 given directions.
  90828. */
  90829. export class BoxParticleEmitter implements IParticleEmitterType {
  90830. /**
  90831. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90832. */
  90833. direction1: Vector3;
  90834. /**
  90835. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90836. */
  90837. direction2: Vector3;
  90838. /**
  90839. * 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.
  90840. */
  90841. minEmitBox: Vector3;
  90842. /**
  90843. * 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.
  90844. */
  90845. maxEmitBox: Vector3;
  90846. /**
  90847. * Creates a new instance BoxParticleEmitter
  90848. */
  90849. constructor();
  90850. /**
  90851. * Called by the particle System when the direction is computed for the created particle.
  90852. * @param worldMatrix is the world matrix of the particle system
  90853. * @param directionToUpdate is the direction vector to update with the result
  90854. * @param particle is the particle we are computed the direction for
  90855. * @param isLocal defines if the direction should be set in local space
  90856. */
  90857. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90858. /**
  90859. * Called by the particle System when the position is computed for the created particle.
  90860. * @param worldMatrix is the world matrix of the particle system
  90861. * @param positionToUpdate is the position vector to update with the result
  90862. * @param particle is the particle we are computed the position for
  90863. * @param isLocal defines if the position should be set in local space
  90864. */
  90865. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90866. /**
  90867. * Clones the current emitter and returns a copy of it
  90868. * @returns the new emitter
  90869. */
  90870. clone(): BoxParticleEmitter;
  90871. /**
  90872. * Called by the GPUParticleSystem to setup the update shader
  90873. * @param effect defines the update shader
  90874. */
  90875. applyToShader(effect: Effect): void;
  90876. /**
  90877. * Returns a string to use to update the GPU particles update shader
  90878. * @returns a string containng the defines string
  90879. */
  90880. getEffectDefines(): string;
  90881. /**
  90882. * Returns the string "BoxParticleEmitter"
  90883. * @returns a string containing the class name
  90884. */
  90885. getClassName(): string;
  90886. /**
  90887. * Serializes the particle system to a JSON object.
  90888. * @returns the JSON object
  90889. */
  90890. serialize(): any;
  90891. /**
  90892. * Parse properties from a JSON object
  90893. * @param serializationObject defines the JSON object
  90894. */
  90895. parse(serializationObject: any): void;
  90896. }
  90897. }
  90898. declare module BABYLON {
  90899. /**
  90900. * Particle emitter emitting particles from the inside of a cone.
  90901. * It emits the particles alongside the cone volume from the base to the particle.
  90902. * The emission direction might be randomized.
  90903. */
  90904. export class ConeParticleEmitter implements IParticleEmitterType {
  90905. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90906. directionRandomizer: number;
  90907. private _radius;
  90908. private _angle;
  90909. private _height;
  90910. /**
  90911. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  90912. */
  90913. radiusRange: number;
  90914. /**
  90915. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  90916. */
  90917. heightRange: number;
  90918. /**
  90919. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  90920. */
  90921. emitFromSpawnPointOnly: boolean;
  90922. /**
  90923. * Gets or sets the radius of the emission cone
  90924. */
  90925. get radius(): number;
  90926. set radius(value: number);
  90927. /**
  90928. * Gets or sets the angle of the emission cone
  90929. */
  90930. get angle(): number;
  90931. set angle(value: number);
  90932. private _buildHeight;
  90933. /**
  90934. * Creates a new instance ConeParticleEmitter
  90935. * @param radius the radius of the emission cone (1 by default)
  90936. * @param angle the cone base angle (PI by default)
  90937. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  90938. */
  90939. constructor(radius?: number, angle?: number,
  90940. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90941. directionRandomizer?: number);
  90942. /**
  90943. * Called by the particle System when the direction is computed for the created particle.
  90944. * @param worldMatrix is the world matrix of the particle system
  90945. * @param directionToUpdate is the direction vector to update with the result
  90946. * @param particle is the particle we are computed the direction for
  90947. * @param isLocal defines if the direction should be set in local space
  90948. */
  90949. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90950. /**
  90951. * Called by the particle System when the position is computed for the created particle.
  90952. * @param worldMatrix is the world matrix of the particle system
  90953. * @param positionToUpdate is the position vector to update with the result
  90954. * @param particle is the particle we are computed the position for
  90955. * @param isLocal defines if the position should be set in local space
  90956. */
  90957. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90958. /**
  90959. * Clones the current emitter and returns a copy of it
  90960. * @returns the new emitter
  90961. */
  90962. clone(): ConeParticleEmitter;
  90963. /**
  90964. * Called by the GPUParticleSystem to setup the update shader
  90965. * @param effect defines the update shader
  90966. */
  90967. applyToShader(effect: Effect): void;
  90968. /**
  90969. * Returns a string to use to update the GPU particles update shader
  90970. * @returns a string containng the defines string
  90971. */
  90972. getEffectDefines(): string;
  90973. /**
  90974. * Returns the string "ConeParticleEmitter"
  90975. * @returns a string containing the class name
  90976. */
  90977. getClassName(): string;
  90978. /**
  90979. * Serializes the particle system to a JSON object.
  90980. * @returns the JSON object
  90981. */
  90982. serialize(): any;
  90983. /**
  90984. * Parse properties from a JSON object
  90985. * @param serializationObject defines the JSON object
  90986. */
  90987. parse(serializationObject: any): void;
  90988. }
  90989. }
  90990. declare module BABYLON {
  90991. /**
  90992. * Particle emitter emitting particles from the inside of a cylinder.
  90993. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  90994. */
  90995. export class CylinderParticleEmitter implements IParticleEmitterType {
  90996. /**
  90997. * The radius of the emission cylinder.
  90998. */
  90999. radius: number;
  91000. /**
  91001. * The height of the emission cylinder.
  91002. */
  91003. height: number;
  91004. /**
  91005. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91006. */
  91007. radiusRange: number;
  91008. /**
  91009. * How much to randomize the particle direction [0-1].
  91010. */
  91011. directionRandomizer: number;
  91012. /**
  91013. * Creates a new instance CylinderParticleEmitter
  91014. * @param radius the radius of the emission cylinder (1 by default)
  91015. * @param height the height of the emission cylinder (1 by default)
  91016. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91017. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91018. */
  91019. constructor(
  91020. /**
  91021. * The radius of the emission cylinder.
  91022. */
  91023. radius?: number,
  91024. /**
  91025. * The height of the emission cylinder.
  91026. */
  91027. height?: number,
  91028. /**
  91029. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91030. */
  91031. radiusRange?: number,
  91032. /**
  91033. * How much to randomize the particle direction [0-1].
  91034. */
  91035. directionRandomizer?: number);
  91036. /**
  91037. * Called by the particle System when the direction is computed for the created particle.
  91038. * @param worldMatrix is the world matrix of the particle system
  91039. * @param directionToUpdate is the direction vector to update with the result
  91040. * @param particle is the particle we are computed the direction for
  91041. * @param isLocal defines if the direction should be set in local space
  91042. */
  91043. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91044. /**
  91045. * Called by the particle System when the position is computed for the created particle.
  91046. * @param worldMatrix is the world matrix of the particle system
  91047. * @param positionToUpdate is the position vector to update with the result
  91048. * @param particle is the particle we are computed the position for
  91049. * @param isLocal defines if the position should be set in local space
  91050. */
  91051. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91052. /**
  91053. * Clones the current emitter and returns a copy of it
  91054. * @returns the new emitter
  91055. */
  91056. clone(): CylinderParticleEmitter;
  91057. /**
  91058. * Called by the GPUParticleSystem to setup the update shader
  91059. * @param effect defines the update shader
  91060. */
  91061. applyToShader(effect: Effect): void;
  91062. /**
  91063. * Returns a string to use to update the GPU particles update shader
  91064. * @returns a string containng the defines string
  91065. */
  91066. getEffectDefines(): string;
  91067. /**
  91068. * Returns the string "CylinderParticleEmitter"
  91069. * @returns a string containing the class name
  91070. */
  91071. getClassName(): string;
  91072. /**
  91073. * Serializes the particle system to a JSON object.
  91074. * @returns the JSON object
  91075. */
  91076. serialize(): any;
  91077. /**
  91078. * Parse properties from a JSON object
  91079. * @param serializationObject defines the JSON object
  91080. */
  91081. parse(serializationObject: any): void;
  91082. }
  91083. /**
  91084. * Particle emitter emitting particles from the inside of a cylinder.
  91085. * It emits the particles randomly between two vectors.
  91086. */
  91087. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  91088. /**
  91089. * The min limit of the emission direction.
  91090. */
  91091. direction1: Vector3;
  91092. /**
  91093. * The max limit of the emission direction.
  91094. */
  91095. direction2: Vector3;
  91096. /**
  91097. * Creates a new instance CylinderDirectedParticleEmitter
  91098. * @param radius the radius of the emission cylinder (1 by default)
  91099. * @param height the height of the emission cylinder (1 by default)
  91100. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91101. * @param direction1 the min limit of the emission direction (up vector by default)
  91102. * @param direction2 the max limit of the emission direction (up vector by default)
  91103. */
  91104. constructor(radius?: number, height?: number, radiusRange?: number,
  91105. /**
  91106. * The min limit of the emission direction.
  91107. */
  91108. direction1?: Vector3,
  91109. /**
  91110. * The max limit of the emission direction.
  91111. */
  91112. direction2?: Vector3);
  91113. /**
  91114. * Called by the particle System when the direction is computed for the created particle.
  91115. * @param worldMatrix is the world matrix of the particle system
  91116. * @param directionToUpdate is the direction vector to update with the result
  91117. * @param particle is the particle we are computed the direction for
  91118. */
  91119. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91120. /**
  91121. * Clones the current emitter and returns a copy of it
  91122. * @returns the new emitter
  91123. */
  91124. clone(): CylinderDirectedParticleEmitter;
  91125. /**
  91126. * Called by the GPUParticleSystem to setup the update shader
  91127. * @param effect defines the update shader
  91128. */
  91129. applyToShader(effect: Effect): void;
  91130. /**
  91131. * Returns a string to use to update the GPU particles update shader
  91132. * @returns a string containng the defines string
  91133. */
  91134. getEffectDefines(): string;
  91135. /**
  91136. * Returns the string "CylinderDirectedParticleEmitter"
  91137. * @returns a string containing the class name
  91138. */
  91139. getClassName(): string;
  91140. /**
  91141. * Serializes the particle system to a JSON object.
  91142. * @returns the JSON object
  91143. */
  91144. serialize(): any;
  91145. /**
  91146. * Parse properties from a JSON object
  91147. * @param serializationObject defines the JSON object
  91148. */
  91149. parse(serializationObject: any): void;
  91150. }
  91151. }
  91152. declare module BABYLON {
  91153. /**
  91154. * Particle emitter emitting particles from the inside of a hemisphere.
  91155. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  91156. */
  91157. export class HemisphericParticleEmitter implements IParticleEmitterType {
  91158. /**
  91159. * The radius of the emission hemisphere.
  91160. */
  91161. radius: number;
  91162. /**
  91163. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91164. */
  91165. radiusRange: number;
  91166. /**
  91167. * How much to randomize the particle direction [0-1].
  91168. */
  91169. directionRandomizer: number;
  91170. /**
  91171. * Creates a new instance HemisphericParticleEmitter
  91172. * @param radius the radius of the emission hemisphere (1 by default)
  91173. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91174. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91175. */
  91176. constructor(
  91177. /**
  91178. * The radius of the emission hemisphere.
  91179. */
  91180. radius?: number,
  91181. /**
  91182. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91183. */
  91184. radiusRange?: number,
  91185. /**
  91186. * How much to randomize the particle direction [0-1].
  91187. */
  91188. directionRandomizer?: number);
  91189. /**
  91190. * Called by the particle System when the direction is computed for the created particle.
  91191. * @param worldMatrix is the world matrix of the particle system
  91192. * @param directionToUpdate is the direction vector to update with the result
  91193. * @param particle is the particle we are computed the direction for
  91194. * @param isLocal defines if the direction should be set in local space
  91195. */
  91196. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91197. /**
  91198. * Called by the particle System when the position is computed for the created particle.
  91199. * @param worldMatrix is the world matrix of the particle system
  91200. * @param positionToUpdate is the position vector to update with the result
  91201. * @param particle is the particle we are computed the position for
  91202. * @param isLocal defines if the position should be set in local space
  91203. */
  91204. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91205. /**
  91206. * Clones the current emitter and returns a copy of it
  91207. * @returns the new emitter
  91208. */
  91209. clone(): HemisphericParticleEmitter;
  91210. /**
  91211. * Called by the GPUParticleSystem to setup the update shader
  91212. * @param effect defines the update shader
  91213. */
  91214. applyToShader(effect: Effect): void;
  91215. /**
  91216. * Returns a string to use to update the GPU particles update shader
  91217. * @returns a string containng the defines string
  91218. */
  91219. getEffectDefines(): string;
  91220. /**
  91221. * Returns the string "HemisphericParticleEmitter"
  91222. * @returns a string containing the class name
  91223. */
  91224. getClassName(): string;
  91225. /**
  91226. * Serializes the particle system to a JSON object.
  91227. * @returns the JSON object
  91228. */
  91229. serialize(): any;
  91230. /**
  91231. * Parse properties from a JSON object
  91232. * @param serializationObject defines the JSON object
  91233. */
  91234. parse(serializationObject: any): void;
  91235. }
  91236. }
  91237. declare module BABYLON {
  91238. /**
  91239. * Particle emitter emitting particles from a point.
  91240. * It emits the particles randomly between 2 given directions.
  91241. */
  91242. export class PointParticleEmitter implements IParticleEmitterType {
  91243. /**
  91244. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91245. */
  91246. direction1: Vector3;
  91247. /**
  91248. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91249. */
  91250. direction2: Vector3;
  91251. /**
  91252. * Creates a new instance PointParticleEmitter
  91253. */
  91254. constructor();
  91255. /**
  91256. * Called by the particle System when the direction is computed for the created particle.
  91257. * @param worldMatrix is the world matrix of the particle system
  91258. * @param directionToUpdate is the direction vector to update with the result
  91259. * @param particle is the particle we are computed the direction for
  91260. * @param isLocal defines if the direction should be set in local space
  91261. */
  91262. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91263. /**
  91264. * Called by the particle System when the position is computed for the created particle.
  91265. * @param worldMatrix is the world matrix of the particle system
  91266. * @param positionToUpdate is the position vector to update with the result
  91267. * @param particle is the particle we are computed the position for
  91268. * @param isLocal defines if the position should be set in local space
  91269. */
  91270. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91271. /**
  91272. * Clones the current emitter and returns a copy of it
  91273. * @returns the new emitter
  91274. */
  91275. clone(): PointParticleEmitter;
  91276. /**
  91277. * Called by the GPUParticleSystem to setup the update shader
  91278. * @param effect defines the update shader
  91279. */
  91280. applyToShader(effect: Effect): void;
  91281. /**
  91282. * Returns a string to use to update the GPU particles update shader
  91283. * @returns a string containng the defines string
  91284. */
  91285. getEffectDefines(): string;
  91286. /**
  91287. * Returns the string "PointParticleEmitter"
  91288. * @returns a string containing the class name
  91289. */
  91290. getClassName(): string;
  91291. /**
  91292. * Serializes the particle system to a JSON object.
  91293. * @returns the JSON object
  91294. */
  91295. serialize(): any;
  91296. /**
  91297. * Parse properties from a JSON object
  91298. * @param serializationObject defines the JSON object
  91299. */
  91300. parse(serializationObject: any): void;
  91301. }
  91302. }
  91303. declare module BABYLON {
  91304. /**
  91305. * Particle emitter emitting particles from the inside of a sphere.
  91306. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  91307. */
  91308. export class SphereParticleEmitter implements IParticleEmitterType {
  91309. /**
  91310. * The radius of the emission sphere.
  91311. */
  91312. radius: number;
  91313. /**
  91314. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91315. */
  91316. radiusRange: number;
  91317. /**
  91318. * How much to randomize the particle direction [0-1].
  91319. */
  91320. directionRandomizer: number;
  91321. /**
  91322. * Creates a new instance SphereParticleEmitter
  91323. * @param radius the radius of the emission sphere (1 by default)
  91324. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91325. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91326. */
  91327. constructor(
  91328. /**
  91329. * The radius of the emission sphere.
  91330. */
  91331. radius?: number,
  91332. /**
  91333. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91334. */
  91335. radiusRange?: number,
  91336. /**
  91337. * How much to randomize the particle direction [0-1].
  91338. */
  91339. directionRandomizer?: number);
  91340. /**
  91341. * Called by the particle System when the direction is computed for the created particle.
  91342. * @param worldMatrix is the world matrix of the particle system
  91343. * @param directionToUpdate is the direction vector to update with the result
  91344. * @param particle is the particle we are computed the direction for
  91345. * @param isLocal defines if the direction should be set in local space
  91346. */
  91347. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91348. /**
  91349. * Called by the particle System when the position is computed for the created particle.
  91350. * @param worldMatrix is the world matrix of the particle system
  91351. * @param positionToUpdate is the position vector to update with the result
  91352. * @param particle is the particle we are computed the position for
  91353. * @param isLocal defines if the position should be set in local space
  91354. */
  91355. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91356. /**
  91357. * Clones the current emitter and returns a copy of it
  91358. * @returns the new emitter
  91359. */
  91360. clone(): SphereParticleEmitter;
  91361. /**
  91362. * Called by the GPUParticleSystem to setup the update shader
  91363. * @param effect defines the update shader
  91364. */
  91365. applyToShader(effect: Effect): void;
  91366. /**
  91367. * Returns a string to use to update the GPU particles update shader
  91368. * @returns a string containng the defines string
  91369. */
  91370. getEffectDefines(): string;
  91371. /**
  91372. * Returns the string "SphereParticleEmitter"
  91373. * @returns a string containing the class name
  91374. */
  91375. getClassName(): string;
  91376. /**
  91377. * Serializes the particle system to a JSON object.
  91378. * @returns the JSON object
  91379. */
  91380. serialize(): any;
  91381. /**
  91382. * Parse properties from a JSON object
  91383. * @param serializationObject defines the JSON object
  91384. */
  91385. parse(serializationObject: any): void;
  91386. }
  91387. /**
  91388. * Particle emitter emitting particles from the inside of a sphere.
  91389. * It emits the particles randomly between two vectors.
  91390. */
  91391. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  91392. /**
  91393. * The min limit of the emission direction.
  91394. */
  91395. direction1: Vector3;
  91396. /**
  91397. * The max limit of the emission direction.
  91398. */
  91399. direction2: Vector3;
  91400. /**
  91401. * Creates a new instance SphereDirectedParticleEmitter
  91402. * @param radius the radius of the emission sphere (1 by default)
  91403. * @param direction1 the min limit of the emission direction (up vector by default)
  91404. * @param direction2 the max limit of the emission direction (up vector by default)
  91405. */
  91406. constructor(radius?: number,
  91407. /**
  91408. * The min limit of the emission direction.
  91409. */
  91410. direction1?: Vector3,
  91411. /**
  91412. * The max limit of the emission direction.
  91413. */
  91414. direction2?: Vector3);
  91415. /**
  91416. * Called by the particle System when the direction is computed for the created particle.
  91417. * @param worldMatrix is the world matrix of the particle system
  91418. * @param directionToUpdate is the direction vector to update with the result
  91419. * @param particle is the particle we are computed the direction for
  91420. */
  91421. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91422. /**
  91423. * Clones the current emitter and returns a copy of it
  91424. * @returns the new emitter
  91425. */
  91426. clone(): SphereDirectedParticleEmitter;
  91427. /**
  91428. * Called by the GPUParticleSystem to setup the update shader
  91429. * @param effect defines the update shader
  91430. */
  91431. applyToShader(effect: Effect): void;
  91432. /**
  91433. * Returns a string to use to update the GPU particles update shader
  91434. * @returns a string containng the defines string
  91435. */
  91436. getEffectDefines(): string;
  91437. /**
  91438. * Returns the string "SphereDirectedParticleEmitter"
  91439. * @returns a string containing the class name
  91440. */
  91441. getClassName(): string;
  91442. /**
  91443. * Serializes the particle system to a JSON object.
  91444. * @returns the JSON object
  91445. */
  91446. serialize(): any;
  91447. /**
  91448. * Parse properties from a JSON object
  91449. * @param serializationObject defines the JSON object
  91450. */
  91451. parse(serializationObject: any): void;
  91452. }
  91453. }
  91454. declare module BABYLON {
  91455. /**
  91456. * Particle emitter emitting particles from a custom list of positions.
  91457. */
  91458. export class CustomParticleEmitter implements IParticleEmitterType {
  91459. /**
  91460. * Gets or sets the position generator that will create the inital position of each particle.
  91461. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91462. */
  91463. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  91464. /**
  91465. * Gets or sets the destination generator that will create the final destination of each particle.
  91466. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91467. */
  91468. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  91469. /**
  91470. * Creates a new instance CustomParticleEmitter
  91471. */
  91472. constructor();
  91473. /**
  91474. * Called by the particle System when the direction is computed for the created particle.
  91475. * @param worldMatrix is the world matrix of the particle system
  91476. * @param directionToUpdate is the direction vector to update with the result
  91477. * @param particle is the particle we are computed the direction for
  91478. * @param isLocal defines if the direction should be set in local space
  91479. */
  91480. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91481. /**
  91482. * Called by the particle System when the position is computed for the created particle.
  91483. * @param worldMatrix is the world matrix of the particle system
  91484. * @param positionToUpdate is the position vector to update with the result
  91485. * @param particle is the particle we are computed the position for
  91486. * @param isLocal defines if the position should be set in local space
  91487. */
  91488. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91489. /**
  91490. * Clones the current emitter and returns a copy of it
  91491. * @returns the new emitter
  91492. */
  91493. clone(): CustomParticleEmitter;
  91494. /**
  91495. * Called by the GPUParticleSystem to setup the update shader
  91496. * @param effect defines the update shader
  91497. */
  91498. applyToShader(effect: Effect): void;
  91499. /**
  91500. * Returns a string to use to update the GPU particles update shader
  91501. * @returns a string containng the defines string
  91502. */
  91503. getEffectDefines(): string;
  91504. /**
  91505. * Returns the string "PointParticleEmitter"
  91506. * @returns a string containing the class name
  91507. */
  91508. getClassName(): string;
  91509. /**
  91510. * Serializes the particle system to a JSON object.
  91511. * @returns the JSON object
  91512. */
  91513. serialize(): any;
  91514. /**
  91515. * Parse properties from a JSON object
  91516. * @param serializationObject defines the JSON object
  91517. */
  91518. parse(serializationObject: any): void;
  91519. }
  91520. }
  91521. declare module BABYLON {
  91522. /**
  91523. * Particle emitter emitting particles from the inside of a box.
  91524. * It emits the particles randomly between 2 given directions.
  91525. */
  91526. export class MeshParticleEmitter implements IParticleEmitterType {
  91527. private _indices;
  91528. private _positions;
  91529. private _normals;
  91530. private _storedNormal;
  91531. private _mesh;
  91532. /**
  91533. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91534. */
  91535. direction1: Vector3;
  91536. /**
  91537. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91538. */
  91539. direction2: Vector3;
  91540. /**
  91541. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  91542. */
  91543. useMeshNormalsForDirection: boolean;
  91544. /** Defines the mesh to use as source */
  91545. get mesh(): Nullable<AbstractMesh>;
  91546. set mesh(value: Nullable<AbstractMesh>);
  91547. /**
  91548. * Creates a new instance MeshParticleEmitter
  91549. * @param mesh defines the mesh to use as source
  91550. */
  91551. constructor(mesh?: Nullable<AbstractMesh>);
  91552. /**
  91553. * Called by the particle System when the direction is computed for the created particle.
  91554. * @param worldMatrix is the world matrix of the particle system
  91555. * @param directionToUpdate is the direction vector to update with the result
  91556. * @param particle is the particle we are computed the direction for
  91557. * @param isLocal defines if the direction should be set in local space
  91558. */
  91559. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91560. /**
  91561. * Called by the particle System when the position is computed for the created particle.
  91562. * @param worldMatrix is the world matrix of the particle system
  91563. * @param positionToUpdate is the position vector to update with the result
  91564. * @param particle is the particle we are computed the position for
  91565. * @param isLocal defines if the position should be set in local space
  91566. */
  91567. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91568. /**
  91569. * Clones the current emitter and returns a copy of it
  91570. * @returns the new emitter
  91571. */
  91572. clone(): MeshParticleEmitter;
  91573. /**
  91574. * Called by the GPUParticleSystem to setup the update shader
  91575. * @param effect defines the update shader
  91576. */
  91577. applyToShader(effect: Effect): void;
  91578. /**
  91579. * Returns a string to use to update the GPU particles update shader
  91580. * @returns a string containng the defines string
  91581. */
  91582. getEffectDefines(): string;
  91583. /**
  91584. * Returns the string "BoxParticleEmitter"
  91585. * @returns a string containing the class name
  91586. */
  91587. getClassName(): string;
  91588. /**
  91589. * Serializes the particle system to a JSON object.
  91590. * @returns the JSON object
  91591. */
  91592. serialize(): any;
  91593. /**
  91594. * Parse properties from a JSON object
  91595. * @param serializationObject defines the JSON object
  91596. * @param scene defines the hosting scene
  91597. */
  91598. parse(serializationObject: any, scene: Scene): void;
  91599. }
  91600. }
  91601. declare module BABYLON {
  91602. /**
  91603. * Interface representing a particle system in Babylon.js.
  91604. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  91605. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  91606. */
  91607. export interface IParticleSystem {
  91608. /**
  91609. * List of animations used by the particle system.
  91610. */
  91611. animations: Animation[];
  91612. /**
  91613. * The id of the Particle system.
  91614. */
  91615. id: string;
  91616. /**
  91617. * The name of the Particle system.
  91618. */
  91619. name: string;
  91620. /**
  91621. * The emitter represents the Mesh or position we are attaching the particle system to.
  91622. */
  91623. emitter: Nullable<AbstractMesh | Vector3>;
  91624. /**
  91625. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91626. */
  91627. isBillboardBased: boolean;
  91628. /**
  91629. * The rendering group used by the Particle system to chose when to render.
  91630. */
  91631. renderingGroupId: number;
  91632. /**
  91633. * The layer mask we are rendering the particles through.
  91634. */
  91635. layerMask: number;
  91636. /**
  91637. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91638. */
  91639. updateSpeed: number;
  91640. /**
  91641. * The amount of time the particle system is running (depends of the overall update speed).
  91642. */
  91643. targetStopDuration: number;
  91644. /**
  91645. * The texture used to render each particle. (this can be a spritesheet)
  91646. */
  91647. particleTexture: Nullable<Texture>;
  91648. /**
  91649. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  91650. */
  91651. blendMode: number;
  91652. /**
  91653. * Minimum life time of emitting particles.
  91654. */
  91655. minLifeTime: number;
  91656. /**
  91657. * Maximum life time of emitting particles.
  91658. */
  91659. maxLifeTime: number;
  91660. /**
  91661. * Minimum Size of emitting particles.
  91662. */
  91663. minSize: number;
  91664. /**
  91665. * Maximum Size of emitting particles.
  91666. */
  91667. maxSize: number;
  91668. /**
  91669. * Minimum scale of emitting particles on X axis.
  91670. */
  91671. minScaleX: number;
  91672. /**
  91673. * Maximum scale of emitting particles on X axis.
  91674. */
  91675. maxScaleX: number;
  91676. /**
  91677. * Minimum scale of emitting particles on Y axis.
  91678. */
  91679. minScaleY: number;
  91680. /**
  91681. * Maximum scale of emitting particles on Y axis.
  91682. */
  91683. maxScaleY: number;
  91684. /**
  91685. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91686. */
  91687. color1: Color4;
  91688. /**
  91689. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91690. */
  91691. color2: Color4;
  91692. /**
  91693. * Color the particle will have at the end of its lifetime.
  91694. */
  91695. colorDead: Color4;
  91696. /**
  91697. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  91698. */
  91699. emitRate: number;
  91700. /**
  91701. * You can use gravity if you want to give an orientation to your particles.
  91702. */
  91703. gravity: Vector3;
  91704. /**
  91705. * Minimum power of emitting particles.
  91706. */
  91707. minEmitPower: number;
  91708. /**
  91709. * Maximum power of emitting particles.
  91710. */
  91711. maxEmitPower: number;
  91712. /**
  91713. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91714. */
  91715. minAngularSpeed: number;
  91716. /**
  91717. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91718. */
  91719. maxAngularSpeed: number;
  91720. /**
  91721. * Gets or sets the minimal initial rotation in radians.
  91722. */
  91723. minInitialRotation: number;
  91724. /**
  91725. * Gets or sets the maximal initial rotation in radians.
  91726. */
  91727. maxInitialRotation: number;
  91728. /**
  91729. * The particle emitter type defines the emitter used by the particle system.
  91730. * It can be for example box, sphere, or cone...
  91731. */
  91732. particleEmitterType: Nullable<IParticleEmitterType>;
  91733. /**
  91734. * Defines the delay in milliseconds before starting the system (0 by default)
  91735. */
  91736. startDelay: number;
  91737. /**
  91738. * 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
  91739. */
  91740. preWarmCycles: number;
  91741. /**
  91742. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  91743. */
  91744. preWarmStepOffset: number;
  91745. /**
  91746. * 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)
  91747. */
  91748. spriteCellChangeSpeed: number;
  91749. /**
  91750. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91751. */
  91752. startSpriteCellID: number;
  91753. /**
  91754. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91755. */
  91756. endSpriteCellID: number;
  91757. /**
  91758. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91759. */
  91760. spriteCellWidth: number;
  91761. /**
  91762. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91763. */
  91764. spriteCellHeight: number;
  91765. /**
  91766. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91767. */
  91768. spriteRandomStartCell: boolean;
  91769. /**
  91770. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  91771. */
  91772. isAnimationSheetEnabled: boolean;
  91773. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91774. translationPivot: Vector2;
  91775. /**
  91776. * Gets or sets a texture used to add random noise to particle positions
  91777. */
  91778. noiseTexture: Nullable<BaseTexture>;
  91779. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91780. noiseStrength: Vector3;
  91781. /**
  91782. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91783. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91784. */
  91785. billboardMode: number;
  91786. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91787. limitVelocityDamping: number;
  91788. /**
  91789. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91790. */
  91791. beginAnimationOnStart: boolean;
  91792. /**
  91793. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91794. */
  91795. beginAnimationFrom: number;
  91796. /**
  91797. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91798. */
  91799. beginAnimationTo: number;
  91800. /**
  91801. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91802. */
  91803. beginAnimationLoop: boolean;
  91804. /**
  91805. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91806. */
  91807. disposeOnStop: boolean;
  91808. /**
  91809. * Specifies if the particles are updated in emitter local space or world space
  91810. */
  91811. isLocal: boolean;
  91812. /** Snippet ID if the particle system was created from the snippet server */
  91813. snippetId: string;
  91814. /**
  91815. * Gets the maximum number of particles active at the same time.
  91816. * @returns The max number of active particles.
  91817. */
  91818. getCapacity(): number;
  91819. /**
  91820. * Gets the number of particles active at the same time.
  91821. * @returns The number of active particles.
  91822. */
  91823. getActiveCount(): number;
  91824. /**
  91825. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91826. * @returns True if it has been started, otherwise false.
  91827. */
  91828. isStarted(): boolean;
  91829. /**
  91830. * Animates the particle system for this frame.
  91831. */
  91832. animate(): void;
  91833. /**
  91834. * Renders the particle system in its current state.
  91835. * @returns the current number of particles
  91836. */
  91837. render(): number;
  91838. /**
  91839. * Dispose the particle system and frees its associated resources.
  91840. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91841. */
  91842. dispose(disposeTexture?: boolean): void;
  91843. /**
  91844. * An event triggered when the system is disposed
  91845. */
  91846. onDisposeObservable: Observable<IParticleSystem>;
  91847. /**
  91848. * Clones the particle system.
  91849. * @param name The name of the cloned object
  91850. * @param newEmitter The new emitter to use
  91851. * @returns the cloned particle system
  91852. */
  91853. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  91854. /**
  91855. * Serializes the particle system to a JSON object
  91856. * @param serializeTexture defines if the texture must be serialized as well
  91857. * @returns the JSON object
  91858. */
  91859. serialize(serializeTexture: boolean): any;
  91860. /**
  91861. * Rebuild the particle system
  91862. */
  91863. rebuild(): void;
  91864. /** Force the system to rebuild all gradients that need to be resync */
  91865. forceRefreshGradients(): void;
  91866. /**
  91867. * Starts the particle system and begins to emit
  91868. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  91869. */
  91870. start(delay?: number): void;
  91871. /**
  91872. * Stops the particle system.
  91873. */
  91874. stop(): void;
  91875. /**
  91876. * Remove all active particles
  91877. */
  91878. reset(): void;
  91879. /**
  91880. * Gets a boolean indicating that the system is stopping
  91881. * @returns true if the system is currently stopping
  91882. */
  91883. isStopping(): boolean;
  91884. /**
  91885. * Is this system ready to be used/rendered
  91886. * @return true if the system is ready
  91887. */
  91888. isReady(): boolean;
  91889. /**
  91890. * Returns the string "ParticleSystem"
  91891. * @returns a string containing the class name
  91892. */
  91893. getClassName(): string;
  91894. /**
  91895. * Gets the custom effect used to render the particles
  91896. * @param blendMode Blend mode for which the effect should be retrieved
  91897. * @returns The effect
  91898. */
  91899. getCustomEffect(blendMode: number): Nullable<Effect>;
  91900. /**
  91901. * Sets the custom effect used to render the particles
  91902. * @param effect The effect to set
  91903. * @param blendMode Blend mode for which the effect should be set
  91904. */
  91905. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  91906. /**
  91907. * Fill the defines array according to the current settings of the particle system
  91908. * @param defines Array to be updated
  91909. * @param blendMode blend mode to take into account when updating the array
  91910. */
  91911. fillDefines(defines: Array<string>, blendMode: number): void;
  91912. /**
  91913. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  91914. * @param uniforms Uniforms array to fill
  91915. * @param attributes Attributes array to fill
  91916. * @param samplers Samplers array to fill
  91917. */
  91918. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  91919. /**
  91920. * Observable that will be called just before the particles are drawn
  91921. */
  91922. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  91923. /**
  91924. * Gets the name of the particle vertex shader
  91925. */
  91926. vertexShaderName: string;
  91927. /**
  91928. * Adds a new color gradient
  91929. * @param gradient defines the gradient to use (between 0 and 1)
  91930. * @param color1 defines the color to affect to the specified gradient
  91931. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91932. * @returns the current particle system
  91933. */
  91934. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91935. /**
  91936. * Remove a specific color gradient
  91937. * @param gradient defines the gradient to remove
  91938. * @returns the current particle system
  91939. */
  91940. removeColorGradient(gradient: number): IParticleSystem;
  91941. /**
  91942. * Adds a new size gradient
  91943. * @param gradient defines the gradient to use (between 0 and 1)
  91944. * @param factor defines the size factor to affect to the specified gradient
  91945. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91946. * @returns the current particle system
  91947. */
  91948. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91949. /**
  91950. * Remove a specific size gradient
  91951. * @param gradient defines the gradient to remove
  91952. * @returns the current particle system
  91953. */
  91954. removeSizeGradient(gradient: number): IParticleSystem;
  91955. /**
  91956. * Gets the current list of color gradients.
  91957. * You must use addColorGradient and removeColorGradient to udpate this list
  91958. * @returns the list of color gradients
  91959. */
  91960. getColorGradients(): Nullable<Array<ColorGradient>>;
  91961. /**
  91962. * Gets the current list of size gradients.
  91963. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91964. * @returns the list of size gradients
  91965. */
  91966. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91967. /**
  91968. * Gets the current list of angular speed gradients.
  91969. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91970. * @returns the list of angular speed gradients
  91971. */
  91972. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91973. /**
  91974. * Adds a new angular speed gradient
  91975. * @param gradient defines the gradient to use (between 0 and 1)
  91976. * @param factor defines the angular speed to affect to the specified gradient
  91977. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91978. * @returns the current particle system
  91979. */
  91980. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91981. /**
  91982. * Remove a specific angular speed gradient
  91983. * @param gradient defines the gradient to remove
  91984. * @returns the current particle system
  91985. */
  91986. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91987. /**
  91988. * Gets the current list of velocity gradients.
  91989. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91990. * @returns the list of velocity gradients
  91991. */
  91992. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91993. /**
  91994. * Adds a new velocity gradient
  91995. * @param gradient defines the gradient to use (between 0 and 1)
  91996. * @param factor defines the velocity to affect to the specified gradient
  91997. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91998. * @returns the current particle system
  91999. */
  92000. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92001. /**
  92002. * Remove a specific velocity gradient
  92003. * @param gradient defines the gradient to remove
  92004. * @returns the current particle system
  92005. */
  92006. removeVelocityGradient(gradient: number): IParticleSystem;
  92007. /**
  92008. * Gets the current list of limit velocity gradients.
  92009. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92010. * @returns the list of limit velocity gradients
  92011. */
  92012. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92013. /**
  92014. * Adds a new limit velocity gradient
  92015. * @param gradient defines the gradient to use (between 0 and 1)
  92016. * @param factor defines the limit velocity to affect to the specified gradient
  92017. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92018. * @returns the current particle system
  92019. */
  92020. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92021. /**
  92022. * Remove a specific limit velocity gradient
  92023. * @param gradient defines the gradient to remove
  92024. * @returns the current particle system
  92025. */
  92026. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  92027. /**
  92028. * Adds a new drag gradient
  92029. * @param gradient defines the gradient to use (between 0 and 1)
  92030. * @param factor defines the drag to affect to the specified gradient
  92031. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92032. * @returns the current particle system
  92033. */
  92034. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92035. /**
  92036. * Remove a specific drag gradient
  92037. * @param gradient defines the gradient to remove
  92038. * @returns the current particle system
  92039. */
  92040. removeDragGradient(gradient: number): IParticleSystem;
  92041. /**
  92042. * Gets the current list of drag gradients.
  92043. * You must use addDragGradient and removeDragGradient to udpate this list
  92044. * @returns the list of drag gradients
  92045. */
  92046. getDragGradients(): Nullable<Array<FactorGradient>>;
  92047. /**
  92048. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  92049. * @param gradient defines the gradient to use (between 0 and 1)
  92050. * @param factor defines the emit rate to affect to the specified gradient
  92051. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92052. * @returns the current particle system
  92053. */
  92054. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92055. /**
  92056. * Remove a specific emit rate gradient
  92057. * @param gradient defines the gradient to remove
  92058. * @returns the current particle system
  92059. */
  92060. removeEmitRateGradient(gradient: number): IParticleSystem;
  92061. /**
  92062. * Gets the current list of emit rate gradients.
  92063. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92064. * @returns the list of emit rate gradients
  92065. */
  92066. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92067. /**
  92068. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  92069. * @param gradient defines the gradient to use (between 0 and 1)
  92070. * @param factor defines the start size to affect to the specified gradient
  92071. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92072. * @returns the current particle system
  92073. */
  92074. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92075. /**
  92076. * Remove a specific start size gradient
  92077. * @param gradient defines the gradient to remove
  92078. * @returns the current particle system
  92079. */
  92080. removeStartSizeGradient(gradient: number): IParticleSystem;
  92081. /**
  92082. * Gets the current list of start size gradients.
  92083. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92084. * @returns the list of start size gradients
  92085. */
  92086. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92087. /**
  92088. * Adds a new life time gradient
  92089. * @param gradient defines the gradient to use (between 0 and 1)
  92090. * @param factor defines the life time factor to affect to the specified gradient
  92091. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92092. * @returns the current particle system
  92093. */
  92094. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92095. /**
  92096. * Remove a specific life time gradient
  92097. * @param gradient defines the gradient to remove
  92098. * @returns the current particle system
  92099. */
  92100. removeLifeTimeGradient(gradient: number): IParticleSystem;
  92101. /**
  92102. * Gets the current list of life time gradients.
  92103. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92104. * @returns the list of life time gradients
  92105. */
  92106. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92107. /**
  92108. * Gets the current list of color gradients.
  92109. * You must use addColorGradient and removeColorGradient to udpate this list
  92110. * @returns the list of color gradients
  92111. */
  92112. getColorGradients(): Nullable<Array<ColorGradient>>;
  92113. /**
  92114. * Adds a new ramp gradient used to remap particle colors
  92115. * @param gradient defines the gradient to use (between 0 and 1)
  92116. * @param color defines the color to affect to the specified gradient
  92117. * @returns the current particle system
  92118. */
  92119. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  92120. /**
  92121. * Gets the current list of ramp gradients.
  92122. * You must use addRampGradient and removeRampGradient to udpate this list
  92123. * @returns the list of ramp gradients
  92124. */
  92125. getRampGradients(): Nullable<Array<Color3Gradient>>;
  92126. /** Gets or sets a boolean indicating that ramp gradients must be used
  92127. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92128. */
  92129. useRampGradients: boolean;
  92130. /**
  92131. * Adds a new color remap gradient
  92132. * @param gradient defines the gradient to use (between 0 and 1)
  92133. * @param min defines the color remap minimal range
  92134. * @param max defines the color remap maximal range
  92135. * @returns the current particle system
  92136. */
  92137. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92138. /**
  92139. * Gets the current list of color remap gradients.
  92140. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92141. * @returns the list of color remap gradients
  92142. */
  92143. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92144. /**
  92145. * Adds a new alpha remap gradient
  92146. * @param gradient defines the gradient to use (between 0 and 1)
  92147. * @param min defines the alpha remap minimal range
  92148. * @param max defines the alpha remap maximal range
  92149. * @returns the current particle system
  92150. */
  92151. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92152. /**
  92153. * Gets the current list of alpha remap gradients.
  92154. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92155. * @returns the list of alpha remap gradients
  92156. */
  92157. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92158. /**
  92159. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92160. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92161. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92162. * @returns the emitter
  92163. */
  92164. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92165. /**
  92166. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92167. * @param radius The radius of the hemisphere to emit from
  92168. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92169. * @returns the emitter
  92170. */
  92171. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  92172. /**
  92173. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92174. * @param radius The radius of the sphere to emit from
  92175. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92176. * @returns the emitter
  92177. */
  92178. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  92179. /**
  92180. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92181. * @param radius The radius of the sphere to emit from
  92182. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92183. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92184. * @returns the emitter
  92185. */
  92186. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92187. /**
  92188. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92189. * @param radius The radius of the emission cylinder
  92190. * @param height The height of the emission cylinder
  92191. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92192. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92193. * @returns the emitter
  92194. */
  92195. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  92196. /**
  92197. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92198. * @param radius The radius of the cylinder to emit from
  92199. * @param height The height of the emission cylinder
  92200. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92201. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92202. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92203. * @returns the emitter
  92204. */
  92205. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92206. /**
  92207. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92208. * @param radius The radius of the cone to emit from
  92209. * @param angle The base angle of the cone
  92210. * @returns the emitter
  92211. */
  92212. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  92213. /**
  92214. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92215. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92216. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92217. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92218. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92219. * @returns the emitter
  92220. */
  92221. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92222. /**
  92223. * Get hosting scene
  92224. * @returns the scene
  92225. */
  92226. getScene(): Scene;
  92227. }
  92228. }
  92229. declare module BABYLON {
  92230. /**
  92231. * 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.
  92232. * @see https://doc.babylonjs.com/how_to/transformnode
  92233. */
  92234. export class TransformNode extends Node {
  92235. /**
  92236. * Object will not rotate to face the camera
  92237. */
  92238. static BILLBOARDMODE_NONE: number;
  92239. /**
  92240. * Object will rotate to face the camera but only on the x axis
  92241. */
  92242. static BILLBOARDMODE_X: number;
  92243. /**
  92244. * Object will rotate to face the camera but only on the y axis
  92245. */
  92246. static BILLBOARDMODE_Y: number;
  92247. /**
  92248. * Object will rotate to face the camera but only on the z axis
  92249. */
  92250. static BILLBOARDMODE_Z: number;
  92251. /**
  92252. * Object will rotate to face the camera
  92253. */
  92254. static BILLBOARDMODE_ALL: number;
  92255. /**
  92256. * Object will rotate to face the camera's position instead of orientation
  92257. */
  92258. static BILLBOARDMODE_USE_POSITION: number;
  92259. private _forward;
  92260. private _forwardInverted;
  92261. private _up;
  92262. private _right;
  92263. private _rightInverted;
  92264. private _position;
  92265. private _rotation;
  92266. private _rotationQuaternion;
  92267. protected _scaling: Vector3;
  92268. protected _isDirty: boolean;
  92269. private _transformToBoneReferal;
  92270. private _isAbsoluteSynced;
  92271. private _billboardMode;
  92272. /**
  92273. * Gets or sets the billboard mode. Default is 0.
  92274. *
  92275. * | Value | Type | Description |
  92276. * | --- | --- | --- |
  92277. * | 0 | BILLBOARDMODE_NONE | |
  92278. * | 1 | BILLBOARDMODE_X | |
  92279. * | 2 | BILLBOARDMODE_Y | |
  92280. * | 4 | BILLBOARDMODE_Z | |
  92281. * | 7 | BILLBOARDMODE_ALL | |
  92282. *
  92283. */
  92284. get billboardMode(): number;
  92285. set billboardMode(value: number);
  92286. private _preserveParentRotationForBillboard;
  92287. /**
  92288. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  92289. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  92290. */
  92291. get preserveParentRotationForBillboard(): boolean;
  92292. set preserveParentRotationForBillboard(value: boolean);
  92293. /**
  92294. * 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
  92295. */
  92296. scalingDeterminant: number;
  92297. private _infiniteDistance;
  92298. /**
  92299. * Gets or sets the distance of the object to max, often used by skybox
  92300. */
  92301. get infiniteDistance(): boolean;
  92302. set infiniteDistance(value: boolean);
  92303. /**
  92304. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  92305. * By default the system will update normals to compensate
  92306. */
  92307. ignoreNonUniformScaling: boolean;
  92308. /**
  92309. * 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
  92310. */
  92311. reIntegrateRotationIntoRotationQuaternion: boolean;
  92312. /** @hidden */
  92313. _poseMatrix: Nullable<Matrix>;
  92314. /** @hidden */
  92315. _localMatrix: Matrix;
  92316. private _usePivotMatrix;
  92317. private _absolutePosition;
  92318. private _absoluteScaling;
  92319. private _absoluteRotationQuaternion;
  92320. private _pivotMatrix;
  92321. private _pivotMatrixInverse;
  92322. protected _postMultiplyPivotMatrix: boolean;
  92323. protected _isWorldMatrixFrozen: boolean;
  92324. /** @hidden */
  92325. _indexInSceneTransformNodesArray: number;
  92326. /**
  92327. * An event triggered after the world matrix is updated
  92328. */
  92329. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  92330. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  92331. /**
  92332. * Gets a string identifying the name of the class
  92333. * @returns "TransformNode" string
  92334. */
  92335. getClassName(): string;
  92336. /**
  92337. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  92338. */
  92339. get position(): Vector3;
  92340. set position(newPosition: Vector3);
  92341. /**
  92342. * 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)).
  92343. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  92344. */
  92345. get rotation(): Vector3;
  92346. set rotation(newRotation: Vector3);
  92347. /**
  92348. * 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)).
  92349. */
  92350. get scaling(): Vector3;
  92351. set scaling(newScaling: Vector3);
  92352. /**
  92353. * 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).
  92354. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  92355. */
  92356. get rotationQuaternion(): Nullable<Quaternion>;
  92357. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  92358. /**
  92359. * The forward direction of that transform in world space.
  92360. */
  92361. get forward(): Vector3;
  92362. /**
  92363. * The up direction of that transform in world space.
  92364. */
  92365. get up(): Vector3;
  92366. /**
  92367. * The right direction of that transform in world space.
  92368. */
  92369. get right(): Vector3;
  92370. /**
  92371. * Copies the parameter passed Matrix into the mesh Pose matrix.
  92372. * @param matrix the matrix to copy the pose from
  92373. * @returns this TransformNode.
  92374. */
  92375. updatePoseMatrix(matrix: Matrix): TransformNode;
  92376. /**
  92377. * Returns the mesh Pose matrix.
  92378. * @returns the pose matrix
  92379. */
  92380. getPoseMatrix(): Matrix;
  92381. /** @hidden */
  92382. _isSynchronized(): boolean;
  92383. /** @hidden */
  92384. _initCache(): void;
  92385. /**
  92386. * Flag the transform node as dirty (Forcing it to update everything)
  92387. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  92388. * @returns this transform node
  92389. */
  92390. markAsDirty(property: string): TransformNode;
  92391. /**
  92392. * Returns the current mesh absolute position.
  92393. * Returns a Vector3.
  92394. */
  92395. get absolutePosition(): Vector3;
  92396. /**
  92397. * Returns the current mesh absolute scaling.
  92398. * Returns a Vector3.
  92399. */
  92400. get absoluteScaling(): Vector3;
  92401. /**
  92402. * Returns the current mesh absolute rotation.
  92403. * Returns a Quaternion.
  92404. */
  92405. get absoluteRotationQuaternion(): Quaternion;
  92406. /**
  92407. * Sets a new matrix to apply before all other transformation
  92408. * @param matrix defines the transform matrix
  92409. * @returns the current TransformNode
  92410. */
  92411. setPreTransformMatrix(matrix: Matrix): TransformNode;
  92412. /**
  92413. * Sets a new pivot matrix to the current node
  92414. * @param matrix defines the new pivot matrix to use
  92415. * @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
  92416. * @returns the current TransformNode
  92417. */
  92418. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  92419. /**
  92420. * Returns the mesh pivot matrix.
  92421. * Default : Identity.
  92422. * @returns the matrix
  92423. */
  92424. getPivotMatrix(): Matrix;
  92425. /**
  92426. * Instantiate (when possible) or clone that node with its hierarchy
  92427. * @param newParent defines the new parent to use for the instance (or clone)
  92428. * @param options defines options to configure how copy is done
  92429. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  92430. * @returns an instance (or a clone) of the current node with its hiearchy
  92431. */
  92432. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92433. doNotInstantiate: boolean;
  92434. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92435. /**
  92436. * Prevents the World matrix to be computed any longer
  92437. * @param newWorldMatrix defines an optional matrix to use as world matrix
  92438. * @returns the TransformNode.
  92439. */
  92440. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  92441. /**
  92442. * Allows back the World matrix computation.
  92443. * @returns the TransformNode.
  92444. */
  92445. unfreezeWorldMatrix(): this;
  92446. /**
  92447. * True if the World matrix has been frozen.
  92448. */
  92449. get isWorldMatrixFrozen(): boolean;
  92450. /**
  92451. * Retuns the mesh absolute position in the World.
  92452. * @returns a Vector3.
  92453. */
  92454. getAbsolutePosition(): Vector3;
  92455. /**
  92456. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  92457. * @param absolutePosition the absolute position to set
  92458. * @returns the TransformNode.
  92459. */
  92460. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  92461. /**
  92462. * Sets the mesh position in its local space.
  92463. * @param vector3 the position to set in localspace
  92464. * @returns the TransformNode.
  92465. */
  92466. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  92467. /**
  92468. * Returns the mesh position in the local space from the current World matrix values.
  92469. * @returns a new Vector3.
  92470. */
  92471. getPositionExpressedInLocalSpace(): Vector3;
  92472. /**
  92473. * Translates the mesh along the passed Vector3 in its local space.
  92474. * @param vector3 the distance to translate in localspace
  92475. * @returns the TransformNode.
  92476. */
  92477. locallyTranslate(vector3: Vector3): TransformNode;
  92478. private static _lookAtVectorCache;
  92479. /**
  92480. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  92481. * @param targetPoint the position (must be in same space as current mesh) to look at
  92482. * @param yawCor optional yaw (y-axis) correction in radians
  92483. * @param pitchCor optional pitch (x-axis) correction in radians
  92484. * @param rollCor optional roll (z-axis) correction in radians
  92485. * @param space the choosen space of the target
  92486. * @returns the TransformNode.
  92487. */
  92488. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  92489. /**
  92490. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92491. * This Vector3 is expressed in the World space.
  92492. * @param localAxis axis to rotate
  92493. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92494. */
  92495. getDirection(localAxis: Vector3): Vector3;
  92496. /**
  92497. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  92498. * localAxis is expressed in the mesh local space.
  92499. * result is computed in the Wordl space from the mesh World matrix.
  92500. * @param localAxis axis to rotate
  92501. * @param result the resulting transformnode
  92502. * @returns this TransformNode.
  92503. */
  92504. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  92505. /**
  92506. * Sets this transform node rotation to the given local axis.
  92507. * @param localAxis the axis in local space
  92508. * @param yawCor optional yaw (y-axis) correction in radians
  92509. * @param pitchCor optional pitch (x-axis) correction in radians
  92510. * @param rollCor optional roll (z-axis) correction in radians
  92511. * @returns this TransformNode
  92512. */
  92513. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  92514. /**
  92515. * Sets a new pivot point to the current node
  92516. * @param point defines the new pivot point to use
  92517. * @param space defines if the point is in world or local space (local by default)
  92518. * @returns the current TransformNode
  92519. */
  92520. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  92521. /**
  92522. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  92523. * @returns the pivot point
  92524. */
  92525. getPivotPoint(): Vector3;
  92526. /**
  92527. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  92528. * @param result the vector3 to store the result
  92529. * @returns this TransformNode.
  92530. */
  92531. getPivotPointToRef(result: Vector3): TransformNode;
  92532. /**
  92533. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  92534. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  92535. */
  92536. getAbsolutePivotPoint(): Vector3;
  92537. /**
  92538. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  92539. * @param result vector3 to store the result
  92540. * @returns this TransformNode.
  92541. */
  92542. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  92543. /**
  92544. * Defines the passed node as the parent of the current node.
  92545. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  92546. * @see https://doc.babylonjs.com/how_to/parenting
  92547. * @param node the node ot set as the parent
  92548. * @returns this TransformNode.
  92549. */
  92550. setParent(node: Nullable<Node>): TransformNode;
  92551. private _nonUniformScaling;
  92552. /**
  92553. * True if the scaling property of this object is non uniform eg. (1,2,1)
  92554. */
  92555. get nonUniformScaling(): boolean;
  92556. /** @hidden */
  92557. _updateNonUniformScalingState(value: boolean): boolean;
  92558. /**
  92559. * Attach the current TransformNode to another TransformNode associated with a bone
  92560. * @param bone Bone affecting the TransformNode
  92561. * @param affectedTransformNode TransformNode associated with the bone
  92562. * @returns this object
  92563. */
  92564. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  92565. /**
  92566. * Detach the transform node if its associated with a bone
  92567. * @returns this object
  92568. */
  92569. detachFromBone(): TransformNode;
  92570. private static _rotationAxisCache;
  92571. /**
  92572. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  92573. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92574. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92575. * The passed axis is also normalized.
  92576. * @param axis the axis to rotate around
  92577. * @param amount the amount to rotate in radians
  92578. * @param space Space to rotate in (Default: local)
  92579. * @returns the TransformNode.
  92580. */
  92581. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  92582. /**
  92583. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  92584. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92585. * The passed axis is also normalized. .
  92586. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  92587. * @param point the point to rotate around
  92588. * @param axis the axis to rotate around
  92589. * @param amount the amount to rotate in radians
  92590. * @returns the TransformNode
  92591. */
  92592. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  92593. /**
  92594. * Translates the mesh along the axis vector for the passed distance in the given space.
  92595. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92596. * @param axis the axis to translate in
  92597. * @param distance the distance to translate
  92598. * @param space Space to rotate in (Default: local)
  92599. * @returns the TransformNode.
  92600. */
  92601. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  92602. /**
  92603. * Adds a rotation step to the mesh current rotation.
  92604. * x, y, z are Euler angles expressed in radians.
  92605. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  92606. * This means this rotation is made in the mesh local space only.
  92607. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  92608. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  92609. * ```javascript
  92610. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  92611. * ```
  92612. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  92613. * 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.
  92614. * @param x Rotation to add
  92615. * @param y Rotation to add
  92616. * @param z Rotation to add
  92617. * @returns the TransformNode.
  92618. */
  92619. addRotation(x: number, y: number, z: number): TransformNode;
  92620. /**
  92621. * @hidden
  92622. */
  92623. protected _getEffectiveParent(): Nullable<Node>;
  92624. /**
  92625. * Computes the world matrix of the node
  92626. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92627. * @returns the world matrix
  92628. */
  92629. computeWorldMatrix(force?: boolean): Matrix;
  92630. /**
  92631. * Resets this nodeTransform's local matrix to Matrix.Identity().
  92632. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  92633. */
  92634. resetLocalMatrix(independentOfChildren?: boolean): void;
  92635. protected _afterComputeWorldMatrix(): void;
  92636. /**
  92637. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  92638. * @param func callback function to add
  92639. *
  92640. * @returns the TransformNode.
  92641. */
  92642. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  92643. /**
  92644. * Removes a registered callback function.
  92645. * @param func callback function to remove
  92646. * @returns the TransformNode.
  92647. */
  92648. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  92649. /**
  92650. * Gets the position of the current mesh in camera space
  92651. * @param camera defines the camera to use
  92652. * @returns a position
  92653. */
  92654. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  92655. /**
  92656. * Returns the distance from the mesh to the active camera
  92657. * @param camera defines the camera to use
  92658. * @returns the distance
  92659. */
  92660. getDistanceToCamera(camera?: Nullable<Camera>): number;
  92661. /**
  92662. * Clone the current transform node
  92663. * @param name Name of the new clone
  92664. * @param newParent New parent for the clone
  92665. * @param doNotCloneChildren Do not clone children hierarchy
  92666. * @returns the new transform node
  92667. */
  92668. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  92669. /**
  92670. * Serializes the objects information.
  92671. * @param currentSerializationObject defines the object to serialize in
  92672. * @returns the serialized object
  92673. */
  92674. serialize(currentSerializationObject?: any): any;
  92675. /**
  92676. * Returns a new TransformNode object parsed from the source provided.
  92677. * @param parsedTransformNode is the source.
  92678. * @param scene the scne the object belongs to
  92679. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  92680. * @returns a new TransformNode object parsed from the source provided.
  92681. */
  92682. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  92683. /**
  92684. * Get all child-transformNodes of this node
  92685. * @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
  92686. * @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
  92687. * @returns an array of TransformNode
  92688. */
  92689. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  92690. /**
  92691. * Releases resources associated with this transform node.
  92692. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92693. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92694. */
  92695. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92696. /**
  92697. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  92698. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  92699. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  92700. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  92701. * @returns the current mesh
  92702. */
  92703. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  92704. private _syncAbsoluteScalingAndRotation;
  92705. }
  92706. }
  92707. declare module BABYLON {
  92708. /**
  92709. * Class used to override all child animations of a given target
  92710. */
  92711. export class AnimationPropertiesOverride {
  92712. /**
  92713. * Gets or sets a value indicating if animation blending must be used
  92714. */
  92715. enableBlending: boolean;
  92716. /**
  92717. * Gets or sets the blending speed to use when enableBlending is true
  92718. */
  92719. blendingSpeed: number;
  92720. /**
  92721. * Gets or sets the default loop mode to use
  92722. */
  92723. loopMode: number;
  92724. }
  92725. }
  92726. declare module BABYLON {
  92727. /**
  92728. * Class used to store bone information
  92729. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92730. */
  92731. export class Bone extends Node {
  92732. /**
  92733. * defines the bone name
  92734. */
  92735. name: string;
  92736. private static _tmpVecs;
  92737. private static _tmpQuat;
  92738. private static _tmpMats;
  92739. /**
  92740. * Gets the list of child bones
  92741. */
  92742. children: Bone[];
  92743. /** Gets the animations associated with this bone */
  92744. animations: Animation[];
  92745. /**
  92746. * Gets or sets bone length
  92747. */
  92748. length: number;
  92749. /**
  92750. * @hidden Internal only
  92751. * Set this value to map this bone to a different index in the transform matrices
  92752. * Set this value to -1 to exclude the bone from the transform matrices
  92753. */
  92754. _index: Nullable<number>;
  92755. private _skeleton;
  92756. private _localMatrix;
  92757. private _restPose;
  92758. private _baseMatrix;
  92759. private _absoluteTransform;
  92760. private _invertedAbsoluteTransform;
  92761. private _parent;
  92762. private _scalingDeterminant;
  92763. private _worldTransform;
  92764. private _localScaling;
  92765. private _localRotation;
  92766. private _localPosition;
  92767. private _needToDecompose;
  92768. private _needToCompose;
  92769. /** @hidden */
  92770. _linkedTransformNode: Nullable<TransformNode>;
  92771. /** @hidden */
  92772. _waitingTransformNodeId: Nullable<string>;
  92773. /** @hidden */
  92774. get _matrix(): Matrix;
  92775. /** @hidden */
  92776. set _matrix(value: Matrix);
  92777. /**
  92778. * Create a new bone
  92779. * @param name defines the bone name
  92780. * @param skeleton defines the parent skeleton
  92781. * @param parentBone defines the parent (can be null if the bone is the root)
  92782. * @param localMatrix defines the local matrix
  92783. * @param restPose defines the rest pose matrix
  92784. * @param baseMatrix defines the base matrix
  92785. * @param index defines index of the bone in the hiearchy
  92786. */
  92787. constructor(
  92788. /**
  92789. * defines the bone name
  92790. */
  92791. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  92792. /**
  92793. * Gets the current object class name.
  92794. * @return the class name
  92795. */
  92796. getClassName(): string;
  92797. /**
  92798. * Gets the parent skeleton
  92799. * @returns a skeleton
  92800. */
  92801. getSkeleton(): Skeleton;
  92802. /**
  92803. * Gets parent bone
  92804. * @returns a bone or null if the bone is the root of the bone hierarchy
  92805. */
  92806. getParent(): Nullable<Bone>;
  92807. /**
  92808. * Returns an array containing the root bones
  92809. * @returns an array containing the root bones
  92810. */
  92811. getChildren(): Array<Bone>;
  92812. /**
  92813. * Gets the node index in matrix array generated for rendering
  92814. * @returns the node index
  92815. */
  92816. getIndex(): number;
  92817. /**
  92818. * Sets the parent bone
  92819. * @param parent defines the parent (can be null if the bone is the root)
  92820. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  92821. */
  92822. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  92823. /**
  92824. * Gets the local matrix
  92825. * @returns a matrix
  92826. */
  92827. getLocalMatrix(): Matrix;
  92828. /**
  92829. * Gets the base matrix (initial matrix which remains unchanged)
  92830. * @returns a matrix
  92831. */
  92832. getBaseMatrix(): Matrix;
  92833. /**
  92834. * Gets the rest pose matrix
  92835. * @returns a matrix
  92836. */
  92837. getRestPose(): Matrix;
  92838. /**
  92839. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  92840. */
  92841. getWorldMatrix(): Matrix;
  92842. /**
  92843. * Sets the local matrix to rest pose matrix
  92844. */
  92845. returnToRest(): void;
  92846. /**
  92847. * Gets the inverse of the absolute transform matrix.
  92848. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  92849. * @returns a matrix
  92850. */
  92851. getInvertedAbsoluteTransform(): Matrix;
  92852. /**
  92853. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  92854. * @returns a matrix
  92855. */
  92856. getAbsoluteTransform(): Matrix;
  92857. /**
  92858. * Links with the given transform node.
  92859. * The local matrix of this bone is copied from the transform node every frame.
  92860. * @param transformNode defines the transform node to link to
  92861. */
  92862. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  92863. /**
  92864. * Gets the node used to drive the bone's transformation
  92865. * @returns a transform node or null
  92866. */
  92867. getTransformNode(): Nullable<TransformNode>;
  92868. /** Gets or sets current position (in local space) */
  92869. get position(): Vector3;
  92870. set position(newPosition: Vector3);
  92871. /** Gets or sets current rotation (in local space) */
  92872. get rotation(): Vector3;
  92873. set rotation(newRotation: Vector3);
  92874. /** Gets or sets current rotation quaternion (in local space) */
  92875. get rotationQuaternion(): Quaternion;
  92876. set rotationQuaternion(newRotation: Quaternion);
  92877. /** Gets or sets current scaling (in local space) */
  92878. get scaling(): Vector3;
  92879. set scaling(newScaling: Vector3);
  92880. /**
  92881. * Gets the animation properties override
  92882. */
  92883. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  92884. private _decompose;
  92885. private _compose;
  92886. /**
  92887. * Update the base and local matrices
  92888. * @param matrix defines the new base or local matrix
  92889. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  92890. * @param updateLocalMatrix defines if the local matrix should be updated
  92891. */
  92892. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  92893. /** @hidden */
  92894. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  92895. /**
  92896. * Flag the bone as dirty (Forcing it to update everything)
  92897. */
  92898. markAsDirty(): void;
  92899. /** @hidden */
  92900. _markAsDirtyAndCompose(): void;
  92901. private _markAsDirtyAndDecompose;
  92902. /**
  92903. * Translate the bone in local or world space
  92904. * @param vec The amount to translate the bone
  92905. * @param space The space that the translation is in
  92906. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92907. */
  92908. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92909. /**
  92910. * Set the postion of the bone in local or world space
  92911. * @param position The position to set the bone
  92912. * @param space The space that the position is in
  92913. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92914. */
  92915. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92916. /**
  92917. * Set the absolute position of the bone (world space)
  92918. * @param position The position to set the bone
  92919. * @param mesh The mesh that this bone is attached to
  92920. */
  92921. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  92922. /**
  92923. * Scale the bone on the x, y and z axes (in local space)
  92924. * @param x The amount to scale the bone on the x axis
  92925. * @param y The amount to scale the bone on the y axis
  92926. * @param z The amount to scale the bone on the z axis
  92927. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  92928. */
  92929. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  92930. /**
  92931. * Set the bone scaling in local space
  92932. * @param scale defines the scaling vector
  92933. */
  92934. setScale(scale: Vector3): void;
  92935. /**
  92936. * Gets the current scaling in local space
  92937. * @returns the current scaling vector
  92938. */
  92939. getScale(): Vector3;
  92940. /**
  92941. * Gets the current scaling in local space and stores it in a target vector
  92942. * @param result defines the target vector
  92943. */
  92944. getScaleToRef(result: Vector3): void;
  92945. /**
  92946. * Set the yaw, pitch, and roll of the bone in local or world space
  92947. * @param yaw The rotation of the bone on the y axis
  92948. * @param pitch The rotation of the bone on the x axis
  92949. * @param roll The rotation of the bone on the z axis
  92950. * @param space The space that the axes of rotation are in
  92951. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92952. */
  92953. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  92954. /**
  92955. * Add a rotation to the bone on an axis in local or world space
  92956. * @param axis The axis to rotate the bone on
  92957. * @param amount The amount to rotate the bone
  92958. * @param space The space that the axis is in
  92959. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92960. */
  92961. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  92962. /**
  92963. * Set the rotation of the bone to a particular axis angle in local or world space
  92964. * @param axis The axis to rotate the bone on
  92965. * @param angle The angle that the bone should be rotated to
  92966. * @param space The space that the axis is in
  92967. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92968. */
  92969. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  92970. /**
  92971. * Set the euler rotation of the bone in local of world space
  92972. * @param rotation The euler rotation that the bone should be set to
  92973. * @param space The space that the rotation is in
  92974. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92975. */
  92976. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92977. /**
  92978. * Set the quaternion rotation of the bone in local of world space
  92979. * @param quat The quaternion rotation that the bone should be set to
  92980. * @param space The space that the rotation is in
  92981. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92982. */
  92983. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  92984. /**
  92985. * Set the rotation matrix of the bone in local of world space
  92986. * @param rotMat The rotation matrix that the bone should be set to
  92987. * @param space The space that the rotation is in
  92988. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92989. */
  92990. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  92991. private _rotateWithMatrix;
  92992. private _getNegativeRotationToRef;
  92993. /**
  92994. * Get the position of the bone in local or world space
  92995. * @param space The space that the returned position is in
  92996. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92997. * @returns The position of the bone
  92998. */
  92999. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93000. /**
  93001. * Copy the position of the bone to a vector3 in local or world space
  93002. * @param space The space that the returned position is in
  93003. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93004. * @param result The vector3 to copy the position to
  93005. */
  93006. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  93007. /**
  93008. * Get the absolute position of the bone (world space)
  93009. * @param mesh The mesh that this bone is attached to
  93010. * @returns The absolute position of the bone
  93011. */
  93012. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  93013. /**
  93014. * Copy the absolute position of the bone (world space) to the result param
  93015. * @param mesh The mesh that this bone is attached to
  93016. * @param result The vector3 to copy the absolute position to
  93017. */
  93018. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  93019. /**
  93020. * Compute the absolute transforms of this bone and its children
  93021. */
  93022. computeAbsoluteTransforms(): void;
  93023. /**
  93024. * Get the world direction from an axis that is in the local space of the bone
  93025. * @param localAxis The local direction that is used to compute the world direction
  93026. * @param mesh The mesh that this bone is attached to
  93027. * @returns The world direction
  93028. */
  93029. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93030. /**
  93031. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  93032. * @param localAxis The local direction that is used to compute the world direction
  93033. * @param mesh The mesh that this bone is attached to
  93034. * @param result The vector3 that the world direction will be copied to
  93035. */
  93036. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93037. /**
  93038. * Get the euler rotation of the bone in local or world space
  93039. * @param space The space that the rotation should be in
  93040. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93041. * @returns The euler rotation
  93042. */
  93043. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93044. /**
  93045. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  93046. * @param space The space that the rotation should be in
  93047. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93048. * @param result The vector3 that the rotation should be copied to
  93049. */
  93050. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93051. /**
  93052. * Get the quaternion rotation of the bone in either local or world space
  93053. * @param space The space that the rotation should be in
  93054. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93055. * @returns The quaternion rotation
  93056. */
  93057. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  93058. /**
  93059. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  93060. * @param space The space that the rotation should be in
  93061. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93062. * @param result The quaternion that the rotation should be copied to
  93063. */
  93064. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  93065. /**
  93066. * Get the rotation matrix of the bone in local or world space
  93067. * @param space The space that the rotation should be in
  93068. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93069. * @returns The rotation matrix
  93070. */
  93071. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  93072. /**
  93073. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  93074. * @param space The space that the rotation should be in
  93075. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93076. * @param result The quaternion that the rotation should be copied to
  93077. */
  93078. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  93079. /**
  93080. * Get the world position of a point that is in the local space of the bone
  93081. * @param position The local position
  93082. * @param mesh The mesh that this bone is attached to
  93083. * @returns The world position
  93084. */
  93085. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93086. /**
  93087. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  93088. * @param position The local position
  93089. * @param mesh The mesh that this bone is attached to
  93090. * @param result The vector3 that the world position should be copied to
  93091. */
  93092. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93093. /**
  93094. * Get the local position of a point that is in world space
  93095. * @param position The world position
  93096. * @param mesh The mesh that this bone is attached to
  93097. * @returns The local position
  93098. */
  93099. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93100. /**
  93101. * Get the local position of a point that is in world space and copy it to the result param
  93102. * @param position The world position
  93103. * @param mesh The mesh that this bone is attached to
  93104. * @param result The vector3 that the local position should be copied to
  93105. */
  93106. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93107. }
  93108. }
  93109. declare module BABYLON {
  93110. /**
  93111. * Defines a runtime animation
  93112. */
  93113. export class RuntimeAnimation {
  93114. private _events;
  93115. /**
  93116. * The current frame of the runtime animation
  93117. */
  93118. private _currentFrame;
  93119. /**
  93120. * The animation used by the runtime animation
  93121. */
  93122. private _animation;
  93123. /**
  93124. * The target of the runtime animation
  93125. */
  93126. private _target;
  93127. /**
  93128. * The initiating animatable
  93129. */
  93130. private _host;
  93131. /**
  93132. * The original value of the runtime animation
  93133. */
  93134. private _originalValue;
  93135. /**
  93136. * The original blend value of the runtime animation
  93137. */
  93138. private _originalBlendValue;
  93139. /**
  93140. * The offsets cache of the runtime animation
  93141. */
  93142. private _offsetsCache;
  93143. /**
  93144. * The high limits cache of the runtime animation
  93145. */
  93146. private _highLimitsCache;
  93147. /**
  93148. * Specifies if the runtime animation has been stopped
  93149. */
  93150. private _stopped;
  93151. /**
  93152. * The blending factor of the runtime animation
  93153. */
  93154. private _blendingFactor;
  93155. /**
  93156. * The BabylonJS scene
  93157. */
  93158. private _scene;
  93159. /**
  93160. * The current value of the runtime animation
  93161. */
  93162. private _currentValue;
  93163. /** @hidden */
  93164. _animationState: _IAnimationState;
  93165. /**
  93166. * The active target of the runtime animation
  93167. */
  93168. private _activeTargets;
  93169. private _currentActiveTarget;
  93170. private _directTarget;
  93171. /**
  93172. * The target path of the runtime animation
  93173. */
  93174. private _targetPath;
  93175. /**
  93176. * The weight of the runtime animation
  93177. */
  93178. private _weight;
  93179. /**
  93180. * The ratio offset of the runtime animation
  93181. */
  93182. private _ratioOffset;
  93183. /**
  93184. * The previous delay of the runtime animation
  93185. */
  93186. private _previousDelay;
  93187. /**
  93188. * The previous ratio of the runtime animation
  93189. */
  93190. private _previousRatio;
  93191. private _enableBlending;
  93192. private _keys;
  93193. private _minFrame;
  93194. private _maxFrame;
  93195. private _minValue;
  93196. private _maxValue;
  93197. private _targetIsArray;
  93198. /**
  93199. * Gets the current frame of the runtime animation
  93200. */
  93201. get currentFrame(): number;
  93202. /**
  93203. * Gets the weight of the runtime animation
  93204. */
  93205. get weight(): number;
  93206. /**
  93207. * Gets the current value of the runtime animation
  93208. */
  93209. get currentValue(): any;
  93210. /**
  93211. * Gets the target path of the runtime animation
  93212. */
  93213. get targetPath(): string;
  93214. /**
  93215. * Gets the actual target of the runtime animation
  93216. */
  93217. get target(): any;
  93218. /**
  93219. * Gets the additive state of the runtime animation
  93220. */
  93221. get isAdditive(): boolean;
  93222. /** @hidden */
  93223. _onLoop: () => void;
  93224. /**
  93225. * Create a new RuntimeAnimation object
  93226. * @param target defines the target of the animation
  93227. * @param animation defines the source animation object
  93228. * @param scene defines the hosting scene
  93229. * @param host defines the initiating Animatable
  93230. */
  93231. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  93232. private _preparePath;
  93233. /**
  93234. * Gets the animation from the runtime animation
  93235. */
  93236. get animation(): Animation;
  93237. /**
  93238. * Resets the runtime animation to the beginning
  93239. * @param restoreOriginal defines whether to restore the target property to the original value
  93240. */
  93241. reset(restoreOriginal?: boolean): void;
  93242. /**
  93243. * Specifies if the runtime animation is stopped
  93244. * @returns Boolean specifying if the runtime animation is stopped
  93245. */
  93246. isStopped(): boolean;
  93247. /**
  93248. * Disposes of the runtime animation
  93249. */
  93250. dispose(): void;
  93251. /**
  93252. * Apply the interpolated value to the target
  93253. * @param currentValue defines the value computed by the animation
  93254. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  93255. */
  93256. setValue(currentValue: any, weight: number): void;
  93257. private _getOriginalValues;
  93258. private _setValue;
  93259. /**
  93260. * Gets the loop pmode of the runtime animation
  93261. * @returns Loop Mode
  93262. */
  93263. private _getCorrectLoopMode;
  93264. /**
  93265. * Move the current animation to a given frame
  93266. * @param frame defines the frame to move to
  93267. */
  93268. goToFrame(frame: number): void;
  93269. /**
  93270. * @hidden Internal use only
  93271. */
  93272. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  93273. /**
  93274. * Execute the current animation
  93275. * @param delay defines the delay to add to the current frame
  93276. * @param from defines the lower bound of the animation range
  93277. * @param to defines the upper bound of the animation range
  93278. * @param loop defines if the current animation must loop
  93279. * @param speedRatio defines the current speed ratio
  93280. * @param weight defines the weight of the animation (default is -1 so no weight)
  93281. * @param onLoop optional callback called when animation loops
  93282. * @returns a boolean indicating if the animation is running
  93283. */
  93284. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  93285. }
  93286. }
  93287. declare module BABYLON {
  93288. /**
  93289. * Class used to store an actual running animation
  93290. */
  93291. export class Animatable {
  93292. /** defines the target object */
  93293. target: any;
  93294. /** defines the starting frame number (default is 0) */
  93295. fromFrame: number;
  93296. /** defines the ending frame number (default is 100) */
  93297. toFrame: number;
  93298. /** defines if the animation must loop (default is false) */
  93299. loopAnimation: boolean;
  93300. /** defines a callback to call when animation ends if it is not looping */
  93301. onAnimationEnd?: (() => void) | null | undefined;
  93302. /** defines a callback to call when animation loops */
  93303. onAnimationLoop?: (() => void) | null | undefined;
  93304. /** defines whether the animation should be evaluated additively */
  93305. isAdditive: boolean;
  93306. private _localDelayOffset;
  93307. private _pausedDelay;
  93308. private _runtimeAnimations;
  93309. private _paused;
  93310. private _scene;
  93311. private _speedRatio;
  93312. private _weight;
  93313. private _syncRoot;
  93314. /**
  93315. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  93316. * This will only apply for non looping animation (default is true)
  93317. */
  93318. disposeOnEnd: boolean;
  93319. /**
  93320. * Gets a boolean indicating if the animation has started
  93321. */
  93322. animationStarted: boolean;
  93323. /**
  93324. * Observer raised when the animation ends
  93325. */
  93326. onAnimationEndObservable: Observable<Animatable>;
  93327. /**
  93328. * Observer raised when the animation loops
  93329. */
  93330. onAnimationLoopObservable: Observable<Animatable>;
  93331. /**
  93332. * Gets the root Animatable used to synchronize and normalize animations
  93333. */
  93334. get syncRoot(): Nullable<Animatable>;
  93335. /**
  93336. * Gets the current frame of the first RuntimeAnimation
  93337. * Used to synchronize Animatables
  93338. */
  93339. get masterFrame(): number;
  93340. /**
  93341. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  93342. */
  93343. get weight(): number;
  93344. set weight(value: number);
  93345. /**
  93346. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  93347. */
  93348. get speedRatio(): number;
  93349. set speedRatio(value: number);
  93350. /**
  93351. * Creates a new Animatable
  93352. * @param scene defines the hosting scene
  93353. * @param target defines the target object
  93354. * @param fromFrame defines the starting frame number (default is 0)
  93355. * @param toFrame defines the ending frame number (default is 100)
  93356. * @param loopAnimation defines if the animation must loop (default is false)
  93357. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  93358. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  93359. * @param animations defines a group of animation to add to the new Animatable
  93360. * @param onAnimationLoop defines a callback to call when animation loops
  93361. * @param isAdditive defines whether the animation should be evaluated additively
  93362. */
  93363. constructor(scene: Scene,
  93364. /** defines the target object */
  93365. target: any,
  93366. /** defines the starting frame number (default is 0) */
  93367. fromFrame?: number,
  93368. /** defines the ending frame number (default is 100) */
  93369. toFrame?: number,
  93370. /** defines if the animation must loop (default is false) */
  93371. loopAnimation?: boolean, speedRatio?: number,
  93372. /** defines a callback to call when animation ends if it is not looping */
  93373. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  93374. /** defines a callback to call when animation loops */
  93375. onAnimationLoop?: (() => void) | null | undefined,
  93376. /** defines whether the animation should be evaluated additively */
  93377. isAdditive?: boolean);
  93378. /**
  93379. * Synchronize and normalize current Animatable with a source Animatable
  93380. * This is useful when using animation weights and when animations are not of the same length
  93381. * @param root defines the root Animatable to synchronize with
  93382. * @returns the current Animatable
  93383. */
  93384. syncWith(root: Animatable): Animatable;
  93385. /**
  93386. * Gets the list of runtime animations
  93387. * @returns an array of RuntimeAnimation
  93388. */
  93389. getAnimations(): RuntimeAnimation[];
  93390. /**
  93391. * Adds more animations to the current animatable
  93392. * @param target defines the target of the animations
  93393. * @param animations defines the new animations to add
  93394. */
  93395. appendAnimations(target: any, animations: Animation[]): void;
  93396. /**
  93397. * Gets the source animation for a specific property
  93398. * @param property defines the propertyu to look for
  93399. * @returns null or the source animation for the given property
  93400. */
  93401. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  93402. /**
  93403. * Gets the runtime animation for a specific property
  93404. * @param property defines the propertyu to look for
  93405. * @returns null or the runtime animation for the given property
  93406. */
  93407. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  93408. /**
  93409. * Resets the animatable to its original state
  93410. */
  93411. reset(): void;
  93412. /**
  93413. * Allows the animatable to blend with current running animations
  93414. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  93415. * @param blendingSpeed defines the blending speed to use
  93416. */
  93417. enableBlending(blendingSpeed: number): void;
  93418. /**
  93419. * Disable animation blending
  93420. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  93421. */
  93422. disableBlending(): void;
  93423. /**
  93424. * Jump directly to a given frame
  93425. * @param frame defines the frame to jump to
  93426. */
  93427. goToFrame(frame: number): void;
  93428. /**
  93429. * Pause the animation
  93430. */
  93431. pause(): void;
  93432. /**
  93433. * Restart the animation
  93434. */
  93435. restart(): void;
  93436. private _raiseOnAnimationEnd;
  93437. /**
  93438. * Stop and delete the current animation
  93439. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  93440. * @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)
  93441. */
  93442. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  93443. /**
  93444. * Wait asynchronously for the animation to end
  93445. * @returns a promise which will be fullfilled when the animation ends
  93446. */
  93447. waitAsync(): Promise<Animatable>;
  93448. /** @hidden */
  93449. _animate(delay: number): boolean;
  93450. }
  93451. interface Scene {
  93452. /** @hidden */
  93453. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  93454. /** @hidden */
  93455. _processLateAnimationBindingsForMatrices(holder: {
  93456. totalWeight: number;
  93457. totalAdditiveWeight: number;
  93458. animations: RuntimeAnimation[];
  93459. additiveAnimations: RuntimeAnimation[];
  93460. originalValue: Matrix;
  93461. }): any;
  93462. /** @hidden */
  93463. _processLateAnimationBindingsForQuaternions(holder: {
  93464. totalWeight: number;
  93465. totalAdditiveWeight: number;
  93466. animations: RuntimeAnimation[];
  93467. additiveAnimations: RuntimeAnimation[];
  93468. originalValue: Quaternion;
  93469. }, refQuaternion: Quaternion): Quaternion;
  93470. /** @hidden */
  93471. _processLateAnimationBindings(): void;
  93472. /**
  93473. * Will start the animation sequence of a given target
  93474. * @param target defines the target
  93475. * @param from defines from which frame should animation start
  93476. * @param to defines until which frame should animation run.
  93477. * @param weight defines the weight to apply to the animation (1.0 by default)
  93478. * @param loop defines if the animation loops
  93479. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93480. * @param onAnimationEnd defines the function to be executed when the animation ends
  93481. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93482. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  93483. * @param onAnimationLoop defines the callback to call when an animation loops
  93484. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93485. * @returns the animatable object created for this animation
  93486. */
  93487. 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;
  93488. /**
  93489. * Will start the animation sequence of a given target
  93490. * @param target defines the target
  93491. * @param from defines from which frame should animation start
  93492. * @param to defines until which frame should animation run.
  93493. * @param loop defines if the animation loops
  93494. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93495. * @param onAnimationEnd defines the function to be executed when the animation ends
  93496. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93497. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  93498. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  93499. * @param onAnimationLoop defines the callback to call when an animation loops
  93500. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93501. * @returns the animatable object created for this animation
  93502. */
  93503. 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;
  93504. /**
  93505. * Will start the animation sequence of a given target and its hierarchy
  93506. * @param target defines the target
  93507. * @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.
  93508. * @param from defines from which frame should animation start
  93509. * @param to defines until which frame should animation run.
  93510. * @param loop defines if the animation loops
  93511. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93512. * @param onAnimationEnd defines the function to be executed when the animation ends
  93513. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93514. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  93515. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  93516. * @param onAnimationLoop defines the callback to call when an animation loops
  93517. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93518. * @returns the list of created animatables
  93519. */
  93520. 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[];
  93521. /**
  93522. * Begin a new animation on a given node
  93523. * @param target defines the target where the animation will take place
  93524. * @param animations defines the list of animations to start
  93525. * @param from defines the initial value
  93526. * @param to defines the final value
  93527. * @param loop defines if you want animation to loop (off by default)
  93528. * @param speedRatio defines the speed ratio to apply to all animations
  93529. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93530. * @param onAnimationLoop defines the callback to call when an animation loops
  93531. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93532. * @returns the list of created animatables
  93533. */
  93534. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  93535. /**
  93536. * Begin a new animation on a given node and its hierarchy
  93537. * @param target defines the root node where the animation will take place
  93538. * @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.
  93539. * @param animations defines the list of animations to start
  93540. * @param from defines the initial value
  93541. * @param to defines the final value
  93542. * @param loop defines if you want animation to loop (off by default)
  93543. * @param speedRatio defines the speed ratio to apply to all animations
  93544. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93545. * @param onAnimationLoop defines the callback to call when an animation loops
  93546. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93547. * @returns the list of animatables created for all nodes
  93548. */
  93549. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  93550. /**
  93551. * Gets the animatable associated with a specific target
  93552. * @param target defines the target of the animatable
  93553. * @returns the required animatable if found
  93554. */
  93555. getAnimatableByTarget(target: any): Nullable<Animatable>;
  93556. /**
  93557. * Gets all animatables associated with a given target
  93558. * @param target defines the target to look animatables for
  93559. * @returns an array of Animatables
  93560. */
  93561. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  93562. /**
  93563. * Stops and removes all animations that have been applied to the scene
  93564. */
  93565. stopAllAnimations(): void;
  93566. /**
  93567. * Gets the current delta time used by animation engine
  93568. */
  93569. deltaTime: number;
  93570. }
  93571. interface Bone {
  93572. /**
  93573. * Copy an animation range from another bone
  93574. * @param source defines the source bone
  93575. * @param rangeName defines the range name to copy
  93576. * @param frameOffset defines the frame offset
  93577. * @param rescaleAsRequired defines if rescaling must be applied if required
  93578. * @param skelDimensionsRatio defines the scaling ratio
  93579. * @returns true if operation was successful
  93580. */
  93581. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  93582. }
  93583. }
  93584. declare module BABYLON {
  93585. /**
  93586. * Class used to handle skinning animations
  93587. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93588. */
  93589. export class Skeleton implements IAnimatable {
  93590. /** defines the skeleton name */
  93591. name: string;
  93592. /** defines the skeleton Id */
  93593. id: string;
  93594. /**
  93595. * Defines the list of child bones
  93596. */
  93597. bones: Bone[];
  93598. /**
  93599. * Defines an estimate of the dimension of the skeleton at rest
  93600. */
  93601. dimensionsAtRest: Vector3;
  93602. /**
  93603. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  93604. */
  93605. needInitialSkinMatrix: boolean;
  93606. /**
  93607. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  93608. */
  93609. overrideMesh: Nullable<AbstractMesh>;
  93610. /**
  93611. * Gets the list of animations attached to this skeleton
  93612. */
  93613. animations: Array<Animation>;
  93614. private _scene;
  93615. private _isDirty;
  93616. private _transformMatrices;
  93617. private _transformMatrixTexture;
  93618. private _meshesWithPoseMatrix;
  93619. private _animatables;
  93620. private _identity;
  93621. private _synchronizedWithMesh;
  93622. private _ranges;
  93623. private _lastAbsoluteTransformsUpdateId;
  93624. private _canUseTextureForBones;
  93625. private _uniqueId;
  93626. /** @hidden */
  93627. _numBonesWithLinkedTransformNode: number;
  93628. /** @hidden */
  93629. _hasWaitingData: Nullable<boolean>;
  93630. /**
  93631. * Specifies if the skeleton should be serialized
  93632. */
  93633. doNotSerialize: boolean;
  93634. private _useTextureToStoreBoneMatrices;
  93635. /**
  93636. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  93637. * Please note that this option is not available if the hardware does not support it
  93638. */
  93639. get useTextureToStoreBoneMatrices(): boolean;
  93640. set useTextureToStoreBoneMatrices(value: boolean);
  93641. private _animationPropertiesOverride;
  93642. /**
  93643. * Gets or sets the animation properties override
  93644. */
  93645. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93646. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  93647. /**
  93648. * List of inspectable custom properties (used by the Inspector)
  93649. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93650. */
  93651. inspectableCustomProperties: IInspectable[];
  93652. /**
  93653. * An observable triggered before computing the skeleton's matrices
  93654. */
  93655. onBeforeComputeObservable: Observable<Skeleton>;
  93656. /**
  93657. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  93658. */
  93659. get isUsingTextureForMatrices(): boolean;
  93660. /**
  93661. * Gets the unique ID of this skeleton
  93662. */
  93663. get uniqueId(): number;
  93664. /**
  93665. * Creates a new skeleton
  93666. * @param name defines the skeleton name
  93667. * @param id defines the skeleton Id
  93668. * @param scene defines the hosting scene
  93669. */
  93670. constructor(
  93671. /** defines the skeleton name */
  93672. name: string,
  93673. /** defines the skeleton Id */
  93674. id: string, scene: Scene);
  93675. /**
  93676. * Gets the current object class name.
  93677. * @return the class name
  93678. */
  93679. getClassName(): string;
  93680. /**
  93681. * Returns an array containing the root bones
  93682. * @returns an array containing the root bones
  93683. */
  93684. getChildren(): Array<Bone>;
  93685. /**
  93686. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  93687. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  93688. * @returns a Float32Array containing matrices data
  93689. */
  93690. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  93691. /**
  93692. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  93693. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  93694. * @returns a raw texture containing the data
  93695. */
  93696. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  93697. /**
  93698. * Gets the current hosting scene
  93699. * @returns a scene object
  93700. */
  93701. getScene(): Scene;
  93702. /**
  93703. * Gets a string representing the current skeleton data
  93704. * @param fullDetails defines a boolean indicating if we want a verbose version
  93705. * @returns a string representing the current skeleton data
  93706. */
  93707. toString(fullDetails?: boolean): string;
  93708. /**
  93709. * Get bone's index searching by name
  93710. * @param name defines bone's name to search for
  93711. * @return the indice of the bone. Returns -1 if not found
  93712. */
  93713. getBoneIndexByName(name: string): number;
  93714. /**
  93715. * Creater a new animation range
  93716. * @param name defines the name of the range
  93717. * @param from defines the start key
  93718. * @param to defines the end key
  93719. */
  93720. createAnimationRange(name: string, from: number, to: number): void;
  93721. /**
  93722. * Delete a specific animation range
  93723. * @param name defines the name of the range
  93724. * @param deleteFrames defines if frames must be removed as well
  93725. */
  93726. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93727. /**
  93728. * Gets a specific animation range
  93729. * @param name defines the name of the range to look for
  93730. * @returns the requested animation range or null if not found
  93731. */
  93732. getAnimationRange(name: string): Nullable<AnimationRange>;
  93733. /**
  93734. * Gets the list of all animation ranges defined on this skeleton
  93735. * @returns an array
  93736. */
  93737. getAnimationRanges(): Nullable<AnimationRange>[];
  93738. /**
  93739. * Copy animation range from a source skeleton.
  93740. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  93741. * @param source defines the source skeleton
  93742. * @param name defines the name of the range to copy
  93743. * @param rescaleAsRequired defines if rescaling must be applied if required
  93744. * @returns true if operation was successful
  93745. */
  93746. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  93747. /**
  93748. * Forces the skeleton to go to rest pose
  93749. */
  93750. returnToRest(): void;
  93751. private _getHighestAnimationFrame;
  93752. /**
  93753. * Begin a specific animation range
  93754. * @param name defines the name of the range to start
  93755. * @param loop defines if looping must be turned on (false by default)
  93756. * @param speedRatio defines the speed ratio to apply (1 by default)
  93757. * @param onAnimationEnd defines a callback which will be called when animation will end
  93758. * @returns a new animatable
  93759. */
  93760. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93761. /**
  93762. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  93763. * @param skeleton defines the Skeleton containing the animation range to convert
  93764. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  93765. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  93766. * @returns the original skeleton
  93767. */
  93768. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  93769. /** @hidden */
  93770. _markAsDirty(): void;
  93771. /** @hidden */
  93772. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  93773. /** @hidden */
  93774. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  93775. private _computeTransformMatrices;
  93776. /**
  93777. * Build all resources required to render a skeleton
  93778. */
  93779. prepare(): void;
  93780. /**
  93781. * Gets the list of animatables currently running for this skeleton
  93782. * @returns an array of animatables
  93783. */
  93784. getAnimatables(): IAnimatable[];
  93785. /**
  93786. * Clone the current skeleton
  93787. * @param name defines the name of the new skeleton
  93788. * @param id defines the id of the new skeleton
  93789. * @returns the new skeleton
  93790. */
  93791. clone(name: string, id?: string): Skeleton;
  93792. /**
  93793. * Enable animation blending for this skeleton
  93794. * @param blendingSpeed defines the blending speed to apply
  93795. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  93796. */
  93797. enableBlending(blendingSpeed?: number): void;
  93798. /**
  93799. * Releases all resources associated with the current skeleton
  93800. */
  93801. dispose(): void;
  93802. /**
  93803. * Serialize the skeleton in a JSON object
  93804. * @returns a JSON object
  93805. */
  93806. serialize(): any;
  93807. /**
  93808. * Creates a new skeleton from serialized data
  93809. * @param parsedSkeleton defines the serialized data
  93810. * @param scene defines the hosting scene
  93811. * @returns a new skeleton
  93812. */
  93813. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  93814. /**
  93815. * Compute all node absolute transforms
  93816. * @param forceUpdate defines if computation must be done even if cache is up to date
  93817. */
  93818. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  93819. /**
  93820. * Gets the root pose matrix
  93821. * @returns a matrix
  93822. */
  93823. getPoseMatrix(): Nullable<Matrix>;
  93824. /**
  93825. * Sorts bones per internal index
  93826. */
  93827. sortBones(): void;
  93828. private _sortBones;
  93829. }
  93830. }
  93831. declare module BABYLON {
  93832. /**
  93833. * Creates an instance based on a source mesh.
  93834. */
  93835. export class InstancedMesh extends AbstractMesh {
  93836. private _sourceMesh;
  93837. private _currentLOD;
  93838. /** @hidden */
  93839. _indexInSourceMeshInstanceArray: number;
  93840. constructor(name: string, source: Mesh);
  93841. /**
  93842. * Returns the string "InstancedMesh".
  93843. */
  93844. getClassName(): string;
  93845. /** Gets the list of lights affecting that mesh */
  93846. get lightSources(): Light[];
  93847. _resyncLightSources(): void;
  93848. _resyncLightSource(light: Light): void;
  93849. _removeLightSource(light: Light, dispose: boolean): void;
  93850. /**
  93851. * If the source mesh receives shadows
  93852. */
  93853. get receiveShadows(): boolean;
  93854. /**
  93855. * The material of the source mesh
  93856. */
  93857. get material(): Nullable<Material>;
  93858. /**
  93859. * Visibility of the source mesh
  93860. */
  93861. get visibility(): number;
  93862. /**
  93863. * Skeleton of the source mesh
  93864. */
  93865. get skeleton(): Nullable<Skeleton>;
  93866. /**
  93867. * Rendering ground id of the source mesh
  93868. */
  93869. get renderingGroupId(): number;
  93870. set renderingGroupId(value: number);
  93871. /**
  93872. * Returns the total number of vertices (integer).
  93873. */
  93874. getTotalVertices(): number;
  93875. /**
  93876. * Returns a positive integer : the total number of indices in this mesh geometry.
  93877. * @returns the numner of indices or zero if the mesh has no geometry.
  93878. */
  93879. getTotalIndices(): number;
  93880. /**
  93881. * The source mesh of the instance
  93882. */
  93883. get sourceMesh(): Mesh;
  93884. /**
  93885. * Creates a new InstancedMesh object from the mesh model.
  93886. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93887. * @param name defines the name of the new instance
  93888. * @returns a new InstancedMesh
  93889. */
  93890. createInstance(name: string): InstancedMesh;
  93891. /**
  93892. * Is this node ready to be used/rendered
  93893. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93894. * @return {boolean} is it ready
  93895. */
  93896. isReady(completeCheck?: boolean): boolean;
  93897. /**
  93898. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  93899. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  93900. * @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.
  93901. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  93902. */
  93903. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  93904. /**
  93905. * Sets the vertex data of the mesh geometry for the requested `kind`.
  93906. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  93907. * The `data` are either a numeric array either a Float32Array.
  93908. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  93909. * 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).
  93910. * Note that a new underlying VertexBuffer object is created each call.
  93911. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  93912. *
  93913. * Possible `kind` values :
  93914. * - VertexBuffer.PositionKind
  93915. * - VertexBuffer.UVKind
  93916. * - VertexBuffer.UV2Kind
  93917. * - VertexBuffer.UV3Kind
  93918. * - VertexBuffer.UV4Kind
  93919. * - VertexBuffer.UV5Kind
  93920. * - VertexBuffer.UV6Kind
  93921. * - VertexBuffer.ColorKind
  93922. * - VertexBuffer.MatricesIndicesKind
  93923. * - VertexBuffer.MatricesIndicesExtraKind
  93924. * - VertexBuffer.MatricesWeightsKind
  93925. * - VertexBuffer.MatricesWeightsExtraKind
  93926. *
  93927. * Returns the Mesh.
  93928. */
  93929. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93930. /**
  93931. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  93932. * If the mesh has no geometry, it is simply returned as it is.
  93933. * The `data` are either a numeric array either a Float32Array.
  93934. * No new underlying VertexBuffer object is created.
  93935. * 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.
  93936. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  93937. *
  93938. * Possible `kind` values :
  93939. * - VertexBuffer.PositionKind
  93940. * - VertexBuffer.UVKind
  93941. * - VertexBuffer.UV2Kind
  93942. * - VertexBuffer.UV3Kind
  93943. * - VertexBuffer.UV4Kind
  93944. * - VertexBuffer.UV5Kind
  93945. * - VertexBuffer.UV6Kind
  93946. * - VertexBuffer.ColorKind
  93947. * - VertexBuffer.MatricesIndicesKind
  93948. * - VertexBuffer.MatricesIndicesExtraKind
  93949. * - VertexBuffer.MatricesWeightsKind
  93950. * - VertexBuffer.MatricesWeightsExtraKind
  93951. *
  93952. * Returns the Mesh.
  93953. */
  93954. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  93955. /**
  93956. * Sets the mesh indices.
  93957. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  93958. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  93959. * This method creates a new index buffer each call.
  93960. * Returns the Mesh.
  93961. */
  93962. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  93963. /**
  93964. * Boolean : True if the mesh owns the requested kind of data.
  93965. */
  93966. isVerticesDataPresent(kind: string): boolean;
  93967. /**
  93968. * Returns an array of indices (IndicesArray).
  93969. */
  93970. getIndices(): Nullable<IndicesArray>;
  93971. get _positions(): Nullable<Vector3[]>;
  93972. /**
  93973. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93974. * This means the mesh underlying bounding box and sphere are recomputed.
  93975. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93976. * @returns the current mesh
  93977. */
  93978. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  93979. /** @hidden */
  93980. _preActivate(): InstancedMesh;
  93981. /** @hidden */
  93982. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93983. /** @hidden */
  93984. _postActivate(): void;
  93985. getWorldMatrix(): Matrix;
  93986. get isAnInstance(): boolean;
  93987. /**
  93988. * Returns the current associated LOD AbstractMesh.
  93989. */
  93990. getLOD(camera: Camera): AbstractMesh;
  93991. /** @hidden */
  93992. _preActivateForIntermediateRendering(renderId: number): Mesh;
  93993. /** @hidden */
  93994. _syncSubMeshes(): InstancedMesh;
  93995. /** @hidden */
  93996. _generatePointsArray(): boolean;
  93997. /**
  93998. * Creates a new InstancedMesh from the current mesh.
  93999. * - name (string) : the cloned mesh name
  94000. * - newParent (optional Node) : the optional Node to parent the clone to.
  94001. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  94002. *
  94003. * Returns the clone.
  94004. */
  94005. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  94006. /**
  94007. * Disposes the InstancedMesh.
  94008. * Returns nothing.
  94009. */
  94010. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94011. }
  94012. interface Mesh {
  94013. /**
  94014. * Register a custom buffer that will be instanced
  94015. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94016. * @param kind defines the buffer kind
  94017. * @param stride defines the stride in floats
  94018. */
  94019. registerInstancedBuffer(kind: string, stride: number): void;
  94020. /**
  94021. * true to use the edge renderer for all instances of this mesh
  94022. */
  94023. edgesShareWithInstances: boolean;
  94024. /** @hidden */
  94025. _userInstancedBuffersStorage: {
  94026. data: {
  94027. [key: string]: Float32Array;
  94028. };
  94029. sizes: {
  94030. [key: string]: number;
  94031. };
  94032. vertexBuffers: {
  94033. [key: string]: Nullable<VertexBuffer>;
  94034. };
  94035. strides: {
  94036. [key: string]: number;
  94037. };
  94038. };
  94039. }
  94040. interface AbstractMesh {
  94041. /**
  94042. * Object used to store instanced buffers defined by user
  94043. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94044. */
  94045. instancedBuffers: {
  94046. [key: string]: any;
  94047. };
  94048. }
  94049. }
  94050. declare module BABYLON {
  94051. /**
  94052. * Defines the options associated with the creation of a shader material.
  94053. */
  94054. export interface IShaderMaterialOptions {
  94055. /**
  94056. * Does the material work in alpha blend mode
  94057. */
  94058. needAlphaBlending: boolean;
  94059. /**
  94060. * Does the material work in alpha test mode
  94061. */
  94062. needAlphaTesting: boolean;
  94063. /**
  94064. * The list of attribute names used in the shader
  94065. */
  94066. attributes: string[];
  94067. /**
  94068. * The list of unifrom names used in the shader
  94069. */
  94070. uniforms: string[];
  94071. /**
  94072. * The list of UBO names used in the shader
  94073. */
  94074. uniformBuffers: string[];
  94075. /**
  94076. * The list of sampler names used in the shader
  94077. */
  94078. samplers: string[];
  94079. /**
  94080. * The list of defines used in the shader
  94081. */
  94082. defines: string[];
  94083. }
  94084. /**
  94085. * 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.
  94086. *
  94087. * This returned material effects how the mesh will look based on the code in the shaders.
  94088. *
  94089. * @see http://doc.babylonjs.com/how_to/shader_material
  94090. */
  94091. export class ShaderMaterial extends Material {
  94092. private _shaderPath;
  94093. private _options;
  94094. private _textures;
  94095. private _textureArrays;
  94096. private _floats;
  94097. private _ints;
  94098. private _floatsArrays;
  94099. private _colors3;
  94100. private _colors3Arrays;
  94101. private _colors4;
  94102. private _colors4Arrays;
  94103. private _vectors2;
  94104. private _vectors3;
  94105. private _vectors4;
  94106. private _matrices;
  94107. private _matrixArrays;
  94108. private _matrices3x3;
  94109. private _matrices2x2;
  94110. private _vectors2Arrays;
  94111. private _vectors3Arrays;
  94112. private _vectors4Arrays;
  94113. private _cachedWorldViewMatrix;
  94114. private _cachedWorldViewProjectionMatrix;
  94115. private _renderId;
  94116. private _multiview;
  94117. private _cachedDefines;
  94118. /** Define the Url to load snippets */
  94119. static SnippetUrl: string;
  94120. /** Snippet ID if the material was created from the snippet server */
  94121. snippetId: string;
  94122. /**
  94123. * Instantiate a new shader material.
  94124. * 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.
  94125. * This returned material effects how the mesh will look based on the code in the shaders.
  94126. * @see http://doc.babylonjs.com/how_to/shader_material
  94127. * @param name Define the name of the material in the scene
  94128. * @param scene Define the scene the material belongs to
  94129. * @param shaderPath Defines the route to the shader code in one of three ways:
  94130. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  94131. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  94132. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  94133. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  94134. * @param options Define the options used to create the shader
  94135. */
  94136. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  94137. /**
  94138. * Gets the shader path used to define the shader code
  94139. * It can be modified to trigger a new compilation
  94140. */
  94141. get shaderPath(): any;
  94142. /**
  94143. * Sets the shader path used to define the shader code
  94144. * It can be modified to trigger a new compilation
  94145. */
  94146. set shaderPath(shaderPath: any);
  94147. /**
  94148. * Gets the options used to compile the shader.
  94149. * They can be modified to trigger a new compilation
  94150. */
  94151. get options(): IShaderMaterialOptions;
  94152. /**
  94153. * Gets the current class name of the material e.g. "ShaderMaterial"
  94154. * Mainly use in serialization.
  94155. * @returns the class name
  94156. */
  94157. getClassName(): string;
  94158. /**
  94159. * Specifies if the material will require alpha blending
  94160. * @returns a boolean specifying if alpha blending is needed
  94161. */
  94162. needAlphaBlending(): boolean;
  94163. /**
  94164. * Specifies if this material should be rendered in alpha test mode
  94165. * @returns a boolean specifying if an alpha test is needed.
  94166. */
  94167. needAlphaTesting(): boolean;
  94168. private _checkUniform;
  94169. /**
  94170. * Set a texture in the shader.
  94171. * @param name Define the name of the uniform samplers as defined in the shader
  94172. * @param texture Define the texture to bind to this sampler
  94173. * @return the material itself allowing "fluent" like uniform updates
  94174. */
  94175. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  94176. /**
  94177. * Set a texture array in the shader.
  94178. * @param name Define the name of the uniform sampler array as defined in the shader
  94179. * @param textures Define the list of textures to bind to this sampler
  94180. * @return the material itself allowing "fluent" like uniform updates
  94181. */
  94182. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  94183. /**
  94184. * Set a float in the shader.
  94185. * @param name Define the name of the uniform as defined in the shader
  94186. * @param value Define the value to give to the uniform
  94187. * @return the material itself allowing "fluent" like uniform updates
  94188. */
  94189. setFloat(name: string, value: number): ShaderMaterial;
  94190. /**
  94191. * Set a int in the shader.
  94192. * @param name Define the name of the uniform as defined in the shader
  94193. * @param value Define the value to give to the uniform
  94194. * @return the material itself allowing "fluent" like uniform updates
  94195. */
  94196. setInt(name: string, value: number): ShaderMaterial;
  94197. /**
  94198. * Set an array of floats in the shader.
  94199. * @param name Define the name of the uniform as defined in the shader
  94200. * @param value Define the value to give to the uniform
  94201. * @return the material itself allowing "fluent" like uniform updates
  94202. */
  94203. setFloats(name: string, value: number[]): ShaderMaterial;
  94204. /**
  94205. * Set a vec3 in the shader from a Color3.
  94206. * @param name Define the name of the uniform as defined in the shader
  94207. * @param value Define the value to give to the uniform
  94208. * @return the material itself allowing "fluent" like uniform updates
  94209. */
  94210. setColor3(name: string, value: Color3): ShaderMaterial;
  94211. /**
  94212. * Set a vec3 array in the shader from a Color3 array.
  94213. * @param name Define the name of the uniform as defined in the shader
  94214. * @param value Define the value to give to the uniform
  94215. * @return the material itself allowing "fluent" like uniform updates
  94216. */
  94217. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  94218. /**
  94219. * Set a vec4 in the shader from a Color4.
  94220. * @param name Define the name of the uniform as defined in the shader
  94221. * @param value Define the value to give to the uniform
  94222. * @return the material itself allowing "fluent" like uniform updates
  94223. */
  94224. setColor4(name: string, value: Color4): ShaderMaterial;
  94225. /**
  94226. * Set a vec4 array in the shader from a Color4 array.
  94227. * @param name Define the name of the uniform as defined in the shader
  94228. * @param value Define the value to give to the uniform
  94229. * @return the material itself allowing "fluent" like uniform updates
  94230. */
  94231. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  94232. /**
  94233. * Set a vec2 in the shader from a Vector2.
  94234. * @param name Define the name of the uniform as defined in the shader
  94235. * @param value Define the value to give to the uniform
  94236. * @return the material itself allowing "fluent" like uniform updates
  94237. */
  94238. setVector2(name: string, value: Vector2): ShaderMaterial;
  94239. /**
  94240. * Set a vec3 in the shader from a Vector3.
  94241. * @param name Define the name of the uniform as defined in the shader
  94242. * @param value Define the value to give to the uniform
  94243. * @return the material itself allowing "fluent" like uniform updates
  94244. */
  94245. setVector3(name: string, value: Vector3): ShaderMaterial;
  94246. /**
  94247. * Set a vec4 in the shader from a Vector4.
  94248. * @param name Define the name of the uniform as defined in the shader
  94249. * @param value Define the value to give to the uniform
  94250. * @return the material itself allowing "fluent" like uniform updates
  94251. */
  94252. setVector4(name: string, value: Vector4): ShaderMaterial;
  94253. /**
  94254. * Set a mat4 in the shader from a Matrix.
  94255. * @param name Define the name of the uniform as defined in the shader
  94256. * @param value Define the value to give to the uniform
  94257. * @return the material itself allowing "fluent" like uniform updates
  94258. */
  94259. setMatrix(name: string, value: Matrix): ShaderMaterial;
  94260. /**
  94261. * Set a float32Array in the shader from a matrix array.
  94262. * @param name Define the name of the uniform as defined in the shader
  94263. * @param value Define the value to give to the uniform
  94264. * @return the material itself allowing "fluent" like uniform updates
  94265. */
  94266. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  94267. /**
  94268. * Set a mat3 in the shader from a Float32Array.
  94269. * @param name Define the name of the uniform as defined in the shader
  94270. * @param value Define the value to give to the uniform
  94271. * @return the material itself allowing "fluent" like uniform updates
  94272. */
  94273. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  94274. /**
  94275. * Set a mat2 in the shader from a Float32Array.
  94276. * @param name Define the name of the uniform as defined in the shader
  94277. * @param value Define the value to give to the uniform
  94278. * @return the material itself allowing "fluent" like uniform updates
  94279. */
  94280. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  94281. /**
  94282. * Set a vec2 array in the shader from a number array.
  94283. * @param name Define the name of the uniform as defined in the shader
  94284. * @param value Define the value to give to the uniform
  94285. * @return the material itself allowing "fluent" like uniform updates
  94286. */
  94287. setArray2(name: string, value: number[]): ShaderMaterial;
  94288. /**
  94289. * Set a vec3 array in the shader from a number array.
  94290. * @param name Define the name of the uniform as defined in the shader
  94291. * @param value Define the value to give to the uniform
  94292. * @return the material itself allowing "fluent" like uniform updates
  94293. */
  94294. setArray3(name: string, value: number[]): ShaderMaterial;
  94295. /**
  94296. * Set a vec4 array in the shader from a number array.
  94297. * @param name Define the name of the uniform as defined in the shader
  94298. * @param value Define the value to give to the uniform
  94299. * @return the material itself allowing "fluent" like uniform updates
  94300. */
  94301. setArray4(name: string, value: number[]): ShaderMaterial;
  94302. private _checkCache;
  94303. /**
  94304. * Specifies that the submesh is ready to be used
  94305. * @param mesh defines the mesh to check
  94306. * @param subMesh defines which submesh to check
  94307. * @param useInstances specifies that instances should be used
  94308. * @returns a boolean indicating that the submesh is ready or not
  94309. */
  94310. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  94311. /**
  94312. * Checks if the material is ready to render the requested mesh
  94313. * @param mesh Define the mesh to render
  94314. * @param useInstances Define whether or not the material is used with instances
  94315. * @returns true if ready, otherwise false
  94316. */
  94317. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94318. /**
  94319. * Binds the world matrix to the material
  94320. * @param world defines the world transformation matrix
  94321. * @param effectOverride - If provided, use this effect instead of internal effect
  94322. */
  94323. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  94324. /**
  94325. * Binds the submesh to this material by preparing the effect and shader to draw
  94326. * @param world defines the world transformation matrix
  94327. * @param mesh defines the mesh containing the submesh
  94328. * @param subMesh defines the submesh to bind the material to
  94329. */
  94330. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94331. /**
  94332. * Binds the material to the mesh
  94333. * @param world defines the world transformation matrix
  94334. * @param mesh defines the mesh to bind the material to
  94335. * @param effectOverride - If provided, use this effect instead of internal effect
  94336. */
  94337. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  94338. protected _afterBind(mesh?: Mesh): void;
  94339. /**
  94340. * Gets the active textures from the material
  94341. * @returns an array of textures
  94342. */
  94343. getActiveTextures(): BaseTexture[];
  94344. /**
  94345. * Specifies if the material uses a texture
  94346. * @param texture defines the texture to check against the material
  94347. * @returns a boolean specifying if the material uses the texture
  94348. */
  94349. hasTexture(texture: BaseTexture): boolean;
  94350. /**
  94351. * Makes a duplicate of the material, and gives it a new name
  94352. * @param name defines the new name for the duplicated material
  94353. * @returns the cloned material
  94354. */
  94355. clone(name: string): ShaderMaterial;
  94356. /**
  94357. * Disposes the material
  94358. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94359. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94360. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94361. */
  94362. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94363. /**
  94364. * Serializes this material in a JSON representation
  94365. * @returns the serialized material object
  94366. */
  94367. serialize(): any;
  94368. /**
  94369. * Creates a shader material from parsed shader material data
  94370. * @param source defines the JSON represnetation of the material
  94371. * @param scene defines the hosting scene
  94372. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94373. * @returns a new material
  94374. */
  94375. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  94376. /**
  94377. * Creates a new ShaderMaterial from a snippet saved in a remote file
  94378. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  94379. * @param url defines the url to load from
  94380. * @param scene defines the hosting scene
  94381. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94382. * @returns a promise that will resolve to the new ShaderMaterial
  94383. */
  94384. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  94385. /**
  94386. * Creates a ShaderMaterial from a snippet saved by the Inspector
  94387. * @param snippetId defines the snippet to load
  94388. * @param scene defines the hosting scene
  94389. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94390. * @returns a promise that will resolve to the new ShaderMaterial
  94391. */
  94392. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  94393. }
  94394. }
  94395. declare module BABYLON {
  94396. /** @hidden */
  94397. export var colorPixelShader: {
  94398. name: string;
  94399. shader: string;
  94400. };
  94401. }
  94402. declare module BABYLON {
  94403. /** @hidden */
  94404. export var colorVertexShader: {
  94405. name: string;
  94406. shader: string;
  94407. };
  94408. }
  94409. declare module BABYLON {
  94410. /**
  94411. * Line mesh
  94412. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  94413. */
  94414. export class LinesMesh extends Mesh {
  94415. /**
  94416. * If vertex color should be applied to the mesh
  94417. */
  94418. readonly useVertexColor?: boolean | undefined;
  94419. /**
  94420. * If vertex alpha should be applied to the mesh
  94421. */
  94422. readonly useVertexAlpha?: boolean | undefined;
  94423. /**
  94424. * Color of the line (Default: White)
  94425. */
  94426. color: Color3;
  94427. /**
  94428. * Alpha of the line (Default: 1)
  94429. */
  94430. alpha: number;
  94431. /**
  94432. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  94433. * This margin is expressed in world space coordinates, so its value may vary.
  94434. * Default value is 0.1
  94435. */
  94436. intersectionThreshold: number;
  94437. private _colorShader;
  94438. private color4;
  94439. /**
  94440. * Creates a new LinesMesh
  94441. * @param name defines the name
  94442. * @param scene defines the hosting scene
  94443. * @param parent defines the parent mesh if any
  94444. * @param source defines the optional source LinesMesh used to clone data from
  94445. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  94446. * When false, achieved by calling a clone(), also passing False.
  94447. * This will make creation of children, recursive.
  94448. * @param useVertexColor defines if this LinesMesh supports vertex color
  94449. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  94450. */
  94451. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  94452. /**
  94453. * If vertex color should be applied to the mesh
  94454. */
  94455. useVertexColor?: boolean | undefined,
  94456. /**
  94457. * If vertex alpha should be applied to the mesh
  94458. */
  94459. useVertexAlpha?: boolean | undefined);
  94460. private _addClipPlaneDefine;
  94461. private _removeClipPlaneDefine;
  94462. isReady(): boolean;
  94463. /**
  94464. * Returns the string "LineMesh"
  94465. */
  94466. getClassName(): string;
  94467. /**
  94468. * @hidden
  94469. */
  94470. get material(): Material;
  94471. /**
  94472. * @hidden
  94473. */
  94474. set material(value: Material);
  94475. /**
  94476. * @hidden
  94477. */
  94478. get checkCollisions(): boolean;
  94479. /** @hidden */
  94480. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  94481. /** @hidden */
  94482. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  94483. /**
  94484. * Disposes of the line mesh
  94485. * @param doNotRecurse If children should be disposed
  94486. */
  94487. dispose(doNotRecurse?: boolean): void;
  94488. /**
  94489. * Returns a new LineMesh object cloned from the current one.
  94490. */
  94491. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  94492. /**
  94493. * Creates a new InstancedLinesMesh object from the mesh model.
  94494. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  94495. * @param name defines the name of the new instance
  94496. * @returns a new InstancedLinesMesh
  94497. */
  94498. createInstance(name: string): InstancedLinesMesh;
  94499. }
  94500. /**
  94501. * Creates an instance based on a source LinesMesh
  94502. */
  94503. export class InstancedLinesMesh extends InstancedMesh {
  94504. /**
  94505. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  94506. * This margin is expressed in world space coordinates, so its value may vary.
  94507. * Initilized with the intersectionThreshold value of the source LinesMesh
  94508. */
  94509. intersectionThreshold: number;
  94510. constructor(name: string, source: LinesMesh);
  94511. /**
  94512. * Returns the string "InstancedLinesMesh".
  94513. */
  94514. getClassName(): string;
  94515. }
  94516. }
  94517. declare module BABYLON {
  94518. /** @hidden */
  94519. export var linePixelShader: {
  94520. name: string;
  94521. shader: string;
  94522. };
  94523. }
  94524. declare module BABYLON {
  94525. /** @hidden */
  94526. export var lineVertexShader: {
  94527. name: string;
  94528. shader: string;
  94529. };
  94530. }
  94531. declare module BABYLON {
  94532. interface Scene {
  94533. /** @hidden */
  94534. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  94535. }
  94536. interface AbstractMesh {
  94537. /**
  94538. * Gets the edgesRenderer associated with the mesh
  94539. */
  94540. edgesRenderer: Nullable<EdgesRenderer>;
  94541. }
  94542. interface LinesMesh {
  94543. /**
  94544. * Enables the edge rendering mode on the mesh.
  94545. * This mode makes the mesh edges visible
  94546. * @param epsilon defines the maximal distance between two angles to detect a face
  94547. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94548. * @returns the currentAbstractMesh
  94549. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94550. */
  94551. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  94552. }
  94553. interface InstancedLinesMesh {
  94554. /**
  94555. * Enables the edge rendering mode on the mesh.
  94556. * This mode makes the mesh edges visible
  94557. * @param epsilon defines the maximal distance between two angles to detect a face
  94558. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94559. * @returns the current InstancedLinesMesh
  94560. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94561. */
  94562. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  94563. }
  94564. /**
  94565. * Defines the minimum contract an Edges renderer should follow.
  94566. */
  94567. export interface IEdgesRenderer extends IDisposable {
  94568. /**
  94569. * Gets or sets a boolean indicating if the edgesRenderer is active
  94570. */
  94571. isEnabled: boolean;
  94572. /**
  94573. * Renders the edges of the attached mesh,
  94574. */
  94575. render(): void;
  94576. /**
  94577. * Checks wether or not the edges renderer is ready to render.
  94578. * @return true if ready, otherwise false.
  94579. */
  94580. isReady(): boolean;
  94581. /**
  94582. * List of instances to render in case the source mesh has instances
  94583. */
  94584. customInstances: SmartArray<Matrix>;
  94585. }
  94586. /**
  94587. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  94588. */
  94589. export class EdgesRenderer implements IEdgesRenderer {
  94590. /**
  94591. * Define the size of the edges with an orthographic camera
  94592. */
  94593. edgesWidthScalerForOrthographic: number;
  94594. /**
  94595. * Define the size of the edges with a perspective camera
  94596. */
  94597. edgesWidthScalerForPerspective: number;
  94598. protected _source: AbstractMesh;
  94599. protected _linesPositions: number[];
  94600. protected _linesNormals: number[];
  94601. protected _linesIndices: number[];
  94602. protected _epsilon: number;
  94603. protected _indicesCount: number;
  94604. protected _lineShader: ShaderMaterial;
  94605. protected _ib: DataBuffer;
  94606. protected _buffers: {
  94607. [key: string]: Nullable<VertexBuffer>;
  94608. };
  94609. protected _buffersForInstances: {
  94610. [key: string]: Nullable<VertexBuffer>;
  94611. };
  94612. protected _checkVerticesInsteadOfIndices: boolean;
  94613. private _meshRebuildObserver;
  94614. private _meshDisposeObserver;
  94615. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  94616. isEnabled: boolean;
  94617. /**
  94618. * List of instances to render in case the source mesh has instances
  94619. */
  94620. customInstances: SmartArray<Matrix>;
  94621. private static GetShader;
  94622. /**
  94623. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  94624. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  94625. * @param source Mesh used to create edges
  94626. * @param epsilon sum of angles in adjacency to check for edge
  94627. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  94628. * @param generateEdgesLines - should generate Lines or only prepare resources.
  94629. */
  94630. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  94631. protected _prepareRessources(): void;
  94632. /** @hidden */
  94633. _rebuild(): void;
  94634. /**
  94635. * Releases the required resources for the edges renderer
  94636. */
  94637. dispose(): void;
  94638. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  94639. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  94640. /**
  94641. * Checks if the pair of p0 and p1 is en edge
  94642. * @param faceIndex
  94643. * @param edge
  94644. * @param faceNormals
  94645. * @param p0
  94646. * @param p1
  94647. * @private
  94648. */
  94649. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  94650. /**
  94651. * push line into the position, normal and index buffer
  94652. * @protected
  94653. */
  94654. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  94655. /**
  94656. * Generates lines edges from adjacencjes
  94657. * @private
  94658. */
  94659. _generateEdgesLines(): void;
  94660. /**
  94661. * Checks wether or not the edges renderer is ready to render.
  94662. * @return true if ready, otherwise false.
  94663. */
  94664. isReady(): boolean;
  94665. /**
  94666. * Renders the edges of the attached mesh,
  94667. */
  94668. render(): void;
  94669. }
  94670. /**
  94671. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  94672. */
  94673. export class LineEdgesRenderer extends EdgesRenderer {
  94674. /**
  94675. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  94676. * @param source LineMesh used to generate edges
  94677. * @param epsilon not important (specified angle for edge detection)
  94678. * @param checkVerticesInsteadOfIndices not important for LineMesh
  94679. */
  94680. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  94681. /**
  94682. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  94683. */
  94684. _generateEdgesLines(): void;
  94685. }
  94686. }
  94687. declare module BABYLON {
  94688. /**
  94689. * This represents the object necessary to create a rendering group.
  94690. * This is exclusively used and created by the rendering manager.
  94691. * To modify the behavior, you use the available helpers in your scene or meshes.
  94692. * @hidden
  94693. */
  94694. export class RenderingGroup {
  94695. index: number;
  94696. private static _zeroVector;
  94697. private _scene;
  94698. private _opaqueSubMeshes;
  94699. private _transparentSubMeshes;
  94700. private _alphaTestSubMeshes;
  94701. private _depthOnlySubMeshes;
  94702. private _particleSystems;
  94703. private _spriteManagers;
  94704. private _opaqueSortCompareFn;
  94705. private _alphaTestSortCompareFn;
  94706. private _transparentSortCompareFn;
  94707. private _renderOpaque;
  94708. private _renderAlphaTest;
  94709. private _renderTransparent;
  94710. /** @hidden */
  94711. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  94712. onBeforeTransparentRendering: () => void;
  94713. /**
  94714. * Set the opaque sort comparison function.
  94715. * If null the sub meshes will be render in the order they were created
  94716. */
  94717. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94718. /**
  94719. * Set the alpha test sort comparison function.
  94720. * If null the sub meshes will be render in the order they were created
  94721. */
  94722. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94723. /**
  94724. * Set the transparent sort comparison function.
  94725. * If null the sub meshes will be render in the order they were created
  94726. */
  94727. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94728. /**
  94729. * Creates a new rendering group.
  94730. * @param index The rendering group index
  94731. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  94732. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  94733. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  94734. */
  94735. 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>);
  94736. /**
  94737. * Render all the sub meshes contained in the group.
  94738. * @param customRenderFunction Used to override the default render behaviour of the group.
  94739. * @returns true if rendered some submeshes.
  94740. */
  94741. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  94742. /**
  94743. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  94744. * @param subMeshes The submeshes to render
  94745. */
  94746. private renderOpaqueSorted;
  94747. /**
  94748. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  94749. * @param subMeshes The submeshes to render
  94750. */
  94751. private renderAlphaTestSorted;
  94752. /**
  94753. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  94754. * @param subMeshes The submeshes to render
  94755. */
  94756. private renderTransparentSorted;
  94757. /**
  94758. * Renders the submeshes in a specified order.
  94759. * @param subMeshes The submeshes to sort before render
  94760. * @param sortCompareFn The comparison function use to sort
  94761. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  94762. * @param transparent Specifies to activate blending if true
  94763. */
  94764. private static renderSorted;
  94765. /**
  94766. * Renders the submeshes in the order they were dispatched (no sort applied).
  94767. * @param subMeshes The submeshes to render
  94768. */
  94769. private static renderUnsorted;
  94770. /**
  94771. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94772. * are rendered back to front if in the same alpha index.
  94773. *
  94774. * @param a The first submesh
  94775. * @param b The second submesh
  94776. * @returns The result of the comparison
  94777. */
  94778. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  94779. /**
  94780. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94781. * are rendered back to front.
  94782. *
  94783. * @param a The first submesh
  94784. * @param b The second submesh
  94785. * @returns The result of the comparison
  94786. */
  94787. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  94788. /**
  94789. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94790. * are rendered front to back (prevent overdraw).
  94791. *
  94792. * @param a The first submesh
  94793. * @param b The second submesh
  94794. * @returns The result of the comparison
  94795. */
  94796. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  94797. /**
  94798. * Resets the different lists of submeshes to prepare a new frame.
  94799. */
  94800. prepare(): void;
  94801. dispose(): void;
  94802. /**
  94803. * Inserts the submesh in its correct queue depending on its material.
  94804. * @param subMesh The submesh to dispatch
  94805. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  94806. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  94807. */
  94808. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  94809. dispatchSprites(spriteManager: ISpriteManager): void;
  94810. dispatchParticles(particleSystem: IParticleSystem): void;
  94811. private _renderParticles;
  94812. private _renderSprites;
  94813. }
  94814. }
  94815. declare module BABYLON {
  94816. /**
  94817. * Interface describing the different options available in the rendering manager
  94818. * regarding Auto Clear between groups.
  94819. */
  94820. export interface IRenderingManagerAutoClearSetup {
  94821. /**
  94822. * Defines whether or not autoclear is enable.
  94823. */
  94824. autoClear: boolean;
  94825. /**
  94826. * Defines whether or not to autoclear the depth buffer.
  94827. */
  94828. depth: boolean;
  94829. /**
  94830. * Defines whether or not to autoclear the stencil buffer.
  94831. */
  94832. stencil: boolean;
  94833. }
  94834. /**
  94835. * This class is used by the onRenderingGroupObservable
  94836. */
  94837. export class RenderingGroupInfo {
  94838. /**
  94839. * The Scene that being rendered
  94840. */
  94841. scene: Scene;
  94842. /**
  94843. * The camera currently used for the rendering pass
  94844. */
  94845. camera: Nullable<Camera>;
  94846. /**
  94847. * The ID of the renderingGroup being processed
  94848. */
  94849. renderingGroupId: number;
  94850. }
  94851. /**
  94852. * This is the manager responsible of all the rendering for meshes sprites and particles.
  94853. * It is enable to manage the different groups as well as the different necessary sort functions.
  94854. * This should not be used directly aside of the few static configurations
  94855. */
  94856. export class RenderingManager {
  94857. /**
  94858. * The max id used for rendering groups (not included)
  94859. */
  94860. static MAX_RENDERINGGROUPS: number;
  94861. /**
  94862. * The min id used for rendering groups (included)
  94863. */
  94864. static MIN_RENDERINGGROUPS: number;
  94865. /**
  94866. * Used to globally prevent autoclearing scenes.
  94867. */
  94868. static AUTOCLEAR: boolean;
  94869. /**
  94870. * @hidden
  94871. */
  94872. _useSceneAutoClearSetup: boolean;
  94873. private _scene;
  94874. private _renderingGroups;
  94875. private _depthStencilBufferAlreadyCleaned;
  94876. private _autoClearDepthStencil;
  94877. private _customOpaqueSortCompareFn;
  94878. private _customAlphaTestSortCompareFn;
  94879. private _customTransparentSortCompareFn;
  94880. private _renderingGroupInfo;
  94881. /**
  94882. * Instantiates a new rendering group for a particular scene
  94883. * @param scene Defines the scene the groups belongs to
  94884. */
  94885. constructor(scene: Scene);
  94886. private _clearDepthStencilBuffer;
  94887. /**
  94888. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  94889. * @hidden
  94890. */
  94891. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  94892. /**
  94893. * Resets the different information of the group to prepare a new frame
  94894. * @hidden
  94895. */
  94896. reset(): void;
  94897. /**
  94898. * Dispose and release the group and its associated resources.
  94899. * @hidden
  94900. */
  94901. dispose(): void;
  94902. /**
  94903. * Clear the info related to rendering groups preventing retention points during dispose.
  94904. */
  94905. freeRenderingGroups(): void;
  94906. private _prepareRenderingGroup;
  94907. /**
  94908. * Add a sprite manager to the rendering manager in order to render it this frame.
  94909. * @param spriteManager Define the sprite manager to render
  94910. */
  94911. dispatchSprites(spriteManager: ISpriteManager): void;
  94912. /**
  94913. * Add a particle system to the rendering manager in order to render it this frame.
  94914. * @param particleSystem Define the particle system to render
  94915. */
  94916. dispatchParticles(particleSystem: IParticleSystem): void;
  94917. /**
  94918. * Add a submesh to the manager in order to render it this frame
  94919. * @param subMesh The submesh to dispatch
  94920. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  94921. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  94922. */
  94923. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  94924. /**
  94925. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  94926. * This allowed control for front to back rendering or reversly depending of the special needs.
  94927. *
  94928. * @param renderingGroupId The rendering group id corresponding to its index
  94929. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  94930. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  94931. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  94932. */
  94933. 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;
  94934. /**
  94935. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94936. *
  94937. * @param renderingGroupId The rendering group id corresponding to its index
  94938. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94939. * @param depth Automatically clears depth between groups if true and autoClear is true.
  94940. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  94941. */
  94942. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  94943. /**
  94944. * Gets the current auto clear configuration for one rendering group of the rendering
  94945. * manager.
  94946. * @param index the rendering group index to get the information for
  94947. * @returns The auto clear setup for the requested rendering group
  94948. */
  94949. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  94950. }
  94951. }
  94952. declare module BABYLON {
  94953. /**
  94954. * Defines the options associated with the creation of a custom shader for a shadow generator.
  94955. */
  94956. export interface ICustomShaderOptions {
  94957. /**
  94958. * Gets or sets the custom shader name to use
  94959. */
  94960. shaderName: string;
  94961. /**
  94962. * The list of attribute names used in the shader
  94963. */
  94964. attributes?: string[];
  94965. /**
  94966. * The list of unifrom names used in the shader
  94967. */
  94968. uniforms?: string[];
  94969. /**
  94970. * The list of sampler names used in the shader
  94971. */
  94972. samplers?: string[];
  94973. /**
  94974. * The list of defines used in the shader
  94975. */
  94976. defines?: string[];
  94977. }
  94978. /**
  94979. * Interface to implement to create a shadow generator compatible with BJS.
  94980. */
  94981. export interface IShadowGenerator {
  94982. /**
  94983. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  94984. * @returns The render target texture if present otherwise, null
  94985. */
  94986. getShadowMap(): Nullable<RenderTargetTexture>;
  94987. /**
  94988. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  94989. * @param subMesh The submesh we want to render in the shadow map
  94990. * @param useInstances Defines wether will draw in the map using instances
  94991. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  94992. * @returns true if ready otherwise, false
  94993. */
  94994. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  94995. /**
  94996. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  94997. * @param defines Defines of the material we want to update
  94998. * @param lightIndex Index of the light in the enabled light list of the material
  94999. */
  95000. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  95001. /**
  95002. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  95003. * defined in the generator but impacting the effect).
  95004. * It implies the unifroms available on the materials are the standard BJS ones.
  95005. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95006. * @param effect The effect we are binfing the information for
  95007. */
  95008. bindShadowLight(lightIndex: string, effect: Effect): void;
  95009. /**
  95010. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95011. * (eq to shadow prjection matrix * light transform matrix)
  95012. * @returns The transform matrix used to create the shadow map
  95013. */
  95014. getTransformMatrix(): Matrix;
  95015. /**
  95016. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95017. * Cube and 2D textures for instance.
  95018. */
  95019. recreateShadowMap(): void;
  95020. /**
  95021. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95022. * @param onCompiled Callback triggered at the and of the effects compilation
  95023. * @param options Sets of optional options forcing the compilation with different modes
  95024. */
  95025. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  95026. useInstances: boolean;
  95027. }>): void;
  95028. /**
  95029. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95030. * @param options Sets of optional options forcing the compilation with different modes
  95031. * @returns A promise that resolves when the compilation completes
  95032. */
  95033. forceCompilationAsync(options?: Partial<{
  95034. useInstances: boolean;
  95035. }>): Promise<void>;
  95036. /**
  95037. * Serializes the shadow generator setup to a json object.
  95038. * @returns The serialized JSON object
  95039. */
  95040. serialize(): any;
  95041. /**
  95042. * Disposes the Shadow map and related Textures and effects.
  95043. */
  95044. dispose(): void;
  95045. }
  95046. /**
  95047. * Default implementation IShadowGenerator.
  95048. * This is the main object responsible of generating shadows in the framework.
  95049. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  95050. */
  95051. export class ShadowGenerator implements IShadowGenerator {
  95052. /**
  95053. * Name of the shadow generator class
  95054. */
  95055. static CLASSNAME: string;
  95056. /**
  95057. * Shadow generator mode None: no filtering applied.
  95058. */
  95059. static readonly FILTER_NONE: number;
  95060. /**
  95061. * Shadow generator mode ESM: Exponential Shadow Mapping.
  95062. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95063. */
  95064. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  95065. /**
  95066. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  95067. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  95068. */
  95069. static readonly FILTER_POISSONSAMPLING: number;
  95070. /**
  95071. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  95072. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95073. */
  95074. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  95075. /**
  95076. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  95077. * edge artifacts on steep falloff.
  95078. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95079. */
  95080. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  95081. /**
  95082. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  95083. * edge artifacts on steep falloff.
  95084. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95085. */
  95086. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  95087. /**
  95088. * Shadow generator mode PCF: Percentage Closer Filtering
  95089. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  95090. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  95091. */
  95092. static readonly FILTER_PCF: number;
  95093. /**
  95094. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  95095. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  95096. * Contact Hardening
  95097. */
  95098. static readonly FILTER_PCSS: number;
  95099. /**
  95100. * Reserved for PCF and PCSS
  95101. * Highest Quality.
  95102. *
  95103. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  95104. *
  95105. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  95106. */
  95107. static readonly QUALITY_HIGH: number;
  95108. /**
  95109. * Reserved for PCF and PCSS
  95110. * Good tradeoff for quality/perf cross devices
  95111. *
  95112. * Execute PCF on a 3*3 kernel.
  95113. *
  95114. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  95115. */
  95116. static readonly QUALITY_MEDIUM: number;
  95117. /**
  95118. * Reserved for PCF and PCSS
  95119. * The lowest quality but the fastest.
  95120. *
  95121. * Execute PCF on a 1*1 kernel.
  95122. *
  95123. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  95124. */
  95125. static readonly QUALITY_LOW: number;
  95126. /** Gets or sets the custom shader name to use */
  95127. customShaderOptions: ICustomShaderOptions;
  95128. /**
  95129. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  95130. */
  95131. onBeforeShadowMapRenderObservable: Observable<Effect>;
  95132. /**
  95133. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  95134. */
  95135. onAfterShadowMapRenderObservable: Observable<Effect>;
  95136. /**
  95137. * Observable triggered before a mesh is rendered in the shadow map.
  95138. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  95139. */
  95140. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  95141. /**
  95142. * Observable triggered after a mesh is rendered in the shadow map.
  95143. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  95144. */
  95145. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  95146. protected _bias: number;
  95147. /**
  95148. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  95149. */
  95150. get bias(): number;
  95151. /**
  95152. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  95153. */
  95154. set bias(bias: number);
  95155. protected _normalBias: number;
  95156. /**
  95157. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95158. */
  95159. get normalBias(): number;
  95160. /**
  95161. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95162. */
  95163. set normalBias(normalBias: number);
  95164. protected _blurBoxOffset: number;
  95165. /**
  95166. * Gets the blur box offset: offset applied during the blur pass.
  95167. * Only useful if useKernelBlur = false
  95168. */
  95169. get blurBoxOffset(): number;
  95170. /**
  95171. * Sets the blur box offset: offset applied during the blur pass.
  95172. * Only useful if useKernelBlur = false
  95173. */
  95174. set blurBoxOffset(value: number);
  95175. protected _blurScale: number;
  95176. /**
  95177. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  95178. * 2 means half of the size.
  95179. */
  95180. get blurScale(): number;
  95181. /**
  95182. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  95183. * 2 means half of the size.
  95184. */
  95185. set blurScale(value: number);
  95186. protected _blurKernel: number;
  95187. /**
  95188. * Gets the blur kernel: kernel size of the blur pass.
  95189. * Only useful if useKernelBlur = true
  95190. */
  95191. get blurKernel(): number;
  95192. /**
  95193. * Sets the blur kernel: kernel size of the blur pass.
  95194. * Only useful if useKernelBlur = true
  95195. */
  95196. set blurKernel(value: number);
  95197. protected _useKernelBlur: boolean;
  95198. /**
  95199. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  95200. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95201. */
  95202. get useKernelBlur(): boolean;
  95203. /**
  95204. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  95205. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95206. */
  95207. set useKernelBlur(value: boolean);
  95208. protected _depthScale: number;
  95209. /**
  95210. * Gets the depth scale used in ESM mode.
  95211. */
  95212. get depthScale(): number;
  95213. /**
  95214. * Sets the depth scale used in ESM mode.
  95215. * This can override the scale stored on the light.
  95216. */
  95217. set depthScale(value: number);
  95218. protected _validateFilter(filter: number): number;
  95219. protected _filter: number;
  95220. /**
  95221. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  95222. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95223. */
  95224. get filter(): number;
  95225. /**
  95226. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  95227. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95228. */
  95229. set filter(value: number);
  95230. /**
  95231. * Gets if the current filter is set to Poisson Sampling.
  95232. */
  95233. get usePoissonSampling(): boolean;
  95234. /**
  95235. * Sets the current filter to Poisson Sampling.
  95236. */
  95237. set usePoissonSampling(value: boolean);
  95238. /**
  95239. * Gets if the current filter is set to ESM.
  95240. */
  95241. get useExponentialShadowMap(): boolean;
  95242. /**
  95243. * Sets the current filter is to ESM.
  95244. */
  95245. set useExponentialShadowMap(value: boolean);
  95246. /**
  95247. * Gets if the current filter is set to filtered ESM.
  95248. */
  95249. get useBlurExponentialShadowMap(): boolean;
  95250. /**
  95251. * Gets if the current filter is set to filtered ESM.
  95252. */
  95253. set useBlurExponentialShadowMap(value: boolean);
  95254. /**
  95255. * Gets if the current filter is set to "close ESM" (using the inverse of the
  95256. * exponential to prevent steep falloff artifacts).
  95257. */
  95258. get useCloseExponentialShadowMap(): boolean;
  95259. /**
  95260. * Sets the current filter to "close ESM" (using the inverse of the
  95261. * exponential to prevent steep falloff artifacts).
  95262. */
  95263. set useCloseExponentialShadowMap(value: boolean);
  95264. /**
  95265. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  95266. * exponential to prevent steep falloff artifacts).
  95267. */
  95268. get useBlurCloseExponentialShadowMap(): boolean;
  95269. /**
  95270. * Sets the current filter to filtered "close ESM" (using the inverse of the
  95271. * exponential to prevent steep falloff artifacts).
  95272. */
  95273. set useBlurCloseExponentialShadowMap(value: boolean);
  95274. /**
  95275. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  95276. */
  95277. get usePercentageCloserFiltering(): boolean;
  95278. /**
  95279. * Sets the current filter to "PCF" (percentage closer filtering).
  95280. */
  95281. set usePercentageCloserFiltering(value: boolean);
  95282. protected _filteringQuality: number;
  95283. /**
  95284. * Gets the PCF or PCSS Quality.
  95285. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95286. */
  95287. get filteringQuality(): number;
  95288. /**
  95289. * Sets the PCF or PCSS Quality.
  95290. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95291. */
  95292. set filteringQuality(filteringQuality: number);
  95293. /**
  95294. * Gets if the current filter is set to "PCSS" (contact hardening).
  95295. */
  95296. get useContactHardeningShadow(): boolean;
  95297. /**
  95298. * Sets the current filter to "PCSS" (contact hardening).
  95299. */
  95300. set useContactHardeningShadow(value: boolean);
  95301. protected _contactHardeningLightSizeUVRatio: number;
  95302. /**
  95303. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95304. * Using a ratio helps keeping shape stability independently of the map size.
  95305. *
  95306. * It does not account for the light projection as it was having too much
  95307. * instability during the light setup or during light position changes.
  95308. *
  95309. * Only valid if useContactHardeningShadow is true.
  95310. */
  95311. get contactHardeningLightSizeUVRatio(): number;
  95312. /**
  95313. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95314. * Using a ratio helps keeping shape stability independently of the map size.
  95315. *
  95316. * It does not account for the light projection as it was having too much
  95317. * instability during the light setup or during light position changes.
  95318. *
  95319. * Only valid if useContactHardeningShadow is true.
  95320. */
  95321. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  95322. protected _darkness: number;
  95323. /** Gets or sets the actual darkness of a shadow */
  95324. get darkness(): number;
  95325. set darkness(value: number);
  95326. /**
  95327. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  95328. * 0 means strongest and 1 would means no shadow.
  95329. * @returns the darkness.
  95330. */
  95331. getDarkness(): number;
  95332. /**
  95333. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  95334. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  95335. * @returns the shadow generator allowing fluent coding.
  95336. */
  95337. setDarkness(darkness: number): ShadowGenerator;
  95338. protected _transparencyShadow: boolean;
  95339. /** Gets or sets the ability to have transparent shadow */
  95340. get transparencyShadow(): boolean;
  95341. set transparencyShadow(value: boolean);
  95342. /**
  95343. * Sets the ability to have transparent shadow (boolean).
  95344. * @param transparent True if transparent else False
  95345. * @returns the shadow generator allowing fluent coding
  95346. */
  95347. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  95348. /**
  95349. * Enables or disables shadows with varying strength based on the transparency
  95350. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  95351. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  95352. * mesh.visibility * alphaTexture.a
  95353. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  95354. */
  95355. enableSoftTransparentShadow: boolean;
  95356. protected _shadowMap: Nullable<RenderTargetTexture>;
  95357. protected _shadowMap2: Nullable<RenderTargetTexture>;
  95358. /**
  95359. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  95360. * @returns The render target texture if present otherwise, null
  95361. */
  95362. getShadowMap(): Nullable<RenderTargetTexture>;
  95363. /**
  95364. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  95365. * @returns The render target texture if the shadow map is present otherwise, null
  95366. */
  95367. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  95368. /**
  95369. * Gets the class name of that object
  95370. * @returns "ShadowGenerator"
  95371. */
  95372. getClassName(): string;
  95373. /**
  95374. * Helper function to add a mesh and its descendants to the list of shadow casters.
  95375. * @param mesh Mesh to add
  95376. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  95377. * @returns the Shadow Generator itself
  95378. */
  95379. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  95380. /**
  95381. * Helper function to remove a mesh and its descendants from the list of shadow casters
  95382. * @param mesh Mesh to remove
  95383. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  95384. * @returns the Shadow Generator itself
  95385. */
  95386. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  95387. /**
  95388. * Controls the extent to which the shadows fade out at the edge of the frustum
  95389. */
  95390. frustumEdgeFalloff: number;
  95391. protected _light: IShadowLight;
  95392. /**
  95393. * Returns the associated light object.
  95394. * @returns the light generating the shadow
  95395. */
  95396. getLight(): IShadowLight;
  95397. /**
  95398. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  95399. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  95400. * It might on the other hand introduce peter panning.
  95401. */
  95402. forceBackFacesOnly: boolean;
  95403. protected _scene: Scene;
  95404. protected _lightDirection: Vector3;
  95405. protected _effect: Effect;
  95406. protected _viewMatrix: Matrix;
  95407. protected _projectionMatrix: Matrix;
  95408. protected _transformMatrix: Matrix;
  95409. protected _cachedPosition: Vector3;
  95410. protected _cachedDirection: Vector3;
  95411. protected _cachedDefines: string;
  95412. protected _currentRenderID: number;
  95413. protected _boxBlurPostprocess: Nullable<PostProcess>;
  95414. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  95415. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  95416. protected _blurPostProcesses: PostProcess[];
  95417. protected _mapSize: number;
  95418. protected _currentFaceIndex: number;
  95419. protected _currentFaceIndexCache: number;
  95420. protected _textureType: number;
  95421. protected _defaultTextureMatrix: Matrix;
  95422. protected _storedUniqueId: Nullable<number>;
  95423. /** @hidden */
  95424. static _SceneComponentInitialization: (scene: Scene) => void;
  95425. /**
  95426. * Creates a ShadowGenerator object.
  95427. * A ShadowGenerator is the required tool to use the shadows.
  95428. * Each light casting shadows needs to use its own ShadowGenerator.
  95429. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  95430. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  95431. * @param light The light object generating the shadows.
  95432. * @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.
  95433. */
  95434. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  95435. protected _initializeGenerator(): void;
  95436. protected _createTargetRenderTexture(): void;
  95437. protected _initializeShadowMap(): void;
  95438. protected _initializeBlurRTTAndPostProcesses(): void;
  95439. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  95440. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  95441. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  95442. protected _applyFilterValues(): void;
  95443. /**
  95444. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95445. * @param onCompiled Callback triggered at the and of the effects compilation
  95446. * @param options Sets of optional options forcing the compilation with different modes
  95447. */
  95448. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  95449. useInstances: boolean;
  95450. }>): void;
  95451. /**
  95452. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95453. * @param options Sets of optional options forcing the compilation with different modes
  95454. * @returns A promise that resolves when the compilation completes
  95455. */
  95456. forceCompilationAsync(options?: Partial<{
  95457. useInstances: boolean;
  95458. }>): Promise<void>;
  95459. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  95460. private _prepareShadowDefines;
  95461. /**
  95462. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  95463. * @param subMesh The submesh we want to render in the shadow map
  95464. * @param useInstances Defines wether will draw in the map using instances
  95465. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  95466. * @returns true if ready otherwise, false
  95467. */
  95468. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  95469. /**
  95470. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  95471. * @param defines Defines of the material we want to update
  95472. * @param lightIndex Index of the light in the enabled light list of the material
  95473. */
  95474. prepareDefines(defines: any, lightIndex: number): void;
  95475. /**
  95476. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  95477. * defined in the generator but impacting the effect).
  95478. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95479. * @param effect The effect we are binfing the information for
  95480. */
  95481. bindShadowLight(lightIndex: string, effect: Effect): void;
  95482. /**
  95483. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95484. * (eq to shadow prjection matrix * light transform matrix)
  95485. * @returns The transform matrix used to create the shadow map
  95486. */
  95487. getTransformMatrix(): Matrix;
  95488. /**
  95489. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95490. * Cube and 2D textures for instance.
  95491. */
  95492. recreateShadowMap(): void;
  95493. protected _disposeBlurPostProcesses(): void;
  95494. protected _disposeRTTandPostProcesses(): void;
  95495. /**
  95496. * Disposes the ShadowGenerator.
  95497. * Returns nothing.
  95498. */
  95499. dispose(): void;
  95500. /**
  95501. * Serializes the shadow generator setup to a json object.
  95502. * @returns The serialized JSON object
  95503. */
  95504. serialize(): any;
  95505. /**
  95506. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  95507. * @param parsedShadowGenerator The JSON object to parse
  95508. * @param scene The scene to create the shadow map for
  95509. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  95510. * @returns The parsed shadow generator
  95511. */
  95512. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  95513. }
  95514. }
  95515. declare module BABYLON {
  95516. /**
  95517. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  95518. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  95519. * 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.
  95520. */
  95521. export abstract class Light extends Node {
  95522. /**
  95523. * Falloff Default: light is falling off following the material specification:
  95524. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  95525. */
  95526. static readonly FALLOFF_DEFAULT: number;
  95527. /**
  95528. * Falloff Physical: light is falling off following the inverse squared distance law.
  95529. */
  95530. static readonly FALLOFF_PHYSICAL: number;
  95531. /**
  95532. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  95533. * to enhance interoperability with other engines.
  95534. */
  95535. static readonly FALLOFF_GLTF: number;
  95536. /**
  95537. * Falloff Standard: light is falling off like in the standard material
  95538. * to enhance interoperability with other materials.
  95539. */
  95540. static readonly FALLOFF_STANDARD: number;
  95541. /**
  95542. * If every light affecting the material is in this lightmapMode,
  95543. * material.lightmapTexture adds or multiplies
  95544. * (depends on material.useLightmapAsShadowmap)
  95545. * after every other light calculations.
  95546. */
  95547. static readonly LIGHTMAP_DEFAULT: number;
  95548. /**
  95549. * material.lightmapTexture as only diffuse lighting from this light
  95550. * adds only specular lighting from this light
  95551. * adds dynamic shadows
  95552. */
  95553. static readonly LIGHTMAP_SPECULAR: number;
  95554. /**
  95555. * material.lightmapTexture as only lighting
  95556. * no light calculation from this light
  95557. * only adds dynamic shadows from this light
  95558. */
  95559. static readonly LIGHTMAP_SHADOWSONLY: number;
  95560. /**
  95561. * Each light type uses the default quantity according to its type:
  95562. * point/spot lights use luminous intensity
  95563. * directional lights use illuminance
  95564. */
  95565. static readonly INTENSITYMODE_AUTOMATIC: number;
  95566. /**
  95567. * lumen (lm)
  95568. */
  95569. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  95570. /**
  95571. * candela (lm/sr)
  95572. */
  95573. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  95574. /**
  95575. * lux (lm/m^2)
  95576. */
  95577. static readonly INTENSITYMODE_ILLUMINANCE: number;
  95578. /**
  95579. * nit (cd/m^2)
  95580. */
  95581. static readonly INTENSITYMODE_LUMINANCE: number;
  95582. /**
  95583. * Light type const id of the point light.
  95584. */
  95585. static readonly LIGHTTYPEID_POINTLIGHT: number;
  95586. /**
  95587. * Light type const id of the directional light.
  95588. */
  95589. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  95590. /**
  95591. * Light type const id of the spot light.
  95592. */
  95593. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  95594. /**
  95595. * Light type const id of the hemispheric light.
  95596. */
  95597. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  95598. /**
  95599. * Diffuse gives the basic color to an object.
  95600. */
  95601. diffuse: Color3;
  95602. /**
  95603. * Specular produces a highlight color on an object.
  95604. * Note: This is note affecting PBR materials.
  95605. */
  95606. specular: Color3;
  95607. /**
  95608. * Defines the falloff type for this light. This lets overrriding how punctual light are
  95609. * falling off base on range or angle.
  95610. * This can be set to any values in Light.FALLOFF_x.
  95611. *
  95612. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  95613. * other types of materials.
  95614. */
  95615. falloffType: number;
  95616. /**
  95617. * Strength of the light.
  95618. * Note: By default it is define in the framework own unit.
  95619. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  95620. */
  95621. intensity: number;
  95622. private _range;
  95623. protected _inverseSquaredRange: number;
  95624. /**
  95625. * Defines how far from the source the light is impacting in scene units.
  95626. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  95627. */
  95628. get range(): number;
  95629. /**
  95630. * Defines how far from the source the light is impacting in scene units.
  95631. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  95632. */
  95633. set range(value: number);
  95634. /**
  95635. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  95636. * of light.
  95637. */
  95638. private _photometricScale;
  95639. private _intensityMode;
  95640. /**
  95641. * Gets the photometric scale used to interpret the intensity.
  95642. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  95643. */
  95644. get intensityMode(): number;
  95645. /**
  95646. * Sets the photometric scale used to interpret the intensity.
  95647. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  95648. */
  95649. set intensityMode(value: number);
  95650. private _radius;
  95651. /**
  95652. * Gets the light radius used by PBR Materials to simulate soft area lights.
  95653. */
  95654. get radius(): number;
  95655. /**
  95656. * sets the light radius used by PBR Materials to simulate soft area lights.
  95657. */
  95658. set radius(value: number);
  95659. private _renderPriority;
  95660. /**
  95661. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  95662. * exceeding the number allowed of the materials.
  95663. */
  95664. renderPriority: number;
  95665. private _shadowEnabled;
  95666. /**
  95667. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  95668. * the current shadow generator.
  95669. */
  95670. get shadowEnabled(): boolean;
  95671. /**
  95672. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  95673. * the current shadow generator.
  95674. */
  95675. set shadowEnabled(value: boolean);
  95676. private _includedOnlyMeshes;
  95677. /**
  95678. * Gets the only meshes impacted by this light.
  95679. */
  95680. get includedOnlyMeshes(): AbstractMesh[];
  95681. /**
  95682. * Sets the only meshes impacted by this light.
  95683. */
  95684. set includedOnlyMeshes(value: AbstractMesh[]);
  95685. private _excludedMeshes;
  95686. /**
  95687. * Gets the meshes not impacted by this light.
  95688. */
  95689. get excludedMeshes(): AbstractMesh[];
  95690. /**
  95691. * Sets the meshes not impacted by this light.
  95692. */
  95693. set excludedMeshes(value: AbstractMesh[]);
  95694. private _excludeWithLayerMask;
  95695. /**
  95696. * Gets the layer id use to find what meshes are not impacted by the light.
  95697. * Inactive if 0
  95698. */
  95699. get excludeWithLayerMask(): number;
  95700. /**
  95701. * Sets the layer id use to find what meshes are not impacted by the light.
  95702. * Inactive if 0
  95703. */
  95704. set excludeWithLayerMask(value: number);
  95705. private _includeOnlyWithLayerMask;
  95706. /**
  95707. * Gets the layer id use to find what meshes are impacted by the light.
  95708. * Inactive if 0
  95709. */
  95710. get includeOnlyWithLayerMask(): number;
  95711. /**
  95712. * Sets the layer id use to find what meshes are impacted by the light.
  95713. * Inactive if 0
  95714. */
  95715. set includeOnlyWithLayerMask(value: number);
  95716. private _lightmapMode;
  95717. /**
  95718. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  95719. */
  95720. get lightmapMode(): number;
  95721. /**
  95722. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  95723. */
  95724. set lightmapMode(value: number);
  95725. /**
  95726. * Shadow generator associted to the light.
  95727. * @hidden Internal use only.
  95728. */
  95729. _shadowGenerator: Nullable<IShadowGenerator>;
  95730. /**
  95731. * @hidden Internal use only.
  95732. */
  95733. _excludedMeshesIds: string[];
  95734. /**
  95735. * @hidden Internal use only.
  95736. */
  95737. _includedOnlyMeshesIds: string[];
  95738. /**
  95739. * The current light unifom buffer.
  95740. * @hidden Internal use only.
  95741. */
  95742. _uniformBuffer: UniformBuffer;
  95743. /** @hidden */
  95744. _renderId: number;
  95745. /**
  95746. * Creates a Light object in the scene.
  95747. * Documentation : https://doc.babylonjs.com/babylon101/lights
  95748. * @param name The firendly name of the light
  95749. * @param scene The scene the light belongs too
  95750. */
  95751. constructor(name: string, scene: Scene);
  95752. protected abstract _buildUniformLayout(): void;
  95753. /**
  95754. * Sets the passed Effect "effect" with the Light information.
  95755. * @param effect The effect to update
  95756. * @param lightIndex The index of the light in the effect to update
  95757. * @returns The light
  95758. */
  95759. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  95760. /**
  95761. * Sets the passed Effect "effect" with the Light textures.
  95762. * @param effect The effect to update
  95763. * @param lightIndex The index of the light in the effect to update
  95764. * @returns The light
  95765. */
  95766. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  95767. /**
  95768. * Binds the lights information from the scene to the effect for the given mesh.
  95769. * @param lightIndex Light index
  95770. * @param scene The scene where the light belongs to
  95771. * @param effect The effect we are binding the data to
  95772. * @param useSpecular Defines if specular is supported
  95773. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  95774. */
  95775. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  95776. /**
  95777. * Sets the passed Effect "effect" with the Light information.
  95778. * @param effect The effect to update
  95779. * @param lightDataUniformName The uniform used to store light data (position or direction)
  95780. * @returns The light
  95781. */
  95782. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  95783. /**
  95784. * Returns the string "Light".
  95785. * @returns the class name
  95786. */
  95787. getClassName(): string;
  95788. /** @hidden */
  95789. readonly _isLight: boolean;
  95790. /**
  95791. * Converts the light information to a readable string for debug purpose.
  95792. * @param fullDetails Supports for multiple levels of logging within scene loading
  95793. * @returns the human readable light info
  95794. */
  95795. toString(fullDetails?: boolean): string;
  95796. /** @hidden */
  95797. protected _syncParentEnabledState(): void;
  95798. /**
  95799. * Set the enabled state of this node.
  95800. * @param value - the new enabled state
  95801. */
  95802. setEnabled(value: boolean): void;
  95803. /**
  95804. * Returns the Light associated shadow generator if any.
  95805. * @return the associated shadow generator.
  95806. */
  95807. getShadowGenerator(): Nullable<IShadowGenerator>;
  95808. /**
  95809. * Returns a Vector3, the absolute light position in the World.
  95810. * @returns the world space position of the light
  95811. */
  95812. getAbsolutePosition(): Vector3;
  95813. /**
  95814. * Specifies if the light will affect the passed mesh.
  95815. * @param mesh The mesh to test against the light
  95816. * @return true the mesh is affected otherwise, false.
  95817. */
  95818. canAffectMesh(mesh: AbstractMesh): boolean;
  95819. /**
  95820. * Sort function to order lights for rendering.
  95821. * @param a First Light object to compare to second.
  95822. * @param b Second Light object to compare first.
  95823. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  95824. */
  95825. static CompareLightsPriority(a: Light, b: Light): number;
  95826. /**
  95827. * Releases resources associated with this node.
  95828. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95829. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95830. */
  95831. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95832. /**
  95833. * Returns the light type ID (integer).
  95834. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  95835. */
  95836. getTypeID(): number;
  95837. /**
  95838. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  95839. * @returns the scaled intensity in intensity mode unit
  95840. */
  95841. getScaledIntensity(): number;
  95842. /**
  95843. * Returns a new Light object, named "name", from the current one.
  95844. * @param name The name of the cloned light
  95845. * @param newParent The parent of this light, if it has one
  95846. * @returns the new created light
  95847. */
  95848. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  95849. /**
  95850. * Serializes the current light into a Serialization object.
  95851. * @returns the serialized object.
  95852. */
  95853. serialize(): any;
  95854. /**
  95855. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  95856. * This new light is named "name" and added to the passed scene.
  95857. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  95858. * @param name The friendly name of the light
  95859. * @param scene The scene the new light will belong to
  95860. * @returns the constructor function
  95861. */
  95862. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  95863. /**
  95864. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  95865. * @param parsedLight The JSON representation of the light
  95866. * @param scene The scene to create the parsed light in
  95867. * @returns the created light after parsing
  95868. */
  95869. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  95870. private _hookArrayForExcluded;
  95871. private _hookArrayForIncludedOnly;
  95872. private _resyncMeshes;
  95873. /**
  95874. * Forces the meshes to update their light related information in their rendering used effects
  95875. * @hidden Internal Use Only
  95876. */
  95877. _markMeshesAsLightDirty(): void;
  95878. /**
  95879. * Recomputes the cached photometric scale if needed.
  95880. */
  95881. private _computePhotometricScale;
  95882. /**
  95883. * Returns the Photometric Scale according to the light type and intensity mode.
  95884. */
  95885. private _getPhotometricScale;
  95886. /**
  95887. * Reorder the light in the scene according to their defined priority.
  95888. * @hidden Internal Use Only
  95889. */
  95890. _reorderLightsInScene(): void;
  95891. /**
  95892. * Prepares the list of defines specific to the light type.
  95893. * @param defines the list of defines
  95894. * @param lightIndex defines the index of the light for the effect
  95895. */
  95896. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  95897. }
  95898. }
  95899. declare module BABYLON {
  95900. /**
  95901. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  95902. * This is the base of the follow, arc rotate cameras and Free camera
  95903. * @see http://doc.babylonjs.com/features/cameras
  95904. */
  95905. export class TargetCamera extends Camera {
  95906. private static _RigCamTransformMatrix;
  95907. private static _TargetTransformMatrix;
  95908. private static _TargetFocalPoint;
  95909. /**
  95910. * Define the current direction the camera is moving to
  95911. */
  95912. cameraDirection: Vector3;
  95913. /**
  95914. * Define the current rotation the camera is rotating to
  95915. */
  95916. cameraRotation: Vector2;
  95917. /**
  95918. * When set, the up vector of the camera will be updated by the rotation of the camera
  95919. */
  95920. updateUpVectorFromRotation: boolean;
  95921. private _tmpQuaternion;
  95922. /**
  95923. * Define the current rotation of the camera
  95924. */
  95925. rotation: Vector3;
  95926. /**
  95927. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  95928. */
  95929. rotationQuaternion: Quaternion;
  95930. /**
  95931. * Define the current speed of the camera
  95932. */
  95933. speed: number;
  95934. /**
  95935. * Add constraint to the camera to prevent it to move freely in all directions and
  95936. * around all axis.
  95937. */
  95938. noRotationConstraint: boolean;
  95939. /**
  95940. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  95941. * panning
  95942. */
  95943. invertRotation: boolean;
  95944. /**
  95945. * Speed multiplier for inverse camera panning
  95946. */
  95947. inverseRotationSpeed: number;
  95948. /**
  95949. * Define the current target of the camera as an object or a position.
  95950. */
  95951. lockedTarget: any;
  95952. /** @hidden */
  95953. _currentTarget: Vector3;
  95954. /** @hidden */
  95955. _initialFocalDistance: number;
  95956. /** @hidden */
  95957. _viewMatrix: Matrix;
  95958. /** @hidden */
  95959. _camMatrix: Matrix;
  95960. /** @hidden */
  95961. _cameraTransformMatrix: Matrix;
  95962. /** @hidden */
  95963. _cameraRotationMatrix: Matrix;
  95964. /** @hidden */
  95965. _referencePoint: Vector3;
  95966. /** @hidden */
  95967. _transformedReferencePoint: Vector3;
  95968. /** @hidden */
  95969. _reset: () => void;
  95970. private _defaultUp;
  95971. /**
  95972. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  95973. * This is the base of the follow, arc rotate cameras and Free camera
  95974. * @see http://doc.babylonjs.com/features/cameras
  95975. * @param name Defines the name of the camera in the scene
  95976. * @param position Defines the start position of the camera in the scene
  95977. * @param scene Defines the scene the camera belongs to
  95978. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95979. */
  95980. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95981. /**
  95982. * Gets the position in front of the camera at a given distance.
  95983. * @param distance The distance from the camera we want the position to be
  95984. * @returns the position
  95985. */
  95986. getFrontPosition(distance: number): Vector3;
  95987. /** @hidden */
  95988. _getLockedTargetPosition(): Nullable<Vector3>;
  95989. private _storedPosition;
  95990. private _storedRotation;
  95991. private _storedRotationQuaternion;
  95992. /**
  95993. * Store current camera state of the camera (fov, position, rotation, etc..)
  95994. * @returns the camera
  95995. */
  95996. storeState(): Camera;
  95997. /**
  95998. * Restored camera state. You must call storeState() first
  95999. * @returns whether it was successful or not
  96000. * @hidden
  96001. */
  96002. _restoreStateValues(): boolean;
  96003. /** @hidden */
  96004. _initCache(): void;
  96005. /** @hidden */
  96006. _updateCache(ignoreParentClass?: boolean): void;
  96007. /** @hidden */
  96008. _isSynchronizedViewMatrix(): boolean;
  96009. /** @hidden */
  96010. _computeLocalCameraSpeed(): number;
  96011. /**
  96012. * Defines the target the camera should look at.
  96013. * @param target Defines the new target as a Vector or a mesh
  96014. */
  96015. setTarget(target: Vector3): void;
  96016. /**
  96017. * Return the current target position of the camera. This value is expressed in local space.
  96018. * @returns the target position
  96019. */
  96020. getTarget(): Vector3;
  96021. /** @hidden */
  96022. _decideIfNeedsToMove(): boolean;
  96023. /** @hidden */
  96024. _updatePosition(): void;
  96025. /** @hidden */
  96026. _checkInputs(): void;
  96027. protected _updateCameraRotationMatrix(): void;
  96028. /**
  96029. * 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)
  96030. * @returns the current camera
  96031. */
  96032. private _rotateUpVectorWithCameraRotationMatrix;
  96033. private _cachedRotationZ;
  96034. private _cachedQuaternionRotationZ;
  96035. /** @hidden */
  96036. _getViewMatrix(): Matrix;
  96037. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  96038. /**
  96039. * @hidden
  96040. */
  96041. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  96042. /**
  96043. * @hidden
  96044. */
  96045. _updateRigCameras(): void;
  96046. private _getRigCamPositionAndTarget;
  96047. /**
  96048. * Gets the current object class name.
  96049. * @return the class name
  96050. */
  96051. getClassName(): string;
  96052. }
  96053. }
  96054. declare module BABYLON {
  96055. /**
  96056. * Gather the list of keyboard event types as constants.
  96057. */
  96058. export class KeyboardEventTypes {
  96059. /**
  96060. * The keydown event is fired when a key becomes active (pressed).
  96061. */
  96062. static readonly KEYDOWN: number;
  96063. /**
  96064. * The keyup event is fired when a key has been released.
  96065. */
  96066. static readonly KEYUP: number;
  96067. }
  96068. /**
  96069. * This class is used to store keyboard related info for the onKeyboardObservable event.
  96070. */
  96071. export class KeyboardInfo {
  96072. /**
  96073. * Defines the type of event (KeyboardEventTypes)
  96074. */
  96075. type: number;
  96076. /**
  96077. * Defines the related dom event
  96078. */
  96079. event: KeyboardEvent;
  96080. /**
  96081. * Instantiates a new keyboard info.
  96082. * This class is used to store keyboard related info for the onKeyboardObservable event.
  96083. * @param type Defines the type of event (KeyboardEventTypes)
  96084. * @param event Defines the related dom event
  96085. */
  96086. constructor(
  96087. /**
  96088. * Defines the type of event (KeyboardEventTypes)
  96089. */
  96090. type: number,
  96091. /**
  96092. * Defines the related dom event
  96093. */
  96094. event: KeyboardEvent);
  96095. }
  96096. /**
  96097. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96098. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  96099. */
  96100. export class KeyboardInfoPre extends KeyboardInfo {
  96101. /**
  96102. * Defines the type of event (KeyboardEventTypes)
  96103. */
  96104. type: number;
  96105. /**
  96106. * Defines the related dom event
  96107. */
  96108. event: KeyboardEvent;
  96109. /**
  96110. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  96111. */
  96112. skipOnPointerObservable: boolean;
  96113. /**
  96114. * Instantiates a new keyboard pre info.
  96115. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96116. * @param type Defines the type of event (KeyboardEventTypes)
  96117. * @param event Defines the related dom event
  96118. */
  96119. constructor(
  96120. /**
  96121. * Defines the type of event (KeyboardEventTypes)
  96122. */
  96123. type: number,
  96124. /**
  96125. * Defines the related dom event
  96126. */
  96127. event: KeyboardEvent);
  96128. }
  96129. }
  96130. declare module BABYLON {
  96131. /**
  96132. * Manage the keyboard inputs to control the movement of a free camera.
  96133. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96134. */
  96135. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  96136. /**
  96137. * Defines the camera the input is attached to.
  96138. */
  96139. camera: FreeCamera;
  96140. /**
  96141. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96142. */
  96143. keysUp: number[];
  96144. /**
  96145. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96146. */
  96147. keysUpward: number[];
  96148. /**
  96149. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96150. */
  96151. keysDown: number[];
  96152. /**
  96153. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96154. */
  96155. keysDownward: number[];
  96156. /**
  96157. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96158. */
  96159. keysLeft: number[];
  96160. /**
  96161. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96162. */
  96163. keysRight: number[];
  96164. private _keys;
  96165. private _onCanvasBlurObserver;
  96166. private _onKeyboardObserver;
  96167. private _engine;
  96168. private _scene;
  96169. /**
  96170. * Attach the input controls to a specific dom element to get the input from.
  96171. * @param element Defines the element the controls should be listened from
  96172. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96173. */
  96174. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96175. /**
  96176. * Detach the current controls from the specified dom element.
  96177. * @param element Defines the element to stop listening the inputs from
  96178. */
  96179. detachControl(element: Nullable<HTMLElement>): void;
  96180. /**
  96181. * Update the current camera state depending on the inputs that have been used this frame.
  96182. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96183. */
  96184. checkInputs(): void;
  96185. /**
  96186. * Gets the class name of the current intput.
  96187. * @returns the class name
  96188. */
  96189. getClassName(): string;
  96190. /** @hidden */
  96191. _onLostFocus(): void;
  96192. /**
  96193. * Get the friendly name associated with the input class.
  96194. * @returns the input friendly name
  96195. */
  96196. getSimpleName(): string;
  96197. }
  96198. }
  96199. declare module BABYLON {
  96200. /**
  96201. * Gather the list of pointer event types as constants.
  96202. */
  96203. export class PointerEventTypes {
  96204. /**
  96205. * 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.
  96206. */
  96207. static readonly POINTERDOWN: number;
  96208. /**
  96209. * The pointerup event is fired when a pointer is no longer active.
  96210. */
  96211. static readonly POINTERUP: number;
  96212. /**
  96213. * The pointermove event is fired when a pointer changes coordinates.
  96214. */
  96215. static readonly POINTERMOVE: number;
  96216. /**
  96217. * The pointerwheel event is fired when a mouse wheel has been rotated.
  96218. */
  96219. static readonly POINTERWHEEL: number;
  96220. /**
  96221. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  96222. */
  96223. static readonly POINTERPICK: number;
  96224. /**
  96225. * The pointertap event is fired when a the object has been touched and released without drag.
  96226. */
  96227. static readonly POINTERTAP: number;
  96228. /**
  96229. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  96230. */
  96231. static readonly POINTERDOUBLETAP: number;
  96232. }
  96233. /**
  96234. * Base class of pointer info types.
  96235. */
  96236. export class PointerInfoBase {
  96237. /**
  96238. * Defines the type of event (PointerEventTypes)
  96239. */
  96240. type: number;
  96241. /**
  96242. * Defines the related dom event
  96243. */
  96244. event: PointerEvent | MouseWheelEvent;
  96245. /**
  96246. * Instantiates the base class of pointers info.
  96247. * @param type Defines the type of event (PointerEventTypes)
  96248. * @param event Defines the related dom event
  96249. */
  96250. constructor(
  96251. /**
  96252. * Defines the type of event (PointerEventTypes)
  96253. */
  96254. type: number,
  96255. /**
  96256. * Defines the related dom event
  96257. */
  96258. event: PointerEvent | MouseWheelEvent);
  96259. }
  96260. /**
  96261. * This class is used to store pointer related info for the onPrePointerObservable event.
  96262. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  96263. */
  96264. export class PointerInfoPre extends PointerInfoBase {
  96265. /**
  96266. * Ray from a pointer if availible (eg. 6dof controller)
  96267. */
  96268. ray: Nullable<Ray>;
  96269. /**
  96270. * Defines the local position of the pointer on the canvas.
  96271. */
  96272. localPosition: Vector2;
  96273. /**
  96274. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  96275. */
  96276. skipOnPointerObservable: boolean;
  96277. /**
  96278. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  96279. * @param type Defines the type of event (PointerEventTypes)
  96280. * @param event Defines the related dom event
  96281. * @param localX Defines the local x coordinates of the pointer when the event occured
  96282. * @param localY Defines the local y coordinates of the pointer when the event occured
  96283. */
  96284. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  96285. }
  96286. /**
  96287. * This type contains all the data related to a pointer event in Babylon.js.
  96288. * 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.
  96289. */
  96290. export class PointerInfo extends PointerInfoBase {
  96291. /**
  96292. * Defines the picking info associated to the info (if any)\
  96293. */
  96294. pickInfo: Nullable<PickingInfo>;
  96295. /**
  96296. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  96297. * @param type Defines the type of event (PointerEventTypes)
  96298. * @param event Defines the related dom event
  96299. * @param pickInfo Defines the picking info associated to the info (if any)\
  96300. */
  96301. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  96302. /**
  96303. * Defines the picking info associated to the info (if any)\
  96304. */
  96305. pickInfo: Nullable<PickingInfo>);
  96306. }
  96307. /**
  96308. * Data relating to a touch event on the screen.
  96309. */
  96310. export interface PointerTouch {
  96311. /**
  96312. * X coordinate of touch.
  96313. */
  96314. x: number;
  96315. /**
  96316. * Y coordinate of touch.
  96317. */
  96318. y: number;
  96319. /**
  96320. * Id of touch. Unique for each finger.
  96321. */
  96322. pointerId: number;
  96323. /**
  96324. * Event type passed from DOM.
  96325. */
  96326. type: any;
  96327. }
  96328. }
  96329. declare module BABYLON {
  96330. /**
  96331. * Manage the mouse inputs to control the movement of a free camera.
  96332. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96333. */
  96334. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  96335. /**
  96336. * Define if touch is enabled in the mouse input
  96337. */
  96338. touchEnabled: boolean;
  96339. /**
  96340. * Defines the camera the input is attached to.
  96341. */
  96342. camera: FreeCamera;
  96343. /**
  96344. * Defines the buttons associated with the input to handle camera move.
  96345. */
  96346. buttons: number[];
  96347. /**
  96348. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  96349. */
  96350. angularSensibility: number;
  96351. private _pointerInput;
  96352. private _onMouseMove;
  96353. private _observer;
  96354. private previousPosition;
  96355. /**
  96356. * Observable for when a pointer move event occurs containing the move offset
  96357. */
  96358. onPointerMovedObservable: Observable<{
  96359. offsetX: number;
  96360. offsetY: number;
  96361. }>;
  96362. /**
  96363. * @hidden
  96364. * If the camera should be rotated automatically based on pointer movement
  96365. */
  96366. _allowCameraRotation: boolean;
  96367. /**
  96368. * Manage the mouse inputs to control the movement of a free camera.
  96369. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96370. * @param touchEnabled Defines if touch is enabled or not
  96371. */
  96372. constructor(
  96373. /**
  96374. * Define if touch is enabled in the mouse input
  96375. */
  96376. touchEnabled?: boolean);
  96377. /**
  96378. * Attach the input controls to a specific dom element to get the input from.
  96379. * @param element Defines the element the controls should be listened from
  96380. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96381. */
  96382. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96383. /**
  96384. * Called on JS contextmenu event.
  96385. * Override this method to provide functionality.
  96386. */
  96387. protected onContextMenu(evt: PointerEvent): void;
  96388. /**
  96389. * Detach the current controls from the specified dom element.
  96390. * @param element Defines the element to stop listening the inputs from
  96391. */
  96392. detachControl(element: Nullable<HTMLElement>): void;
  96393. /**
  96394. * Gets the class name of the current intput.
  96395. * @returns the class name
  96396. */
  96397. getClassName(): string;
  96398. /**
  96399. * Get the friendly name associated with the input class.
  96400. * @returns the input friendly name
  96401. */
  96402. getSimpleName(): string;
  96403. }
  96404. }
  96405. declare module BABYLON {
  96406. /**
  96407. * Manage the touch inputs to control the movement of a free camera.
  96408. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96409. */
  96410. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  96411. /**
  96412. * Defines the camera the input is attached to.
  96413. */
  96414. camera: FreeCamera;
  96415. /**
  96416. * Defines the touch sensibility for rotation.
  96417. * The higher the faster.
  96418. */
  96419. touchAngularSensibility: number;
  96420. /**
  96421. * Defines the touch sensibility for move.
  96422. * The higher the faster.
  96423. */
  96424. touchMoveSensibility: number;
  96425. private _offsetX;
  96426. private _offsetY;
  96427. private _pointerPressed;
  96428. private _pointerInput;
  96429. private _observer;
  96430. private _onLostFocus;
  96431. /**
  96432. * Attach the input controls to a specific dom element to get the input from.
  96433. * @param element Defines the element the controls should be listened from
  96434. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96435. */
  96436. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96437. /**
  96438. * Detach the current controls from the specified dom element.
  96439. * @param element Defines the element to stop listening the inputs from
  96440. */
  96441. detachControl(element: Nullable<HTMLElement>): void;
  96442. /**
  96443. * Update the current camera state depending on the inputs that have been used this frame.
  96444. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96445. */
  96446. checkInputs(): void;
  96447. /**
  96448. * Gets the class name of the current intput.
  96449. * @returns the class name
  96450. */
  96451. getClassName(): string;
  96452. /**
  96453. * Get the friendly name associated with the input class.
  96454. * @returns the input friendly name
  96455. */
  96456. getSimpleName(): string;
  96457. }
  96458. }
  96459. declare module BABYLON {
  96460. /**
  96461. * Default Inputs manager for the FreeCamera.
  96462. * It groups all the default supported inputs for ease of use.
  96463. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96464. */
  96465. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  96466. /**
  96467. * @hidden
  96468. */
  96469. _mouseInput: Nullable<FreeCameraMouseInput>;
  96470. /**
  96471. * Instantiates a new FreeCameraInputsManager.
  96472. * @param camera Defines the camera the inputs belong to
  96473. */
  96474. constructor(camera: FreeCamera);
  96475. /**
  96476. * Add keyboard input support to the input manager.
  96477. * @returns the current input manager
  96478. */
  96479. addKeyboard(): FreeCameraInputsManager;
  96480. /**
  96481. * Add mouse input support to the input manager.
  96482. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  96483. * @returns the current input manager
  96484. */
  96485. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  96486. /**
  96487. * Removes the mouse input support from the manager
  96488. * @returns the current input manager
  96489. */
  96490. removeMouse(): FreeCameraInputsManager;
  96491. /**
  96492. * Add touch input support to the input manager.
  96493. * @returns the current input manager
  96494. */
  96495. addTouch(): FreeCameraInputsManager;
  96496. /**
  96497. * Remove all attached input methods from a camera
  96498. */
  96499. clear(): void;
  96500. }
  96501. }
  96502. declare module BABYLON {
  96503. /**
  96504. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96505. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  96506. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96507. */
  96508. export class FreeCamera extends TargetCamera {
  96509. /**
  96510. * Define the collision ellipsoid of the camera.
  96511. * This is helpful to simulate a camera body like the player body around the camera
  96512. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  96513. */
  96514. ellipsoid: Vector3;
  96515. /**
  96516. * Define an offset for the position of the ellipsoid around the camera.
  96517. * This can be helpful to determine the center of the body near the gravity center of the body
  96518. * instead of its head.
  96519. */
  96520. ellipsoidOffset: Vector3;
  96521. /**
  96522. * Enable or disable collisions of the camera with the rest of the scene objects.
  96523. */
  96524. checkCollisions: boolean;
  96525. /**
  96526. * Enable or disable gravity on the camera.
  96527. */
  96528. applyGravity: boolean;
  96529. /**
  96530. * Define the input manager associated to the camera.
  96531. */
  96532. inputs: FreeCameraInputsManager;
  96533. /**
  96534. * Gets the input sensibility for a mouse input. (default is 2000.0)
  96535. * Higher values reduce sensitivity.
  96536. */
  96537. get angularSensibility(): number;
  96538. /**
  96539. * Sets the input sensibility for a mouse input. (default is 2000.0)
  96540. * Higher values reduce sensitivity.
  96541. */
  96542. set angularSensibility(value: number);
  96543. /**
  96544. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96545. */
  96546. get keysUp(): number[];
  96547. set keysUp(value: number[]);
  96548. /**
  96549. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96550. */
  96551. get keysUpward(): number[];
  96552. set keysUpward(value: number[]);
  96553. /**
  96554. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96555. */
  96556. get keysDown(): number[];
  96557. set keysDown(value: number[]);
  96558. /**
  96559. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96560. */
  96561. get keysDownward(): number[];
  96562. set keysDownward(value: number[]);
  96563. /**
  96564. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96565. */
  96566. get keysLeft(): number[];
  96567. set keysLeft(value: number[]);
  96568. /**
  96569. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96570. */
  96571. get keysRight(): number[];
  96572. set keysRight(value: number[]);
  96573. /**
  96574. * Event raised when the camera collide with a mesh in the scene.
  96575. */
  96576. onCollide: (collidedMesh: AbstractMesh) => void;
  96577. private _collider;
  96578. private _needMoveForGravity;
  96579. private _oldPosition;
  96580. private _diffPosition;
  96581. private _newPosition;
  96582. /** @hidden */
  96583. _localDirection: Vector3;
  96584. /** @hidden */
  96585. _transformedDirection: Vector3;
  96586. /**
  96587. * Instantiates a Free Camera.
  96588. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96589. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  96590. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96591. * @param name Define the name of the camera in the scene
  96592. * @param position Define the start position of the camera in the scene
  96593. * @param scene Define the scene the camera belongs to
  96594. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  96595. */
  96596. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96597. /**
  96598. * Attached controls to the current camera.
  96599. * @param element Defines the element the controls should be listened from
  96600. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96601. */
  96602. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96603. /**
  96604. * Detach the current controls from the camera.
  96605. * The camera will stop reacting to inputs.
  96606. * @param element Defines the element to stop listening the inputs from
  96607. */
  96608. detachControl(element: HTMLElement): void;
  96609. private _collisionMask;
  96610. /**
  96611. * Define a collision mask to limit the list of object the camera can collide with
  96612. */
  96613. get collisionMask(): number;
  96614. set collisionMask(mask: number);
  96615. /** @hidden */
  96616. _collideWithWorld(displacement: Vector3): void;
  96617. private _onCollisionPositionChange;
  96618. /** @hidden */
  96619. _checkInputs(): void;
  96620. /** @hidden */
  96621. _decideIfNeedsToMove(): boolean;
  96622. /** @hidden */
  96623. _updatePosition(): void;
  96624. /**
  96625. * Destroy the camera and release the current resources hold by it.
  96626. */
  96627. dispose(): void;
  96628. /**
  96629. * Gets the current object class name.
  96630. * @return the class name
  96631. */
  96632. getClassName(): string;
  96633. }
  96634. }
  96635. declare module BABYLON {
  96636. /**
  96637. * Represents a gamepad control stick position
  96638. */
  96639. export class StickValues {
  96640. /**
  96641. * The x component of the control stick
  96642. */
  96643. x: number;
  96644. /**
  96645. * The y component of the control stick
  96646. */
  96647. y: number;
  96648. /**
  96649. * Initializes the gamepad x and y control stick values
  96650. * @param x The x component of the gamepad control stick value
  96651. * @param y The y component of the gamepad control stick value
  96652. */
  96653. constructor(
  96654. /**
  96655. * The x component of the control stick
  96656. */
  96657. x: number,
  96658. /**
  96659. * The y component of the control stick
  96660. */
  96661. y: number);
  96662. }
  96663. /**
  96664. * An interface which manages callbacks for gamepad button changes
  96665. */
  96666. export interface GamepadButtonChanges {
  96667. /**
  96668. * Called when a gamepad has been changed
  96669. */
  96670. changed: boolean;
  96671. /**
  96672. * Called when a gamepad press event has been triggered
  96673. */
  96674. pressChanged: boolean;
  96675. /**
  96676. * Called when a touch event has been triggered
  96677. */
  96678. touchChanged: boolean;
  96679. /**
  96680. * Called when a value has changed
  96681. */
  96682. valueChanged: boolean;
  96683. }
  96684. /**
  96685. * Represents a gamepad
  96686. */
  96687. export class Gamepad {
  96688. /**
  96689. * The id of the gamepad
  96690. */
  96691. id: string;
  96692. /**
  96693. * The index of the gamepad
  96694. */
  96695. index: number;
  96696. /**
  96697. * The browser gamepad
  96698. */
  96699. browserGamepad: any;
  96700. /**
  96701. * Specifies what type of gamepad this represents
  96702. */
  96703. type: number;
  96704. private _leftStick;
  96705. private _rightStick;
  96706. /** @hidden */
  96707. _isConnected: boolean;
  96708. private _leftStickAxisX;
  96709. private _leftStickAxisY;
  96710. private _rightStickAxisX;
  96711. private _rightStickAxisY;
  96712. /**
  96713. * Triggered when the left control stick has been changed
  96714. */
  96715. private _onleftstickchanged;
  96716. /**
  96717. * Triggered when the right control stick has been changed
  96718. */
  96719. private _onrightstickchanged;
  96720. /**
  96721. * Represents a gamepad controller
  96722. */
  96723. static GAMEPAD: number;
  96724. /**
  96725. * Represents a generic controller
  96726. */
  96727. static GENERIC: number;
  96728. /**
  96729. * Represents an XBox controller
  96730. */
  96731. static XBOX: number;
  96732. /**
  96733. * Represents a pose-enabled controller
  96734. */
  96735. static POSE_ENABLED: number;
  96736. /**
  96737. * Represents an Dual Shock controller
  96738. */
  96739. static DUALSHOCK: number;
  96740. /**
  96741. * Specifies whether the left control stick should be Y-inverted
  96742. */
  96743. protected _invertLeftStickY: boolean;
  96744. /**
  96745. * Specifies if the gamepad has been connected
  96746. */
  96747. get isConnected(): boolean;
  96748. /**
  96749. * Initializes the gamepad
  96750. * @param id The id of the gamepad
  96751. * @param index The index of the gamepad
  96752. * @param browserGamepad The browser gamepad
  96753. * @param leftStickX The x component of the left joystick
  96754. * @param leftStickY The y component of the left joystick
  96755. * @param rightStickX The x component of the right joystick
  96756. * @param rightStickY The y component of the right joystick
  96757. */
  96758. constructor(
  96759. /**
  96760. * The id of the gamepad
  96761. */
  96762. id: string,
  96763. /**
  96764. * The index of the gamepad
  96765. */
  96766. index: number,
  96767. /**
  96768. * The browser gamepad
  96769. */
  96770. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  96771. /**
  96772. * Callback triggered when the left joystick has changed
  96773. * @param callback
  96774. */
  96775. onleftstickchanged(callback: (values: StickValues) => void): void;
  96776. /**
  96777. * Callback triggered when the right joystick has changed
  96778. * @param callback
  96779. */
  96780. onrightstickchanged(callback: (values: StickValues) => void): void;
  96781. /**
  96782. * Gets the left joystick
  96783. */
  96784. get leftStick(): StickValues;
  96785. /**
  96786. * Sets the left joystick values
  96787. */
  96788. set leftStick(newValues: StickValues);
  96789. /**
  96790. * Gets the right joystick
  96791. */
  96792. get rightStick(): StickValues;
  96793. /**
  96794. * Sets the right joystick value
  96795. */
  96796. set rightStick(newValues: StickValues);
  96797. /**
  96798. * Updates the gamepad joystick positions
  96799. */
  96800. update(): void;
  96801. /**
  96802. * Disposes the gamepad
  96803. */
  96804. dispose(): void;
  96805. }
  96806. /**
  96807. * Represents a generic gamepad
  96808. */
  96809. export class GenericPad extends Gamepad {
  96810. private _buttons;
  96811. private _onbuttondown;
  96812. private _onbuttonup;
  96813. /**
  96814. * Observable triggered when a button has been pressed
  96815. */
  96816. onButtonDownObservable: Observable<number>;
  96817. /**
  96818. * Observable triggered when a button has been released
  96819. */
  96820. onButtonUpObservable: Observable<number>;
  96821. /**
  96822. * Callback triggered when a button has been pressed
  96823. * @param callback Called when a button has been pressed
  96824. */
  96825. onbuttondown(callback: (buttonPressed: number) => void): void;
  96826. /**
  96827. * Callback triggered when a button has been released
  96828. * @param callback Called when a button has been released
  96829. */
  96830. onbuttonup(callback: (buttonReleased: number) => void): void;
  96831. /**
  96832. * Initializes the generic gamepad
  96833. * @param id The id of the generic gamepad
  96834. * @param index The index of the generic gamepad
  96835. * @param browserGamepad The browser gamepad
  96836. */
  96837. constructor(id: string, index: number, browserGamepad: any);
  96838. private _setButtonValue;
  96839. /**
  96840. * Updates the generic gamepad
  96841. */
  96842. update(): void;
  96843. /**
  96844. * Disposes the generic gamepad
  96845. */
  96846. dispose(): void;
  96847. }
  96848. }
  96849. declare module BABYLON {
  96850. /**
  96851. * Defines the types of pose enabled controllers that are supported
  96852. */
  96853. export enum PoseEnabledControllerType {
  96854. /**
  96855. * HTC Vive
  96856. */
  96857. VIVE = 0,
  96858. /**
  96859. * Oculus Rift
  96860. */
  96861. OCULUS = 1,
  96862. /**
  96863. * Windows mixed reality
  96864. */
  96865. WINDOWS = 2,
  96866. /**
  96867. * Samsung gear VR
  96868. */
  96869. GEAR_VR = 3,
  96870. /**
  96871. * Google Daydream
  96872. */
  96873. DAYDREAM = 4,
  96874. /**
  96875. * Generic
  96876. */
  96877. GENERIC = 5
  96878. }
  96879. /**
  96880. * Defines the MutableGamepadButton interface for the state of a gamepad button
  96881. */
  96882. export interface MutableGamepadButton {
  96883. /**
  96884. * Value of the button/trigger
  96885. */
  96886. value: number;
  96887. /**
  96888. * If the button/trigger is currently touched
  96889. */
  96890. touched: boolean;
  96891. /**
  96892. * If the button/trigger is currently pressed
  96893. */
  96894. pressed: boolean;
  96895. }
  96896. /**
  96897. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  96898. * @hidden
  96899. */
  96900. export interface ExtendedGamepadButton extends GamepadButton {
  96901. /**
  96902. * If the button/trigger is currently pressed
  96903. */
  96904. readonly pressed: boolean;
  96905. /**
  96906. * If the button/trigger is currently touched
  96907. */
  96908. readonly touched: boolean;
  96909. /**
  96910. * Value of the button/trigger
  96911. */
  96912. readonly value: number;
  96913. }
  96914. /** @hidden */
  96915. export interface _GamePadFactory {
  96916. /**
  96917. * Returns whether or not the current gamepad can be created for this type of controller.
  96918. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  96919. * @returns true if it can be created, otherwise false
  96920. */
  96921. canCreate(gamepadInfo: any): boolean;
  96922. /**
  96923. * Creates a new instance of the Gamepad.
  96924. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  96925. * @returns the new gamepad instance
  96926. */
  96927. create(gamepadInfo: any): Gamepad;
  96928. }
  96929. /**
  96930. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  96931. */
  96932. export class PoseEnabledControllerHelper {
  96933. /** @hidden */
  96934. static _ControllerFactories: _GamePadFactory[];
  96935. /** @hidden */
  96936. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  96937. /**
  96938. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  96939. * @param vrGamepad the gamepad to initialized
  96940. * @returns a vr controller of the type the gamepad identified as
  96941. */
  96942. static InitiateController(vrGamepad: any): Gamepad;
  96943. }
  96944. /**
  96945. * Defines the PoseEnabledController object that contains state of a vr capable controller
  96946. */
  96947. export class PoseEnabledController extends Gamepad implements PoseControlled {
  96948. /**
  96949. * If the controller is used in a webXR session
  96950. */
  96951. isXR: boolean;
  96952. private _deviceRoomPosition;
  96953. private _deviceRoomRotationQuaternion;
  96954. /**
  96955. * The device position in babylon space
  96956. */
  96957. devicePosition: Vector3;
  96958. /**
  96959. * The device rotation in babylon space
  96960. */
  96961. deviceRotationQuaternion: Quaternion;
  96962. /**
  96963. * The scale factor of the device in babylon space
  96964. */
  96965. deviceScaleFactor: number;
  96966. /**
  96967. * (Likely devicePosition should be used instead) The device position in its room space
  96968. */
  96969. position: Vector3;
  96970. /**
  96971. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  96972. */
  96973. rotationQuaternion: Quaternion;
  96974. /**
  96975. * The type of controller (Eg. Windows mixed reality)
  96976. */
  96977. controllerType: PoseEnabledControllerType;
  96978. protected _calculatedPosition: Vector3;
  96979. private _calculatedRotation;
  96980. /**
  96981. * The raw pose from the device
  96982. */
  96983. rawPose: DevicePose;
  96984. private _trackPosition;
  96985. private _maxRotationDistFromHeadset;
  96986. private _draggedRoomRotation;
  96987. /**
  96988. * @hidden
  96989. */
  96990. _disableTrackPosition(fixedPosition: Vector3): void;
  96991. /**
  96992. * Internal, the mesh attached to the controller
  96993. * @hidden
  96994. */
  96995. _mesh: Nullable<AbstractMesh>;
  96996. private _poseControlledCamera;
  96997. private _leftHandSystemQuaternion;
  96998. /**
  96999. * Internal, matrix used to convert room space to babylon space
  97000. * @hidden
  97001. */
  97002. _deviceToWorld: Matrix;
  97003. /**
  97004. * Node to be used when casting a ray from the controller
  97005. * @hidden
  97006. */
  97007. _pointingPoseNode: Nullable<TransformNode>;
  97008. /**
  97009. * Name of the child mesh that can be used to cast a ray from the controller
  97010. */
  97011. static readonly POINTING_POSE: string;
  97012. /**
  97013. * Creates a new PoseEnabledController from a gamepad
  97014. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  97015. */
  97016. constructor(browserGamepad: any);
  97017. private _workingMatrix;
  97018. /**
  97019. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  97020. */
  97021. update(): void;
  97022. /**
  97023. * Updates only the pose device and mesh without doing any button event checking
  97024. */
  97025. protected _updatePoseAndMesh(): void;
  97026. /**
  97027. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  97028. * @param poseData raw pose fromthe device
  97029. */
  97030. updateFromDevice(poseData: DevicePose): void;
  97031. /**
  97032. * @hidden
  97033. */
  97034. _meshAttachedObservable: Observable<AbstractMesh>;
  97035. /**
  97036. * Attaches a mesh to the controller
  97037. * @param mesh the mesh to be attached
  97038. */
  97039. attachToMesh(mesh: AbstractMesh): void;
  97040. /**
  97041. * Attaches the controllers mesh to a camera
  97042. * @param camera the camera the mesh should be attached to
  97043. */
  97044. attachToPoseControlledCamera(camera: TargetCamera): void;
  97045. /**
  97046. * Disposes of the controller
  97047. */
  97048. dispose(): void;
  97049. /**
  97050. * The mesh that is attached to the controller
  97051. */
  97052. get mesh(): Nullable<AbstractMesh>;
  97053. /**
  97054. * Gets the ray of the controller in the direction the controller is pointing
  97055. * @param length the length the resulting ray should be
  97056. * @returns a ray in the direction the controller is pointing
  97057. */
  97058. getForwardRay(length?: number): Ray;
  97059. }
  97060. }
  97061. declare module BABYLON {
  97062. /**
  97063. * Defines the WebVRController object that represents controllers tracked in 3D space
  97064. */
  97065. export abstract class WebVRController extends PoseEnabledController {
  97066. /**
  97067. * Internal, the default controller model for the controller
  97068. */
  97069. protected _defaultModel: Nullable<AbstractMesh>;
  97070. /**
  97071. * Fired when the trigger state has changed
  97072. */
  97073. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  97074. /**
  97075. * Fired when the main button state has changed
  97076. */
  97077. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97078. /**
  97079. * Fired when the secondary button state has changed
  97080. */
  97081. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97082. /**
  97083. * Fired when the pad state has changed
  97084. */
  97085. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  97086. /**
  97087. * Fired when controllers stick values have changed
  97088. */
  97089. onPadValuesChangedObservable: Observable<StickValues>;
  97090. /**
  97091. * Array of button availible on the controller
  97092. */
  97093. protected _buttons: Array<MutableGamepadButton>;
  97094. private _onButtonStateChange;
  97095. /**
  97096. * Fired when a controller button's state has changed
  97097. * @param callback the callback containing the button that was modified
  97098. */
  97099. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  97100. /**
  97101. * X and Y axis corresponding to the controllers joystick
  97102. */
  97103. pad: StickValues;
  97104. /**
  97105. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  97106. */
  97107. hand: string;
  97108. /**
  97109. * The default controller model for the controller
  97110. */
  97111. get defaultModel(): Nullable<AbstractMesh>;
  97112. /**
  97113. * Creates a new WebVRController from a gamepad
  97114. * @param vrGamepad the gamepad that the WebVRController should be created from
  97115. */
  97116. constructor(vrGamepad: any);
  97117. /**
  97118. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  97119. */
  97120. update(): void;
  97121. /**
  97122. * Function to be called when a button is modified
  97123. */
  97124. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97125. /**
  97126. * Loads a mesh and attaches it to the controller
  97127. * @param scene the scene the mesh should be added to
  97128. * @param meshLoaded callback for when the mesh has been loaded
  97129. */
  97130. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97131. private _setButtonValue;
  97132. private _changes;
  97133. private _checkChanges;
  97134. /**
  97135. * Disposes of th webVRCOntroller
  97136. */
  97137. dispose(): void;
  97138. }
  97139. }
  97140. declare module BABYLON {
  97141. /**
  97142. * The HemisphericLight simulates the ambient environment light,
  97143. * so the passed direction is the light reflection direction, not the incoming direction.
  97144. */
  97145. export class HemisphericLight extends Light {
  97146. /**
  97147. * The groundColor is the light in the opposite direction to the one specified during creation.
  97148. * 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.
  97149. */
  97150. groundColor: Color3;
  97151. /**
  97152. * The light reflection direction, not the incoming direction.
  97153. */
  97154. direction: Vector3;
  97155. /**
  97156. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  97157. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  97158. * The HemisphericLight can't cast shadows.
  97159. * Documentation : https://doc.babylonjs.com/babylon101/lights
  97160. * @param name The friendly name of the light
  97161. * @param direction The direction of the light reflection
  97162. * @param scene The scene the light belongs to
  97163. */
  97164. constructor(name: string, direction: Vector3, scene: Scene);
  97165. protected _buildUniformLayout(): void;
  97166. /**
  97167. * Returns the string "HemisphericLight".
  97168. * @return The class name
  97169. */
  97170. getClassName(): string;
  97171. /**
  97172. * Sets the HemisphericLight direction towards the passed target (Vector3).
  97173. * Returns the updated direction.
  97174. * @param target The target the direction should point to
  97175. * @return The computed direction
  97176. */
  97177. setDirectionToTarget(target: Vector3): Vector3;
  97178. /**
  97179. * Returns the shadow generator associated to the light.
  97180. * @returns Always null for hemispheric lights because it does not support shadows.
  97181. */
  97182. getShadowGenerator(): Nullable<IShadowGenerator>;
  97183. /**
  97184. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  97185. * @param effect The effect to update
  97186. * @param lightIndex The index of the light in the effect to update
  97187. * @returns The hemispheric light
  97188. */
  97189. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  97190. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  97191. /**
  97192. * Computes the world matrix of the node
  97193. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  97194. * @param useWasUpdatedFlag defines a reserved property
  97195. * @returns the world matrix
  97196. */
  97197. computeWorldMatrix(): Matrix;
  97198. /**
  97199. * Returns the integer 3.
  97200. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  97201. */
  97202. getTypeID(): number;
  97203. /**
  97204. * Prepares the list of defines specific to the light type.
  97205. * @param defines the list of defines
  97206. * @param lightIndex defines the index of the light for the effect
  97207. */
  97208. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  97209. }
  97210. }
  97211. declare module BABYLON {
  97212. /** @hidden */
  97213. export var vrMultiviewToSingleviewPixelShader: {
  97214. name: string;
  97215. shader: string;
  97216. };
  97217. }
  97218. declare module BABYLON {
  97219. /**
  97220. * Renders to multiple views with a single draw call
  97221. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  97222. */
  97223. export class MultiviewRenderTarget extends RenderTargetTexture {
  97224. /**
  97225. * Creates a multiview render target
  97226. * @param scene scene used with the render target
  97227. * @param size the size of the render target (used for each view)
  97228. */
  97229. constructor(scene: Scene, size?: number | {
  97230. width: number;
  97231. height: number;
  97232. } | {
  97233. ratio: number;
  97234. });
  97235. /**
  97236. * @hidden
  97237. * @param faceIndex the face index, if its a cube texture
  97238. */
  97239. _bindFrameBuffer(faceIndex?: number): void;
  97240. /**
  97241. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  97242. * @returns the view count
  97243. */
  97244. getViewCount(): number;
  97245. }
  97246. }
  97247. declare module BABYLON {
  97248. interface Engine {
  97249. /**
  97250. * Creates a new multiview render target
  97251. * @param width defines the width of the texture
  97252. * @param height defines the height of the texture
  97253. * @returns the created multiview texture
  97254. */
  97255. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  97256. /**
  97257. * Binds a multiview framebuffer to be drawn to
  97258. * @param multiviewTexture texture to bind
  97259. */
  97260. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  97261. }
  97262. interface Camera {
  97263. /**
  97264. * @hidden
  97265. * 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)
  97266. */
  97267. _useMultiviewToSingleView: boolean;
  97268. /**
  97269. * @hidden
  97270. * 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)
  97271. */
  97272. _multiviewTexture: Nullable<RenderTargetTexture>;
  97273. /**
  97274. * @hidden
  97275. * ensures the multiview texture of the camera exists and has the specified width/height
  97276. * @param width height to set on the multiview texture
  97277. * @param height width to set on the multiview texture
  97278. */
  97279. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  97280. }
  97281. interface Scene {
  97282. /** @hidden */
  97283. _transformMatrixR: Matrix;
  97284. /** @hidden */
  97285. _multiviewSceneUbo: Nullable<UniformBuffer>;
  97286. /** @hidden */
  97287. _createMultiviewUbo(): void;
  97288. /** @hidden */
  97289. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  97290. /** @hidden */
  97291. _renderMultiviewToSingleView(camera: Camera): void;
  97292. }
  97293. }
  97294. declare module BABYLON {
  97295. /**
  97296. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  97297. * This will not be used for webXR as it supports displaying texture arrays directly
  97298. */
  97299. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  97300. /**
  97301. * Initializes a VRMultiviewToSingleview
  97302. * @param name name of the post process
  97303. * @param camera camera to be applied to
  97304. * @param scaleFactor scaling factor to the size of the output texture
  97305. */
  97306. constructor(name: string, camera: Camera, scaleFactor: number);
  97307. }
  97308. }
  97309. declare module BABYLON {
  97310. /**
  97311. * Interface used to define additional presentation attributes
  97312. */
  97313. export interface IVRPresentationAttributes {
  97314. /**
  97315. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  97316. */
  97317. highRefreshRate: boolean;
  97318. /**
  97319. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  97320. */
  97321. foveationLevel: number;
  97322. }
  97323. interface Engine {
  97324. /** @hidden */
  97325. _vrDisplay: any;
  97326. /** @hidden */
  97327. _vrSupported: boolean;
  97328. /** @hidden */
  97329. _oldSize: Size;
  97330. /** @hidden */
  97331. _oldHardwareScaleFactor: number;
  97332. /** @hidden */
  97333. _vrExclusivePointerMode: boolean;
  97334. /** @hidden */
  97335. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  97336. /** @hidden */
  97337. _onVRDisplayPointerRestricted: () => void;
  97338. /** @hidden */
  97339. _onVRDisplayPointerUnrestricted: () => void;
  97340. /** @hidden */
  97341. _onVrDisplayConnect: Nullable<(display: any) => void>;
  97342. /** @hidden */
  97343. _onVrDisplayDisconnect: Nullable<() => void>;
  97344. /** @hidden */
  97345. _onVrDisplayPresentChange: Nullable<() => void>;
  97346. /**
  97347. * Observable signaled when VR display mode changes
  97348. */
  97349. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  97350. /**
  97351. * Observable signaled when VR request present is complete
  97352. */
  97353. onVRRequestPresentComplete: Observable<boolean>;
  97354. /**
  97355. * Observable signaled when VR request present starts
  97356. */
  97357. onVRRequestPresentStart: Observable<Engine>;
  97358. /**
  97359. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  97360. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  97361. */
  97362. isInVRExclusivePointerMode: boolean;
  97363. /**
  97364. * Gets a boolean indicating if a webVR device was detected
  97365. * @returns true if a webVR device was detected
  97366. */
  97367. isVRDevicePresent(): boolean;
  97368. /**
  97369. * Gets the current webVR device
  97370. * @returns the current webVR device (or null)
  97371. */
  97372. getVRDevice(): any;
  97373. /**
  97374. * Initializes a webVR display and starts listening to display change events
  97375. * The onVRDisplayChangedObservable will be notified upon these changes
  97376. * @returns A promise containing a VRDisplay and if vr is supported
  97377. */
  97378. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  97379. /** @hidden */
  97380. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  97381. /**
  97382. * Gets or sets the presentation attributes used to configure VR rendering
  97383. */
  97384. vrPresentationAttributes?: IVRPresentationAttributes;
  97385. /**
  97386. * Call this function to switch to webVR mode
  97387. * Will do nothing if webVR is not supported or if there is no webVR device
  97388. * @param options the webvr options provided to the camera. mainly used for multiview
  97389. * @see http://doc.babylonjs.com/how_to/webvr_camera
  97390. */
  97391. enableVR(options: WebVROptions): void;
  97392. /** @hidden */
  97393. _onVRFullScreenTriggered(): void;
  97394. }
  97395. }
  97396. declare module BABYLON {
  97397. /**
  97398. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  97399. * IMPORTANT!! The data is right-hand data.
  97400. * @export
  97401. * @interface DevicePose
  97402. */
  97403. export interface DevicePose {
  97404. /**
  97405. * The position of the device, values in array are [x,y,z].
  97406. */
  97407. readonly position: Nullable<Float32Array>;
  97408. /**
  97409. * The linearVelocity of the device, values in array are [x,y,z].
  97410. */
  97411. readonly linearVelocity: Nullable<Float32Array>;
  97412. /**
  97413. * The linearAcceleration of the device, values in array are [x,y,z].
  97414. */
  97415. readonly linearAcceleration: Nullable<Float32Array>;
  97416. /**
  97417. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  97418. */
  97419. readonly orientation: Nullable<Float32Array>;
  97420. /**
  97421. * The angularVelocity of the device, values in array are [x,y,z].
  97422. */
  97423. readonly angularVelocity: Nullable<Float32Array>;
  97424. /**
  97425. * The angularAcceleration of the device, values in array are [x,y,z].
  97426. */
  97427. readonly angularAcceleration: Nullable<Float32Array>;
  97428. }
  97429. /**
  97430. * Interface representing a pose controlled object in Babylon.
  97431. * A pose controlled object has both regular pose values as well as pose values
  97432. * from an external device such as a VR head mounted display
  97433. */
  97434. export interface PoseControlled {
  97435. /**
  97436. * The position of the object in babylon space.
  97437. */
  97438. position: Vector3;
  97439. /**
  97440. * The rotation quaternion of the object in babylon space.
  97441. */
  97442. rotationQuaternion: Quaternion;
  97443. /**
  97444. * The position of the device in babylon space.
  97445. */
  97446. devicePosition?: Vector3;
  97447. /**
  97448. * The rotation quaternion of the device in babylon space.
  97449. */
  97450. deviceRotationQuaternion: Quaternion;
  97451. /**
  97452. * The raw pose coming from the device.
  97453. */
  97454. rawPose: Nullable<DevicePose>;
  97455. /**
  97456. * The scale of the device to be used when translating from device space to babylon space.
  97457. */
  97458. deviceScaleFactor: number;
  97459. /**
  97460. * Updates the poseControlled values based on the input device pose.
  97461. * @param poseData the pose data to update the object with
  97462. */
  97463. updateFromDevice(poseData: DevicePose): void;
  97464. }
  97465. /**
  97466. * Set of options to customize the webVRCamera
  97467. */
  97468. export interface WebVROptions {
  97469. /**
  97470. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  97471. */
  97472. trackPosition?: boolean;
  97473. /**
  97474. * Sets the scale of the vrDevice in babylon space. (default: 1)
  97475. */
  97476. positionScale?: number;
  97477. /**
  97478. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  97479. */
  97480. displayName?: string;
  97481. /**
  97482. * Should the native controller meshes be initialized. (default: true)
  97483. */
  97484. controllerMeshes?: boolean;
  97485. /**
  97486. * Creating a default HemiLight only on controllers. (default: true)
  97487. */
  97488. defaultLightingOnControllers?: boolean;
  97489. /**
  97490. * If you don't want to use the default VR button of the helper. (default: false)
  97491. */
  97492. useCustomVRButton?: boolean;
  97493. /**
  97494. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  97495. */
  97496. customVRButton?: HTMLButtonElement;
  97497. /**
  97498. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  97499. */
  97500. rayLength?: number;
  97501. /**
  97502. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  97503. */
  97504. defaultHeight?: number;
  97505. /**
  97506. * If multiview should be used if availible (default: false)
  97507. */
  97508. useMultiview?: boolean;
  97509. }
  97510. /**
  97511. * This represents a WebVR camera.
  97512. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  97513. * @example http://doc.babylonjs.com/how_to/webvr_camera
  97514. */
  97515. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  97516. private webVROptions;
  97517. /**
  97518. * @hidden
  97519. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  97520. */
  97521. _vrDevice: any;
  97522. /**
  97523. * The rawPose of the vrDevice.
  97524. */
  97525. rawPose: Nullable<DevicePose>;
  97526. private _onVREnabled;
  97527. private _specsVersion;
  97528. private _attached;
  97529. private _frameData;
  97530. protected _descendants: Array<Node>;
  97531. private _deviceRoomPosition;
  97532. /** @hidden */
  97533. _deviceRoomRotationQuaternion: Quaternion;
  97534. private _standingMatrix;
  97535. /**
  97536. * Represents device position in babylon space.
  97537. */
  97538. devicePosition: Vector3;
  97539. /**
  97540. * Represents device rotation in babylon space.
  97541. */
  97542. deviceRotationQuaternion: Quaternion;
  97543. /**
  97544. * The scale of the device to be used when translating from device space to babylon space.
  97545. */
  97546. deviceScaleFactor: number;
  97547. private _deviceToWorld;
  97548. private _worldToDevice;
  97549. /**
  97550. * References to the webVR controllers for the vrDevice.
  97551. */
  97552. controllers: Array<WebVRController>;
  97553. /**
  97554. * Emits an event when a controller is attached.
  97555. */
  97556. onControllersAttachedObservable: Observable<WebVRController[]>;
  97557. /**
  97558. * Emits an event when a controller's mesh has been loaded;
  97559. */
  97560. onControllerMeshLoadedObservable: Observable<WebVRController>;
  97561. /**
  97562. * Emits an event when the HMD's pose has been updated.
  97563. */
  97564. onPoseUpdatedFromDeviceObservable: Observable<any>;
  97565. private _poseSet;
  97566. /**
  97567. * If the rig cameras be used as parent instead of this camera.
  97568. */
  97569. rigParenting: boolean;
  97570. private _lightOnControllers;
  97571. private _defaultHeight?;
  97572. /**
  97573. * Instantiates a WebVRFreeCamera.
  97574. * @param name The name of the WebVRFreeCamera
  97575. * @param position The starting anchor position for the camera
  97576. * @param scene The scene the camera belongs to
  97577. * @param webVROptions a set of customizable options for the webVRCamera
  97578. */
  97579. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  97580. /**
  97581. * Gets the device distance from the ground in meters.
  97582. * @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.
  97583. */
  97584. deviceDistanceToRoomGround(): number;
  97585. /**
  97586. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  97587. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  97588. */
  97589. useStandingMatrix(callback?: (bool: boolean) => void): void;
  97590. /**
  97591. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  97592. * @returns A promise with a boolean set to if the standing matrix is supported.
  97593. */
  97594. useStandingMatrixAsync(): Promise<boolean>;
  97595. /**
  97596. * Disposes the camera
  97597. */
  97598. dispose(): void;
  97599. /**
  97600. * Gets a vrController by name.
  97601. * @param name The name of the controller to retreive
  97602. * @returns the controller matching the name specified or null if not found
  97603. */
  97604. getControllerByName(name: string): Nullable<WebVRController>;
  97605. private _leftController;
  97606. /**
  97607. * The controller corresponding to the users left hand.
  97608. */
  97609. get leftController(): Nullable<WebVRController>;
  97610. private _rightController;
  97611. /**
  97612. * The controller corresponding to the users right hand.
  97613. */
  97614. get rightController(): Nullable<WebVRController>;
  97615. /**
  97616. * Casts a ray forward from the vrCamera's gaze.
  97617. * @param length Length of the ray (default: 100)
  97618. * @returns the ray corresponding to the gaze
  97619. */
  97620. getForwardRay(length?: number): Ray;
  97621. /**
  97622. * @hidden
  97623. * Updates the camera based on device's frame data
  97624. */
  97625. _checkInputs(): void;
  97626. /**
  97627. * Updates the poseControlled values based on the input device pose.
  97628. * @param poseData Pose coming from the device
  97629. */
  97630. updateFromDevice(poseData: DevicePose): void;
  97631. private _htmlElementAttached;
  97632. private _detachIfAttached;
  97633. /**
  97634. * WebVR's attach control will start broadcasting frames to the device.
  97635. * Note that in certain browsers (chrome for example) this function must be called
  97636. * within a user-interaction callback. Example:
  97637. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  97638. *
  97639. * @param element html element to attach the vrDevice to
  97640. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  97641. */
  97642. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97643. /**
  97644. * Detaches the camera from the html element and disables VR
  97645. *
  97646. * @param element html element to detach from
  97647. */
  97648. detachControl(element: HTMLElement): void;
  97649. /**
  97650. * @returns the name of this class
  97651. */
  97652. getClassName(): string;
  97653. /**
  97654. * Calls resetPose on the vrDisplay
  97655. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  97656. */
  97657. resetToCurrentRotation(): void;
  97658. /**
  97659. * @hidden
  97660. * Updates the rig cameras (left and right eye)
  97661. */
  97662. _updateRigCameras(): void;
  97663. private _workingVector;
  97664. private _oneVector;
  97665. private _workingMatrix;
  97666. private updateCacheCalled;
  97667. private _correctPositionIfNotTrackPosition;
  97668. /**
  97669. * @hidden
  97670. * Updates the cached values of the camera
  97671. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  97672. */
  97673. _updateCache(ignoreParentClass?: boolean): void;
  97674. /**
  97675. * @hidden
  97676. * Get current device position in babylon world
  97677. */
  97678. _computeDevicePosition(): void;
  97679. /**
  97680. * Updates the current device position and rotation in the babylon world
  97681. */
  97682. update(): void;
  97683. /**
  97684. * @hidden
  97685. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  97686. * @returns an identity matrix
  97687. */
  97688. _getViewMatrix(): Matrix;
  97689. private _tmpMatrix;
  97690. /**
  97691. * This function is called by the two RIG cameras.
  97692. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  97693. * @hidden
  97694. */
  97695. _getWebVRViewMatrix(): Matrix;
  97696. /** @hidden */
  97697. _getWebVRProjectionMatrix(): Matrix;
  97698. private _onGamepadConnectedObserver;
  97699. private _onGamepadDisconnectedObserver;
  97700. private _updateCacheWhenTrackingDisabledObserver;
  97701. /**
  97702. * Initializes the controllers and their meshes
  97703. */
  97704. initControllers(): void;
  97705. }
  97706. }
  97707. declare module BABYLON {
  97708. /**
  97709. * "Static Class" containing the most commonly used helper while dealing with material for
  97710. * rendering purpose.
  97711. *
  97712. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  97713. *
  97714. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  97715. */
  97716. export class MaterialHelper {
  97717. /**
  97718. * Bind the current view position to an effect.
  97719. * @param effect The effect to be bound
  97720. * @param scene The scene the eyes position is used from
  97721. * @param variableName name of the shader variable that will hold the eye position
  97722. */
  97723. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  97724. /**
  97725. * Helps preparing the defines values about the UVs in used in the effect.
  97726. * UVs are shared as much as we can accross channels in the shaders.
  97727. * @param texture The texture we are preparing the UVs for
  97728. * @param defines The defines to update
  97729. * @param key The channel key "diffuse", "specular"... used in the shader
  97730. */
  97731. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  97732. /**
  97733. * Binds a texture matrix value to its corrsponding uniform
  97734. * @param texture The texture to bind the matrix for
  97735. * @param uniformBuffer The uniform buffer receivin the data
  97736. * @param key The channel key "diffuse", "specular"... used in the shader
  97737. */
  97738. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  97739. /**
  97740. * Gets the current status of the fog (should it be enabled?)
  97741. * @param mesh defines the mesh to evaluate for fog support
  97742. * @param scene defines the hosting scene
  97743. * @returns true if fog must be enabled
  97744. */
  97745. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  97746. /**
  97747. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  97748. * @param mesh defines the current mesh
  97749. * @param scene defines the current scene
  97750. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  97751. * @param pointsCloud defines if point cloud rendering has to be turned on
  97752. * @param fogEnabled defines if fog has to be turned on
  97753. * @param alphaTest defines if alpha testing has to be turned on
  97754. * @param defines defines the current list of defines
  97755. */
  97756. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  97757. /**
  97758. * Helper used to prepare the list of defines associated with frame values for shader compilation
  97759. * @param scene defines the current scene
  97760. * @param engine defines the current engine
  97761. * @param defines specifies the list of active defines
  97762. * @param useInstances defines if instances have to be turned on
  97763. * @param useClipPlane defines if clip plane have to be turned on
  97764. * @param useInstances defines if instances have to be turned on
  97765. * @param useThinInstances defines if thin instances have to be turned on
  97766. */
  97767. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  97768. /**
  97769. * Prepares the defines for bones
  97770. * @param mesh The mesh containing the geometry data we will draw
  97771. * @param defines The defines to update
  97772. */
  97773. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  97774. /**
  97775. * Prepares the defines for morph targets
  97776. * @param mesh The mesh containing the geometry data we will draw
  97777. * @param defines The defines to update
  97778. */
  97779. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  97780. /**
  97781. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  97782. * @param mesh The mesh containing the geometry data we will draw
  97783. * @param defines The defines to update
  97784. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  97785. * @param useBones Precise whether bones should be used or not (override mesh info)
  97786. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  97787. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  97788. * @returns false if defines are considered not dirty and have not been checked
  97789. */
  97790. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  97791. /**
  97792. * Prepares the defines related to multiview
  97793. * @param scene The scene we are intending to draw
  97794. * @param defines The defines to update
  97795. */
  97796. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  97797. /**
  97798. * Prepares the defines related to the light information passed in parameter
  97799. * @param scene The scene we are intending to draw
  97800. * @param mesh The mesh the effect is compiling for
  97801. * @param light The light the effect is compiling for
  97802. * @param lightIndex The index of the light
  97803. * @param defines The defines to update
  97804. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  97805. * @param state Defines the current state regarding what is needed (normals, etc...)
  97806. */
  97807. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  97808. needNormals: boolean;
  97809. needRebuild: boolean;
  97810. shadowEnabled: boolean;
  97811. specularEnabled: boolean;
  97812. lightmapMode: boolean;
  97813. }): void;
  97814. /**
  97815. * Prepares the defines related to the light information passed in parameter
  97816. * @param scene The scene we are intending to draw
  97817. * @param mesh The mesh the effect is compiling for
  97818. * @param defines The defines to update
  97819. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  97820. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  97821. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  97822. * @returns true if normals will be required for the rest of the effect
  97823. */
  97824. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  97825. /**
  97826. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  97827. * @param lightIndex defines the light index
  97828. * @param uniformsList The uniform list
  97829. * @param samplersList The sampler list
  97830. * @param projectedLightTexture defines if projected texture must be used
  97831. * @param uniformBuffersList defines an optional list of uniform buffers
  97832. */
  97833. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  97834. /**
  97835. * Prepares the uniforms and samplers list to be used in the effect
  97836. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  97837. * @param samplersList The sampler list
  97838. * @param defines The defines helping in the list generation
  97839. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  97840. */
  97841. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  97842. /**
  97843. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  97844. * @param defines The defines to update while falling back
  97845. * @param fallbacks The authorized effect fallbacks
  97846. * @param maxSimultaneousLights The maximum number of lights allowed
  97847. * @param rank the current rank of the Effect
  97848. * @returns The newly affected rank
  97849. */
  97850. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  97851. private static _TmpMorphInfluencers;
  97852. /**
  97853. * Prepares the list of attributes required for morph targets according to the effect defines.
  97854. * @param attribs The current list of supported attribs
  97855. * @param mesh The mesh to prepare the morph targets attributes for
  97856. * @param influencers The number of influencers
  97857. */
  97858. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  97859. /**
  97860. * Prepares the list of attributes required for morph targets according to the effect defines.
  97861. * @param attribs The current list of supported attribs
  97862. * @param mesh The mesh to prepare the morph targets attributes for
  97863. * @param defines The current Defines of the effect
  97864. */
  97865. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  97866. /**
  97867. * Prepares the list of attributes required for bones according to the effect defines.
  97868. * @param attribs The current list of supported attribs
  97869. * @param mesh The mesh to prepare the bones attributes for
  97870. * @param defines The current Defines of the effect
  97871. * @param fallbacks The current efffect fallback strategy
  97872. */
  97873. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  97874. /**
  97875. * Check and prepare the list of attributes required for instances according to the effect defines.
  97876. * @param attribs The current list of supported attribs
  97877. * @param defines The current MaterialDefines of the effect
  97878. */
  97879. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  97880. /**
  97881. * Add the list of attributes required for instances to the attribs array.
  97882. * @param attribs The current list of supported attribs
  97883. */
  97884. static PushAttributesForInstances(attribs: string[]): void;
  97885. /**
  97886. * Binds the light information to the effect.
  97887. * @param light The light containing the generator
  97888. * @param effect The effect we are binding the data to
  97889. * @param lightIndex The light index in the effect used to render
  97890. */
  97891. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  97892. /**
  97893. * Binds the lights information from the scene to the effect for the given mesh.
  97894. * @param light Light to bind
  97895. * @param lightIndex Light index
  97896. * @param scene The scene where the light belongs to
  97897. * @param effect The effect we are binding the data to
  97898. * @param useSpecular Defines if specular is supported
  97899. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97900. */
  97901. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  97902. /**
  97903. * Binds the lights information from the scene to the effect for the given mesh.
  97904. * @param scene The scene the lights belongs to
  97905. * @param mesh The mesh we are binding the information to render
  97906. * @param effect The effect we are binding the data to
  97907. * @param defines The generated defines for the effect
  97908. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  97909. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97910. */
  97911. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  97912. private static _tempFogColor;
  97913. /**
  97914. * Binds the fog information from the scene to the effect for the given mesh.
  97915. * @param scene The scene the lights belongs to
  97916. * @param mesh The mesh we are binding the information to render
  97917. * @param effect The effect we are binding the data to
  97918. * @param linearSpace Defines if the fog effect is applied in linear space
  97919. */
  97920. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  97921. /**
  97922. * Binds the bones information from the mesh to the effect.
  97923. * @param mesh The mesh we are binding the information to render
  97924. * @param effect The effect we are binding the data to
  97925. */
  97926. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  97927. /**
  97928. * Binds the morph targets information from the mesh to the effect.
  97929. * @param abstractMesh The mesh we are binding the information to render
  97930. * @param effect The effect we are binding the data to
  97931. */
  97932. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  97933. /**
  97934. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  97935. * @param defines The generated defines used in the effect
  97936. * @param effect The effect we are binding the data to
  97937. * @param scene The scene we are willing to render with logarithmic scale for
  97938. */
  97939. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  97940. /**
  97941. * Binds the clip plane information from the scene to the effect.
  97942. * @param scene The scene the clip plane information are extracted from
  97943. * @param effect The effect we are binding the data to
  97944. */
  97945. static BindClipPlane(effect: Effect, scene: Scene): void;
  97946. }
  97947. }
  97948. declare module BABYLON {
  97949. /**
  97950. * Block used to expose an input value
  97951. */
  97952. export class InputBlock extends NodeMaterialBlock {
  97953. private _mode;
  97954. private _associatedVariableName;
  97955. private _storedValue;
  97956. private _valueCallback;
  97957. private _type;
  97958. private _animationType;
  97959. /** Gets or set a value used to limit the range of float values */
  97960. min: number;
  97961. /** Gets or set a value used to limit the range of float values */
  97962. max: number;
  97963. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  97964. isBoolean: boolean;
  97965. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  97966. matrixMode: number;
  97967. /** @hidden */
  97968. _systemValue: Nullable<NodeMaterialSystemValues>;
  97969. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  97970. visibleInInspector: boolean;
  97971. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  97972. isConstant: boolean;
  97973. /** Gets or sets the group to use to display this block in the Inspector */
  97974. groupInInspector: string;
  97975. /** Gets an observable raised when the value is changed */
  97976. onValueChangedObservable: Observable<InputBlock>;
  97977. /**
  97978. * Gets or sets the connection point type (default is float)
  97979. */
  97980. get type(): NodeMaterialBlockConnectionPointTypes;
  97981. /**
  97982. * Creates a new InputBlock
  97983. * @param name defines the block name
  97984. * @param target defines the target of that block (Vertex by default)
  97985. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  97986. */
  97987. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  97988. /**
  97989. * Gets the output component
  97990. */
  97991. get output(): NodeMaterialConnectionPoint;
  97992. /**
  97993. * Set the source of this connection point to a vertex attribute
  97994. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  97995. * @returns the current connection point
  97996. */
  97997. setAsAttribute(attributeName?: string): InputBlock;
  97998. /**
  97999. * Set the source of this connection point to a system value
  98000. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  98001. * @returns the current connection point
  98002. */
  98003. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  98004. /**
  98005. * Gets or sets the value of that point.
  98006. * Please note that this value will be ignored if valueCallback is defined
  98007. */
  98008. get value(): any;
  98009. set value(value: any);
  98010. /**
  98011. * Gets or sets a callback used to get the value of that point.
  98012. * Please note that setting this value will force the connection point to ignore the value property
  98013. */
  98014. get valueCallback(): () => any;
  98015. set valueCallback(value: () => any);
  98016. /**
  98017. * Gets or sets the associated variable name in the shader
  98018. */
  98019. get associatedVariableName(): string;
  98020. set associatedVariableName(value: string);
  98021. /** Gets or sets the type of animation applied to the input */
  98022. get animationType(): AnimatedInputBlockTypes;
  98023. set animationType(value: AnimatedInputBlockTypes);
  98024. /**
  98025. * Gets a boolean indicating that this connection point not defined yet
  98026. */
  98027. get isUndefined(): boolean;
  98028. /**
  98029. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  98030. * In this case the connection point name must be the name of the uniform to use.
  98031. * Can only be set on inputs
  98032. */
  98033. get isUniform(): boolean;
  98034. set isUniform(value: boolean);
  98035. /**
  98036. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  98037. * In this case the connection point name must be the name of the attribute to use
  98038. * Can only be set on inputs
  98039. */
  98040. get isAttribute(): boolean;
  98041. set isAttribute(value: boolean);
  98042. /**
  98043. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  98044. * Can only be set on exit points
  98045. */
  98046. get isVarying(): boolean;
  98047. set isVarying(value: boolean);
  98048. /**
  98049. * Gets a boolean indicating that the current connection point is a system value
  98050. */
  98051. get isSystemValue(): boolean;
  98052. /**
  98053. * Gets or sets the current well known value or null if not defined as a system value
  98054. */
  98055. get systemValue(): Nullable<NodeMaterialSystemValues>;
  98056. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  98057. /**
  98058. * Gets the current class name
  98059. * @returns the class name
  98060. */
  98061. getClassName(): string;
  98062. /**
  98063. * Animate the input if animationType !== None
  98064. * @param scene defines the rendering scene
  98065. */
  98066. animate(scene: Scene): void;
  98067. private _emitDefine;
  98068. initialize(state: NodeMaterialBuildState): void;
  98069. /**
  98070. * Set the input block to its default value (based on its type)
  98071. */
  98072. setDefaultValue(): void;
  98073. private _emitConstant;
  98074. /** @hidden */
  98075. get _noContextSwitch(): boolean;
  98076. private _emit;
  98077. /** @hidden */
  98078. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  98079. /** @hidden */
  98080. _transmit(effect: Effect, scene: Scene): void;
  98081. protected _buildBlock(state: NodeMaterialBuildState): void;
  98082. protected _dumpPropertiesCode(): string;
  98083. dispose(): void;
  98084. serialize(): any;
  98085. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98086. }
  98087. }
  98088. declare module BABYLON {
  98089. /**
  98090. * Enum used to define the compatibility state between two connection points
  98091. */
  98092. export enum NodeMaterialConnectionPointCompatibilityStates {
  98093. /** Points are compatibles */
  98094. Compatible = 0,
  98095. /** Points are incompatible because of their types */
  98096. TypeIncompatible = 1,
  98097. /** Points are incompatible because of their targets (vertex vs fragment) */
  98098. TargetIncompatible = 2
  98099. }
  98100. /**
  98101. * Defines the direction of a connection point
  98102. */
  98103. export enum NodeMaterialConnectionPointDirection {
  98104. /** Input */
  98105. Input = 0,
  98106. /** Output */
  98107. Output = 1
  98108. }
  98109. /**
  98110. * Defines a connection point for a block
  98111. */
  98112. export class NodeMaterialConnectionPoint {
  98113. /** @hidden */
  98114. _ownerBlock: NodeMaterialBlock;
  98115. /** @hidden */
  98116. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  98117. private _endpoints;
  98118. private _associatedVariableName;
  98119. private _direction;
  98120. /** @hidden */
  98121. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98122. /** @hidden */
  98123. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98124. private _type;
  98125. /** @hidden */
  98126. _enforceAssociatedVariableName: boolean;
  98127. /** Gets the direction of the point */
  98128. get direction(): NodeMaterialConnectionPointDirection;
  98129. /** Indicates that this connection point needs dual validation before being connected to another point */
  98130. needDualDirectionValidation: boolean;
  98131. /**
  98132. * Gets or sets the additional types supported by this connection point
  98133. */
  98134. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98135. /**
  98136. * Gets or sets the additional types excluded by this connection point
  98137. */
  98138. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98139. /**
  98140. * Observable triggered when this point is connected
  98141. */
  98142. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  98143. /**
  98144. * Gets or sets the associated variable name in the shader
  98145. */
  98146. get associatedVariableName(): string;
  98147. set associatedVariableName(value: string);
  98148. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  98149. get innerType(): NodeMaterialBlockConnectionPointTypes;
  98150. /**
  98151. * Gets or sets the connection point type (default is float)
  98152. */
  98153. get type(): NodeMaterialBlockConnectionPointTypes;
  98154. set type(value: NodeMaterialBlockConnectionPointTypes);
  98155. /**
  98156. * Gets or sets the connection point name
  98157. */
  98158. name: string;
  98159. /**
  98160. * Gets or sets the connection point name
  98161. */
  98162. displayName: string;
  98163. /**
  98164. * Gets or sets a boolean indicating that this connection point can be omitted
  98165. */
  98166. isOptional: boolean;
  98167. /**
  98168. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  98169. */
  98170. isExposedOnFrame: boolean;
  98171. /**
  98172. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  98173. */
  98174. define: string;
  98175. /** @hidden */
  98176. _prioritizeVertex: boolean;
  98177. private _target;
  98178. /** Gets or sets the target of that connection point */
  98179. get target(): NodeMaterialBlockTargets;
  98180. set target(value: NodeMaterialBlockTargets);
  98181. /**
  98182. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  98183. */
  98184. get isConnected(): boolean;
  98185. /**
  98186. * Gets a boolean indicating that the current point is connected to an input block
  98187. */
  98188. get isConnectedToInputBlock(): boolean;
  98189. /**
  98190. * Gets a the connected input block (if any)
  98191. */
  98192. get connectInputBlock(): Nullable<InputBlock>;
  98193. /** Get the other side of the connection (if any) */
  98194. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  98195. /** Get the block that owns this connection point */
  98196. get ownerBlock(): NodeMaterialBlock;
  98197. /** Get the block connected on the other side of this connection (if any) */
  98198. get sourceBlock(): Nullable<NodeMaterialBlock>;
  98199. /** Get the block connected on the endpoints of this connection (if any) */
  98200. get connectedBlocks(): Array<NodeMaterialBlock>;
  98201. /** Gets the list of connected endpoints */
  98202. get endpoints(): NodeMaterialConnectionPoint[];
  98203. /** Gets a boolean indicating if that output point is connected to at least one input */
  98204. get hasEndpoints(): boolean;
  98205. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  98206. get isConnectedInVertexShader(): boolean;
  98207. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  98208. get isConnectedInFragmentShader(): boolean;
  98209. /**
  98210. * Creates a block suitable to be used as an input for this input point.
  98211. * If null is returned, a block based on the point type will be created.
  98212. * @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
  98213. */
  98214. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98215. /**
  98216. * Creates a new connection point
  98217. * @param name defines the connection point name
  98218. * @param ownerBlock defines the block hosting this connection point
  98219. * @param direction defines the direction of the connection point
  98220. */
  98221. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  98222. /**
  98223. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  98224. * @returns the class name
  98225. */
  98226. getClassName(): string;
  98227. /**
  98228. * Gets a boolean indicating if the current point can be connected to another point
  98229. * @param connectionPoint defines the other connection point
  98230. * @returns a boolean
  98231. */
  98232. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  98233. /**
  98234. * Gets a number indicating if the current point can be connected to another point
  98235. * @param connectionPoint defines the other connection point
  98236. * @returns a number defining the compatibility state
  98237. */
  98238. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98239. /**
  98240. * Connect this point to another connection point
  98241. * @param connectionPoint defines the other connection point
  98242. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  98243. * @returns the current connection point
  98244. */
  98245. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  98246. /**
  98247. * Disconnect this point from one of his endpoint
  98248. * @param endpoint defines the other connection point
  98249. * @returns the current connection point
  98250. */
  98251. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  98252. /**
  98253. * Serializes this point in a JSON representation
  98254. * @param isInput defines if the connection point is an input (default is true)
  98255. * @returns the serialized point object
  98256. */
  98257. serialize(isInput?: boolean): any;
  98258. /**
  98259. * Release resources
  98260. */
  98261. dispose(): void;
  98262. }
  98263. }
  98264. declare module BABYLON {
  98265. /**
  98266. * Enum used to define the material modes
  98267. */
  98268. export enum NodeMaterialModes {
  98269. /** Regular material */
  98270. Material = 0,
  98271. /** For post process */
  98272. PostProcess = 1,
  98273. /** For particle system */
  98274. Particle = 2
  98275. }
  98276. }
  98277. declare module BABYLON {
  98278. /**
  98279. * Block used to read a texture from a sampler
  98280. */
  98281. export class TextureBlock extends NodeMaterialBlock {
  98282. private _defineName;
  98283. private _linearDefineName;
  98284. private _gammaDefineName;
  98285. private _tempTextureRead;
  98286. private _samplerName;
  98287. private _transformedUVName;
  98288. private _textureTransformName;
  98289. private _textureInfoName;
  98290. private _mainUVName;
  98291. private _mainUVDefineName;
  98292. private _fragmentOnly;
  98293. /**
  98294. * Gets or sets the texture associated with the node
  98295. */
  98296. texture: Nullable<Texture>;
  98297. /**
  98298. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98299. */
  98300. convertToGammaSpace: boolean;
  98301. /**
  98302. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98303. */
  98304. convertToLinearSpace: boolean;
  98305. /**
  98306. * Create a new TextureBlock
  98307. * @param name defines the block name
  98308. */
  98309. constructor(name: string, fragmentOnly?: boolean);
  98310. /**
  98311. * Gets the current class name
  98312. * @returns the class name
  98313. */
  98314. getClassName(): string;
  98315. /**
  98316. * Gets the uv input component
  98317. */
  98318. get uv(): NodeMaterialConnectionPoint;
  98319. /**
  98320. * Gets the rgba output component
  98321. */
  98322. get rgba(): NodeMaterialConnectionPoint;
  98323. /**
  98324. * Gets the rgb output component
  98325. */
  98326. get rgb(): NodeMaterialConnectionPoint;
  98327. /**
  98328. * Gets the r output component
  98329. */
  98330. get r(): NodeMaterialConnectionPoint;
  98331. /**
  98332. * Gets the g output component
  98333. */
  98334. get g(): NodeMaterialConnectionPoint;
  98335. /**
  98336. * Gets the b output component
  98337. */
  98338. get b(): NodeMaterialConnectionPoint;
  98339. /**
  98340. * Gets the a output component
  98341. */
  98342. get a(): NodeMaterialConnectionPoint;
  98343. get target(): NodeMaterialBlockTargets;
  98344. autoConfigure(material: NodeMaterial): void;
  98345. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98346. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98347. isReady(): boolean;
  98348. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98349. private get _isMixed();
  98350. private _injectVertexCode;
  98351. private _writeTextureRead;
  98352. private _writeOutput;
  98353. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98354. protected _dumpPropertiesCode(): string;
  98355. serialize(): any;
  98356. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98357. }
  98358. }
  98359. declare module BABYLON {
  98360. /** @hidden */
  98361. export var reflectionFunction: {
  98362. name: string;
  98363. shader: string;
  98364. };
  98365. }
  98366. declare module BABYLON {
  98367. /**
  98368. * Base block used to read a reflection texture from a sampler
  98369. */
  98370. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  98371. /** @hidden */
  98372. _define3DName: string;
  98373. /** @hidden */
  98374. _defineCubicName: string;
  98375. /** @hidden */
  98376. _defineExplicitName: string;
  98377. /** @hidden */
  98378. _defineProjectionName: string;
  98379. /** @hidden */
  98380. _defineLocalCubicName: string;
  98381. /** @hidden */
  98382. _defineSphericalName: string;
  98383. /** @hidden */
  98384. _definePlanarName: string;
  98385. /** @hidden */
  98386. _defineEquirectangularName: string;
  98387. /** @hidden */
  98388. _defineMirroredEquirectangularFixedName: string;
  98389. /** @hidden */
  98390. _defineEquirectangularFixedName: string;
  98391. /** @hidden */
  98392. _defineSkyboxName: string;
  98393. /** @hidden */
  98394. _defineOppositeZ: string;
  98395. /** @hidden */
  98396. _cubeSamplerName: string;
  98397. /** @hidden */
  98398. _2DSamplerName: string;
  98399. protected _positionUVWName: string;
  98400. protected _directionWName: string;
  98401. protected _reflectionVectorName: string;
  98402. /** @hidden */
  98403. _reflectionCoordsName: string;
  98404. /** @hidden */
  98405. _reflectionMatrixName: string;
  98406. protected _reflectionColorName: string;
  98407. /**
  98408. * Gets or sets the texture associated with the node
  98409. */
  98410. texture: Nullable<BaseTexture>;
  98411. /**
  98412. * Create a new ReflectionTextureBaseBlock
  98413. * @param name defines the block name
  98414. */
  98415. constructor(name: string);
  98416. /**
  98417. * Gets the current class name
  98418. * @returns the class name
  98419. */
  98420. getClassName(): string;
  98421. /**
  98422. * Gets the world position input component
  98423. */
  98424. abstract get position(): NodeMaterialConnectionPoint;
  98425. /**
  98426. * Gets the world position input component
  98427. */
  98428. abstract get worldPosition(): NodeMaterialConnectionPoint;
  98429. /**
  98430. * Gets the world normal input component
  98431. */
  98432. abstract get worldNormal(): NodeMaterialConnectionPoint;
  98433. /**
  98434. * Gets the world input component
  98435. */
  98436. abstract get world(): NodeMaterialConnectionPoint;
  98437. /**
  98438. * Gets the camera (or eye) position component
  98439. */
  98440. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  98441. /**
  98442. * Gets the view input component
  98443. */
  98444. abstract get view(): NodeMaterialConnectionPoint;
  98445. protected _getTexture(): Nullable<BaseTexture>;
  98446. autoConfigure(material: NodeMaterial): void;
  98447. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98448. isReady(): boolean;
  98449. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98450. /**
  98451. * Gets the code to inject in the vertex shader
  98452. * @param state current state of the node material building
  98453. * @returns the shader code
  98454. */
  98455. handleVertexSide(state: NodeMaterialBuildState): string;
  98456. /**
  98457. * Handles the inits for the fragment code path
  98458. * @param state node material build state
  98459. */
  98460. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  98461. /**
  98462. * Generates the reflection coords code for the fragment code path
  98463. * @param worldNormalVarName name of the world normal variable
  98464. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  98465. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  98466. * @returns the shader code
  98467. */
  98468. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  98469. /**
  98470. * Generates the reflection color code for the fragment code path
  98471. * @param lodVarName name of the lod variable
  98472. * @param swizzleLookupTexture swizzle to use for the final color variable
  98473. * @returns the shader code
  98474. */
  98475. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  98476. /**
  98477. * Generates the code corresponding to the connected output points
  98478. * @param state node material build state
  98479. * @param varName name of the variable to output
  98480. * @returns the shader code
  98481. */
  98482. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  98483. protected _buildBlock(state: NodeMaterialBuildState): this;
  98484. protected _dumpPropertiesCode(): string;
  98485. serialize(): any;
  98486. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98487. }
  98488. }
  98489. declare module BABYLON {
  98490. /**
  98491. * Defines a connection point to be used for points with a custom object type
  98492. */
  98493. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  98494. private _blockType;
  98495. private _blockName;
  98496. private _nameForCheking?;
  98497. /**
  98498. * Creates a new connection point
  98499. * @param name defines the connection point name
  98500. * @param ownerBlock defines the block hosting this connection point
  98501. * @param direction defines the direction of the connection point
  98502. */
  98503. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  98504. /**
  98505. * Gets a number indicating if the current point can be connected to another point
  98506. * @param connectionPoint defines the other connection point
  98507. * @returns a number defining the compatibility state
  98508. */
  98509. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98510. /**
  98511. * Creates a block suitable to be used as an input for this input point.
  98512. * If null is returned, a block based on the point type will be created.
  98513. * @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
  98514. */
  98515. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98516. }
  98517. }
  98518. declare module BABYLON {
  98519. /**
  98520. * Enum defining the type of properties that can be edited in the property pages in the NME
  98521. */
  98522. export enum PropertyTypeForEdition {
  98523. /** property is a boolean */
  98524. Boolean = 0,
  98525. /** property is a float */
  98526. Float = 1,
  98527. /** property is a Vector2 */
  98528. Vector2 = 2,
  98529. /** property is a list of values */
  98530. List = 3
  98531. }
  98532. /**
  98533. * Interface that defines an option in a variable of type list
  98534. */
  98535. export interface IEditablePropertyListOption {
  98536. /** label of the option */
  98537. "label": string;
  98538. /** value of the option */
  98539. "value": number;
  98540. }
  98541. /**
  98542. * Interface that defines the options available for an editable property
  98543. */
  98544. export interface IEditablePropertyOption {
  98545. /** min value */
  98546. "min"?: number;
  98547. /** max value */
  98548. "max"?: number;
  98549. /** notifiers: indicates which actions to take when the property is changed */
  98550. "notifiers"?: {
  98551. /** the material should be rebuilt */
  98552. "rebuild"?: boolean;
  98553. /** the preview should be updated */
  98554. "update"?: boolean;
  98555. };
  98556. /** list of the options for a variable of type list */
  98557. "options"?: IEditablePropertyListOption[];
  98558. }
  98559. /**
  98560. * Interface that describes an editable property
  98561. */
  98562. export interface IPropertyDescriptionForEdition {
  98563. /** name of the property */
  98564. "propertyName": string;
  98565. /** display name of the property */
  98566. "displayName": string;
  98567. /** type of the property */
  98568. "type": PropertyTypeForEdition;
  98569. /** group of the property - all properties with the same group value will be displayed in a specific section */
  98570. "groupName": string;
  98571. /** options for the property */
  98572. "options": IEditablePropertyOption;
  98573. }
  98574. /**
  98575. * Decorator that flags a property in a node material block as being editable
  98576. */
  98577. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  98578. }
  98579. declare module BABYLON {
  98580. /**
  98581. * Block used to implement the refraction part of the sub surface module of the PBR material
  98582. */
  98583. export class RefractionBlock extends NodeMaterialBlock {
  98584. /** @hidden */
  98585. _define3DName: string;
  98586. /** @hidden */
  98587. _refractionMatrixName: string;
  98588. /** @hidden */
  98589. _defineLODRefractionAlpha: string;
  98590. /** @hidden */
  98591. _defineLinearSpecularRefraction: string;
  98592. /** @hidden */
  98593. _defineOppositeZ: string;
  98594. /** @hidden */
  98595. _cubeSamplerName: string;
  98596. /** @hidden */
  98597. _2DSamplerName: string;
  98598. /** @hidden */
  98599. _vRefractionMicrosurfaceInfosName: string;
  98600. /** @hidden */
  98601. _vRefractionInfosName: string;
  98602. private _scene;
  98603. /**
  98604. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  98605. * Materials half opaque for instance using refraction could benefit from this control.
  98606. */
  98607. linkRefractionWithTransparency: boolean;
  98608. /**
  98609. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  98610. */
  98611. invertRefractionY: boolean;
  98612. /**
  98613. * Gets or sets the texture associated with the node
  98614. */
  98615. texture: Nullable<BaseTexture>;
  98616. /**
  98617. * Create a new RefractionBlock
  98618. * @param name defines the block name
  98619. */
  98620. constructor(name: string);
  98621. /**
  98622. * Gets the current class name
  98623. * @returns the class name
  98624. */
  98625. getClassName(): string;
  98626. /**
  98627. * Gets the intensity input component
  98628. */
  98629. get intensity(): NodeMaterialConnectionPoint;
  98630. /**
  98631. * Gets the index of refraction input component
  98632. */
  98633. get indexOfRefraction(): NodeMaterialConnectionPoint;
  98634. /**
  98635. * Gets the tint at distance input component
  98636. */
  98637. get tintAtDistance(): NodeMaterialConnectionPoint;
  98638. /**
  98639. * Gets the view input component
  98640. */
  98641. get view(): NodeMaterialConnectionPoint;
  98642. /**
  98643. * Gets the refraction object output component
  98644. */
  98645. get refraction(): NodeMaterialConnectionPoint;
  98646. /**
  98647. * Returns true if the block has a texture
  98648. */
  98649. get hasTexture(): boolean;
  98650. protected _getTexture(): Nullable<BaseTexture>;
  98651. autoConfigure(material: NodeMaterial): void;
  98652. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98653. isReady(): boolean;
  98654. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  98655. /**
  98656. * Gets the main code of the block (fragment side)
  98657. * @param state current state of the node material building
  98658. * @returns the shader code
  98659. */
  98660. getCode(state: NodeMaterialBuildState): string;
  98661. protected _buildBlock(state: NodeMaterialBuildState): this;
  98662. protected _dumpPropertiesCode(): string;
  98663. serialize(): any;
  98664. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98665. }
  98666. }
  98667. declare module BABYLON {
  98668. /**
  98669. * Base block used as input for post process
  98670. */
  98671. export class CurrentScreenBlock extends NodeMaterialBlock {
  98672. private _samplerName;
  98673. private _linearDefineName;
  98674. private _gammaDefineName;
  98675. private _mainUVName;
  98676. private _tempTextureRead;
  98677. /**
  98678. * Gets or sets the texture associated with the node
  98679. */
  98680. texture: Nullable<BaseTexture>;
  98681. /**
  98682. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98683. */
  98684. convertToGammaSpace: boolean;
  98685. /**
  98686. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98687. */
  98688. convertToLinearSpace: boolean;
  98689. /**
  98690. * Create a new CurrentScreenBlock
  98691. * @param name defines the block name
  98692. */
  98693. constructor(name: string);
  98694. /**
  98695. * Gets the current class name
  98696. * @returns the class name
  98697. */
  98698. getClassName(): string;
  98699. /**
  98700. * Gets the uv input component
  98701. */
  98702. get uv(): NodeMaterialConnectionPoint;
  98703. /**
  98704. * Gets the rgba output component
  98705. */
  98706. get rgba(): NodeMaterialConnectionPoint;
  98707. /**
  98708. * Gets the rgb output component
  98709. */
  98710. get rgb(): NodeMaterialConnectionPoint;
  98711. /**
  98712. * Gets the r output component
  98713. */
  98714. get r(): NodeMaterialConnectionPoint;
  98715. /**
  98716. * Gets the g output component
  98717. */
  98718. get g(): NodeMaterialConnectionPoint;
  98719. /**
  98720. * Gets the b output component
  98721. */
  98722. get b(): NodeMaterialConnectionPoint;
  98723. /**
  98724. * Gets the a output component
  98725. */
  98726. get a(): NodeMaterialConnectionPoint;
  98727. /**
  98728. * Initialize the block and prepare the context for build
  98729. * @param state defines the state that will be used for the build
  98730. */
  98731. initialize(state: NodeMaterialBuildState): void;
  98732. get target(): NodeMaterialBlockTargets;
  98733. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98734. isReady(): boolean;
  98735. private _injectVertexCode;
  98736. private _writeTextureRead;
  98737. private _writeOutput;
  98738. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98739. serialize(): any;
  98740. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98741. }
  98742. }
  98743. declare module BABYLON {
  98744. /**
  98745. * Base block used for the particle texture
  98746. */
  98747. export class ParticleTextureBlock extends NodeMaterialBlock {
  98748. private _samplerName;
  98749. private _linearDefineName;
  98750. private _gammaDefineName;
  98751. private _tempTextureRead;
  98752. /**
  98753. * Gets or sets the texture associated with the node
  98754. */
  98755. texture: Nullable<BaseTexture>;
  98756. /**
  98757. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98758. */
  98759. convertToGammaSpace: boolean;
  98760. /**
  98761. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98762. */
  98763. convertToLinearSpace: boolean;
  98764. /**
  98765. * Create a new ParticleTextureBlock
  98766. * @param name defines the block name
  98767. */
  98768. constructor(name: string);
  98769. /**
  98770. * Gets the current class name
  98771. * @returns the class name
  98772. */
  98773. getClassName(): string;
  98774. /**
  98775. * Gets the uv input component
  98776. */
  98777. get uv(): NodeMaterialConnectionPoint;
  98778. /**
  98779. * Gets the rgba output component
  98780. */
  98781. get rgba(): NodeMaterialConnectionPoint;
  98782. /**
  98783. * Gets the rgb output component
  98784. */
  98785. get rgb(): NodeMaterialConnectionPoint;
  98786. /**
  98787. * Gets the r output component
  98788. */
  98789. get r(): NodeMaterialConnectionPoint;
  98790. /**
  98791. * Gets the g output component
  98792. */
  98793. get g(): NodeMaterialConnectionPoint;
  98794. /**
  98795. * Gets the b output component
  98796. */
  98797. get b(): NodeMaterialConnectionPoint;
  98798. /**
  98799. * Gets the a output component
  98800. */
  98801. get a(): NodeMaterialConnectionPoint;
  98802. /**
  98803. * Initialize the block and prepare the context for build
  98804. * @param state defines the state that will be used for the build
  98805. */
  98806. initialize(state: NodeMaterialBuildState): void;
  98807. autoConfigure(material: NodeMaterial): void;
  98808. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98809. isReady(): boolean;
  98810. private _writeOutput;
  98811. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98812. serialize(): any;
  98813. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98814. }
  98815. }
  98816. declare module BABYLON {
  98817. /**
  98818. * Class used to store shared data between 2 NodeMaterialBuildState
  98819. */
  98820. export class NodeMaterialBuildStateSharedData {
  98821. /**
  98822. * Gets the list of emitted varyings
  98823. */
  98824. temps: string[];
  98825. /**
  98826. * Gets the list of emitted varyings
  98827. */
  98828. varyings: string[];
  98829. /**
  98830. * Gets the varying declaration string
  98831. */
  98832. varyingDeclaration: string;
  98833. /**
  98834. * Input blocks
  98835. */
  98836. inputBlocks: InputBlock[];
  98837. /**
  98838. * Input blocks
  98839. */
  98840. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  98841. /**
  98842. * Bindable blocks (Blocks that need to set data to the effect)
  98843. */
  98844. bindableBlocks: NodeMaterialBlock[];
  98845. /**
  98846. * List of blocks that can provide a compilation fallback
  98847. */
  98848. blocksWithFallbacks: NodeMaterialBlock[];
  98849. /**
  98850. * List of blocks that can provide a define update
  98851. */
  98852. blocksWithDefines: NodeMaterialBlock[];
  98853. /**
  98854. * List of blocks that can provide a repeatable content
  98855. */
  98856. repeatableContentBlocks: NodeMaterialBlock[];
  98857. /**
  98858. * List of blocks that can provide a dynamic list of uniforms
  98859. */
  98860. dynamicUniformBlocks: NodeMaterialBlock[];
  98861. /**
  98862. * List of blocks that can block the isReady function for the material
  98863. */
  98864. blockingBlocks: NodeMaterialBlock[];
  98865. /**
  98866. * Gets the list of animated inputs
  98867. */
  98868. animatedInputs: InputBlock[];
  98869. /**
  98870. * Build Id used to avoid multiple recompilations
  98871. */
  98872. buildId: number;
  98873. /** List of emitted variables */
  98874. variableNames: {
  98875. [key: string]: number;
  98876. };
  98877. /** List of emitted defines */
  98878. defineNames: {
  98879. [key: string]: number;
  98880. };
  98881. /** Should emit comments? */
  98882. emitComments: boolean;
  98883. /** Emit build activity */
  98884. verbose: boolean;
  98885. /** Gets or sets the hosting scene */
  98886. scene: Scene;
  98887. /**
  98888. * Gets the compilation hints emitted at compilation time
  98889. */
  98890. hints: {
  98891. needWorldViewMatrix: boolean;
  98892. needWorldViewProjectionMatrix: boolean;
  98893. needAlphaBlending: boolean;
  98894. needAlphaTesting: boolean;
  98895. };
  98896. /**
  98897. * List of compilation checks
  98898. */
  98899. checks: {
  98900. emitVertex: boolean;
  98901. emitFragment: boolean;
  98902. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  98903. };
  98904. /**
  98905. * Is vertex program allowed to be empty?
  98906. */
  98907. allowEmptyVertexProgram: boolean;
  98908. /** Creates a new shared data */
  98909. constructor();
  98910. /**
  98911. * Emits console errors and exceptions if there is a failing check
  98912. */
  98913. emitErrors(): void;
  98914. }
  98915. }
  98916. declare module BABYLON {
  98917. /**
  98918. * Class used to store node based material build state
  98919. */
  98920. export class NodeMaterialBuildState {
  98921. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  98922. supportUniformBuffers: boolean;
  98923. /**
  98924. * Gets the list of emitted attributes
  98925. */
  98926. attributes: string[];
  98927. /**
  98928. * Gets the list of emitted uniforms
  98929. */
  98930. uniforms: string[];
  98931. /**
  98932. * Gets the list of emitted constants
  98933. */
  98934. constants: string[];
  98935. /**
  98936. * Gets the list of emitted samplers
  98937. */
  98938. samplers: string[];
  98939. /**
  98940. * Gets the list of emitted functions
  98941. */
  98942. functions: {
  98943. [key: string]: string;
  98944. };
  98945. /**
  98946. * Gets the list of emitted extensions
  98947. */
  98948. extensions: {
  98949. [key: string]: string;
  98950. };
  98951. /**
  98952. * Gets the target of the compilation state
  98953. */
  98954. target: NodeMaterialBlockTargets;
  98955. /**
  98956. * Gets the list of emitted counters
  98957. */
  98958. counters: {
  98959. [key: string]: number;
  98960. };
  98961. /**
  98962. * Shared data between multiple NodeMaterialBuildState instances
  98963. */
  98964. sharedData: NodeMaterialBuildStateSharedData;
  98965. /** @hidden */
  98966. _vertexState: NodeMaterialBuildState;
  98967. /** @hidden */
  98968. _attributeDeclaration: string;
  98969. /** @hidden */
  98970. _uniformDeclaration: string;
  98971. /** @hidden */
  98972. _constantDeclaration: string;
  98973. /** @hidden */
  98974. _samplerDeclaration: string;
  98975. /** @hidden */
  98976. _varyingTransfer: string;
  98977. /** @hidden */
  98978. _injectAtEnd: string;
  98979. private _repeatableContentAnchorIndex;
  98980. /** @hidden */
  98981. _builtCompilationString: string;
  98982. /**
  98983. * Gets the emitted compilation strings
  98984. */
  98985. compilationString: string;
  98986. /**
  98987. * Finalize the compilation strings
  98988. * @param state defines the current compilation state
  98989. */
  98990. finalize(state: NodeMaterialBuildState): void;
  98991. /** @hidden */
  98992. get _repeatableContentAnchor(): string;
  98993. /** @hidden */
  98994. _getFreeVariableName(prefix: string): string;
  98995. /** @hidden */
  98996. _getFreeDefineName(prefix: string): string;
  98997. /** @hidden */
  98998. _excludeVariableName(name: string): void;
  98999. /** @hidden */
  99000. _emit2DSampler(name: string): void;
  99001. /** @hidden */
  99002. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  99003. /** @hidden */
  99004. _emitExtension(name: string, extension: string, define?: string): void;
  99005. /** @hidden */
  99006. _emitFunction(name: string, code: string, comments: string): void;
  99007. /** @hidden */
  99008. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  99009. replaceStrings?: {
  99010. search: RegExp;
  99011. replace: string;
  99012. }[];
  99013. repeatKey?: string;
  99014. }): string;
  99015. /** @hidden */
  99016. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  99017. repeatKey?: string;
  99018. removeAttributes?: boolean;
  99019. removeUniforms?: boolean;
  99020. removeVaryings?: boolean;
  99021. removeIfDef?: boolean;
  99022. replaceStrings?: {
  99023. search: RegExp;
  99024. replace: string;
  99025. }[];
  99026. }, storeKey?: string): void;
  99027. /** @hidden */
  99028. _registerTempVariable(name: string): boolean;
  99029. /** @hidden */
  99030. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  99031. /** @hidden */
  99032. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  99033. /** @hidden */
  99034. _emitFloat(value: number): string;
  99035. }
  99036. }
  99037. declare module BABYLON {
  99038. /**
  99039. * Helper class used to generate session unique ID
  99040. */
  99041. export class UniqueIdGenerator {
  99042. private static _UniqueIdCounter;
  99043. /**
  99044. * Gets an unique (relatively to the current scene) Id
  99045. */
  99046. static get UniqueId(): number;
  99047. }
  99048. }
  99049. declare module BABYLON {
  99050. /**
  99051. * Defines a block that can be used inside a node based material
  99052. */
  99053. export class NodeMaterialBlock {
  99054. private _buildId;
  99055. private _buildTarget;
  99056. private _target;
  99057. private _isFinalMerger;
  99058. private _isInput;
  99059. protected _isUnique: boolean;
  99060. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  99061. inputsAreExclusive: boolean;
  99062. /** @hidden */
  99063. _codeVariableName: string;
  99064. /** @hidden */
  99065. _inputs: NodeMaterialConnectionPoint[];
  99066. /** @hidden */
  99067. _outputs: NodeMaterialConnectionPoint[];
  99068. /** @hidden */
  99069. _preparationId: number;
  99070. /**
  99071. * Gets or sets the name of the block
  99072. */
  99073. name: string;
  99074. /**
  99075. * Gets or sets the unique id of the node
  99076. */
  99077. uniqueId: number;
  99078. /**
  99079. * Gets or sets the comments associated with this block
  99080. */
  99081. comments: string;
  99082. /**
  99083. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  99084. */
  99085. get isUnique(): boolean;
  99086. /**
  99087. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  99088. */
  99089. get isFinalMerger(): boolean;
  99090. /**
  99091. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  99092. */
  99093. get isInput(): boolean;
  99094. /**
  99095. * Gets or sets the build Id
  99096. */
  99097. get buildId(): number;
  99098. set buildId(value: number);
  99099. /**
  99100. * Gets or sets the target of the block
  99101. */
  99102. get target(): NodeMaterialBlockTargets;
  99103. set target(value: NodeMaterialBlockTargets);
  99104. /**
  99105. * Gets the list of input points
  99106. */
  99107. get inputs(): NodeMaterialConnectionPoint[];
  99108. /** Gets the list of output points */
  99109. get outputs(): NodeMaterialConnectionPoint[];
  99110. /**
  99111. * Find an input by its name
  99112. * @param name defines the name of the input to look for
  99113. * @returns the input or null if not found
  99114. */
  99115. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99116. /**
  99117. * Find an output by its name
  99118. * @param name defines the name of the outputto look for
  99119. * @returns the output or null if not found
  99120. */
  99121. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99122. /**
  99123. * Creates a new NodeMaterialBlock
  99124. * @param name defines the block name
  99125. * @param target defines the target of that block (Vertex by default)
  99126. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  99127. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  99128. */
  99129. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  99130. /**
  99131. * Initialize the block and prepare the context for build
  99132. * @param state defines the state that will be used for the build
  99133. */
  99134. initialize(state: NodeMaterialBuildState): void;
  99135. /**
  99136. * Bind data to effect. Will only be called for blocks with isBindable === true
  99137. * @param effect defines the effect to bind data to
  99138. * @param nodeMaterial defines the hosting NodeMaterial
  99139. * @param mesh defines the mesh that will be rendered
  99140. * @param subMesh defines the submesh that will be rendered
  99141. */
  99142. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99143. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  99144. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  99145. protected _writeFloat(value: number): string;
  99146. /**
  99147. * Gets the current class name e.g. "NodeMaterialBlock"
  99148. * @returns the class name
  99149. */
  99150. getClassName(): string;
  99151. /**
  99152. * Register a new input. Must be called inside a block constructor
  99153. * @param name defines the connection point name
  99154. * @param type defines the connection point type
  99155. * @param isOptional defines a boolean indicating that this input can be omitted
  99156. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99157. * @param point an already created connection point. If not provided, create a new one
  99158. * @returns the current block
  99159. */
  99160. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99161. /**
  99162. * Register a new output. Must be called inside a block constructor
  99163. * @param name defines the connection point name
  99164. * @param type defines the connection point type
  99165. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99166. * @param point an already created connection point. If not provided, create a new one
  99167. * @returns the current block
  99168. */
  99169. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99170. /**
  99171. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  99172. * @param forOutput defines an optional connection point to check compatibility with
  99173. * @returns the first available input or null
  99174. */
  99175. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  99176. /**
  99177. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  99178. * @param forBlock defines an optional block to check compatibility with
  99179. * @returns the first available input or null
  99180. */
  99181. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  99182. /**
  99183. * Gets the sibling of the given output
  99184. * @param current defines the current output
  99185. * @returns the next output in the list or null
  99186. */
  99187. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  99188. /**
  99189. * Connect current block with another block
  99190. * @param other defines the block to connect with
  99191. * @param options define the various options to help pick the right connections
  99192. * @returns the current block
  99193. */
  99194. connectTo(other: NodeMaterialBlock, options?: {
  99195. input?: string;
  99196. output?: string;
  99197. outputSwizzle?: string;
  99198. }): this | undefined;
  99199. protected _buildBlock(state: NodeMaterialBuildState): void;
  99200. /**
  99201. * Add uniforms, samplers and uniform buffers at compilation time
  99202. * @param state defines the state to update
  99203. * @param nodeMaterial defines the node material requesting the update
  99204. * @param defines defines the material defines to update
  99205. * @param uniformBuffers defines the list of uniform buffer names
  99206. */
  99207. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  99208. /**
  99209. * Add potential fallbacks if shader compilation fails
  99210. * @param mesh defines the mesh to be rendered
  99211. * @param fallbacks defines the current prioritized list of fallbacks
  99212. */
  99213. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  99214. /**
  99215. * Initialize defines for shader compilation
  99216. * @param mesh defines the mesh to be rendered
  99217. * @param nodeMaterial defines the node material requesting the update
  99218. * @param defines defines the material defines to update
  99219. * @param useInstances specifies that instances should be used
  99220. */
  99221. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  99222. /**
  99223. * Update defines for shader compilation
  99224. * @param mesh defines the mesh to be rendered
  99225. * @param nodeMaterial defines the node material requesting the update
  99226. * @param defines defines the material defines to update
  99227. * @param useInstances specifies that instances should be used
  99228. * @param subMesh defines which submesh to render
  99229. */
  99230. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99231. /**
  99232. * Lets the block try to connect some inputs automatically
  99233. * @param material defines the hosting NodeMaterial
  99234. */
  99235. autoConfigure(material: NodeMaterial): void;
  99236. /**
  99237. * Function called when a block is declared as repeatable content generator
  99238. * @param vertexShaderState defines the current compilation state for the vertex shader
  99239. * @param fragmentShaderState defines the current compilation state for the fragment shader
  99240. * @param mesh defines the mesh to be rendered
  99241. * @param defines defines the material defines to update
  99242. */
  99243. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  99244. /**
  99245. * Checks if the block is ready
  99246. * @param mesh defines the mesh to be rendered
  99247. * @param nodeMaterial defines the node material requesting the update
  99248. * @param defines defines the material defines to update
  99249. * @param useInstances specifies that instances should be used
  99250. * @returns true if the block is ready
  99251. */
  99252. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  99253. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  99254. private _processBuild;
  99255. /**
  99256. * Compile the current node and generate the shader code
  99257. * @param state defines the current compilation state (uniforms, samplers, current string)
  99258. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  99259. * @returns true if already built
  99260. */
  99261. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  99262. protected _inputRename(name: string): string;
  99263. protected _outputRename(name: string): string;
  99264. protected _dumpPropertiesCode(): string;
  99265. /** @hidden */
  99266. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  99267. /** @hidden */
  99268. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  99269. /**
  99270. * Clone the current block to a new identical block
  99271. * @param scene defines the hosting scene
  99272. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99273. * @returns a copy of the current block
  99274. */
  99275. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  99276. /**
  99277. * Serializes this block in a JSON representation
  99278. * @returns the serialized block object
  99279. */
  99280. serialize(): any;
  99281. /** @hidden */
  99282. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99283. private _deserializePortDisplayNamesAndExposedOnFrame;
  99284. /**
  99285. * Release resources
  99286. */
  99287. dispose(): void;
  99288. }
  99289. }
  99290. declare module BABYLON {
  99291. /**
  99292. * Base class of materials working in push mode in babylon JS
  99293. * @hidden
  99294. */
  99295. export class PushMaterial extends Material {
  99296. protected _activeEffect: Effect;
  99297. protected _normalMatrix: Matrix;
  99298. constructor(name: string, scene: Scene);
  99299. getEffect(): Effect;
  99300. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99301. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  99302. /**
  99303. * Binds the given world matrix to the active effect
  99304. *
  99305. * @param world the matrix to bind
  99306. */
  99307. bindOnlyWorldMatrix(world: Matrix): void;
  99308. /**
  99309. * Binds the given normal matrix to the active effect
  99310. *
  99311. * @param normalMatrix the matrix to bind
  99312. */
  99313. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99314. bind(world: Matrix, mesh?: Mesh): void;
  99315. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99316. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99317. }
  99318. }
  99319. declare module BABYLON {
  99320. /**
  99321. * Root class for all node material optimizers
  99322. */
  99323. export class NodeMaterialOptimizer {
  99324. /**
  99325. * Function used to optimize a NodeMaterial graph
  99326. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  99327. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  99328. */
  99329. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  99330. }
  99331. }
  99332. declare module BABYLON {
  99333. /**
  99334. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  99335. */
  99336. export class TransformBlock extends NodeMaterialBlock {
  99337. /**
  99338. * Defines the value to use to complement W value to transform it to a Vector4
  99339. */
  99340. complementW: number;
  99341. /**
  99342. * Defines the value to use to complement z value to transform it to a Vector4
  99343. */
  99344. complementZ: number;
  99345. /**
  99346. * Creates a new TransformBlock
  99347. * @param name defines the block name
  99348. */
  99349. constructor(name: string);
  99350. /**
  99351. * Gets the current class name
  99352. * @returns the class name
  99353. */
  99354. getClassName(): string;
  99355. /**
  99356. * Gets the vector input
  99357. */
  99358. get vector(): NodeMaterialConnectionPoint;
  99359. /**
  99360. * Gets the output component
  99361. */
  99362. get output(): NodeMaterialConnectionPoint;
  99363. /**
  99364. * Gets the xyz output component
  99365. */
  99366. get xyz(): NodeMaterialConnectionPoint;
  99367. /**
  99368. * Gets the matrix transform input
  99369. */
  99370. get transform(): NodeMaterialConnectionPoint;
  99371. protected _buildBlock(state: NodeMaterialBuildState): this;
  99372. /**
  99373. * Update defines for shader compilation
  99374. * @param mesh defines the mesh to be rendered
  99375. * @param nodeMaterial defines the node material requesting the update
  99376. * @param defines defines the material defines to update
  99377. * @param useInstances specifies that instances should be used
  99378. * @param subMesh defines which submesh to render
  99379. */
  99380. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99381. serialize(): any;
  99382. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99383. protected _dumpPropertiesCode(): string;
  99384. }
  99385. }
  99386. declare module BABYLON {
  99387. /**
  99388. * Block used to output the vertex position
  99389. */
  99390. export class VertexOutputBlock extends NodeMaterialBlock {
  99391. /**
  99392. * Creates a new VertexOutputBlock
  99393. * @param name defines the block name
  99394. */
  99395. constructor(name: string);
  99396. /**
  99397. * Gets the current class name
  99398. * @returns the class name
  99399. */
  99400. getClassName(): string;
  99401. /**
  99402. * Gets the vector input component
  99403. */
  99404. get vector(): NodeMaterialConnectionPoint;
  99405. protected _buildBlock(state: NodeMaterialBuildState): this;
  99406. }
  99407. }
  99408. declare module BABYLON {
  99409. /**
  99410. * Block used to output the final color
  99411. */
  99412. export class FragmentOutputBlock extends NodeMaterialBlock {
  99413. /**
  99414. * Create a new FragmentOutputBlock
  99415. * @param name defines the block name
  99416. */
  99417. constructor(name: string);
  99418. /**
  99419. * Gets the current class name
  99420. * @returns the class name
  99421. */
  99422. getClassName(): string;
  99423. /**
  99424. * Gets the rgba input component
  99425. */
  99426. get rgba(): NodeMaterialConnectionPoint;
  99427. /**
  99428. * Gets the rgb input component
  99429. */
  99430. get rgb(): NodeMaterialConnectionPoint;
  99431. /**
  99432. * Gets the a input component
  99433. */
  99434. get a(): NodeMaterialConnectionPoint;
  99435. protected _buildBlock(state: NodeMaterialBuildState): this;
  99436. }
  99437. }
  99438. declare module BABYLON {
  99439. /**
  99440. * Block used for the particle ramp gradient section
  99441. */
  99442. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  99443. /**
  99444. * Create a new ParticleRampGradientBlock
  99445. * @param name defines the block name
  99446. */
  99447. constructor(name: string);
  99448. /**
  99449. * Gets the current class name
  99450. * @returns the class name
  99451. */
  99452. getClassName(): string;
  99453. /**
  99454. * Gets the color input component
  99455. */
  99456. get color(): NodeMaterialConnectionPoint;
  99457. /**
  99458. * Gets the rampColor output component
  99459. */
  99460. get rampColor(): NodeMaterialConnectionPoint;
  99461. /**
  99462. * Initialize the block and prepare the context for build
  99463. * @param state defines the state that will be used for the build
  99464. */
  99465. initialize(state: NodeMaterialBuildState): void;
  99466. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99467. }
  99468. }
  99469. declare module BABYLON {
  99470. /**
  99471. * Block used for the particle blend multiply section
  99472. */
  99473. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  99474. /**
  99475. * Create a new ParticleBlendMultiplyBlock
  99476. * @param name defines the block name
  99477. */
  99478. constructor(name: string);
  99479. /**
  99480. * Gets the current class name
  99481. * @returns the class name
  99482. */
  99483. getClassName(): string;
  99484. /**
  99485. * Gets the color input component
  99486. */
  99487. get color(): NodeMaterialConnectionPoint;
  99488. /**
  99489. * Gets the alphaTexture input component
  99490. */
  99491. get alphaTexture(): NodeMaterialConnectionPoint;
  99492. /**
  99493. * Gets the alphaColor input component
  99494. */
  99495. get alphaColor(): NodeMaterialConnectionPoint;
  99496. /**
  99497. * Gets the blendColor output component
  99498. */
  99499. get blendColor(): NodeMaterialConnectionPoint;
  99500. /**
  99501. * Initialize the block and prepare the context for build
  99502. * @param state defines the state that will be used for the build
  99503. */
  99504. initialize(state: NodeMaterialBuildState): void;
  99505. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99506. }
  99507. }
  99508. declare module BABYLON {
  99509. /**
  99510. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  99511. */
  99512. export class VectorMergerBlock extends NodeMaterialBlock {
  99513. /**
  99514. * Create a new VectorMergerBlock
  99515. * @param name defines the block name
  99516. */
  99517. constructor(name: string);
  99518. /**
  99519. * Gets the current class name
  99520. * @returns the class name
  99521. */
  99522. getClassName(): string;
  99523. /**
  99524. * Gets the xyz component (input)
  99525. */
  99526. get xyzIn(): NodeMaterialConnectionPoint;
  99527. /**
  99528. * Gets the xy component (input)
  99529. */
  99530. get xyIn(): NodeMaterialConnectionPoint;
  99531. /**
  99532. * Gets the x component (input)
  99533. */
  99534. get x(): NodeMaterialConnectionPoint;
  99535. /**
  99536. * Gets the y component (input)
  99537. */
  99538. get y(): NodeMaterialConnectionPoint;
  99539. /**
  99540. * Gets the z component (input)
  99541. */
  99542. get z(): NodeMaterialConnectionPoint;
  99543. /**
  99544. * Gets the w component (input)
  99545. */
  99546. get w(): NodeMaterialConnectionPoint;
  99547. /**
  99548. * Gets the xyzw component (output)
  99549. */
  99550. get xyzw(): NodeMaterialConnectionPoint;
  99551. /**
  99552. * Gets the xyz component (output)
  99553. */
  99554. get xyzOut(): NodeMaterialConnectionPoint;
  99555. /**
  99556. * Gets the xy component (output)
  99557. */
  99558. get xyOut(): NodeMaterialConnectionPoint;
  99559. /**
  99560. * Gets the xy component (output)
  99561. * @deprecated Please use xyOut instead.
  99562. */
  99563. get xy(): NodeMaterialConnectionPoint;
  99564. /**
  99565. * Gets the xyz component (output)
  99566. * @deprecated Please use xyzOut instead.
  99567. */
  99568. get xyz(): NodeMaterialConnectionPoint;
  99569. protected _buildBlock(state: NodeMaterialBuildState): this;
  99570. }
  99571. }
  99572. declare module BABYLON {
  99573. /**
  99574. * Block used to remap a float from a range to a new one
  99575. */
  99576. export class RemapBlock extends NodeMaterialBlock {
  99577. /**
  99578. * Gets or sets the source range
  99579. */
  99580. sourceRange: Vector2;
  99581. /**
  99582. * Gets or sets the target range
  99583. */
  99584. targetRange: Vector2;
  99585. /**
  99586. * Creates a new RemapBlock
  99587. * @param name defines the block name
  99588. */
  99589. constructor(name: string);
  99590. /**
  99591. * Gets the current class name
  99592. * @returns the class name
  99593. */
  99594. getClassName(): string;
  99595. /**
  99596. * Gets the input component
  99597. */
  99598. get input(): NodeMaterialConnectionPoint;
  99599. /**
  99600. * Gets the source min input component
  99601. */
  99602. get sourceMin(): NodeMaterialConnectionPoint;
  99603. /**
  99604. * Gets the source max input component
  99605. */
  99606. get sourceMax(): NodeMaterialConnectionPoint;
  99607. /**
  99608. * Gets the target min input component
  99609. */
  99610. get targetMin(): NodeMaterialConnectionPoint;
  99611. /**
  99612. * Gets the target max input component
  99613. */
  99614. get targetMax(): NodeMaterialConnectionPoint;
  99615. /**
  99616. * Gets the output component
  99617. */
  99618. get output(): NodeMaterialConnectionPoint;
  99619. protected _buildBlock(state: NodeMaterialBuildState): this;
  99620. protected _dumpPropertiesCode(): string;
  99621. serialize(): any;
  99622. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99623. }
  99624. }
  99625. declare module BABYLON {
  99626. /**
  99627. * Block used to multiply 2 values
  99628. */
  99629. export class MultiplyBlock extends NodeMaterialBlock {
  99630. /**
  99631. * Creates a new MultiplyBlock
  99632. * @param name defines the block name
  99633. */
  99634. constructor(name: string);
  99635. /**
  99636. * Gets the current class name
  99637. * @returns the class name
  99638. */
  99639. getClassName(): string;
  99640. /**
  99641. * Gets the left operand input component
  99642. */
  99643. get left(): NodeMaterialConnectionPoint;
  99644. /**
  99645. * Gets the right operand input component
  99646. */
  99647. get right(): NodeMaterialConnectionPoint;
  99648. /**
  99649. * Gets the output component
  99650. */
  99651. get output(): NodeMaterialConnectionPoint;
  99652. protected _buildBlock(state: NodeMaterialBuildState): this;
  99653. }
  99654. }
  99655. declare module BABYLON {
  99656. /**
  99657. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  99658. */
  99659. export class ColorSplitterBlock extends NodeMaterialBlock {
  99660. /**
  99661. * Create a new ColorSplitterBlock
  99662. * @param name defines the block name
  99663. */
  99664. constructor(name: string);
  99665. /**
  99666. * Gets the current class name
  99667. * @returns the class name
  99668. */
  99669. getClassName(): string;
  99670. /**
  99671. * Gets the rgba component (input)
  99672. */
  99673. get rgba(): NodeMaterialConnectionPoint;
  99674. /**
  99675. * Gets the rgb component (input)
  99676. */
  99677. get rgbIn(): NodeMaterialConnectionPoint;
  99678. /**
  99679. * Gets the rgb component (output)
  99680. */
  99681. get rgbOut(): NodeMaterialConnectionPoint;
  99682. /**
  99683. * Gets the r component (output)
  99684. */
  99685. get r(): NodeMaterialConnectionPoint;
  99686. /**
  99687. * Gets the g component (output)
  99688. */
  99689. get g(): NodeMaterialConnectionPoint;
  99690. /**
  99691. * Gets the b component (output)
  99692. */
  99693. get b(): NodeMaterialConnectionPoint;
  99694. /**
  99695. * Gets the a component (output)
  99696. */
  99697. get a(): NodeMaterialConnectionPoint;
  99698. protected _inputRename(name: string): string;
  99699. protected _outputRename(name: string): string;
  99700. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99701. }
  99702. }
  99703. declare module BABYLON {
  99704. /**
  99705. * Interface used to configure the node material editor
  99706. */
  99707. export interface INodeMaterialEditorOptions {
  99708. /** Define the URl to load node editor script */
  99709. editorURL?: string;
  99710. }
  99711. /** @hidden */
  99712. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99713. NORMAL: boolean;
  99714. TANGENT: boolean;
  99715. UV1: boolean;
  99716. /** BONES */
  99717. NUM_BONE_INFLUENCERS: number;
  99718. BonesPerMesh: number;
  99719. BONETEXTURE: boolean;
  99720. /** MORPH TARGETS */
  99721. MORPHTARGETS: boolean;
  99722. MORPHTARGETS_NORMAL: boolean;
  99723. MORPHTARGETS_TANGENT: boolean;
  99724. MORPHTARGETS_UV: boolean;
  99725. NUM_MORPH_INFLUENCERS: number;
  99726. /** IMAGE PROCESSING */
  99727. IMAGEPROCESSING: boolean;
  99728. VIGNETTE: boolean;
  99729. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99730. VIGNETTEBLENDMODEOPAQUE: boolean;
  99731. TONEMAPPING: boolean;
  99732. TONEMAPPING_ACES: boolean;
  99733. CONTRAST: boolean;
  99734. EXPOSURE: boolean;
  99735. COLORCURVES: boolean;
  99736. COLORGRADING: boolean;
  99737. COLORGRADING3D: boolean;
  99738. SAMPLER3DGREENDEPTH: boolean;
  99739. SAMPLER3DBGRMAP: boolean;
  99740. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99741. /** MISC. */
  99742. BUMPDIRECTUV: number;
  99743. constructor();
  99744. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  99745. }
  99746. /**
  99747. * Class used to configure NodeMaterial
  99748. */
  99749. export interface INodeMaterialOptions {
  99750. /**
  99751. * Defines if blocks should emit comments
  99752. */
  99753. emitComments: boolean;
  99754. }
  99755. /**
  99756. * Class used to create a node based material built by assembling shader blocks
  99757. */
  99758. export class NodeMaterial extends PushMaterial {
  99759. private static _BuildIdGenerator;
  99760. private _options;
  99761. private _vertexCompilationState;
  99762. private _fragmentCompilationState;
  99763. private _sharedData;
  99764. private _buildId;
  99765. private _buildWasSuccessful;
  99766. private _cachedWorldViewMatrix;
  99767. private _cachedWorldViewProjectionMatrix;
  99768. private _optimizers;
  99769. private _animationFrame;
  99770. /** Define the Url to load node editor script */
  99771. static EditorURL: string;
  99772. /** Define the Url to load snippets */
  99773. static SnippetUrl: string;
  99774. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  99775. static IgnoreTexturesAtLoadTime: boolean;
  99776. private BJSNODEMATERIALEDITOR;
  99777. /** Get the inspector from bundle or global */
  99778. private _getGlobalNodeMaterialEditor;
  99779. /**
  99780. * Snippet ID if the material was created from the snippet server
  99781. */
  99782. snippetId: string;
  99783. /**
  99784. * Gets or sets data used by visual editor
  99785. * @see https://nme.babylonjs.com
  99786. */
  99787. editorData: any;
  99788. /**
  99789. * 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)
  99790. */
  99791. ignoreAlpha: boolean;
  99792. /**
  99793. * Defines the maximum number of lights that can be used in the material
  99794. */
  99795. maxSimultaneousLights: number;
  99796. /**
  99797. * Observable raised when the material is built
  99798. */
  99799. onBuildObservable: Observable<NodeMaterial>;
  99800. /**
  99801. * Gets or sets the root nodes of the material vertex shader
  99802. */
  99803. _vertexOutputNodes: NodeMaterialBlock[];
  99804. /**
  99805. * Gets or sets the root nodes of the material fragment (pixel) shader
  99806. */
  99807. _fragmentOutputNodes: NodeMaterialBlock[];
  99808. /** Gets or sets options to control the node material overall behavior */
  99809. get options(): INodeMaterialOptions;
  99810. set options(options: INodeMaterialOptions);
  99811. /**
  99812. * Default configuration related to image processing available in the standard Material.
  99813. */
  99814. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99815. /**
  99816. * Gets the image processing configuration used either in this material.
  99817. */
  99818. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99819. /**
  99820. * Sets the Default image processing configuration used either in the this material.
  99821. *
  99822. * If sets to null, the scene one is in use.
  99823. */
  99824. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99825. /**
  99826. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  99827. */
  99828. attachedBlocks: NodeMaterialBlock[];
  99829. /**
  99830. * Specifies the mode of the node material
  99831. * @hidden
  99832. */
  99833. _mode: NodeMaterialModes;
  99834. /**
  99835. * Gets the mode property
  99836. */
  99837. get mode(): NodeMaterialModes;
  99838. /**
  99839. * Create a new node based material
  99840. * @param name defines the material name
  99841. * @param scene defines the hosting scene
  99842. * @param options defines creation option
  99843. */
  99844. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  99845. /**
  99846. * Gets the current class name of the material e.g. "NodeMaterial"
  99847. * @returns the class name
  99848. */
  99849. getClassName(): string;
  99850. /**
  99851. * Keep track of the image processing observer to allow dispose and replace.
  99852. */
  99853. private _imageProcessingObserver;
  99854. /**
  99855. * Attaches a new image processing configuration to the Standard Material.
  99856. * @param configuration
  99857. */
  99858. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99859. /**
  99860. * Get a block by its name
  99861. * @param name defines the name of the block to retrieve
  99862. * @returns the required block or null if not found
  99863. */
  99864. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  99865. /**
  99866. * Get a block by its name
  99867. * @param predicate defines the predicate used to find the good candidate
  99868. * @returns the required block or null if not found
  99869. */
  99870. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  99871. /**
  99872. * Get an input block by its name
  99873. * @param predicate defines the predicate used to find the good candidate
  99874. * @returns the required input block or null if not found
  99875. */
  99876. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  99877. /**
  99878. * Gets the list of input blocks attached to this material
  99879. * @returns an array of InputBlocks
  99880. */
  99881. getInputBlocks(): InputBlock[];
  99882. /**
  99883. * Adds a new optimizer to the list of optimizers
  99884. * @param optimizer defines the optimizers to add
  99885. * @returns the current material
  99886. */
  99887. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99888. /**
  99889. * Remove an optimizer from the list of optimizers
  99890. * @param optimizer defines the optimizers to remove
  99891. * @returns the current material
  99892. */
  99893. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99894. /**
  99895. * Add a new block to the list of output nodes
  99896. * @param node defines the node to add
  99897. * @returns the current material
  99898. */
  99899. addOutputNode(node: NodeMaterialBlock): this;
  99900. /**
  99901. * Remove a block from the list of root nodes
  99902. * @param node defines the node to remove
  99903. * @returns the current material
  99904. */
  99905. removeOutputNode(node: NodeMaterialBlock): this;
  99906. private _addVertexOutputNode;
  99907. private _removeVertexOutputNode;
  99908. private _addFragmentOutputNode;
  99909. private _removeFragmentOutputNode;
  99910. /**
  99911. * Specifies if the material will require alpha blending
  99912. * @returns a boolean specifying if alpha blending is needed
  99913. */
  99914. needAlphaBlending(): boolean;
  99915. /**
  99916. * Specifies if this material should be rendered in alpha test mode
  99917. * @returns a boolean specifying if an alpha test is needed.
  99918. */
  99919. needAlphaTesting(): boolean;
  99920. private _initializeBlock;
  99921. private _resetDualBlocks;
  99922. /**
  99923. * Remove a block from the current node material
  99924. * @param block defines the block to remove
  99925. */
  99926. removeBlock(block: NodeMaterialBlock): void;
  99927. /**
  99928. * Build the material and generates the inner effect
  99929. * @param verbose defines if the build should log activity
  99930. */
  99931. build(verbose?: boolean): void;
  99932. /**
  99933. * Runs an otpimization phase to try to improve the shader code
  99934. */
  99935. optimize(): void;
  99936. private _prepareDefinesForAttributes;
  99937. /**
  99938. * Create a post process from the material
  99939. * @param camera The camera to apply the render pass to.
  99940. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99941. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99942. * @param engine The engine which the post process will be applied. (default: current engine)
  99943. * @param reusable If the post process can be reused on the same frame. (default: false)
  99944. * @param textureType Type of textures used when performing the post process. (default: 0)
  99945. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  99946. * @returns the post process created
  99947. */
  99948. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  99949. /**
  99950. * Create the post process effect from the material
  99951. * @param postProcess The post process to create the effect for
  99952. */
  99953. createEffectForPostProcess(postProcess: PostProcess): void;
  99954. private _createEffectOrPostProcess;
  99955. private _createEffectForParticles;
  99956. /**
  99957. * Create the effect to be used as the custom effect for a particle system
  99958. * @param particleSystem Particle system to create the effect for
  99959. * @param onCompiled defines a function to call when the effect creation is successful
  99960. * @param onError defines a function to call when the effect creation has failed
  99961. */
  99962. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99963. private _processDefines;
  99964. /**
  99965. * Get if the submesh is ready to be used and all its information available.
  99966. * Child classes can use it to update shaders
  99967. * @param mesh defines the mesh to check
  99968. * @param subMesh defines which submesh to check
  99969. * @param useInstances specifies that instances should be used
  99970. * @returns a boolean indicating that the submesh is ready or not
  99971. */
  99972. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99973. /**
  99974. * Get a string representing the shaders built by the current node graph
  99975. */
  99976. get compiledShaders(): string;
  99977. /**
  99978. * Binds the world matrix to the material
  99979. * @param world defines the world transformation matrix
  99980. */
  99981. bindOnlyWorldMatrix(world: Matrix): void;
  99982. /**
  99983. * Binds the submesh to this material by preparing the effect and shader to draw
  99984. * @param world defines the world transformation matrix
  99985. * @param mesh defines the mesh containing the submesh
  99986. * @param subMesh defines the submesh to bind the material to
  99987. */
  99988. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99989. /**
  99990. * Gets the active textures from the material
  99991. * @returns an array of textures
  99992. */
  99993. getActiveTextures(): BaseTexture[];
  99994. /**
  99995. * Gets the list of texture blocks
  99996. * @returns an array of texture blocks
  99997. */
  99998. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  99999. /**
  100000. * Specifies if the material uses a texture
  100001. * @param texture defines the texture to check against the material
  100002. * @returns a boolean specifying if the material uses the texture
  100003. */
  100004. hasTexture(texture: BaseTexture): boolean;
  100005. /**
  100006. * Disposes the material
  100007. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100008. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100009. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  100010. */
  100011. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  100012. /** Creates the node editor window. */
  100013. private _createNodeEditor;
  100014. /**
  100015. * Launch the node material editor
  100016. * @param config Define the configuration of the editor
  100017. * @return a promise fulfilled when the node editor is visible
  100018. */
  100019. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  100020. /**
  100021. * Clear the current material
  100022. */
  100023. clear(): void;
  100024. /**
  100025. * Clear the current material and set it to a default state
  100026. */
  100027. setToDefault(): void;
  100028. /**
  100029. * Clear the current material and set it to a default state for post process
  100030. */
  100031. setToDefaultPostProcess(): void;
  100032. /**
  100033. * Clear the current material and set it to a default state for particle
  100034. */
  100035. setToDefaultParticle(): void;
  100036. /**
  100037. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  100038. * @param url defines the url to load from
  100039. * @returns a promise that will fullfil when the material is fully loaded
  100040. */
  100041. loadAsync(url: string): Promise<void>;
  100042. private _gatherBlocks;
  100043. /**
  100044. * Generate a string containing the code declaration required to create an equivalent of this material
  100045. * @returns a string
  100046. */
  100047. generateCode(): string;
  100048. /**
  100049. * Serializes this material in a JSON representation
  100050. * @returns the serialized material object
  100051. */
  100052. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  100053. private _restoreConnections;
  100054. /**
  100055. * Clear the current graph and load a new one from a serialization object
  100056. * @param source defines the JSON representation of the material
  100057. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100058. */
  100059. loadFromSerialization(source: any, rootUrl?: string): void;
  100060. /**
  100061. * Makes a duplicate of the current material.
  100062. * @param name - name to use for the new material.
  100063. */
  100064. clone(name: string): NodeMaterial;
  100065. /**
  100066. * Creates a node material from parsed material data
  100067. * @param source defines the JSON representation of the material
  100068. * @param scene defines the hosting scene
  100069. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100070. * @returns a new node material
  100071. */
  100072. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  100073. /**
  100074. * Creates a node material from a snippet saved in a remote file
  100075. * @param name defines the name of the material to create
  100076. * @param url defines the url to load from
  100077. * @param scene defines the hosting scene
  100078. * @returns a promise that will resolve to the new node material
  100079. */
  100080. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  100081. /**
  100082. * Creates a node material from a snippet saved by the node material editor
  100083. * @param snippetId defines the snippet to load
  100084. * @param scene defines the hosting scene
  100085. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100086. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  100087. * @returns a promise that will resolve to the new node material
  100088. */
  100089. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  100090. /**
  100091. * Creates a new node material set to default basic configuration
  100092. * @param name defines the name of the material
  100093. * @param scene defines the hosting scene
  100094. * @returns a new NodeMaterial
  100095. */
  100096. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  100097. }
  100098. }
  100099. declare module BABYLON {
  100100. /**
  100101. * Size options for a post process
  100102. */
  100103. export type PostProcessOptions = {
  100104. width: number;
  100105. height: number;
  100106. };
  100107. /**
  100108. * PostProcess can be used to apply a shader to a texture after it has been rendered
  100109. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  100110. */
  100111. export class PostProcess {
  100112. /** Name of the PostProcess. */
  100113. name: string;
  100114. /**
  100115. * Gets or sets the unique id of the post process
  100116. */
  100117. uniqueId: number;
  100118. /**
  100119. * Width of the texture to apply the post process on
  100120. */
  100121. width: number;
  100122. /**
  100123. * Height of the texture to apply the post process on
  100124. */
  100125. height: number;
  100126. /**
  100127. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  100128. */
  100129. nodeMaterialSource: Nullable<NodeMaterial>;
  100130. /**
  100131. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  100132. * @hidden
  100133. */
  100134. _outputTexture: Nullable<InternalTexture>;
  100135. /**
  100136. * Sampling mode used by the shader
  100137. * See https://doc.babylonjs.com/classes/3.1/texture
  100138. */
  100139. renderTargetSamplingMode: number;
  100140. /**
  100141. * Clear color to use when screen clearing
  100142. */
  100143. clearColor: Color4;
  100144. /**
  100145. * If the buffer needs to be cleared before applying the post process. (default: true)
  100146. * Should be set to false if shader will overwrite all previous pixels.
  100147. */
  100148. autoClear: boolean;
  100149. /**
  100150. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  100151. */
  100152. alphaMode: number;
  100153. /**
  100154. * Sets the setAlphaBlendConstants of the babylon engine
  100155. */
  100156. alphaConstants: Color4;
  100157. /**
  100158. * Animations to be used for the post processing
  100159. */
  100160. animations: Animation[];
  100161. /**
  100162. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  100163. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  100164. */
  100165. enablePixelPerfectMode: boolean;
  100166. /**
  100167. * Force the postprocess to be applied without taking in account viewport
  100168. */
  100169. forceFullscreenViewport: boolean;
  100170. /**
  100171. * List of inspectable custom properties (used by the Inspector)
  100172. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100173. */
  100174. inspectableCustomProperties: IInspectable[];
  100175. /**
  100176. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  100177. *
  100178. * | Value | Type | Description |
  100179. * | ----- | ----------------------------------- | ----------- |
  100180. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  100181. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  100182. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  100183. *
  100184. */
  100185. scaleMode: number;
  100186. /**
  100187. * Force textures to be a power of two (default: false)
  100188. */
  100189. alwaysForcePOT: boolean;
  100190. private _samples;
  100191. /**
  100192. * Number of sample textures (default: 1)
  100193. */
  100194. get samples(): number;
  100195. set samples(n: number);
  100196. /**
  100197. * Modify the scale of the post process to be the same as the viewport (default: false)
  100198. */
  100199. adaptScaleToCurrentViewport: boolean;
  100200. private _camera;
  100201. private _scene;
  100202. private _engine;
  100203. private _options;
  100204. private _reusable;
  100205. private _textureType;
  100206. private _textureFormat;
  100207. /**
  100208. * Smart array of input and output textures for the post process.
  100209. * @hidden
  100210. */
  100211. _textures: SmartArray<InternalTexture>;
  100212. /**
  100213. * The index in _textures that corresponds to the output texture.
  100214. * @hidden
  100215. */
  100216. _currentRenderTextureInd: number;
  100217. private _effect;
  100218. private _samplers;
  100219. private _fragmentUrl;
  100220. private _vertexUrl;
  100221. private _parameters;
  100222. private _scaleRatio;
  100223. protected _indexParameters: any;
  100224. private _shareOutputWithPostProcess;
  100225. private _texelSize;
  100226. private _forcedOutputTexture;
  100227. /**
  100228. * Returns the fragment url or shader name used in the post process.
  100229. * @returns the fragment url or name in the shader store.
  100230. */
  100231. getEffectName(): string;
  100232. /**
  100233. * An event triggered when the postprocess is activated.
  100234. */
  100235. onActivateObservable: Observable<Camera>;
  100236. private _onActivateObserver;
  100237. /**
  100238. * A function that is added to the onActivateObservable
  100239. */
  100240. set onActivate(callback: Nullable<(camera: Camera) => void>);
  100241. /**
  100242. * An event triggered when the postprocess changes its size.
  100243. */
  100244. onSizeChangedObservable: Observable<PostProcess>;
  100245. private _onSizeChangedObserver;
  100246. /**
  100247. * A function that is added to the onSizeChangedObservable
  100248. */
  100249. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  100250. /**
  100251. * An event triggered when the postprocess applies its effect.
  100252. */
  100253. onApplyObservable: Observable<Effect>;
  100254. private _onApplyObserver;
  100255. /**
  100256. * A function that is added to the onApplyObservable
  100257. */
  100258. set onApply(callback: (effect: Effect) => void);
  100259. /**
  100260. * An event triggered before rendering the postprocess
  100261. */
  100262. onBeforeRenderObservable: Observable<Effect>;
  100263. private _onBeforeRenderObserver;
  100264. /**
  100265. * A function that is added to the onBeforeRenderObservable
  100266. */
  100267. set onBeforeRender(callback: (effect: Effect) => void);
  100268. /**
  100269. * An event triggered after rendering the postprocess
  100270. */
  100271. onAfterRenderObservable: Observable<Effect>;
  100272. private _onAfterRenderObserver;
  100273. /**
  100274. * A function that is added to the onAfterRenderObservable
  100275. */
  100276. set onAfterRender(callback: (efect: Effect) => void);
  100277. /**
  100278. * 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
  100279. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  100280. */
  100281. get inputTexture(): InternalTexture;
  100282. set inputTexture(value: InternalTexture);
  100283. /**
  100284. * Gets the camera which post process is applied to.
  100285. * @returns The camera the post process is applied to.
  100286. */
  100287. getCamera(): Camera;
  100288. /**
  100289. * Gets the texel size of the postprocess.
  100290. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  100291. */
  100292. get texelSize(): Vector2;
  100293. /**
  100294. * Creates a new instance PostProcess
  100295. * @param name The name of the PostProcess.
  100296. * @param fragmentUrl The url of the fragment shader to be used.
  100297. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  100298. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  100299. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100300. * @param camera The camera to apply the render pass to.
  100301. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100302. * @param engine The engine which the post process will be applied. (default: current engine)
  100303. * @param reusable If the post process can be reused on the same frame. (default: false)
  100304. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  100305. * @param textureType Type of textures used when performing the post process. (default: 0)
  100306. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  100307. * @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
  100308. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  100309. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  100310. */
  100311. constructor(
  100312. /** Name of the PostProcess. */
  100313. 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);
  100314. /**
  100315. * Gets a string idenfifying the name of the class
  100316. * @returns "PostProcess" string
  100317. */
  100318. getClassName(): string;
  100319. /**
  100320. * Gets the engine which this post process belongs to.
  100321. * @returns The engine the post process was enabled with.
  100322. */
  100323. getEngine(): Engine;
  100324. /**
  100325. * The effect that is created when initializing the post process.
  100326. * @returns The created effect corresponding the the postprocess.
  100327. */
  100328. getEffect(): Effect;
  100329. /**
  100330. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  100331. * @param postProcess The post process to share the output with.
  100332. * @returns This post process.
  100333. */
  100334. shareOutputWith(postProcess: PostProcess): PostProcess;
  100335. /**
  100336. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  100337. * This should be called if the post process that shares output with this post process is disabled/disposed.
  100338. */
  100339. useOwnOutput(): void;
  100340. /**
  100341. * Updates the effect with the current post process compile time values and recompiles the shader.
  100342. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  100343. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  100344. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  100345. * @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
  100346. * @param onCompiled Called when the shader has been compiled.
  100347. * @param onError Called if there is an error when compiling a shader.
  100348. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  100349. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  100350. */
  100351. 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;
  100352. /**
  100353. * The post process is reusable if it can be used multiple times within one frame.
  100354. * @returns If the post process is reusable
  100355. */
  100356. isReusable(): boolean;
  100357. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  100358. markTextureDirty(): void;
  100359. /**
  100360. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  100361. * 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.
  100362. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  100363. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  100364. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  100365. * @returns The target texture that was bound to be written to.
  100366. */
  100367. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  100368. /**
  100369. * If the post process is supported.
  100370. */
  100371. get isSupported(): boolean;
  100372. /**
  100373. * The aspect ratio of the output texture.
  100374. */
  100375. get aspectRatio(): number;
  100376. /**
  100377. * Get a value indicating if the post-process is ready to be used
  100378. * @returns true if the post-process is ready (shader is compiled)
  100379. */
  100380. isReady(): boolean;
  100381. /**
  100382. * Binds all textures and uniforms to the shader, this will be run on every pass.
  100383. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  100384. */
  100385. apply(): Nullable<Effect>;
  100386. private _disposeTextures;
  100387. /**
  100388. * Disposes the post process.
  100389. * @param camera The camera to dispose the post process on.
  100390. */
  100391. dispose(camera?: Camera): void;
  100392. }
  100393. }
  100394. declare module BABYLON {
  100395. /** @hidden */
  100396. export var kernelBlurVaryingDeclaration: {
  100397. name: string;
  100398. shader: string;
  100399. };
  100400. }
  100401. declare module BABYLON {
  100402. /** @hidden */
  100403. export var kernelBlurFragment: {
  100404. name: string;
  100405. shader: string;
  100406. };
  100407. }
  100408. declare module BABYLON {
  100409. /** @hidden */
  100410. export var kernelBlurFragment2: {
  100411. name: string;
  100412. shader: string;
  100413. };
  100414. }
  100415. declare module BABYLON {
  100416. /** @hidden */
  100417. export var kernelBlurPixelShader: {
  100418. name: string;
  100419. shader: string;
  100420. };
  100421. }
  100422. declare module BABYLON {
  100423. /** @hidden */
  100424. export var kernelBlurVertex: {
  100425. name: string;
  100426. shader: string;
  100427. };
  100428. }
  100429. declare module BABYLON {
  100430. /** @hidden */
  100431. export var kernelBlurVertexShader: {
  100432. name: string;
  100433. shader: string;
  100434. };
  100435. }
  100436. declare module BABYLON {
  100437. /**
  100438. * The Blur Post Process which blurs an image based on a kernel and direction.
  100439. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  100440. */
  100441. export class BlurPostProcess extends PostProcess {
  100442. /** The direction in which to blur the image. */
  100443. direction: Vector2;
  100444. private blockCompilation;
  100445. protected _kernel: number;
  100446. protected _idealKernel: number;
  100447. protected _packedFloat: boolean;
  100448. private _staticDefines;
  100449. /**
  100450. * Sets the length in pixels of the blur sample region
  100451. */
  100452. set kernel(v: number);
  100453. /**
  100454. * Gets the length in pixels of the blur sample region
  100455. */
  100456. get kernel(): number;
  100457. /**
  100458. * Sets wether or not the blur needs to unpack/repack floats
  100459. */
  100460. set packedFloat(v: boolean);
  100461. /**
  100462. * Gets wether or not the blur is unpacking/repacking floats
  100463. */
  100464. get packedFloat(): boolean;
  100465. /**
  100466. * Creates a new instance BlurPostProcess
  100467. * @param name The name of the effect.
  100468. * @param direction The direction in which to blur the image.
  100469. * @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.
  100470. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100471. * @param camera The camera to apply the render pass to.
  100472. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100473. * @param engine The engine which the post process will be applied. (default: current engine)
  100474. * @param reusable If the post process can be reused on the same frame. (default: false)
  100475. * @param textureType Type of textures used when performing the post process. (default: 0)
  100476. * @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)
  100477. */
  100478. constructor(name: string,
  100479. /** The direction in which to blur the image. */
  100480. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  100481. /**
  100482. * Updates the effect with the current post process compile time values and recompiles the shader.
  100483. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  100484. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  100485. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  100486. * @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
  100487. * @param onCompiled Called when the shader has been compiled.
  100488. * @param onError Called if there is an error when compiling a shader.
  100489. */
  100490. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100491. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100492. /**
  100493. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  100494. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  100495. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  100496. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  100497. * The gaps between physical kernels are compensated for in the weighting of the samples
  100498. * @param idealKernel Ideal blur kernel.
  100499. * @return Nearest best kernel.
  100500. */
  100501. protected _nearestBestKernel(idealKernel: number): number;
  100502. /**
  100503. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  100504. * @param x The point on the Gaussian distribution to sample.
  100505. * @return the value of the Gaussian function at x.
  100506. */
  100507. protected _gaussianWeight(x: number): number;
  100508. /**
  100509. * Generates a string that can be used as a floating point number in GLSL.
  100510. * @param x Value to print.
  100511. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  100512. * @return GLSL float string.
  100513. */
  100514. protected _glslFloat(x: number, decimalFigures?: number): string;
  100515. }
  100516. }
  100517. declare module BABYLON {
  100518. /**
  100519. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100520. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100521. * You can then easily use it as a reflectionTexture on a flat surface.
  100522. * In case the surface is not a plane, please consider relying on reflection probes.
  100523. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100524. */
  100525. export class MirrorTexture extends RenderTargetTexture {
  100526. private scene;
  100527. /**
  100528. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  100529. * 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.
  100530. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100531. */
  100532. mirrorPlane: Plane;
  100533. /**
  100534. * Define the blur ratio used to blur the reflection if needed.
  100535. */
  100536. set blurRatio(value: number);
  100537. get blurRatio(): number;
  100538. /**
  100539. * Define the adaptive blur kernel used to blur the reflection if needed.
  100540. * This will autocompute the closest best match for the `blurKernel`
  100541. */
  100542. set adaptiveBlurKernel(value: number);
  100543. /**
  100544. * Define the blur kernel used to blur the reflection if needed.
  100545. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100546. */
  100547. set blurKernel(value: number);
  100548. /**
  100549. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  100550. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100551. */
  100552. set blurKernelX(value: number);
  100553. get blurKernelX(): number;
  100554. /**
  100555. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  100556. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100557. */
  100558. set blurKernelY(value: number);
  100559. get blurKernelY(): number;
  100560. private _autoComputeBlurKernel;
  100561. protected _onRatioRescale(): void;
  100562. private _updateGammaSpace;
  100563. private _imageProcessingConfigChangeObserver;
  100564. private _transformMatrix;
  100565. private _mirrorMatrix;
  100566. private _savedViewMatrix;
  100567. private _blurX;
  100568. private _blurY;
  100569. private _adaptiveBlurKernel;
  100570. private _blurKernelX;
  100571. private _blurKernelY;
  100572. private _blurRatio;
  100573. /**
  100574. * Instantiates a Mirror Texture.
  100575. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100576. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100577. * You can then easily use it as a reflectionTexture on a flat surface.
  100578. * In case the surface is not a plane, please consider relying on reflection probes.
  100579. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100580. * @param name
  100581. * @param size
  100582. * @param scene
  100583. * @param generateMipMaps
  100584. * @param type
  100585. * @param samplingMode
  100586. * @param generateDepthBuffer
  100587. */
  100588. constructor(name: string, size: number | {
  100589. width: number;
  100590. height: number;
  100591. } | {
  100592. ratio: number;
  100593. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  100594. private _preparePostProcesses;
  100595. /**
  100596. * Clone the mirror texture.
  100597. * @returns the cloned texture
  100598. */
  100599. clone(): MirrorTexture;
  100600. /**
  100601. * Serialize the texture to a JSON representation you could use in Parse later on
  100602. * @returns the serialized JSON representation
  100603. */
  100604. serialize(): any;
  100605. /**
  100606. * Dispose the texture and release its associated resources.
  100607. */
  100608. dispose(): void;
  100609. }
  100610. }
  100611. declare module BABYLON {
  100612. /**
  100613. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  100614. * @see http://doc.babylonjs.com/babylon101/materials#texture
  100615. */
  100616. export class Texture extends BaseTexture {
  100617. /**
  100618. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  100619. */
  100620. static SerializeBuffers: boolean;
  100621. /** @hidden */
  100622. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  100623. /** @hidden */
  100624. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  100625. /** @hidden */
  100626. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  100627. /** nearest is mag = nearest and min = nearest and mip = linear */
  100628. static readonly NEAREST_SAMPLINGMODE: number;
  100629. /** nearest is mag = nearest and min = nearest and mip = linear */
  100630. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  100631. /** Bilinear is mag = linear and min = linear and mip = nearest */
  100632. static readonly BILINEAR_SAMPLINGMODE: number;
  100633. /** Bilinear is mag = linear and min = linear and mip = nearest */
  100634. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  100635. /** Trilinear is mag = linear and min = linear and mip = linear */
  100636. static readonly TRILINEAR_SAMPLINGMODE: number;
  100637. /** Trilinear is mag = linear and min = linear and mip = linear */
  100638. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  100639. /** mag = nearest and min = nearest and mip = nearest */
  100640. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  100641. /** mag = nearest and min = linear and mip = nearest */
  100642. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  100643. /** mag = nearest and min = linear and mip = linear */
  100644. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  100645. /** mag = nearest and min = linear and mip = none */
  100646. static readonly NEAREST_LINEAR: number;
  100647. /** mag = nearest and min = nearest and mip = none */
  100648. static readonly NEAREST_NEAREST: number;
  100649. /** mag = linear and min = nearest and mip = nearest */
  100650. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  100651. /** mag = linear and min = nearest and mip = linear */
  100652. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  100653. /** mag = linear and min = linear and mip = none */
  100654. static readonly LINEAR_LINEAR: number;
  100655. /** mag = linear and min = nearest and mip = none */
  100656. static readonly LINEAR_NEAREST: number;
  100657. /** Explicit coordinates mode */
  100658. static readonly EXPLICIT_MODE: number;
  100659. /** Spherical coordinates mode */
  100660. static readonly SPHERICAL_MODE: number;
  100661. /** Planar coordinates mode */
  100662. static readonly PLANAR_MODE: number;
  100663. /** Cubic coordinates mode */
  100664. static readonly CUBIC_MODE: number;
  100665. /** Projection coordinates mode */
  100666. static readonly PROJECTION_MODE: number;
  100667. /** Inverse Cubic coordinates mode */
  100668. static readonly SKYBOX_MODE: number;
  100669. /** Inverse Cubic coordinates mode */
  100670. static readonly INVCUBIC_MODE: number;
  100671. /** Equirectangular coordinates mode */
  100672. static readonly EQUIRECTANGULAR_MODE: number;
  100673. /** Equirectangular Fixed coordinates mode */
  100674. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  100675. /** Equirectangular Fixed Mirrored coordinates mode */
  100676. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  100677. /** Texture is not repeating outside of 0..1 UVs */
  100678. static readonly CLAMP_ADDRESSMODE: number;
  100679. /** Texture is repeating outside of 0..1 UVs */
  100680. static readonly WRAP_ADDRESSMODE: number;
  100681. /** Texture is repeating and mirrored */
  100682. static readonly MIRROR_ADDRESSMODE: number;
  100683. /**
  100684. * 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
  100685. */
  100686. static UseSerializedUrlIfAny: boolean;
  100687. /**
  100688. * Define the url of the texture.
  100689. */
  100690. url: Nullable<string>;
  100691. /**
  100692. * Define an offset on the texture to offset the u coordinates of the UVs
  100693. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  100694. */
  100695. uOffset: number;
  100696. /**
  100697. * Define an offset on the texture to offset the v coordinates of the UVs
  100698. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  100699. */
  100700. vOffset: number;
  100701. /**
  100702. * Define an offset on the texture to scale the u coordinates of the UVs
  100703. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  100704. */
  100705. uScale: number;
  100706. /**
  100707. * Define an offset on the texture to scale the v coordinates of the UVs
  100708. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  100709. */
  100710. vScale: number;
  100711. /**
  100712. * Define an offset on the texture to rotate around the u coordinates of the UVs
  100713. * @see http://doc.babylonjs.com/how_to/more_materials
  100714. */
  100715. uAng: number;
  100716. /**
  100717. * Define an offset on the texture to rotate around the v coordinates of the UVs
  100718. * @see http://doc.babylonjs.com/how_to/more_materials
  100719. */
  100720. vAng: number;
  100721. /**
  100722. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  100723. * @see http://doc.babylonjs.com/how_to/more_materials
  100724. */
  100725. wAng: number;
  100726. /**
  100727. * Defines the center of rotation (U)
  100728. */
  100729. uRotationCenter: number;
  100730. /**
  100731. * Defines the center of rotation (V)
  100732. */
  100733. vRotationCenter: number;
  100734. /**
  100735. * Defines the center of rotation (W)
  100736. */
  100737. wRotationCenter: number;
  100738. /**
  100739. * Are mip maps generated for this texture or not.
  100740. */
  100741. get noMipmap(): boolean;
  100742. /**
  100743. * List of inspectable custom properties (used by the Inspector)
  100744. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100745. */
  100746. inspectableCustomProperties: Nullable<IInspectable[]>;
  100747. private _noMipmap;
  100748. /** @hidden */
  100749. _invertY: boolean;
  100750. private _rowGenerationMatrix;
  100751. private _cachedTextureMatrix;
  100752. private _projectionModeMatrix;
  100753. private _t0;
  100754. private _t1;
  100755. private _t2;
  100756. private _cachedUOffset;
  100757. private _cachedVOffset;
  100758. private _cachedUScale;
  100759. private _cachedVScale;
  100760. private _cachedUAng;
  100761. private _cachedVAng;
  100762. private _cachedWAng;
  100763. private _cachedProjectionMatrixId;
  100764. private _cachedCoordinatesMode;
  100765. /** @hidden */
  100766. protected _initialSamplingMode: number;
  100767. /** @hidden */
  100768. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  100769. private _deleteBuffer;
  100770. protected _format: Nullable<number>;
  100771. private _delayedOnLoad;
  100772. private _delayedOnError;
  100773. private _mimeType?;
  100774. /**
  100775. * Observable triggered once the texture has been loaded.
  100776. */
  100777. onLoadObservable: Observable<Texture>;
  100778. protected _isBlocking: boolean;
  100779. /**
  100780. * Is the texture preventing material to render while loading.
  100781. * If false, a default texture will be used instead of the loading one during the preparation step.
  100782. */
  100783. set isBlocking(value: boolean);
  100784. get isBlocking(): boolean;
  100785. /**
  100786. * Get the current sampling mode associated with the texture.
  100787. */
  100788. get samplingMode(): number;
  100789. /**
  100790. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  100791. */
  100792. get invertY(): boolean;
  100793. /**
  100794. * Instantiates a new texture.
  100795. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  100796. * @see http://doc.babylonjs.com/babylon101/materials#texture
  100797. * @param url defines the url of the picture to load as a texture
  100798. * @param sceneOrEngine defines the scene or engine the texture will belong to
  100799. * @param noMipmap defines if the texture will require mip maps or not
  100800. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  100801. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100802. * @param onLoad defines a callback triggered when the texture has been loaded
  100803. * @param onError defines a callback triggered when an error occurred during the loading session
  100804. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  100805. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  100806. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100807. * @param mimeType defines an optional mime type information
  100808. */
  100809. 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);
  100810. /**
  100811. * Update the url (and optional buffer) of this texture if url was null during construction.
  100812. * @param url the url of the texture
  100813. * @param buffer the buffer of the texture (defaults to null)
  100814. * @param onLoad callback called when the texture is loaded (defaults to null)
  100815. */
  100816. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  100817. /**
  100818. * Finish the loading sequence of a texture flagged as delayed load.
  100819. * @hidden
  100820. */
  100821. delayLoad(): void;
  100822. private _prepareRowForTextureGeneration;
  100823. /**
  100824. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  100825. * @returns the transform matrix of the texture.
  100826. */
  100827. getTextureMatrix(uBase?: number): Matrix;
  100828. /**
  100829. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  100830. * @returns The reflection texture transform
  100831. */
  100832. getReflectionTextureMatrix(): Matrix;
  100833. /**
  100834. * Clones the texture.
  100835. * @returns the cloned texture
  100836. */
  100837. clone(): Texture;
  100838. /**
  100839. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  100840. * @returns The JSON representation of the texture
  100841. */
  100842. serialize(): any;
  100843. /**
  100844. * Get the current class name of the texture useful for serialization or dynamic coding.
  100845. * @returns "Texture"
  100846. */
  100847. getClassName(): string;
  100848. /**
  100849. * Dispose the texture and release its associated resources.
  100850. */
  100851. dispose(): void;
  100852. /**
  100853. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  100854. * @param parsedTexture Define the JSON representation of the texture
  100855. * @param scene Define the scene the parsed texture should be instantiated in
  100856. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  100857. * @returns The parsed texture if successful
  100858. */
  100859. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  100860. /**
  100861. * Creates a texture from its base 64 representation.
  100862. * @param data Define the base64 payload without the data: prefix
  100863. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  100864. * @param scene Define the scene the texture should belong to
  100865. * @param noMipmap Forces the texture to not create mip map information if true
  100866. * @param invertY define if the texture needs to be inverted on the y axis during loading
  100867. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100868. * @param onLoad define a callback triggered when the texture has been loaded
  100869. * @param onError define a callback triggered when an error occurred during the loading session
  100870. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100871. * @returns the created texture
  100872. */
  100873. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  100874. /**
  100875. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  100876. * @param data Define the base64 payload without the data: prefix
  100877. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  100878. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  100879. * @param scene Define the scene the texture should belong to
  100880. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  100881. * @param noMipmap Forces the texture to not create mip map information if true
  100882. * @param invertY define if the texture needs to be inverted on the y axis during loading
  100883. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100884. * @param onLoad define a callback triggered when the texture has been loaded
  100885. * @param onError define a callback triggered when an error occurred during the loading session
  100886. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100887. * @returns the created texture
  100888. */
  100889. 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;
  100890. }
  100891. }
  100892. declare module BABYLON {
  100893. /**
  100894. * PostProcessManager is used to manage one or more post processes or post process pipelines
  100895. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  100896. */
  100897. export class PostProcessManager {
  100898. private _scene;
  100899. private _indexBuffer;
  100900. private _vertexBuffers;
  100901. /**
  100902. * Creates a new instance PostProcess
  100903. * @param scene The scene that the post process is associated with.
  100904. */
  100905. constructor(scene: Scene);
  100906. private _prepareBuffers;
  100907. private _buildIndexBuffer;
  100908. /**
  100909. * Rebuilds the vertex buffers of the manager.
  100910. * @hidden
  100911. */
  100912. _rebuild(): void;
  100913. /**
  100914. * Prepares a frame to be run through a post process.
  100915. * @param sourceTexture The input texture to the post procesess. (default: null)
  100916. * @param postProcesses An array of post processes to be run. (default: null)
  100917. * @returns True if the post processes were able to be run.
  100918. * @hidden
  100919. */
  100920. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  100921. /**
  100922. * Manually render a set of post processes to a texture.
  100923. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  100924. * @param postProcesses An array of post processes to be run.
  100925. * @param targetTexture The target texture to render to.
  100926. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  100927. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  100928. * @param lodLevel defines which lod of the texture to render to
  100929. */
  100930. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  100931. /**
  100932. * Finalize the result of the output of the postprocesses.
  100933. * @param doNotPresent If true the result will not be displayed to the screen.
  100934. * @param targetTexture The target texture to render to.
  100935. * @param faceIndex The index of the face to bind the target texture to.
  100936. * @param postProcesses The array of post processes to render.
  100937. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  100938. * @hidden
  100939. */
  100940. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  100941. /**
  100942. * Disposes of the post process manager.
  100943. */
  100944. dispose(): void;
  100945. }
  100946. }
  100947. declare module BABYLON {
  100948. /**
  100949. * This Helps creating a texture that will be created from a camera in your scene.
  100950. * It is basically a dynamic texture that could be used to create special effects for instance.
  100951. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  100952. */
  100953. export class RenderTargetTexture extends Texture {
  100954. isCube: boolean;
  100955. /**
  100956. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  100957. */
  100958. static readonly REFRESHRATE_RENDER_ONCE: number;
  100959. /**
  100960. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  100961. */
  100962. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  100963. /**
  100964. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  100965. * the central point of your effect and can save a lot of performances.
  100966. */
  100967. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  100968. /**
  100969. * Use this predicate to dynamically define the list of mesh you want to render.
  100970. * If set, the renderList property will be overwritten.
  100971. */
  100972. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  100973. private _renderList;
  100974. /**
  100975. * Use this list to define the list of mesh you want to render.
  100976. */
  100977. get renderList(): Nullable<Array<AbstractMesh>>;
  100978. set renderList(value: Nullable<Array<AbstractMesh>>);
  100979. /**
  100980. * Use this function to overload the renderList array at rendering time.
  100981. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  100982. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  100983. * the cube (if the RTT is a cube, else layerOrFace=0).
  100984. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  100985. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  100986. * hold dummy elements!
  100987. */
  100988. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  100989. private _hookArray;
  100990. /**
  100991. * Define if particles should be rendered in your texture.
  100992. */
  100993. renderParticles: boolean;
  100994. /**
  100995. * Define if sprites should be rendered in your texture.
  100996. */
  100997. renderSprites: boolean;
  100998. /**
  100999. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  101000. */
  101001. coordinatesMode: number;
  101002. /**
  101003. * Define the camera used to render the texture.
  101004. */
  101005. activeCamera: Nullable<Camera>;
  101006. /**
  101007. * Override the mesh isReady function with your own one.
  101008. */
  101009. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  101010. /**
  101011. * Override the render function of the texture with your own one.
  101012. */
  101013. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  101014. /**
  101015. * Define if camera post processes should be use while rendering the texture.
  101016. */
  101017. useCameraPostProcesses: boolean;
  101018. /**
  101019. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  101020. */
  101021. ignoreCameraViewport: boolean;
  101022. private _postProcessManager;
  101023. private _postProcesses;
  101024. private _resizeObserver;
  101025. /**
  101026. * An event triggered when the texture is unbind.
  101027. */
  101028. onBeforeBindObservable: Observable<RenderTargetTexture>;
  101029. /**
  101030. * An event triggered when the texture is unbind.
  101031. */
  101032. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  101033. private _onAfterUnbindObserver;
  101034. /**
  101035. * Set a after unbind callback in the texture.
  101036. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  101037. */
  101038. set onAfterUnbind(callback: () => void);
  101039. /**
  101040. * An event triggered before rendering the texture
  101041. */
  101042. onBeforeRenderObservable: Observable<number>;
  101043. private _onBeforeRenderObserver;
  101044. /**
  101045. * Set a before render callback in the texture.
  101046. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  101047. */
  101048. set onBeforeRender(callback: (faceIndex: number) => void);
  101049. /**
  101050. * An event triggered after rendering the texture
  101051. */
  101052. onAfterRenderObservable: Observable<number>;
  101053. private _onAfterRenderObserver;
  101054. /**
  101055. * Set a after render callback in the texture.
  101056. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  101057. */
  101058. set onAfterRender(callback: (faceIndex: number) => void);
  101059. /**
  101060. * An event triggered after the texture clear
  101061. */
  101062. onClearObservable: Observable<Engine>;
  101063. private _onClearObserver;
  101064. /**
  101065. * Set a clear callback in the texture.
  101066. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  101067. */
  101068. set onClear(callback: (Engine: Engine) => void);
  101069. /**
  101070. * An event triggered when the texture is resized.
  101071. */
  101072. onResizeObservable: Observable<RenderTargetTexture>;
  101073. /**
  101074. * Define the clear color of the Render Target if it should be different from the scene.
  101075. */
  101076. clearColor: Color4;
  101077. protected _size: number | {
  101078. width: number;
  101079. height: number;
  101080. layers?: number;
  101081. };
  101082. protected _initialSizeParameter: number | {
  101083. width: number;
  101084. height: number;
  101085. } | {
  101086. ratio: number;
  101087. };
  101088. protected _sizeRatio: Nullable<number>;
  101089. /** @hidden */
  101090. _generateMipMaps: boolean;
  101091. protected _renderingManager: RenderingManager;
  101092. /** @hidden */
  101093. _waitingRenderList: string[];
  101094. protected _doNotChangeAspectRatio: boolean;
  101095. protected _currentRefreshId: number;
  101096. protected _refreshRate: number;
  101097. protected _textureMatrix: Matrix;
  101098. protected _samples: number;
  101099. protected _renderTargetOptions: RenderTargetCreationOptions;
  101100. /**
  101101. * Gets render target creation options that were used.
  101102. */
  101103. get renderTargetOptions(): RenderTargetCreationOptions;
  101104. protected _onRatioRescale(): void;
  101105. /**
  101106. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  101107. * It must define where the camera used to render the texture is set
  101108. */
  101109. boundingBoxPosition: Vector3;
  101110. private _boundingBoxSize;
  101111. /**
  101112. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  101113. * When defined, the cubemap will switch to local mode
  101114. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  101115. * @example https://www.babylonjs-playground.com/#RNASML
  101116. */
  101117. set boundingBoxSize(value: Vector3);
  101118. get boundingBoxSize(): Vector3;
  101119. /**
  101120. * In case the RTT has been created with a depth texture, get the associated
  101121. * depth texture.
  101122. * Otherwise, return null.
  101123. */
  101124. get depthStencilTexture(): Nullable<InternalTexture>;
  101125. /**
  101126. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  101127. * or used a shadow, depth texture...
  101128. * @param name The friendly name of the texture
  101129. * @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)
  101130. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  101131. * @param generateMipMaps True if mip maps need to be generated after render.
  101132. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  101133. * @param type The type of the buffer in the RTT (int, half float, float...)
  101134. * @param isCube True if a cube texture needs to be created
  101135. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  101136. * @param generateDepthBuffer True to generate a depth buffer
  101137. * @param generateStencilBuffer True to generate a stencil buffer
  101138. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  101139. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  101140. * @param delayAllocation if the texture allocation should be delayed (default: false)
  101141. */
  101142. constructor(name: string, size: number | {
  101143. width: number;
  101144. height: number;
  101145. layers?: number;
  101146. } | {
  101147. ratio: number;
  101148. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  101149. /**
  101150. * Creates a depth stencil texture.
  101151. * This is only available in WebGL 2 or with the depth texture extension available.
  101152. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  101153. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  101154. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  101155. */
  101156. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  101157. private _processSizeParameter;
  101158. /**
  101159. * Define the number of samples to use in case of MSAA.
  101160. * It defaults to one meaning no MSAA has been enabled.
  101161. */
  101162. get samples(): number;
  101163. set samples(value: number);
  101164. /**
  101165. * Resets the refresh counter of the texture and start bak from scratch.
  101166. * Could be useful to regenerate the texture if it is setup to render only once.
  101167. */
  101168. resetRefreshCounter(): void;
  101169. /**
  101170. * Define the refresh rate of the texture or the rendering frequency.
  101171. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  101172. */
  101173. get refreshRate(): number;
  101174. set refreshRate(value: number);
  101175. /**
  101176. * Adds a post process to the render target rendering passes.
  101177. * @param postProcess define the post process to add
  101178. */
  101179. addPostProcess(postProcess: PostProcess): void;
  101180. /**
  101181. * Clear all the post processes attached to the render target
  101182. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  101183. */
  101184. clearPostProcesses(dispose?: boolean): void;
  101185. /**
  101186. * Remove one of the post process from the list of attached post processes to the texture
  101187. * @param postProcess define the post process to remove from the list
  101188. */
  101189. removePostProcess(postProcess: PostProcess): void;
  101190. /** @hidden */
  101191. _shouldRender(): boolean;
  101192. /**
  101193. * Gets the actual render size of the texture.
  101194. * @returns the width of the render size
  101195. */
  101196. getRenderSize(): number;
  101197. /**
  101198. * Gets the actual render width of the texture.
  101199. * @returns the width of the render size
  101200. */
  101201. getRenderWidth(): number;
  101202. /**
  101203. * Gets the actual render height of the texture.
  101204. * @returns the height of the render size
  101205. */
  101206. getRenderHeight(): number;
  101207. /**
  101208. * Gets the actual number of layers of the texture.
  101209. * @returns the number of layers
  101210. */
  101211. getRenderLayers(): number;
  101212. /**
  101213. * Get if the texture can be rescaled or not.
  101214. */
  101215. get canRescale(): boolean;
  101216. /**
  101217. * Resize the texture using a ratio.
  101218. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  101219. */
  101220. scale(ratio: number): void;
  101221. /**
  101222. * Get the texture reflection matrix used to rotate/transform the reflection.
  101223. * @returns the reflection matrix
  101224. */
  101225. getReflectionTextureMatrix(): Matrix;
  101226. /**
  101227. * Resize the texture to a new desired size.
  101228. * Be carrefull as it will recreate all the data in the new texture.
  101229. * @param size Define the new size. It can be:
  101230. * - a number for squared texture,
  101231. * - an object containing { width: number, height: number }
  101232. * - or an object containing a ratio { ratio: number }
  101233. */
  101234. resize(size: number | {
  101235. width: number;
  101236. height: number;
  101237. } | {
  101238. ratio: number;
  101239. }): void;
  101240. private _defaultRenderListPrepared;
  101241. /**
  101242. * Renders all the objects from the render list into the texture.
  101243. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  101244. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  101245. */
  101246. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  101247. private _bestReflectionRenderTargetDimension;
  101248. private _prepareRenderingManager;
  101249. /**
  101250. * @hidden
  101251. * @param faceIndex face index to bind to if this is a cubetexture
  101252. * @param layer defines the index of the texture to bind in the array
  101253. */
  101254. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  101255. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101256. private renderToTarget;
  101257. /**
  101258. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101259. * This allowed control for front to back rendering or reversly depending of the special needs.
  101260. *
  101261. * @param renderingGroupId The rendering group id corresponding to its index
  101262. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101263. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101264. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101265. */
  101266. 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;
  101267. /**
  101268. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101269. *
  101270. * @param renderingGroupId The rendering group id corresponding to its index
  101271. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101272. */
  101273. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  101274. /**
  101275. * Clones the texture.
  101276. * @returns the cloned texture
  101277. */
  101278. clone(): RenderTargetTexture;
  101279. /**
  101280. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  101281. * @returns The JSON representation of the texture
  101282. */
  101283. serialize(): any;
  101284. /**
  101285. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  101286. */
  101287. disposeFramebufferObjects(): void;
  101288. /**
  101289. * Dispose the texture and release its associated resources.
  101290. */
  101291. dispose(): void;
  101292. /** @hidden */
  101293. _rebuild(): void;
  101294. /**
  101295. * Clear the info related to rendering groups preventing retention point in material dispose.
  101296. */
  101297. freeRenderingGroups(): void;
  101298. /**
  101299. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  101300. * @returns the view count
  101301. */
  101302. getViewCount(): number;
  101303. }
  101304. }
  101305. declare module BABYLON {
  101306. /**
  101307. * Class used to manipulate GUIDs
  101308. */
  101309. export class GUID {
  101310. /**
  101311. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  101312. * Be aware Math.random() could cause collisions, but:
  101313. * "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"
  101314. * @returns a pseudo random id
  101315. */
  101316. static RandomId(): string;
  101317. }
  101318. }
  101319. declare module BABYLON {
  101320. /**
  101321. * Options to be used when creating a shadow depth material
  101322. */
  101323. export interface IIOptionShadowDepthMaterial {
  101324. /** Variables in the vertex shader code that need to have their names remapped.
  101325. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  101326. * "var_name" should be either: worldPos or vNormalW
  101327. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  101328. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  101329. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  101330. */
  101331. remappedVariables?: string[];
  101332. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  101333. standalone?: boolean;
  101334. }
  101335. /**
  101336. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  101337. */
  101338. export class ShadowDepthWrapper {
  101339. private _scene;
  101340. private _options?;
  101341. private _baseMaterial;
  101342. private _onEffectCreatedObserver;
  101343. private _subMeshToEffect;
  101344. private _subMeshToDepthEffect;
  101345. private _meshes;
  101346. /** @hidden */
  101347. _matriceNames: any;
  101348. /** Gets the standalone status of the wrapper */
  101349. get standalone(): boolean;
  101350. /** Gets the base material the wrapper is built upon */
  101351. get baseMaterial(): Material;
  101352. /**
  101353. * Instantiate a new shadow depth wrapper.
  101354. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  101355. * generate the shadow depth map. For more information, please refer to the documentation:
  101356. * https://doc.babylonjs.com/babylon101/shadows
  101357. * @param baseMaterial Material to wrap
  101358. * @param scene Define the scene the material belongs to
  101359. * @param options Options used to create the wrapper
  101360. */
  101361. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  101362. /**
  101363. * Gets the effect to use to generate the depth map
  101364. * @param subMesh subMesh to get the effect for
  101365. * @param shadowGenerator shadow generator to get the effect for
  101366. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  101367. */
  101368. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  101369. /**
  101370. * Specifies that the submesh is ready to be used for depth rendering
  101371. * @param subMesh submesh to check
  101372. * @param defines the list of defines to take into account when checking the effect
  101373. * @param shadowGenerator combined with subMesh, it defines the effect to check
  101374. * @param useInstances specifies that instances should be used
  101375. * @returns a boolean indicating that the submesh is ready or not
  101376. */
  101377. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  101378. /**
  101379. * Disposes the resources
  101380. */
  101381. dispose(): void;
  101382. private _makeEffect;
  101383. }
  101384. }
  101385. declare module BABYLON {
  101386. /**
  101387. * Options for compiling materials.
  101388. */
  101389. export interface IMaterialCompilationOptions {
  101390. /**
  101391. * Defines whether clip planes are enabled.
  101392. */
  101393. clipPlane: boolean;
  101394. /**
  101395. * Defines whether instances are enabled.
  101396. */
  101397. useInstances: boolean;
  101398. }
  101399. /**
  101400. * Options passed when calling customShaderNameResolve
  101401. */
  101402. export interface ICustomShaderNameResolveOptions {
  101403. /**
  101404. * 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
  101405. */
  101406. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  101407. }
  101408. /**
  101409. * Base class for the main features of a material in Babylon.js
  101410. */
  101411. export class Material implements IAnimatable {
  101412. /**
  101413. * Returns the triangle fill mode
  101414. */
  101415. static readonly TriangleFillMode: number;
  101416. /**
  101417. * Returns the wireframe mode
  101418. */
  101419. static readonly WireFrameFillMode: number;
  101420. /**
  101421. * Returns the point fill mode
  101422. */
  101423. static readonly PointFillMode: number;
  101424. /**
  101425. * Returns the point list draw mode
  101426. */
  101427. static readonly PointListDrawMode: number;
  101428. /**
  101429. * Returns the line list draw mode
  101430. */
  101431. static readonly LineListDrawMode: number;
  101432. /**
  101433. * Returns the line loop draw mode
  101434. */
  101435. static readonly LineLoopDrawMode: number;
  101436. /**
  101437. * Returns the line strip draw mode
  101438. */
  101439. static readonly LineStripDrawMode: number;
  101440. /**
  101441. * Returns the triangle strip draw mode
  101442. */
  101443. static readonly TriangleStripDrawMode: number;
  101444. /**
  101445. * Returns the triangle fan draw mode
  101446. */
  101447. static readonly TriangleFanDrawMode: number;
  101448. /**
  101449. * Stores the clock-wise side orientation
  101450. */
  101451. static readonly ClockWiseSideOrientation: number;
  101452. /**
  101453. * Stores the counter clock-wise side orientation
  101454. */
  101455. static readonly CounterClockWiseSideOrientation: number;
  101456. /**
  101457. * The dirty texture flag value
  101458. */
  101459. static readonly TextureDirtyFlag: number;
  101460. /**
  101461. * The dirty light flag value
  101462. */
  101463. static readonly LightDirtyFlag: number;
  101464. /**
  101465. * The dirty fresnel flag value
  101466. */
  101467. static readonly FresnelDirtyFlag: number;
  101468. /**
  101469. * The dirty attribute flag value
  101470. */
  101471. static readonly AttributesDirtyFlag: number;
  101472. /**
  101473. * The dirty misc flag value
  101474. */
  101475. static readonly MiscDirtyFlag: number;
  101476. /**
  101477. * The all dirty flag value
  101478. */
  101479. static readonly AllDirtyFlag: number;
  101480. /**
  101481. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101482. */
  101483. static readonly MATERIAL_OPAQUE: number;
  101484. /**
  101485. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101486. */
  101487. static readonly MATERIAL_ALPHATEST: number;
  101488. /**
  101489. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101490. */
  101491. static readonly MATERIAL_ALPHABLEND: number;
  101492. /**
  101493. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101494. * They are also discarded below the alpha cutoff threshold to improve performances.
  101495. */
  101496. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  101497. /**
  101498. * The Whiteout method is used to blend normals.
  101499. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  101500. */
  101501. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  101502. /**
  101503. * The Reoriented Normal Mapping method is used to blend normals.
  101504. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  101505. */
  101506. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  101507. /**
  101508. * Custom callback helping to override the default shader used in the material.
  101509. */
  101510. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  101511. /**
  101512. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  101513. */
  101514. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  101515. /**
  101516. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  101517. * This means that the material can keep using a previous shader while a new one is being compiled.
  101518. * This is mostly used when shader parallel compilation is supported (true by default)
  101519. */
  101520. allowShaderHotSwapping: boolean;
  101521. /**
  101522. * The ID of the material
  101523. */
  101524. id: string;
  101525. /**
  101526. * Gets or sets the unique id of the material
  101527. */
  101528. uniqueId: number;
  101529. /**
  101530. * The name of the material
  101531. */
  101532. name: string;
  101533. /**
  101534. * Gets or sets user defined metadata
  101535. */
  101536. metadata: any;
  101537. /**
  101538. * For internal use only. Please do not use.
  101539. */
  101540. reservedDataStore: any;
  101541. /**
  101542. * Specifies if the ready state should be checked on each call
  101543. */
  101544. checkReadyOnEveryCall: boolean;
  101545. /**
  101546. * Specifies if the ready state should be checked once
  101547. */
  101548. checkReadyOnlyOnce: boolean;
  101549. /**
  101550. * The state of the material
  101551. */
  101552. state: string;
  101553. /**
  101554. * The alpha value of the material
  101555. */
  101556. protected _alpha: number;
  101557. /**
  101558. * List of inspectable custom properties (used by the Inspector)
  101559. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101560. */
  101561. inspectableCustomProperties: IInspectable[];
  101562. /**
  101563. * Sets the alpha value of the material
  101564. */
  101565. set alpha(value: number);
  101566. /**
  101567. * Gets the alpha value of the material
  101568. */
  101569. get alpha(): number;
  101570. /**
  101571. * Specifies if back face culling is enabled
  101572. */
  101573. protected _backFaceCulling: boolean;
  101574. /**
  101575. * Sets the back-face culling state
  101576. */
  101577. set backFaceCulling(value: boolean);
  101578. /**
  101579. * Gets the back-face culling state
  101580. */
  101581. get backFaceCulling(): boolean;
  101582. /**
  101583. * Stores the value for side orientation
  101584. */
  101585. sideOrientation: number;
  101586. /**
  101587. * Callback triggered when the material is compiled
  101588. */
  101589. onCompiled: Nullable<(effect: Effect) => void>;
  101590. /**
  101591. * Callback triggered when an error occurs
  101592. */
  101593. onError: Nullable<(effect: Effect, errors: string) => void>;
  101594. /**
  101595. * Callback triggered to get the render target textures
  101596. */
  101597. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  101598. /**
  101599. * Gets a boolean indicating that current material needs to register RTT
  101600. */
  101601. get hasRenderTargetTextures(): boolean;
  101602. /**
  101603. * Specifies if the material should be serialized
  101604. */
  101605. doNotSerialize: boolean;
  101606. /**
  101607. * @hidden
  101608. */
  101609. _storeEffectOnSubMeshes: boolean;
  101610. /**
  101611. * Stores the animations for the material
  101612. */
  101613. animations: Nullable<Array<Animation>>;
  101614. /**
  101615. * An event triggered when the material is disposed
  101616. */
  101617. onDisposeObservable: Observable<Material>;
  101618. /**
  101619. * An observer which watches for dispose events
  101620. */
  101621. private _onDisposeObserver;
  101622. private _onUnBindObservable;
  101623. /**
  101624. * Called during a dispose event
  101625. */
  101626. set onDispose(callback: () => void);
  101627. private _onBindObservable;
  101628. /**
  101629. * An event triggered when the material is bound
  101630. */
  101631. get onBindObservable(): Observable<AbstractMesh>;
  101632. /**
  101633. * An observer which watches for bind events
  101634. */
  101635. private _onBindObserver;
  101636. /**
  101637. * Called during a bind event
  101638. */
  101639. set onBind(callback: (Mesh: AbstractMesh) => void);
  101640. /**
  101641. * An event triggered when the material is unbound
  101642. */
  101643. get onUnBindObservable(): Observable<Material>;
  101644. protected _onEffectCreatedObservable: Nullable<Observable<{
  101645. effect: Effect;
  101646. subMesh: Nullable<SubMesh>;
  101647. }>>;
  101648. /**
  101649. * An event triggered when the effect is (re)created
  101650. */
  101651. get onEffectCreatedObservable(): Observable<{
  101652. effect: Effect;
  101653. subMesh: Nullable<SubMesh>;
  101654. }>;
  101655. /**
  101656. * Stores the value of the alpha mode
  101657. */
  101658. private _alphaMode;
  101659. /**
  101660. * Sets the value of the alpha mode.
  101661. *
  101662. * | Value | Type | Description |
  101663. * | --- | --- | --- |
  101664. * | 0 | ALPHA_DISABLE | |
  101665. * | 1 | ALPHA_ADD | |
  101666. * | 2 | ALPHA_COMBINE | |
  101667. * | 3 | ALPHA_SUBTRACT | |
  101668. * | 4 | ALPHA_MULTIPLY | |
  101669. * | 5 | ALPHA_MAXIMIZED | |
  101670. * | 6 | ALPHA_ONEONE | |
  101671. * | 7 | ALPHA_PREMULTIPLIED | |
  101672. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  101673. * | 9 | ALPHA_INTERPOLATE | |
  101674. * | 10 | ALPHA_SCREENMODE | |
  101675. *
  101676. */
  101677. set alphaMode(value: number);
  101678. /**
  101679. * Gets the value of the alpha mode
  101680. */
  101681. get alphaMode(): number;
  101682. /**
  101683. * Stores the state of the need depth pre-pass value
  101684. */
  101685. private _needDepthPrePass;
  101686. /**
  101687. * Sets the need depth pre-pass value
  101688. */
  101689. set needDepthPrePass(value: boolean);
  101690. /**
  101691. * Gets the depth pre-pass value
  101692. */
  101693. get needDepthPrePass(): boolean;
  101694. /**
  101695. * Specifies if depth writing should be disabled
  101696. */
  101697. disableDepthWrite: boolean;
  101698. /**
  101699. * Specifies if color writing should be disabled
  101700. */
  101701. disableColorWrite: boolean;
  101702. /**
  101703. * Specifies if depth writing should be forced
  101704. */
  101705. forceDepthWrite: boolean;
  101706. /**
  101707. * Specifies the depth function that should be used. 0 means the default engine function
  101708. */
  101709. depthFunction: number;
  101710. /**
  101711. * Specifies if there should be a separate pass for culling
  101712. */
  101713. separateCullingPass: boolean;
  101714. /**
  101715. * Stores the state specifing if fog should be enabled
  101716. */
  101717. private _fogEnabled;
  101718. /**
  101719. * Sets the state for enabling fog
  101720. */
  101721. set fogEnabled(value: boolean);
  101722. /**
  101723. * Gets the value of the fog enabled state
  101724. */
  101725. get fogEnabled(): boolean;
  101726. /**
  101727. * Stores the size of points
  101728. */
  101729. pointSize: number;
  101730. /**
  101731. * Stores the z offset value
  101732. */
  101733. zOffset: number;
  101734. get wireframe(): boolean;
  101735. /**
  101736. * Sets the state of wireframe mode
  101737. */
  101738. set wireframe(value: boolean);
  101739. /**
  101740. * Gets the value specifying if point clouds are enabled
  101741. */
  101742. get pointsCloud(): boolean;
  101743. /**
  101744. * Sets the state of point cloud mode
  101745. */
  101746. set pointsCloud(value: boolean);
  101747. /**
  101748. * Gets the material fill mode
  101749. */
  101750. get fillMode(): number;
  101751. /**
  101752. * Sets the material fill mode
  101753. */
  101754. set fillMode(value: number);
  101755. /**
  101756. * @hidden
  101757. * Stores the effects for the material
  101758. */
  101759. _effect: Nullable<Effect>;
  101760. /**
  101761. * Specifies if uniform buffers should be used
  101762. */
  101763. private _useUBO;
  101764. /**
  101765. * Stores a reference to the scene
  101766. */
  101767. private _scene;
  101768. /**
  101769. * Stores the fill mode state
  101770. */
  101771. private _fillMode;
  101772. /**
  101773. * Specifies if the depth write state should be cached
  101774. */
  101775. private _cachedDepthWriteState;
  101776. /**
  101777. * Specifies if the color write state should be cached
  101778. */
  101779. private _cachedColorWriteState;
  101780. /**
  101781. * Specifies if the depth function state should be cached
  101782. */
  101783. private _cachedDepthFunctionState;
  101784. /**
  101785. * Stores the uniform buffer
  101786. */
  101787. protected _uniformBuffer: UniformBuffer;
  101788. /** @hidden */
  101789. _indexInSceneMaterialArray: number;
  101790. /** @hidden */
  101791. meshMap: Nullable<{
  101792. [id: string]: AbstractMesh | undefined;
  101793. }>;
  101794. /**
  101795. * Creates a material instance
  101796. * @param name defines the name of the material
  101797. * @param scene defines the scene to reference
  101798. * @param doNotAdd specifies if the material should be added to the scene
  101799. */
  101800. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  101801. /**
  101802. * Returns a string representation of the current material
  101803. * @param fullDetails defines a boolean indicating which levels of logging is desired
  101804. * @returns a string with material information
  101805. */
  101806. toString(fullDetails?: boolean): string;
  101807. /**
  101808. * Gets the class name of the material
  101809. * @returns a string with the class name of the material
  101810. */
  101811. getClassName(): string;
  101812. /**
  101813. * Specifies if updates for the material been locked
  101814. */
  101815. get isFrozen(): boolean;
  101816. /**
  101817. * Locks updates for the material
  101818. */
  101819. freeze(): void;
  101820. /**
  101821. * Unlocks updates for the material
  101822. */
  101823. unfreeze(): void;
  101824. /**
  101825. * Specifies if the material is ready to be used
  101826. * @param mesh defines the mesh to check
  101827. * @param useInstances specifies if instances should be used
  101828. * @returns a boolean indicating if the material is ready to be used
  101829. */
  101830. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101831. /**
  101832. * Specifies that the submesh is ready to be used
  101833. * @param mesh defines the mesh to check
  101834. * @param subMesh defines which submesh to check
  101835. * @param useInstances specifies that instances should be used
  101836. * @returns a boolean indicating that the submesh is ready or not
  101837. */
  101838. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101839. /**
  101840. * Returns the material effect
  101841. * @returns the effect associated with the material
  101842. */
  101843. getEffect(): Nullable<Effect>;
  101844. /**
  101845. * Returns the current scene
  101846. * @returns a Scene
  101847. */
  101848. getScene(): Scene;
  101849. /**
  101850. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101851. */
  101852. protected _forceAlphaTest: boolean;
  101853. /**
  101854. * The transparency mode of the material.
  101855. */
  101856. protected _transparencyMode: Nullable<number>;
  101857. /**
  101858. * Gets the current transparency mode.
  101859. */
  101860. get transparencyMode(): Nullable<number>;
  101861. /**
  101862. * Sets the transparency mode of the material.
  101863. *
  101864. * | Value | Type | Description |
  101865. * | ----- | ----------------------------------- | ----------- |
  101866. * | 0 | OPAQUE | |
  101867. * | 1 | ALPHATEST | |
  101868. * | 2 | ALPHABLEND | |
  101869. * | 3 | ALPHATESTANDBLEND | |
  101870. *
  101871. */
  101872. set transparencyMode(value: Nullable<number>);
  101873. /**
  101874. * Returns true if alpha blending should be disabled.
  101875. */
  101876. protected get _disableAlphaBlending(): boolean;
  101877. /**
  101878. * Specifies whether or not this material should be rendered in alpha blend mode.
  101879. * @returns a boolean specifying if alpha blending is needed
  101880. */
  101881. needAlphaBlending(): boolean;
  101882. /**
  101883. * Specifies if the mesh will require alpha blending
  101884. * @param mesh defines the mesh to check
  101885. * @returns a boolean specifying if alpha blending is needed for the mesh
  101886. */
  101887. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  101888. /**
  101889. * Specifies whether or not this material should be rendered in alpha test mode.
  101890. * @returns a boolean specifying if an alpha test is needed.
  101891. */
  101892. needAlphaTesting(): boolean;
  101893. /**
  101894. * Specifies if material alpha testing should be turned on for the mesh
  101895. * @param mesh defines the mesh to check
  101896. */
  101897. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  101898. /**
  101899. * Gets the texture used for the alpha test
  101900. * @returns the texture to use for alpha testing
  101901. */
  101902. getAlphaTestTexture(): Nullable<BaseTexture>;
  101903. /**
  101904. * Marks the material to indicate that it needs to be re-calculated
  101905. */
  101906. markDirty(): void;
  101907. /** @hidden */
  101908. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  101909. /**
  101910. * Binds the material to the mesh
  101911. * @param world defines the world transformation matrix
  101912. * @param mesh defines the mesh to bind the material to
  101913. */
  101914. bind(world: Matrix, mesh?: Mesh): void;
  101915. /**
  101916. * Binds the submesh to the material
  101917. * @param world defines the world transformation matrix
  101918. * @param mesh defines the mesh containing the submesh
  101919. * @param subMesh defines the submesh to bind the material to
  101920. */
  101921. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101922. /**
  101923. * Binds the world matrix to the material
  101924. * @param world defines the world transformation matrix
  101925. */
  101926. bindOnlyWorldMatrix(world: Matrix): void;
  101927. /**
  101928. * Binds the scene's uniform buffer to the effect.
  101929. * @param effect defines the effect to bind to the scene uniform buffer
  101930. * @param sceneUbo defines the uniform buffer storing scene data
  101931. */
  101932. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  101933. /**
  101934. * Binds the view matrix to the effect
  101935. * @param effect defines the effect to bind the view matrix to
  101936. */
  101937. bindView(effect: Effect): void;
  101938. /**
  101939. * Binds the view projection matrix to the effect
  101940. * @param effect defines the effect to bind the view projection matrix to
  101941. */
  101942. bindViewProjection(effect: Effect): void;
  101943. /**
  101944. * Processes to execute after binding the material to a mesh
  101945. * @param mesh defines the rendered mesh
  101946. */
  101947. protected _afterBind(mesh?: Mesh): void;
  101948. /**
  101949. * Unbinds the material from the mesh
  101950. */
  101951. unbind(): void;
  101952. /**
  101953. * Gets the active textures from the material
  101954. * @returns an array of textures
  101955. */
  101956. getActiveTextures(): BaseTexture[];
  101957. /**
  101958. * Specifies if the material uses a texture
  101959. * @param texture defines the texture to check against the material
  101960. * @returns a boolean specifying if the material uses the texture
  101961. */
  101962. hasTexture(texture: BaseTexture): boolean;
  101963. /**
  101964. * Makes a duplicate of the material, and gives it a new name
  101965. * @param name defines the new name for the duplicated material
  101966. * @returns the cloned material
  101967. */
  101968. clone(name: string): Nullable<Material>;
  101969. /**
  101970. * Gets the meshes bound to the material
  101971. * @returns an array of meshes bound to the material
  101972. */
  101973. getBindedMeshes(): AbstractMesh[];
  101974. /**
  101975. * Force shader compilation
  101976. * @param mesh defines the mesh associated with this material
  101977. * @param onCompiled defines a function to execute once the material is compiled
  101978. * @param options defines the options to configure the compilation
  101979. * @param onError defines a function to execute if the material fails compiling
  101980. */
  101981. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  101982. /**
  101983. * Force shader compilation
  101984. * @param mesh defines the mesh that will use this material
  101985. * @param options defines additional options for compiling the shaders
  101986. * @returns a promise that resolves when the compilation completes
  101987. */
  101988. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  101989. private static readonly _AllDirtyCallBack;
  101990. private static readonly _ImageProcessingDirtyCallBack;
  101991. private static readonly _TextureDirtyCallBack;
  101992. private static readonly _FresnelDirtyCallBack;
  101993. private static readonly _MiscDirtyCallBack;
  101994. private static readonly _LightsDirtyCallBack;
  101995. private static readonly _AttributeDirtyCallBack;
  101996. private static _FresnelAndMiscDirtyCallBack;
  101997. private static _TextureAndMiscDirtyCallBack;
  101998. private static readonly _DirtyCallbackArray;
  101999. private static readonly _RunDirtyCallBacks;
  102000. /**
  102001. * Marks a define in the material to indicate that it needs to be re-computed
  102002. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  102003. */
  102004. markAsDirty(flag: number): void;
  102005. /**
  102006. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  102007. * @param func defines a function which checks material defines against the submeshes
  102008. */
  102009. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  102010. /**
  102011. * Indicates that we need to re-calculated for all submeshes
  102012. */
  102013. protected _markAllSubMeshesAsAllDirty(): void;
  102014. /**
  102015. * Indicates that image processing needs to be re-calculated for all submeshes
  102016. */
  102017. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  102018. /**
  102019. * Indicates that textures need to be re-calculated for all submeshes
  102020. */
  102021. protected _markAllSubMeshesAsTexturesDirty(): void;
  102022. /**
  102023. * Indicates that fresnel needs to be re-calculated for all submeshes
  102024. */
  102025. protected _markAllSubMeshesAsFresnelDirty(): void;
  102026. /**
  102027. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  102028. */
  102029. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  102030. /**
  102031. * Indicates that lights need to be re-calculated for all submeshes
  102032. */
  102033. protected _markAllSubMeshesAsLightsDirty(): void;
  102034. /**
  102035. * Indicates that attributes need to be re-calculated for all submeshes
  102036. */
  102037. protected _markAllSubMeshesAsAttributesDirty(): void;
  102038. /**
  102039. * Indicates that misc needs to be re-calculated for all submeshes
  102040. */
  102041. protected _markAllSubMeshesAsMiscDirty(): void;
  102042. /**
  102043. * Indicates that textures and misc need to be re-calculated for all submeshes
  102044. */
  102045. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  102046. /**
  102047. * Disposes the material
  102048. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102049. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102050. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102051. */
  102052. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102053. /** @hidden */
  102054. private releaseVertexArrayObject;
  102055. /**
  102056. * Serializes this material
  102057. * @returns the serialized material object
  102058. */
  102059. serialize(): any;
  102060. /**
  102061. * Creates a material from parsed material data
  102062. * @param parsedMaterial defines parsed material data
  102063. * @param scene defines the hosting scene
  102064. * @param rootUrl defines the root URL to use to load textures
  102065. * @returns a new material
  102066. */
  102067. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  102068. }
  102069. }
  102070. declare module BABYLON {
  102071. /**
  102072. * A multi-material is used to apply different materials to different parts of the same object without the need of
  102073. * separate meshes. This can be use to improve performances.
  102074. * @see http://doc.babylonjs.com/how_to/multi_materials
  102075. */
  102076. export class MultiMaterial extends Material {
  102077. private _subMaterials;
  102078. /**
  102079. * Gets or Sets the list of Materials used within the multi material.
  102080. * They need to be ordered according to the submeshes order in the associated mesh
  102081. */
  102082. get subMaterials(): Nullable<Material>[];
  102083. set subMaterials(value: Nullable<Material>[]);
  102084. /**
  102085. * Function used to align with Node.getChildren()
  102086. * @returns the list of Materials used within the multi material
  102087. */
  102088. getChildren(): Nullable<Material>[];
  102089. /**
  102090. * Instantiates a new Multi Material
  102091. * A multi-material is used to apply different materials to different parts of the same object without the need of
  102092. * separate meshes. This can be use to improve performances.
  102093. * @see http://doc.babylonjs.com/how_to/multi_materials
  102094. * @param name Define the name in the scene
  102095. * @param scene Define the scene the material belongs to
  102096. */
  102097. constructor(name: string, scene: Scene);
  102098. private _hookArray;
  102099. /**
  102100. * Get one of the submaterial by its index in the submaterials array
  102101. * @param index The index to look the sub material at
  102102. * @returns The Material if the index has been defined
  102103. */
  102104. getSubMaterial(index: number): Nullable<Material>;
  102105. /**
  102106. * Get the list of active textures for the whole sub materials list.
  102107. * @returns All the textures that will be used during the rendering
  102108. */
  102109. getActiveTextures(): BaseTexture[];
  102110. /**
  102111. * Gets the current class name of the material e.g. "MultiMaterial"
  102112. * Mainly use in serialization.
  102113. * @returns the class name
  102114. */
  102115. getClassName(): string;
  102116. /**
  102117. * Checks if the material is ready to render the requested sub mesh
  102118. * @param mesh Define the mesh the submesh belongs to
  102119. * @param subMesh Define the sub mesh to look readyness for
  102120. * @param useInstances Define whether or not the material is used with instances
  102121. * @returns true if ready, otherwise false
  102122. */
  102123. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102124. /**
  102125. * Clones the current material and its related sub materials
  102126. * @param name Define the name of the newly cloned material
  102127. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  102128. * @returns the cloned material
  102129. */
  102130. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  102131. /**
  102132. * Serializes the materials into a JSON representation.
  102133. * @returns the JSON representation
  102134. */
  102135. serialize(): any;
  102136. /**
  102137. * Dispose the material and release its associated resources
  102138. * @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)
  102139. * @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)
  102140. * @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)
  102141. */
  102142. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  102143. /**
  102144. * Creates a MultiMaterial from parsed MultiMaterial data.
  102145. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  102146. * @param scene defines the hosting scene
  102147. * @returns a new MultiMaterial
  102148. */
  102149. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  102150. }
  102151. }
  102152. declare module BABYLON {
  102153. /**
  102154. * Defines a subdivision inside a mesh
  102155. */
  102156. export class SubMesh implements ICullable {
  102157. /** the material index to use */
  102158. materialIndex: number;
  102159. /** vertex index start */
  102160. verticesStart: number;
  102161. /** vertices count */
  102162. verticesCount: number;
  102163. /** index start */
  102164. indexStart: number;
  102165. /** indices count */
  102166. indexCount: number;
  102167. /** @hidden */
  102168. _materialDefines: Nullable<MaterialDefines>;
  102169. /** @hidden */
  102170. _materialEffect: Nullable<Effect>;
  102171. /** @hidden */
  102172. _effectOverride: Nullable<Effect>;
  102173. /**
  102174. * Gets material defines used by the effect associated to the sub mesh
  102175. */
  102176. get materialDefines(): Nullable<MaterialDefines>;
  102177. /**
  102178. * Sets material defines used by the effect associated to the sub mesh
  102179. */
  102180. set materialDefines(defines: Nullable<MaterialDefines>);
  102181. /**
  102182. * Gets associated effect
  102183. */
  102184. get effect(): Nullable<Effect>;
  102185. /**
  102186. * Sets associated effect (effect used to render this submesh)
  102187. * @param effect defines the effect to associate with
  102188. * @param defines defines the set of defines used to compile this effect
  102189. */
  102190. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  102191. /** @hidden */
  102192. _linesIndexCount: number;
  102193. private _mesh;
  102194. private _renderingMesh;
  102195. private _boundingInfo;
  102196. private _linesIndexBuffer;
  102197. /** @hidden */
  102198. _lastColliderWorldVertices: Nullable<Vector3[]>;
  102199. /** @hidden */
  102200. _trianglePlanes: Plane[];
  102201. /** @hidden */
  102202. _lastColliderTransformMatrix: Nullable<Matrix>;
  102203. /** @hidden */
  102204. _renderId: number;
  102205. /** @hidden */
  102206. _alphaIndex: number;
  102207. /** @hidden */
  102208. _distanceToCamera: number;
  102209. /** @hidden */
  102210. _id: number;
  102211. private _currentMaterial;
  102212. /**
  102213. * Add a new submesh to a mesh
  102214. * @param materialIndex defines the material index to use
  102215. * @param verticesStart defines vertex index start
  102216. * @param verticesCount defines vertices count
  102217. * @param indexStart defines index start
  102218. * @param indexCount defines indices count
  102219. * @param mesh defines the parent mesh
  102220. * @param renderingMesh defines an optional rendering mesh
  102221. * @param createBoundingBox defines if bounding box should be created for this submesh
  102222. * @returns the new submesh
  102223. */
  102224. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  102225. /**
  102226. * Creates a new submesh
  102227. * @param materialIndex defines the material index to use
  102228. * @param verticesStart defines vertex index start
  102229. * @param verticesCount defines vertices count
  102230. * @param indexStart defines index start
  102231. * @param indexCount defines indices count
  102232. * @param mesh defines the parent mesh
  102233. * @param renderingMesh defines an optional rendering mesh
  102234. * @param createBoundingBox defines if bounding box should be created for this submesh
  102235. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  102236. */
  102237. constructor(
  102238. /** the material index to use */
  102239. materialIndex: number,
  102240. /** vertex index start */
  102241. verticesStart: number,
  102242. /** vertices count */
  102243. verticesCount: number,
  102244. /** index start */
  102245. indexStart: number,
  102246. /** indices count */
  102247. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  102248. /**
  102249. * Returns true if this submesh covers the entire parent mesh
  102250. * @ignorenaming
  102251. */
  102252. get IsGlobal(): boolean;
  102253. /**
  102254. * Returns the submesh BoudingInfo object
  102255. * @returns current bounding info (or mesh's one if the submesh is global)
  102256. */
  102257. getBoundingInfo(): BoundingInfo;
  102258. /**
  102259. * Sets the submesh BoundingInfo
  102260. * @param boundingInfo defines the new bounding info to use
  102261. * @returns the SubMesh
  102262. */
  102263. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  102264. /**
  102265. * Returns the mesh of the current submesh
  102266. * @return the parent mesh
  102267. */
  102268. getMesh(): AbstractMesh;
  102269. /**
  102270. * Returns the rendering mesh of the submesh
  102271. * @returns the rendering mesh (could be different from parent mesh)
  102272. */
  102273. getRenderingMesh(): Mesh;
  102274. /**
  102275. * Returns the replacement mesh of the submesh
  102276. * @returns the replacement mesh (could be different from parent mesh)
  102277. */
  102278. getReplacementMesh(): Nullable<AbstractMesh>;
  102279. /**
  102280. * Returns the effective mesh of the submesh
  102281. * @returns the effective mesh (could be different from parent mesh)
  102282. */
  102283. getEffectiveMesh(): AbstractMesh;
  102284. /**
  102285. * Returns the submesh material
  102286. * @returns null or the current material
  102287. */
  102288. getMaterial(): Nullable<Material>;
  102289. /**
  102290. * Sets a new updated BoundingInfo object to the submesh
  102291. * @param data defines an optional position array to use to determine the bounding info
  102292. * @returns the SubMesh
  102293. */
  102294. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  102295. /** @hidden */
  102296. _checkCollision(collider: Collider): boolean;
  102297. /**
  102298. * Updates the submesh BoundingInfo
  102299. * @param world defines the world matrix to use to update the bounding info
  102300. * @returns the submesh
  102301. */
  102302. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  102303. /**
  102304. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  102305. * @param frustumPlanes defines the frustum planes
  102306. * @returns true if the submesh is intersecting with the frustum
  102307. */
  102308. isInFrustum(frustumPlanes: Plane[]): boolean;
  102309. /**
  102310. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  102311. * @param frustumPlanes defines the frustum planes
  102312. * @returns true if the submesh is inside the frustum
  102313. */
  102314. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  102315. /**
  102316. * Renders the submesh
  102317. * @param enableAlphaMode defines if alpha needs to be used
  102318. * @returns the submesh
  102319. */
  102320. render(enableAlphaMode: boolean): SubMesh;
  102321. /**
  102322. * @hidden
  102323. */
  102324. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  102325. /**
  102326. * Checks if the submesh intersects with a ray
  102327. * @param ray defines the ray to test
  102328. * @returns true is the passed ray intersects the submesh bounding box
  102329. */
  102330. canIntersects(ray: Ray): boolean;
  102331. /**
  102332. * Intersects current submesh with a ray
  102333. * @param ray defines the ray to test
  102334. * @param positions defines mesh's positions array
  102335. * @param indices defines mesh's indices array
  102336. * @param fastCheck defines if the first intersection will be used (and not the closest)
  102337. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102338. * @returns intersection info or null if no intersection
  102339. */
  102340. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  102341. /** @hidden */
  102342. private _intersectLines;
  102343. /** @hidden */
  102344. private _intersectUnIndexedLines;
  102345. /** @hidden */
  102346. private _intersectTriangles;
  102347. /** @hidden */
  102348. private _intersectUnIndexedTriangles;
  102349. /** @hidden */
  102350. _rebuild(): void;
  102351. /**
  102352. * Creates a new submesh from the passed mesh
  102353. * @param newMesh defines the new hosting mesh
  102354. * @param newRenderingMesh defines an optional rendering mesh
  102355. * @returns the new submesh
  102356. */
  102357. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  102358. /**
  102359. * Release associated resources
  102360. */
  102361. dispose(): void;
  102362. /**
  102363. * Gets the class name
  102364. * @returns the string "SubMesh".
  102365. */
  102366. getClassName(): string;
  102367. /**
  102368. * Creates a new submesh from indices data
  102369. * @param materialIndex the index of the main mesh material
  102370. * @param startIndex the index where to start the copy in the mesh indices array
  102371. * @param indexCount the number of indices to copy then from the startIndex
  102372. * @param mesh the main mesh to create the submesh from
  102373. * @param renderingMesh the optional rendering mesh
  102374. * @returns a new submesh
  102375. */
  102376. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  102377. }
  102378. }
  102379. declare module BABYLON {
  102380. /**
  102381. * Class used to represent data loading progression
  102382. */
  102383. export class SceneLoaderFlags {
  102384. private static _ForceFullSceneLoadingForIncremental;
  102385. private static _ShowLoadingScreen;
  102386. private static _CleanBoneMatrixWeights;
  102387. private static _loggingLevel;
  102388. /**
  102389. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  102390. */
  102391. static get ForceFullSceneLoadingForIncremental(): boolean;
  102392. static set ForceFullSceneLoadingForIncremental(value: boolean);
  102393. /**
  102394. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  102395. */
  102396. static get ShowLoadingScreen(): boolean;
  102397. static set ShowLoadingScreen(value: boolean);
  102398. /**
  102399. * Defines the current logging level (while loading the scene)
  102400. * @ignorenaming
  102401. */
  102402. static get loggingLevel(): number;
  102403. static set loggingLevel(value: number);
  102404. /**
  102405. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  102406. */
  102407. static get CleanBoneMatrixWeights(): boolean;
  102408. static set CleanBoneMatrixWeights(value: boolean);
  102409. }
  102410. }
  102411. declare module BABYLON {
  102412. /**
  102413. * Class used to store geometry data (vertex buffers + index buffer)
  102414. */
  102415. export class Geometry implements IGetSetVerticesData {
  102416. /**
  102417. * Gets or sets the ID of the geometry
  102418. */
  102419. id: string;
  102420. /**
  102421. * Gets or sets the unique ID of the geometry
  102422. */
  102423. uniqueId: number;
  102424. /**
  102425. * Gets the delay loading state of the geometry (none by default which means not delayed)
  102426. */
  102427. delayLoadState: number;
  102428. /**
  102429. * Gets the file containing the data to load when running in delay load state
  102430. */
  102431. delayLoadingFile: Nullable<string>;
  102432. /**
  102433. * Callback called when the geometry is updated
  102434. */
  102435. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  102436. private _scene;
  102437. private _engine;
  102438. private _meshes;
  102439. private _totalVertices;
  102440. /** @hidden */
  102441. _indices: IndicesArray;
  102442. /** @hidden */
  102443. _vertexBuffers: {
  102444. [key: string]: VertexBuffer;
  102445. };
  102446. private _isDisposed;
  102447. private _extend;
  102448. private _boundingBias;
  102449. /** @hidden */
  102450. _delayInfo: Array<string>;
  102451. private _indexBuffer;
  102452. private _indexBufferIsUpdatable;
  102453. /** @hidden */
  102454. _boundingInfo: Nullable<BoundingInfo>;
  102455. /** @hidden */
  102456. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  102457. /** @hidden */
  102458. _softwareSkinningFrameId: number;
  102459. private _vertexArrayObjects;
  102460. private _updatable;
  102461. /** @hidden */
  102462. _positions: Nullable<Vector3[]>;
  102463. /**
  102464. * 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
  102465. */
  102466. get boundingBias(): Vector2;
  102467. /**
  102468. * 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
  102469. */
  102470. set boundingBias(value: Vector2);
  102471. /**
  102472. * Static function used to attach a new empty geometry to a mesh
  102473. * @param mesh defines the mesh to attach the geometry to
  102474. * @returns the new Geometry
  102475. */
  102476. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  102477. /** Get the list of meshes using this geometry */
  102478. get meshes(): Mesh[];
  102479. /**
  102480. * Creates a new geometry
  102481. * @param id defines the unique ID
  102482. * @param scene defines the hosting scene
  102483. * @param vertexData defines the VertexData used to get geometry data
  102484. * @param updatable defines if geometry must be updatable (false by default)
  102485. * @param mesh defines the mesh that will be associated with the geometry
  102486. */
  102487. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  102488. /**
  102489. * Gets the current extend of the geometry
  102490. */
  102491. get extend(): {
  102492. minimum: Vector3;
  102493. maximum: Vector3;
  102494. };
  102495. /**
  102496. * Gets the hosting scene
  102497. * @returns the hosting Scene
  102498. */
  102499. getScene(): Scene;
  102500. /**
  102501. * Gets the hosting engine
  102502. * @returns the hosting Engine
  102503. */
  102504. getEngine(): Engine;
  102505. /**
  102506. * Defines if the geometry is ready to use
  102507. * @returns true if the geometry is ready to be used
  102508. */
  102509. isReady(): boolean;
  102510. /**
  102511. * Gets a value indicating that the geometry should not be serialized
  102512. */
  102513. get doNotSerialize(): boolean;
  102514. /** @hidden */
  102515. _rebuild(): void;
  102516. /**
  102517. * Affects all geometry data in one call
  102518. * @param vertexData defines the geometry data
  102519. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  102520. */
  102521. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  102522. /**
  102523. * Set specific vertex data
  102524. * @param kind defines the data kind (Position, normal, etc...)
  102525. * @param data defines the vertex data to use
  102526. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  102527. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  102528. */
  102529. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  102530. /**
  102531. * Removes a specific vertex data
  102532. * @param kind defines the data kind (Position, normal, etc...)
  102533. */
  102534. removeVerticesData(kind: string): void;
  102535. /**
  102536. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  102537. * @param buffer defines the vertex buffer to use
  102538. * @param totalVertices defines the total number of vertices for position kind (could be null)
  102539. */
  102540. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  102541. /**
  102542. * Update a specific vertex buffer
  102543. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  102544. * It will do nothing if the buffer is not updatable
  102545. * @param kind defines the data kind (Position, normal, etc...)
  102546. * @param data defines the data to use
  102547. * @param offset defines the offset in the target buffer where to store the data
  102548. * @param useBytes set to true if the offset is in bytes
  102549. */
  102550. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  102551. /**
  102552. * Update a specific vertex buffer
  102553. * This function will create a new buffer if the current one is not updatable
  102554. * @param kind defines the data kind (Position, normal, etc...)
  102555. * @param data defines the data to use
  102556. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  102557. */
  102558. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  102559. private _updateBoundingInfo;
  102560. /** @hidden */
  102561. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  102562. /**
  102563. * Gets total number of vertices
  102564. * @returns the total number of vertices
  102565. */
  102566. getTotalVertices(): number;
  102567. /**
  102568. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  102569. * @param kind defines the data kind (Position, normal, etc...)
  102570. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102571. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102572. * @returns a float array containing vertex data
  102573. */
  102574. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  102575. /**
  102576. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  102577. * @param kind defines the data kind (Position, normal, etc...)
  102578. * @returns true if the vertex buffer with the specified kind is updatable
  102579. */
  102580. isVertexBufferUpdatable(kind: string): boolean;
  102581. /**
  102582. * Gets a specific vertex buffer
  102583. * @param kind defines the data kind (Position, normal, etc...)
  102584. * @returns a VertexBuffer
  102585. */
  102586. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  102587. /**
  102588. * Returns all vertex buffers
  102589. * @return an object holding all vertex buffers indexed by kind
  102590. */
  102591. getVertexBuffers(): Nullable<{
  102592. [key: string]: VertexBuffer;
  102593. }>;
  102594. /**
  102595. * Gets a boolean indicating if specific vertex buffer is present
  102596. * @param kind defines the data kind (Position, normal, etc...)
  102597. * @returns true if data is present
  102598. */
  102599. isVerticesDataPresent(kind: string): boolean;
  102600. /**
  102601. * Gets a list of all attached data kinds (Position, normal, etc...)
  102602. * @returns a list of string containing all kinds
  102603. */
  102604. getVerticesDataKinds(): string[];
  102605. /**
  102606. * Update index buffer
  102607. * @param indices defines the indices to store in the index buffer
  102608. * @param offset defines the offset in the target buffer where to store the data
  102609. * @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)
  102610. */
  102611. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  102612. /**
  102613. * Creates a new index buffer
  102614. * @param indices defines the indices to store in the index buffer
  102615. * @param totalVertices defines the total number of vertices (could be null)
  102616. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  102617. */
  102618. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  102619. /**
  102620. * Return the total number of indices
  102621. * @returns the total number of indices
  102622. */
  102623. getTotalIndices(): number;
  102624. /**
  102625. * Gets the index buffer array
  102626. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102627. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102628. * @returns the index buffer array
  102629. */
  102630. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  102631. /**
  102632. * Gets the index buffer
  102633. * @return the index buffer
  102634. */
  102635. getIndexBuffer(): Nullable<DataBuffer>;
  102636. /** @hidden */
  102637. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  102638. /**
  102639. * Release the associated resources for a specific mesh
  102640. * @param mesh defines the source mesh
  102641. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  102642. */
  102643. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  102644. /**
  102645. * Apply current geometry to a given mesh
  102646. * @param mesh defines the mesh to apply geometry to
  102647. */
  102648. applyToMesh(mesh: Mesh): void;
  102649. private _updateExtend;
  102650. private _applyToMesh;
  102651. private notifyUpdate;
  102652. /**
  102653. * Load the geometry if it was flagged as delay loaded
  102654. * @param scene defines the hosting scene
  102655. * @param onLoaded defines a callback called when the geometry is loaded
  102656. */
  102657. load(scene: Scene, onLoaded?: () => void): void;
  102658. private _queueLoad;
  102659. /**
  102660. * Invert the geometry to move from a right handed system to a left handed one.
  102661. */
  102662. toLeftHanded(): void;
  102663. /** @hidden */
  102664. _resetPointsArrayCache(): void;
  102665. /** @hidden */
  102666. _generatePointsArray(): boolean;
  102667. /**
  102668. * Gets a value indicating if the geometry is disposed
  102669. * @returns true if the geometry was disposed
  102670. */
  102671. isDisposed(): boolean;
  102672. private _disposeVertexArrayObjects;
  102673. /**
  102674. * Free all associated resources
  102675. */
  102676. dispose(): void;
  102677. /**
  102678. * Clone the current geometry into a new geometry
  102679. * @param id defines the unique ID of the new geometry
  102680. * @returns a new geometry object
  102681. */
  102682. copy(id: string): Geometry;
  102683. /**
  102684. * Serialize the current geometry info (and not the vertices data) into a JSON object
  102685. * @return a JSON representation of the current geometry data (without the vertices data)
  102686. */
  102687. serialize(): any;
  102688. private toNumberArray;
  102689. /**
  102690. * Serialize all vertices data into a JSON oject
  102691. * @returns a JSON representation of the current geometry data
  102692. */
  102693. serializeVerticeData(): any;
  102694. /**
  102695. * Extracts a clone of a mesh geometry
  102696. * @param mesh defines the source mesh
  102697. * @param id defines the unique ID of the new geometry object
  102698. * @returns the new geometry object
  102699. */
  102700. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  102701. /**
  102702. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  102703. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102704. * Be aware Math.random() could cause collisions, but:
  102705. * "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"
  102706. * @returns a string containing a new GUID
  102707. */
  102708. static RandomId(): string;
  102709. /** @hidden */
  102710. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  102711. private static _CleanMatricesWeights;
  102712. /**
  102713. * Create a new geometry from persisted data (Using .babylon file format)
  102714. * @param parsedVertexData defines the persisted data
  102715. * @param scene defines the hosting scene
  102716. * @param rootUrl defines the root url to use to load assets (like delayed data)
  102717. * @returns the new geometry object
  102718. */
  102719. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  102720. }
  102721. }
  102722. declare module BABYLON {
  102723. /**
  102724. * Define an interface for all classes that will get and set the data on vertices
  102725. */
  102726. export interface IGetSetVerticesData {
  102727. /**
  102728. * Gets a boolean indicating if specific vertex data is present
  102729. * @param kind defines the vertex data kind to use
  102730. * @returns true is data kind is present
  102731. */
  102732. isVerticesDataPresent(kind: string): boolean;
  102733. /**
  102734. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  102735. * @param kind defines the data kind (Position, normal, etc...)
  102736. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102737. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102738. * @returns a float array containing vertex data
  102739. */
  102740. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  102741. /**
  102742. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  102743. * @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.
  102744. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102745. * @returns the indices array or an empty array if the mesh has no geometry
  102746. */
  102747. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  102748. /**
  102749. * Set specific vertex data
  102750. * @param kind defines the data kind (Position, normal, etc...)
  102751. * @param data defines the vertex data to use
  102752. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  102753. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  102754. */
  102755. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  102756. /**
  102757. * Update a specific associated vertex buffer
  102758. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  102759. * - VertexBuffer.PositionKind
  102760. * - VertexBuffer.UVKind
  102761. * - VertexBuffer.UV2Kind
  102762. * - VertexBuffer.UV3Kind
  102763. * - VertexBuffer.UV4Kind
  102764. * - VertexBuffer.UV5Kind
  102765. * - VertexBuffer.UV6Kind
  102766. * - VertexBuffer.ColorKind
  102767. * - VertexBuffer.MatricesIndicesKind
  102768. * - VertexBuffer.MatricesIndicesExtraKind
  102769. * - VertexBuffer.MatricesWeightsKind
  102770. * - VertexBuffer.MatricesWeightsExtraKind
  102771. * @param data defines the data source
  102772. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  102773. * @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)
  102774. */
  102775. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  102776. /**
  102777. * Creates a new index buffer
  102778. * @param indices defines the indices to store in the index buffer
  102779. * @param totalVertices defines the total number of vertices (could be null)
  102780. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  102781. */
  102782. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  102783. }
  102784. /**
  102785. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  102786. */
  102787. export class VertexData {
  102788. /**
  102789. * Mesh side orientation : usually the external or front surface
  102790. */
  102791. static readonly FRONTSIDE: number;
  102792. /**
  102793. * Mesh side orientation : usually the internal or back surface
  102794. */
  102795. static readonly BACKSIDE: number;
  102796. /**
  102797. * Mesh side orientation : both internal and external or front and back surfaces
  102798. */
  102799. static readonly DOUBLESIDE: number;
  102800. /**
  102801. * Mesh side orientation : by default, `FRONTSIDE`
  102802. */
  102803. static readonly DEFAULTSIDE: number;
  102804. /**
  102805. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  102806. */
  102807. positions: Nullable<FloatArray>;
  102808. /**
  102809. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  102810. */
  102811. normals: Nullable<FloatArray>;
  102812. /**
  102813. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  102814. */
  102815. tangents: Nullable<FloatArray>;
  102816. /**
  102817. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102818. */
  102819. uvs: Nullable<FloatArray>;
  102820. /**
  102821. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102822. */
  102823. uvs2: Nullable<FloatArray>;
  102824. /**
  102825. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102826. */
  102827. uvs3: Nullable<FloatArray>;
  102828. /**
  102829. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102830. */
  102831. uvs4: Nullable<FloatArray>;
  102832. /**
  102833. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102834. */
  102835. uvs5: Nullable<FloatArray>;
  102836. /**
  102837. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102838. */
  102839. uvs6: Nullable<FloatArray>;
  102840. /**
  102841. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  102842. */
  102843. colors: Nullable<FloatArray>;
  102844. /**
  102845. * 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).
  102846. */
  102847. matricesIndices: Nullable<FloatArray>;
  102848. /**
  102849. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  102850. */
  102851. matricesWeights: Nullable<FloatArray>;
  102852. /**
  102853. * An array extending the number of possible indices
  102854. */
  102855. matricesIndicesExtra: Nullable<FloatArray>;
  102856. /**
  102857. * An array extending the number of possible weights when the number of indices is extended
  102858. */
  102859. matricesWeightsExtra: Nullable<FloatArray>;
  102860. /**
  102861. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  102862. */
  102863. indices: Nullable<IndicesArray>;
  102864. /**
  102865. * Uses the passed data array to set the set the values for the specified kind of data
  102866. * @param data a linear array of floating numbers
  102867. * @param kind the type of data that is being set, eg positions, colors etc
  102868. */
  102869. set(data: FloatArray, kind: string): void;
  102870. /**
  102871. * Associates the vertexData to the passed Mesh.
  102872. * Sets it as updatable or not (default `false`)
  102873. * @param mesh the mesh the vertexData is applied to
  102874. * @param updatable when used and having the value true allows new data to update the vertexData
  102875. * @returns the VertexData
  102876. */
  102877. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  102878. /**
  102879. * Associates the vertexData to the passed Geometry.
  102880. * Sets it as updatable or not (default `false`)
  102881. * @param geometry the geometry the vertexData is applied to
  102882. * @param updatable when used and having the value true allows new data to update the vertexData
  102883. * @returns VertexData
  102884. */
  102885. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  102886. /**
  102887. * Updates the associated mesh
  102888. * @param mesh the mesh to be updated
  102889. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  102890. * @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
  102891. * @returns VertexData
  102892. */
  102893. updateMesh(mesh: Mesh): VertexData;
  102894. /**
  102895. * Updates the associated geometry
  102896. * @param geometry the geometry to be updated
  102897. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  102898. * @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
  102899. * @returns VertexData.
  102900. */
  102901. updateGeometry(geometry: Geometry): VertexData;
  102902. private _applyTo;
  102903. private _update;
  102904. /**
  102905. * Transforms each position and each normal of the vertexData according to the passed Matrix
  102906. * @param matrix the transforming matrix
  102907. * @returns the VertexData
  102908. */
  102909. transform(matrix: Matrix): VertexData;
  102910. /**
  102911. * Merges the passed VertexData into the current one
  102912. * @param other the VertexData to be merged into the current one
  102913. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  102914. * @returns the modified VertexData
  102915. */
  102916. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  102917. private _mergeElement;
  102918. private _validate;
  102919. /**
  102920. * Serializes the VertexData
  102921. * @returns a serialized object
  102922. */
  102923. serialize(): any;
  102924. /**
  102925. * Extracts the vertexData from a mesh
  102926. * @param mesh the mesh from which to extract the VertexData
  102927. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  102928. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102929. * @returns the object VertexData associated to the passed mesh
  102930. */
  102931. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  102932. /**
  102933. * Extracts the vertexData from the geometry
  102934. * @param geometry the geometry from which to extract the VertexData
  102935. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  102936. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102937. * @returns the object VertexData associated to the passed mesh
  102938. */
  102939. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  102940. private static _ExtractFrom;
  102941. /**
  102942. * Creates the VertexData for a Ribbon
  102943. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  102944. * * pathArray array of paths, each of which an array of successive Vector3
  102945. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  102946. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  102947. * * 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
  102948. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102949. * * 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)
  102950. * * 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)
  102951. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  102952. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  102953. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  102954. * @returns the VertexData of the ribbon
  102955. */
  102956. static CreateRibbon(options: {
  102957. pathArray: Vector3[][];
  102958. closeArray?: boolean;
  102959. closePath?: boolean;
  102960. offset?: number;
  102961. sideOrientation?: number;
  102962. frontUVs?: Vector4;
  102963. backUVs?: Vector4;
  102964. invertUV?: boolean;
  102965. uvs?: Vector2[];
  102966. colors?: Color4[];
  102967. }): VertexData;
  102968. /**
  102969. * Creates the VertexData for a box
  102970. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102971. * * size sets the width, height and depth of the box to the value of size, optional default 1
  102972. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  102973. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  102974. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  102975. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  102976. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  102977. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102978. * * 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)
  102979. * * 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)
  102980. * @returns the VertexData of the box
  102981. */
  102982. static CreateBox(options: {
  102983. size?: number;
  102984. width?: number;
  102985. height?: number;
  102986. depth?: number;
  102987. faceUV?: Vector4[];
  102988. faceColors?: Color4[];
  102989. sideOrientation?: number;
  102990. frontUVs?: Vector4;
  102991. backUVs?: Vector4;
  102992. }): VertexData;
  102993. /**
  102994. * Creates the VertexData for a tiled box
  102995. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102996. * * faceTiles sets the pattern, tile size and number of tiles for a face
  102997. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  102998. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  102999. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103000. * @returns the VertexData of the box
  103001. */
  103002. static CreateTiledBox(options: {
  103003. pattern?: number;
  103004. width?: number;
  103005. height?: number;
  103006. depth?: number;
  103007. tileSize?: number;
  103008. tileWidth?: number;
  103009. tileHeight?: number;
  103010. alignHorizontal?: number;
  103011. alignVertical?: number;
  103012. faceUV?: Vector4[];
  103013. faceColors?: Color4[];
  103014. sideOrientation?: number;
  103015. }): VertexData;
  103016. /**
  103017. * Creates the VertexData for a tiled plane
  103018. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103019. * * pattern a limited pattern arrangement depending on the number
  103020. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  103021. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  103022. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  103023. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103024. * * 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)
  103025. * * 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)
  103026. * @returns the VertexData of the tiled plane
  103027. */
  103028. static CreateTiledPlane(options: {
  103029. pattern?: number;
  103030. tileSize?: number;
  103031. tileWidth?: number;
  103032. tileHeight?: number;
  103033. size?: number;
  103034. width?: number;
  103035. height?: number;
  103036. alignHorizontal?: number;
  103037. alignVertical?: number;
  103038. sideOrientation?: number;
  103039. frontUVs?: Vector4;
  103040. backUVs?: Vector4;
  103041. }): VertexData;
  103042. /**
  103043. * Creates the VertexData for an ellipsoid, defaults to a sphere
  103044. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103045. * * segments sets the number of horizontal strips optional, default 32
  103046. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  103047. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  103048. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  103049. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  103050. * * 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
  103051. * * 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
  103052. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103053. * * 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)
  103054. * * 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)
  103055. * @returns the VertexData of the ellipsoid
  103056. */
  103057. static CreateSphere(options: {
  103058. segments?: number;
  103059. diameter?: number;
  103060. diameterX?: number;
  103061. diameterY?: number;
  103062. diameterZ?: number;
  103063. arc?: number;
  103064. slice?: number;
  103065. sideOrientation?: number;
  103066. frontUVs?: Vector4;
  103067. backUVs?: Vector4;
  103068. }): VertexData;
  103069. /**
  103070. * Creates the VertexData for a cylinder, cone or prism
  103071. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103072. * * height sets the height (y direction) of the cylinder, optional, default 2
  103073. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  103074. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  103075. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  103076. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  103077. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  103078. * * 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
  103079. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103080. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103081. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  103082. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  103083. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103084. * * 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)
  103085. * * 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)
  103086. * @returns the VertexData of the cylinder, cone or prism
  103087. */
  103088. static CreateCylinder(options: {
  103089. height?: number;
  103090. diameterTop?: number;
  103091. diameterBottom?: number;
  103092. diameter?: number;
  103093. tessellation?: number;
  103094. subdivisions?: number;
  103095. arc?: number;
  103096. faceColors?: Color4[];
  103097. faceUV?: Vector4[];
  103098. hasRings?: boolean;
  103099. enclose?: boolean;
  103100. sideOrientation?: number;
  103101. frontUVs?: Vector4;
  103102. backUVs?: Vector4;
  103103. }): VertexData;
  103104. /**
  103105. * Creates the VertexData for a torus
  103106. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103107. * * diameter the diameter of the torus, optional default 1
  103108. * * thickness the diameter of the tube forming the torus, optional default 0.5
  103109. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  103110. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103111. * * 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)
  103112. * * 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)
  103113. * @returns the VertexData of the torus
  103114. */
  103115. static CreateTorus(options: {
  103116. diameter?: number;
  103117. thickness?: number;
  103118. tessellation?: number;
  103119. sideOrientation?: number;
  103120. frontUVs?: Vector4;
  103121. backUVs?: Vector4;
  103122. }): VertexData;
  103123. /**
  103124. * Creates the VertexData of the LineSystem
  103125. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  103126. * - lines an array of lines, each line being an array of successive Vector3
  103127. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  103128. * @returns the VertexData of the LineSystem
  103129. */
  103130. static CreateLineSystem(options: {
  103131. lines: Vector3[][];
  103132. colors?: Nullable<Color4[][]>;
  103133. }): VertexData;
  103134. /**
  103135. * Create the VertexData for a DashedLines
  103136. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  103137. * - points an array successive Vector3
  103138. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  103139. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  103140. * - dashNb the intended total number of dashes, optional, default 200
  103141. * @returns the VertexData for the DashedLines
  103142. */
  103143. static CreateDashedLines(options: {
  103144. points: Vector3[];
  103145. dashSize?: number;
  103146. gapSize?: number;
  103147. dashNb?: number;
  103148. }): VertexData;
  103149. /**
  103150. * Creates the VertexData for a Ground
  103151. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  103152. * - width the width (x direction) of the ground, optional, default 1
  103153. * - height the height (z direction) of the ground, optional, default 1
  103154. * - subdivisions the number of subdivisions per side, optional, default 1
  103155. * @returns the VertexData of the Ground
  103156. */
  103157. static CreateGround(options: {
  103158. width?: number;
  103159. height?: number;
  103160. subdivisions?: number;
  103161. subdivisionsX?: number;
  103162. subdivisionsY?: number;
  103163. }): VertexData;
  103164. /**
  103165. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  103166. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  103167. * * xmin the ground minimum X coordinate, optional, default -1
  103168. * * zmin the ground minimum Z coordinate, optional, default -1
  103169. * * xmax the ground maximum X coordinate, optional, default 1
  103170. * * zmax the ground maximum Z coordinate, optional, default 1
  103171. * * 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}
  103172. * * 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}
  103173. * @returns the VertexData of the TiledGround
  103174. */
  103175. static CreateTiledGround(options: {
  103176. xmin: number;
  103177. zmin: number;
  103178. xmax: number;
  103179. zmax: number;
  103180. subdivisions?: {
  103181. w: number;
  103182. h: number;
  103183. };
  103184. precision?: {
  103185. w: number;
  103186. h: number;
  103187. };
  103188. }): VertexData;
  103189. /**
  103190. * Creates the VertexData of the Ground designed from a heightmap
  103191. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  103192. * * width the width (x direction) of the ground
  103193. * * height the height (z direction) of the ground
  103194. * * subdivisions the number of subdivisions per side
  103195. * * minHeight the minimum altitude on the ground, optional, default 0
  103196. * * maxHeight the maximum altitude on the ground, optional default 1
  103197. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  103198. * * buffer the array holding the image color data
  103199. * * bufferWidth the width of image
  103200. * * bufferHeight the height of image
  103201. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  103202. * @returns the VertexData of the Ground designed from a heightmap
  103203. */
  103204. static CreateGroundFromHeightMap(options: {
  103205. width: number;
  103206. height: number;
  103207. subdivisions: number;
  103208. minHeight: number;
  103209. maxHeight: number;
  103210. colorFilter: Color3;
  103211. buffer: Uint8Array;
  103212. bufferWidth: number;
  103213. bufferHeight: number;
  103214. alphaFilter: number;
  103215. }): VertexData;
  103216. /**
  103217. * Creates the VertexData for a Plane
  103218. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  103219. * * size sets the width and height of the plane to the value of size, optional default 1
  103220. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  103221. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  103222. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103223. * * 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)
  103224. * * 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)
  103225. * @returns the VertexData of the box
  103226. */
  103227. static CreatePlane(options: {
  103228. size?: number;
  103229. width?: number;
  103230. height?: number;
  103231. sideOrientation?: number;
  103232. frontUVs?: Vector4;
  103233. backUVs?: Vector4;
  103234. }): VertexData;
  103235. /**
  103236. * Creates the VertexData of the Disc or regular Polygon
  103237. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  103238. * * radius the radius of the disc, optional default 0.5
  103239. * * tessellation the number of polygon sides, optional, default 64
  103240. * * 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
  103241. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103242. * * 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)
  103243. * * 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)
  103244. * @returns the VertexData of the box
  103245. */
  103246. static CreateDisc(options: {
  103247. radius?: number;
  103248. tessellation?: number;
  103249. arc?: number;
  103250. sideOrientation?: number;
  103251. frontUVs?: Vector4;
  103252. backUVs?: Vector4;
  103253. }): VertexData;
  103254. /**
  103255. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  103256. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  103257. * @param polygon a mesh built from polygonTriangulation.build()
  103258. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103259. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103260. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103261. * @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)
  103262. * @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)
  103263. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  103264. * @returns the VertexData of the Polygon
  103265. */
  103266. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  103267. /**
  103268. * Creates the VertexData of the IcoSphere
  103269. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  103270. * * radius the radius of the IcoSphere, optional default 1
  103271. * * radiusX allows stretching in the x direction, optional, default radius
  103272. * * radiusY allows stretching in the y direction, optional, default radius
  103273. * * radiusZ allows stretching in the z direction, optional, default radius
  103274. * * flat when true creates a flat shaded mesh, optional, default true
  103275. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  103276. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103277. * * 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)
  103278. * * 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)
  103279. * @returns the VertexData of the IcoSphere
  103280. */
  103281. static CreateIcoSphere(options: {
  103282. radius?: number;
  103283. radiusX?: number;
  103284. radiusY?: number;
  103285. radiusZ?: number;
  103286. flat?: boolean;
  103287. subdivisions?: number;
  103288. sideOrientation?: number;
  103289. frontUVs?: Vector4;
  103290. backUVs?: Vector4;
  103291. }): VertexData;
  103292. /**
  103293. * Creates the VertexData for a Polyhedron
  103294. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  103295. * * type provided types are:
  103296. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  103297. * * 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)
  103298. * * size the size of the IcoSphere, optional default 1
  103299. * * sizeX allows stretching in the x direction, optional, default size
  103300. * * sizeY allows stretching in the y direction, optional, default size
  103301. * * sizeZ allows stretching in the z direction, optional, default size
  103302. * * 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
  103303. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103304. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103305. * * flat when true creates a flat shaded mesh, optional, default true
  103306. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  103307. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103308. * * 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)
  103309. * * 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)
  103310. * @returns the VertexData of the Polyhedron
  103311. */
  103312. static CreatePolyhedron(options: {
  103313. type?: number;
  103314. size?: number;
  103315. sizeX?: number;
  103316. sizeY?: number;
  103317. sizeZ?: number;
  103318. custom?: any;
  103319. faceUV?: Vector4[];
  103320. faceColors?: Color4[];
  103321. flat?: boolean;
  103322. sideOrientation?: number;
  103323. frontUVs?: Vector4;
  103324. backUVs?: Vector4;
  103325. }): VertexData;
  103326. /**
  103327. * Creates the VertexData for a TorusKnot
  103328. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  103329. * * radius the radius of the torus knot, optional, default 2
  103330. * * tube the thickness of the tube, optional, default 0.5
  103331. * * radialSegments the number of sides on each tube segments, optional, default 32
  103332. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  103333. * * p the number of windings around the z axis, optional, default 2
  103334. * * q the number of windings around the x axis, optional, default 3
  103335. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103336. * * 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)
  103337. * * 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)
  103338. * @returns the VertexData of the Torus Knot
  103339. */
  103340. static CreateTorusKnot(options: {
  103341. radius?: number;
  103342. tube?: number;
  103343. radialSegments?: number;
  103344. tubularSegments?: number;
  103345. p?: number;
  103346. q?: number;
  103347. sideOrientation?: number;
  103348. frontUVs?: Vector4;
  103349. backUVs?: Vector4;
  103350. }): VertexData;
  103351. /**
  103352. * Compute normals for given positions and indices
  103353. * @param positions an array of vertex positions, [...., x, y, z, ......]
  103354. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  103355. * @param normals an array of vertex normals, [...., x, y, z, ......]
  103356. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  103357. * * facetNormals : optional array of facet normals (vector3)
  103358. * * facetPositions : optional array of facet positions (vector3)
  103359. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  103360. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  103361. * * bInfo : optional bounding info, required for facetPartitioning computation
  103362. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  103363. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  103364. * * useRightHandedSystem: optional boolean to for right handed system computation
  103365. * * depthSort : optional boolean to enable the facet depth sort computation
  103366. * * distanceTo : optional Vector3 to compute the facet depth from this location
  103367. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  103368. */
  103369. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  103370. facetNormals?: any;
  103371. facetPositions?: any;
  103372. facetPartitioning?: any;
  103373. ratio?: number;
  103374. bInfo?: any;
  103375. bbSize?: Vector3;
  103376. subDiv?: any;
  103377. useRightHandedSystem?: boolean;
  103378. depthSort?: boolean;
  103379. distanceTo?: Vector3;
  103380. depthSortedFacets?: any;
  103381. }): void;
  103382. /** @hidden */
  103383. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  103384. /**
  103385. * Applies VertexData created from the imported parameters to the geometry
  103386. * @param parsedVertexData the parsed data from an imported file
  103387. * @param geometry the geometry to apply the VertexData to
  103388. */
  103389. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  103390. }
  103391. }
  103392. declare module BABYLON {
  103393. /**
  103394. * Defines a target to use with MorphTargetManager
  103395. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103396. */
  103397. export class MorphTarget implements IAnimatable {
  103398. /** defines the name of the target */
  103399. name: string;
  103400. /**
  103401. * Gets or sets the list of animations
  103402. */
  103403. animations: Animation[];
  103404. private _scene;
  103405. private _positions;
  103406. private _normals;
  103407. private _tangents;
  103408. private _uvs;
  103409. private _influence;
  103410. private _uniqueId;
  103411. /**
  103412. * Observable raised when the influence changes
  103413. */
  103414. onInfluenceChanged: Observable<boolean>;
  103415. /** @hidden */
  103416. _onDataLayoutChanged: Observable<void>;
  103417. /**
  103418. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  103419. */
  103420. get influence(): number;
  103421. set influence(influence: number);
  103422. /**
  103423. * Gets or sets the id of the morph Target
  103424. */
  103425. id: string;
  103426. private _animationPropertiesOverride;
  103427. /**
  103428. * Gets or sets the animation properties override
  103429. */
  103430. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  103431. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  103432. /**
  103433. * Creates a new MorphTarget
  103434. * @param name defines the name of the target
  103435. * @param influence defines the influence to use
  103436. * @param scene defines the scene the morphtarget belongs to
  103437. */
  103438. constructor(
  103439. /** defines the name of the target */
  103440. name: string, influence?: number, scene?: Nullable<Scene>);
  103441. /**
  103442. * Gets the unique ID of this manager
  103443. */
  103444. get uniqueId(): number;
  103445. /**
  103446. * Gets a boolean defining if the target contains position data
  103447. */
  103448. get hasPositions(): boolean;
  103449. /**
  103450. * Gets a boolean defining if the target contains normal data
  103451. */
  103452. get hasNormals(): boolean;
  103453. /**
  103454. * Gets a boolean defining if the target contains tangent data
  103455. */
  103456. get hasTangents(): boolean;
  103457. /**
  103458. * Gets a boolean defining if the target contains texture coordinates data
  103459. */
  103460. get hasUVs(): boolean;
  103461. /**
  103462. * Affects position data to this target
  103463. * @param data defines the position data to use
  103464. */
  103465. setPositions(data: Nullable<FloatArray>): void;
  103466. /**
  103467. * Gets the position data stored in this target
  103468. * @returns a FloatArray containing the position data (or null if not present)
  103469. */
  103470. getPositions(): Nullable<FloatArray>;
  103471. /**
  103472. * Affects normal data to this target
  103473. * @param data defines the normal data to use
  103474. */
  103475. setNormals(data: Nullable<FloatArray>): void;
  103476. /**
  103477. * Gets the normal data stored in this target
  103478. * @returns a FloatArray containing the normal data (or null if not present)
  103479. */
  103480. getNormals(): Nullable<FloatArray>;
  103481. /**
  103482. * Affects tangent data to this target
  103483. * @param data defines the tangent data to use
  103484. */
  103485. setTangents(data: Nullable<FloatArray>): void;
  103486. /**
  103487. * Gets the tangent data stored in this target
  103488. * @returns a FloatArray containing the tangent data (or null if not present)
  103489. */
  103490. getTangents(): Nullable<FloatArray>;
  103491. /**
  103492. * Affects texture coordinates data to this target
  103493. * @param data defines the texture coordinates data to use
  103494. */
  103495. setUVs(data: Nullable<FloatArray>): void;
  103496. /**
  103497. * Gets the texture coordinates data stored in this target
  103498. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  103499. */
  103500. getUVs(): Nullable<FloatArray>;
  103501. /**
  103502. * Clone the current target
  103503. * @returns a new MorphTarget
  103504. */
  103505. clone(): MorphTarget;
  103506. /**
  103507. * Serializes the current target into a Serialization object
  103508. * @returns the serialized object
  103509. */
  103510. serialize(): any;
  103511. /**
  103512. * Returns the string "MorphTarget"
  103513. * @returns "MorphTarget"
  103514. */
  103515. getClassName(): string;
  103516. /**
  103517. * Creates a new target from serialized data
  103518. * @param serializationObject defines the serialized data to use
  103519. * @returns a new MorphTarget
  103520. */
  103521. static Parse(serializationObject: any): MorphTarget;
  103522. /**
  103523. * Creates a MorphTarget from mesh data
  103524. * @param mesh defines the source mesh
  103525. * @param name defines the name to use for the new target
  103526. * @param influence defines the influence to attach to the target
  103527. * @returns a new MorphTarget
  103528. */
  103529. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  103530. }
  103531. }
  103532. declare module BABYLON {
  103533. /**
  103534. * This class is used to deform meshes using morphing between different targets
  103535. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103536. */
  103537. export class MorphTargetManager {
  103538. private _targets;
  103539. private _targetInfluenceChangedObservers;
  103540. private _targetDataLayoutChangedObservers;
  103541. private _activeTargets;
  103542. private _scene;
  103543. private _influences;
  103544. private _supportsNormals;
  103545. private _supportsTangents;
  103546. private _supportsUVs;
  103547. private _vertexCount;
  103548. private _uniqueId;
  103549. private _tempInfluences;
  103550. /**
  103551. * Gets or sets a boolean indicating if normals must be morphed
  103552. */
  103553. enableNormalMorphing: boolean;
  103554. /**
  103555. * Gets or sets a boolean indicating if tangents must be morphed
  103556. */
  103557. enableTangentMorphing: boolean;
  103558. /**
  103559. * Gets or sets a boolean indicating if UV must be morphed
  103560. */
  103561. enableUVMorphing: boolean;
  103562. /**
  103563. * Creates a new MorphTargetManager
  103564. * @param scene defines the current scene
  103565. */
  103566. constructor(scene?: Nullable<Scene>);
  103567. /**
  103568. * Gets the unique ID of this manager
  103569. */
  103570. get uniqueId(): number;
  103571. /**
  103572. * Gets the number of vertices handled by this manager
  103573. */
  103574. get vertexCount(): number;
  103575. /**
  103576. * Gets a boolean indicating if this manager supports morphing of normals
  103577. */
  103578. get supportsNormals(): boolean;
  103579. /**
  103580. * Gets a boolean indicating if this manager supports morphing of tangents
  103581. */
  103582. get supportsTangents(): boolean;
  103583. /**
  103584. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  103585. */
  103586. get supportsUVs(): boolean;
  103587. /**
  103588. * Gets the number of targets stored in this manager
  103589. */
  103590. get numTargets(): number;
  103591. /**
  103592. * Gets the number of influencers (ie. the number of targets with influences > 0)
  103593. */
  103594. get numInfluencers(): number;
  103595. /**
  103596. * Gets the list of influences (one per target)
  103597. */
  103598. get influences(): Float32Array;
  103599. /**
  103600. * Gets the active target at specified index. An active target is a target with an influence > 0
  103601. * @param index defines the index to check
  103602. * @returns the requested target
  103603. */
  103604. getActiveTarget(index: number): MorphTarget;
  103605. /**
  103606. * Gets the target at specified index
  103607. * @param index defines the index to check
  103608. * @returns the requested target
  103609. */
  103610. getTarget(index: number): MorphTarget;
  103611. /**
  103612. * Add a new target to this manager
  103613. * @param target defines the target to add
  103614. */
  103615. addTarget(target: MorphTarget): void;
  103616. /**
  103617. * Removes a target from the manager
  103618. * @param target defines the target to remove
  103619. */
  103620. removeTarget(target: MorphTarget): void;
  103621. /**
  103622. * Clone the current manager
  103623. * @returns a new MorphTargetManager
  103624. */
  103625. clone(): MorphTargetManager;
  103626. /**
  103627. * Serializes the current manager into a Serialization object
  103628. * @returns the serialized object
  103629. */
  103630. serialize(): any;
  103631. private _syncActiveTargets;
  103632. /**
  103633. * Syncrhonize the targets with all the meshes using this morph target manager
  103634. */
  103635. synchronize(): void;
  103636. /**
  103637. * Creates a new MorphTargetManager from serialized data
  103638. * @param serializationObject defines the serialized data
  103639. * @param scene defines the hosting scene
  103640. * @returns the new MorphTargetManager
  103641. */
  103642. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  103643. }
  103644. }
  103645. declare module BABYLON {
  103646. /**
  103647. * Class used to represent a specific level of detail of a mesh
  103648. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  103649. */
  103650. export class MeshLODLevel {
  103651. /** Defines the distance where this level should start being displayed */
  103652. distance: number;
  103653. /** Defines the mesh to use to render this level */
  103654. mesh: Nullable<Mesh>;
  103655. /**
  103656. * Creates a new LOD level
  103657. * @param distance defines the distance where this level should star being displayed
  103658. * @param mesh defines the mesh to use to render this level
  103659. */
  103660. constructor(
  103661. /** Defines the distance where this level should start being displayed */
  103662. distance: number,
  103663. /** Defines the mesh to use to render this level */
  103664. mesh: Nullable<Mesh>);
  103665. }
  103666. }
  103667. declare module BABYLON {
  103668. /**
  103669. * Mesh representing the gorund
  103670. */
  103671. export class GroundMesh extends Mesh {
  103672. /** If octree should be generated */
  103673. generateOctree: boolean;
  103674. private _heightQuads;
  103675. /** @hidden */
  103676. _subdivisionsX: number;
  103677. /** @hidden */
  103678. _subdivisionsY: number;
  103679. /** @hidden */
  103680. _width: number;
  103681. /** @hidden */
  103682. _height: number;
  103683. /** @hidden */
  103684. _minX: number;
  103685. /** @hidden */
  103686. _maxX: number;
  103687. /** @hidden */
  103688. _minZ: number;
  103689. /** @hidden */
  103690. _maxZ: number;
  103691. constructor(name: string, scene: Scene);
  103692. /**
  103693. * "GroundMesh"
  103694. * @returns "GroundMesh"
  103695. */
  103696. getClassName(): string;
  103697. /**
  103698. * The minimum of x and y subdivisions
  103699. */
  103700. get subdivisions(): number;
  103701. /**
  103702. * X subdivisions
  103703. */
  103704. get subdivisionsX(): number;
  103705. /**
  103706. * Y subdivisions
  103707. */
  103708. get subdivisionsY(): number;
  103709. /**
  103710. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  103711. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103712. * @param chunksCount the number of subdivisions for x and y
  103713. * @param octreeBlocksSize (Default: 32)
  103714. */
  103715. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  103716. /**
  103717. * Returns a height (y) value in the Worl system :
  103718. * the ground altitude at the coordinates (x, z) expressed in the World system.
  103719. * @param x x coordinate
  103720. * @param z z coordinate
  103721. * @returns the ground y position if (x, z) are outside the ground surface.
  103722. */
  103723. getHeightAtCoordinates(x: number, z: number): number;
  103724. /**
  103725. * Returns a normalized vector (Vector3) orthogonal to the ground
  103726. * at the ground coordinates (x, z) expressed in the World system.
  103727. * @param x x coordinate
  103728. * @param z z coordinate
  103729. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  103730. */
  103731. getNormalAtCoordinates(x: number, z: number): Vector3;
  103732. /**
  103733. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  103734. * at the ground coordinates (x, z) expressed in the World system.
  103735. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  103736. * @param x x coordinate
  103737. * @param z z coordinate
  103738. * @param ref vector to store the result
  103739. * @returns the GroundMesh.
  103740. */
  103741. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  103742. /**
  103743. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  103744. * if the ground has been updated.
  103745. * This can be used in the render loop.
  103746. * @returns the GroundMesh.
  103747. */
  103748. updateCoordinateHeights(): GroundMesh;
  103749. private _getFacetAt;
  103750. private _initHeightQuads;
  103751. private _computeHeightQuads;
  103752. /**
  103753. * Serializes this ground mesh
  103754. * @param serializationObject object to write serialization to
  103755. */
  103756. serialize(serializationObject: any): void;
  103757. /**
  103758. * Parses a serialized ground mesh
  103759. * @param parsedMesh the serialized mesh
  103760. * @param scene the scene to create the ground mesh in
  103761. * @returns the created ground mesh
  103762. */
  103763. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  103764. }
  103765. }
  103766. declare module BABYLON {
  103767. /**
  103768. * Interface for Physics-Joint data
  103769. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103770. */
  103771. export interface PhysicsJointData {
  103772. /**
  103773. * The main pivot of the joint
  103774. */
  103775. mainPivot?: Vector3;
  103776. /**
  103777. * The connected pivot of the joint
  103778. */
  103779. connectedPivot?: Vector3;
  103780. /**
  103781. * The main axis of the joint
  103782. */
  103783. mainAxis?: Vector3;
  103784. /**
  103785. * The connected axis of the joint
  103786. */
  103787. connectedAxis?: Vector3;
  103788. /**
  103789. * The collision of the joint
  103790. */
  103791. collision?: boolean;
  103792. /**
  103793. * Native Oimo/Cannon/Energy data
  103794. */
  103795. nativeParams?: any;
  103796. }
  103797. /**
  103798. * This is a holder class for the physics joint created by the physics plugin
  103799. * It holds a set of functions to control the underlying joint
  103800. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103801. */
  103802. export class PhysicsJoint {
  103803. /**
  103804. * The type of the physics joint
  103805. */
  103806. type: number;
  103807. /**
  103808. * The data for the physics joint
  103809. */
  103810. jointData: PhysicsJointData;
  103811. private _physicsJoint;
  103812. protected _physicsPlugin: IPhysicsEnginePlugin;
  103813. /**
  103814. * Initializes the physics joint
  103815. * @param type The type of the physics joint
  103816. * @param jointData The data for the physics joint
  103817. */
  103818. constructor(
  103819. /**
  103820. * The type of the physics joint
  103821. */
  103822. type: number,
  103823. /**
  103824. * The data for the physics joint
  103825. */
  103826. jointData: PhysicsJointData);
  103827. /**
  103828. * Gets the physics joint
  103829. */
  103830. get physicsJoint(): any;
  103831. /**
  103832. * Sets the physics joint
  103833. */
  103834. set physicsJoint(newJoint: any);
  103835. /**
  103836. * Sets the physics plugin
  103837. */
  103838. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  103839. /**
  103840. * Execute a function that is physics-plugin specific.
  103841. * @param {Function} func the function that will be executed.
  103842. * It accepts two parameters: the physics world and the physics joint
  103843. */
  103844. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  103845. /**
  103846. * Distance-Joint type
  103847. */
  103848. static DistanceJoint: number;
  103849. /**
  103850. * Hinge-Joint type
  103851. */
  103852. static HingeJoint: number;
  103853. /**
  103854. * Ball-and-Socket joint type
  103855. */
  103856. static BallAndSocketJoint: number;
  103857. /**
  103858. * Wheel-Joint type
  103859. */
  103860. static WheelJoint: number;
  103861. /**
  103862. * Slider-Joint type
  103863. */
  103864. static SliderJoint: number;
  103865. /**
  103866. * Prismatic-Joint type
  103867. */
  103868. static PrismaticJoint: number;
  103869. /**
  103870. * Universal-Joint type
  103871. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  103872. */
  103873. static UniversalJoint: number;
  103874. /**
  103875. * Hinge-Joint 2 type
  103876. */
  103877. static Hinge2Joint: number;
  103878. /**
  103879. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  103880. */
  103881. static PointToPointJoint: number;
  103882. /**
  103883. * Spring-Joint type
  103884. */
  103885. static SpringJoint: number;
  103886. /**
  103887. * Lock-Joint type
  103888. */
  103889. static LockJoint: number;
  103890. }
  103891. /**
  103892. * A class representing a physics distance joint
  103893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103894. */
  103895. export class DistanceJoint extends PhysicsJoint {
  103896. /**
  103897. *
  103898. * @param jointData The data for the Distance-Joint
  103899. */
  103900. constructor(jointData: DistanceJointData);
  103901. /**
  103902. * Update the predefined distance.
  103903. * @param maxDistance The maximum preferred distance
  103904. * @param minDistance The minimum preferred distance
  103905. */
  103906. updateDistance(maxDistance: number, minDistance?: number): void;
  103907. }
  103908. /**
  103909. * Represents a Motor-Enabled Joint
  103910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103911. */
  103912. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  103913. /**
  103914. * Initializes the Motor-Enabled Joint
  103915. * @param type The type of the joint
  103916. * @param jointData The physica joint data for the joint
  103917. */
  103918. constructor(type: number, jointData: PhysicsJointData);
  103919. /**
  103920. * Set the motor values.
  103921. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103922. * @param force the force to apply
  103923. * @param maxForce max force for this motor.
  103924. */
  103925. setMotor(force?: number, maxForce?: number): void;
  103926. /**
  103927. * Set the motor's limits.
  103928. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103929. * @param upperLimit The upper limit of the motor
  103930. * @param lowerLimit The lower limit of the motor
  103931. */
  103932. setLimit(upperLimit: number, lowerLimit?: number): void;
  103933. }
  103934. /**
  103935. * This class represents a single physics Hinge-Joint
  103936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103937. */
  103938. export class HingeJoint extends MotorEnabledJoint {
  103939. /**
  103940. * Initializes the Hinge-Joint
  103941. * @param jointData The joint data for the Hinge-Joint
  103942. */
  103943. constructor(jointData: PhysicsJointData);
  103944. /**
  103945. * Set the motor values.
  103946. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103947. * @param {number} force the force to apply
  103948. * @param {number} maxForce max force for this motor.
  103949. */
  103950. setMotor(force?: number, maxForce?: number): void;
  103951. /**
  103952. * Set the motor's limits.
  103953. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103954. * @param upperLimit The upper limit of the motor
  103955. * @param lowerLimit The lower limit of the motor
  103956. */
  103957. setLimit(upperLimit: number, lowerLimit?: number): void;
  103958. }
  103959. /**
  103960. * This class represents a dual hinge physics joint (same as wheel joint)
  103961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103962. */
  103963. export class Hinge2Joint extends MotorEnabledJoint {
  103964. /**
  103965. * Initializes the Hinge2-Joint
  103966. * @param jointData The joint data for the Hinge2-Joint
  103967. */
  103968. constructor(jointData: PhysicsJointData);
  103969. /**
  103970. * Set the motor values.
  103971. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103972. * @param {number} targetSpeed the speed the motor is to reach
  103973. * @param {number} maxForce max force for this motor.
  103974. * @param {motorIndex} the motor's index, 0 or 1.
  103975. */
  103976. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  103977. /**
  103978. * Set the motor limits.
  103979. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103980. * @param {number} upperLimit the upper limit
  103981. * @param {number} lowerLimit lower limit
  103982. * @param {motorIndex} the motor's index, 0 or 1.
  103983. */
  103984. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103985. }
  103986. /**
  103987. * Interface for a motor enabled joint
  103988. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103989. */
  103990. export interface IMotorEnabledJoint {
  103991. /**
  103992. * Physics joint
  103993. */
  103994. physicsJoint: any;
  103995. /**
  103996. * Sets the motor of the motor-enabled joint
  103997. * @param force The force of the motor
  103998. * @param maxForce The maximum force of the motor
  103999. * @param motorIndex The index of the motor
  104000. */
  104001. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  104002. /**
  104003. * Sets the limit of the motor
  104004. * @param upperLimit The upper limit of the motor
  104005. * @param lowerLimit The lower limit of the motor
  104006. * @param motorIndex The index of the motor
  104007. */
  104008. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104009. }
  104010. /**
  104011. * Joint data for a Distance-Joint
  104012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104013. */
  104014. export interface DistanceJointData extends PhysicsJointData {
  104015. /**
  104016. * Max distance the 2 joint objects can be apart
  104017. */
  104018. maxDistance: number;
  104019. }
  104020. /**
  104021. * Joint data from a spring joint
  104022. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104023. */
  104024. export interface SpringJointData extends PhysicsJointData {
  104025. /**
  104026. * Length of the spring
  104027. */
  104028. length: number;
  104029. /**
  104030. * Stiffness of the spring
  104031. */
  104032. stiffness: number;
  104033. /**
  104034. * Damping of the spring
  104035. */
  104036. damping: number;
  104037. /** this callback will be called when applying the force to the impostors. */
  104038. forceApplicationCallback: () => void;
  104039. }
  104040. }
  104041. declare module BABYLON {
  104042. /**
  104043. * Holds the data for the raycast result
  104044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104045. */
  104046. export class PhysicsRaycastResult {
  104047. private _hasHit;
  104048. private _hitDistance;
  104049. private _hitNormalWorld;
  104050. private _hitPointWorld;
  104051. private _rayFromWorld;
  104052. private _rayToWorld;
  104053. /**
  104054. * Gets if there was a hit
  104055. */
  104056. get hasHit(): boolean;
  104057. /**
  104058. * Gets the distance from the hit
  104059. */
  104060. get hitDistance(): number;
  104061. /**
  104062. * Gets the hit normal/direction in the world
  104063. */
  104064. get hitNormalWorld(): Vector3;
  104065. /**
  104066. * Gets the hit point in the world
  104067. */
  104068. get hitPointWorld(): Vector3;
  104069. /**
  104070. * Gets the ray "start point" of the ray in the world
  104071. */
  104072. get rayFromWorld(): Vector3;
  104073. /**
  104074. * Gets the ray "end point" of the ray in the world
  104075. */
  104076. get rayToWorld(): Vector3;
  104077. /**
  104078. * Sets the hit data (normal & point in world space)
  104079. * @param hitNormalWorld defines the normal in world space
  104080. * @param hitPointWorld defines the point in world space
  104081. */
  104082. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  104083. /**
  104084. * Sets the distance from the start point to the hit point
  104085. * @param distance
  104086. */
  104087. setHitDistance(distance: number): void;
  104088. /**
  104089. * Calculates the distance manually
  104090. */
  104091. calculateHitDistance(): void;
  104092. /**
  104093. * Resets all the values to default
  104094. * @param from The from point on world space
  104095. * @param to The to point on world space
  104096. */
  104097. reset(from?: Vector3, to?: Vector3): void;
  104098. }
  104099. /**
  104100. * Interface for the size containing width and height
  104101. */
  104102. interface IXYZ {
  104103. /**
  104104. * X
  104105. */
  104106. x: number;
  104107. /**
  104108. * Y
  104109. */
  104110. y: number;
  104111. /**
  104112. * Z
  104113. */
  104114. z: number;
  104115. }
  104116. }
  104117. declare module BABYLON {
  104118. /**
  104119. * Interface used to describe a physics joint
  104120. */
  104121. export interface PhysicsImpostorJoint {
  104122. /** Defines the main impostor to which the joint is linked */
  104123. mainImpostor: PhysicsImpostor;
  104124. /** Defines the impostor that is connected to the main impostor using this joint */
  104125. connectedImpostor: PhysicsImpostor;
  104126. /** Defines the joint itself */
  104127. joint: PhysicsJoint;
  104128. }
  104129. /** @hidden */
  104130. export interface IPhysicsEnginePlugin {
  104131. world: any;
  104132. name: string;
  104133. setGravity(gravity: Vector3): void;
  104134. setTimeStep(timeStep: number): void;
  104135. getTimeStep(): number;
  104136. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  104137. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104138. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104139. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104140. removePhysicsBody(impostor: PhysicsImpostor): void;
  104141. generateJoint(joint: PhysicsImpostorJoint): void;
  104142. removeJoint(joint: PhysicsImpostorJoint): void;
  104143. isSupported(): boolean;
  104144. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104145. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104146. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  104147. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  104148. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104149. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104150. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104151. getBodyMass(impostor: PhysicsImpostor): number;
  104152. getBodyFriction(impostor: PhysicsImpostor): number;
  104153. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104154. getBodyRestitution(impostor: PhysicsImpostor): number;
  104155. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104156. getBodyPressure?(impostor: PhysicsImpostor): number;
  104157. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  104158. getBodyStiffness?(impostor: PhysicsImpostor): number;
  104159. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  104160. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  104161. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  104162. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  104163. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  104164. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  104165. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  104166. sleepBody(impostor: PhysicsImpostor): void;
  104167. wakeUpBody(impostor: PhysicsImpostor): void;
  104168. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  104169. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  104170. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  104171. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104172. getRadius(impostor: PhysicsImpostor): number;
  104173. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104174. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104175. dispose(): void;
  104176. }
  104177. /**
  104178. * Interface used to define a physics engine
  104179. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  104180. */
  104181. export interface IPhysicsEngine {
  104182. /**
  104183. * Gets the gravity vector used by the simulation
  104184. */
  104185. gravity: Vector3;
  104186. /**
  104187. * Sets the gravity vector used by the simulation
  104188. * @param gravity defines the gravity vector to use
  104189. */
  104190. setGravity(gravity: Vector3): void;
  104191. /**
  104192. * Set the time step of the physics engine.
  104193. * Default is 1/60.
  104194. * To slow it down, enter 1/600 for example.
  104195. * To speed it up, 1/30
  104196. * @param newTimeStep the new timestep to apply to this world.
  104197. */
  104198. setTimeStep(newTimeStep: number): void;
  104199. /**
  104200. * Get the time step of the physics engine.
  104201. * @returns the current time step
  104202. */
  104203. getTimeStep(): number;
  104204. /**
  104205. * Set the sub time step of the physics engine.
  104206. * Default is 0 meaning there is no sub steps
  104207. * To increase physics resolution precision, set a small value (like 1 ms)
  104208. * @param subTimeStep defines the new sub timestep used for physics resolution.
  104209. */
  104210. setSubTimeStep(subTimeStep: number): void;
  104211. /**
  104212. * Get the sub time step of the physics engine.
  104213. * @returns the current sub time step
  104214. */
  104215. getSubTimeStep(): number;
  104216. /**
  104217. * Release all resources
  104218. */
  104219. dispose(): void;
  104220. /**
  104221. * Gets the name of the current physics plugin
  104222. * @returns the name of the plugin
  104223. */
  104224. getPhysicsPluginName(): string;
  104225. /**
  104226. * Adding a new impostor for the impostor tracking.
  104227. * This will be done by the impostor itself.
  104228. * @param impostor the impostor to add
  104229. */
  104230. addImpostor(impostor: PhysicsImpostor): void;
  104231. /**
  104232. * Remove an impostor from the engine.
  104233. * This impostor and its mesh will not longer be updated by the physics engine.
  104234. * @param impostor the impostor to remove
  104235. */
  104236. removeImpostor(impostor: PhysicsImpostor): void;
  104237. /**
  104238. * Add a joint to the physics engine
  104239. * @param mainImpostor defines the main impostor to which the joint is added.
  104240. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  104241. * @param joint defines the joint that will connect both impostors.
  104242. */
  104243. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104244. /**
  104245. * Removes a joint from the simulation
  104246. * @param mainImpostor defines the impostor used with the joint
  104247. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  104248. * @param joint defines the joint to remove
  104249. */
  104250. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104251. /**
  104252. * Gets the current plugin used to run the simulation
  104253. * @returns current plugin
  104254. */
  104255. getPhysicsPlugin(): IPhysicsEnginePlugin;
  104256. /**
  104257. * Gets the list of physic impostors
  104258. * @returns an array of PhysicsImpostor
  104259. */
  104260. getImpostors(): Array<PhysicsImpostor>;
  104261. /**
  104262. * Gets the impostor for a physics enabled object
  104263. * @param object defines the object impersonated by the impostor
  104264. * @returns the PhysicsImpostor or null if not found
  104265. */
  104266. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104267. /**
  104268. * Gets the impostor for a physics body object
  104269. * @param body defines physics body used by the impostor
  104270. * @returns the PhysicsImpostor or null if not found
  104271. */
  104272. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  104273. /**
  104274. * Does a raycast in the physics world
  104275. * @param from when should the ray start?
  104276. * @param to when should the ray end?
  104277. * @returns PhysicsRaycastResult
  104278. */
  104279. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  104280. /**
  104281. * Called by the scene. No need to call it.
  104282. * @param delta defines the timespam between frames
  104283. */
  104284. _step(delta: number): void;
  104285. }
  104286. }
  104287. declare module BABYLON {
  104288. /**
  104289. * The interface for the physics imposter parameters
  104290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104291. */
  104292. export interface PhysicsImpostorParameters {
  104293. /**
  104294. * The mass of the physics imposter
  104295. */
  104296. mass: number;
  104297. /**
  104298. * The friction of the physics imposter
  104299. */
  104300. friction?: number;
  104301. /**
  104302. * The coefficient of restitution of the physics imposter
  104303. */
  104304. restitution?: number;
  104305. /**
  104306. * The native options of the physics imposter
  104307. */
  104308. nativeOptions?: any;
  104309. /**
  104310. * Specifies if the parent should be ignored
  104311. */
  104312. ignoreParent?: boolean;
  104313. /**
  104314. * Specifies if bi-directional transformations should be disabled
  104315. */
  104316. disableBidirectionalTransformation?: boolean;
  104317. /**
  104318. * The pressure inside the physics imposter, soft object only
  104319. */
  104320. pressure?: number;
  104321. /**
  104322. * The stiffness the physics imposter, soft object only
  104323. */
  104324. stiffness?: number;
  104325. /**
  104326. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  104327. */
  104328. velocityIterations?: number;
  104329. /**
  104330. * The number of iterations used in maintaining consistent vertex positions, soft object only
  104331. */
  104332. positionIterations?: number;
  104333. /**
  104334. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  104335. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  104336. * Add to fix multiple points
  104337. */
  104338. fixedPoints?: number;
  104339. /**
  104340. * The collision margin around a soft object
  104341. */
  104342. margin?: number;
  104343. /**
  104344. * The collision margin around a soft object
  104345. */
  104346. damping?: number;
  104347. /**
  104348. * The path for a rope based on an extrusion
  104349. */
  104350. path?: any;
  104351. /**
  104352. * The shape of an extrusion used for a rope based on an extrusion
  104353. */
  104354. shape?: any;
  104355. }
  104356. /**
  104357. * Interface for a physics-enabled object
  104358. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104359. */
  104360. export interface IPhysicsEnabledObject {
  104361. /**
  104362. * The position of the physics-enabled object
  104363. */
  104364. position: Vector3;
  104365. /**
  104366. * The rotation of the physics-enabled object
  104367. */
  104368. rotationQuaternion: Nullable<Quaternion>;
  104369. /**
  104370. * The scale of the physics-enabled object
  104371. */
  104372. scaling: Vector3;
  104373. /**
  104374. * The rotation of the physics-enabled object
  104375. */
  104376. rotation?: Vector3;
  104377. /**
  104378. * The parent of the physics-enabled object
  104379. */
  104380. parent?: any;
  104381. /**
  104382. * The bounding info of the physics-enabled object
  104383. * @returns The bounding info of the physics-enabled object
  104384. */
  104385. getBoundingInfo(): BoundingInfo;
  104386. /**
  104387. * Computes the world matrix
  104388. * @param force Specifies if the world matrix should be computed by force
  104389. * @returns A world matrix
  104390. */
  104391. computeWorldMatrix(force: boolean): Matrix;
  104392. /**
  104393. * Gets the world matrix
  104394. * @returns A world matrix
  104395. */
  104396. getWorldMatrix?(): Matrix;
  104397. /**
  104398. * Gets the child meshes
  104399. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  104400. * @returns An array of abstract meshes
  104401. */
  104402. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  104403. /**
  104404. * Gets the vertex data
  104405. * @param kind The type of vertex data
  104406. * @returns A nullable array of numbers, or a float32 array
  104407. */
  104408. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  104409. /**
  104410. * Gets the indices from the mesh
  104411. * @returns A nullable array of index arrays
  104412. */
  104413. getIndices?(): Nullable<IndicesArray>;
  104414. /**
  104415. * Gets the scene from the mesh
  104416. * @returns the indices array or null
  104417. */
  104418. getScene?(): Scene;
  104419. /**
  104420. * Gets the absolute position from the mesh
  104421. * @returns the absolute position
  104422. */
  104423. getAbsolutePosition(): Vector3;
  104424. /**
  104425. * Gets the absolute pivot point from the mesh
  104426. * @returns the absolute pivot point
  104427. */
  104428. getAbsolutePivotPoint(): Vector3;
  104429. /**
  104430. * Rotates the mesh
  104431. * @param axis The axis of rotation
  104432. * @param amount The amount of rotation
  104433. * @param space The space of the rotation
  104434. * @returns The rotation transform node
  104435. */
  104436. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  104437. /**
  104438. * Translates the mesh
  104439. * @param axis The axis of translation
  104440. * @param distance The distance of translation
  104441. * @param space The space of the translation
  104442. * @returns The transform node
  104443. */
  104444. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  104445. /**
  104446. * Sets the absolute position of the mesh
  104447. * @param absolutePosition The absolute position of the mesh
  104448. * @returns The transform node
  104449. */
  104450. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  104451. /**
  104452. * Gets the class name of the mesh
  104453. * @returns The class name
  104454. */
  104455. getClassName(): string;
  104456. }
  104457. /**
  104458. * Represents a physics imposter
  104459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104460. */
  104461. export class PhysicsImpostor {
  104462. /**
  104463. * The physics-enabled object used as the physics imposter
  104464. */
  104465. object: IPhysicsEnabledObject;
  104466. /**
  104467. * The type of the physics imposter
  104468. */
  104469. type: number;
  104470. private _options;
  104471. private _scene?;
  104472. /**
  104473. * The default object size of the imposter
  104474. */
  104475. static DEFAULT_OBJECT_SIZE: Vector3;
  104476. /**
  104477. * The identity quaternion of the imposter
  104478. */
  104479. static IDENTITY_QUATERNION: Quaternion;
  104480. /** @hidden */
  104481. _pluginData: any;
  104482. private _physicsEngine;
  104483. private _physicsBody;
  104484. private _bodyUpdateRequired;
  104485. private _onBeforePhysicsStepCallbacks;
  104486. private _onAfterPhysicsStepCallbacks;
  104487. /** @hidden */
  104488. _onPhysicsCollideCallbacks: Array<{
  104489. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  104490. otherImpostors: Array<PhysicsImpostor>;
  104491. }>;
  104492. private _deltaPosition;
  104493. private _deltaRotation;
  104494. private _deltaRotationConjugated;
  104495. /** @hidden */
  104496. _isFromLine: boolean;
  104497. private _parent;
  104498. private _isDisposed;
  104499. private static _tmpVecs;
  104500. private static _tmpQuat;
  104501. /**
  104502. * Specifies if the physics imposter is disposed
  104503. */
  104504. get isDisposed(): boolean;
  104505. /**
  104506. * Gets the mass of the physics imposter
  104507. */
  104508. get mass(): number;
  104509. set mass(value: number);
  104510. /**
  104511. * Gets the coefficient of friction
  104512. */
  104513. get friction(): number;
  104514. /**
  104515. * Sets the coefficient of friction
  104516. */
  104517. set friction(value: number);
  104518. /**
  104519. * Gets the coefficient of restitution
  104520. */
  104521. get restitution(): number;
  104522. /**
  104523. * Sets the coefficient of restitution
  104524. */
  104525. set restitution(value: number);
  104526. /**
  104527. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  104528. */
  104529. get pressure(): number;
  104530. /**
  104531. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  104532. */
  104533. set pressure(value: number);
  104534. /**
  104535. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  104536. */
  104537. get stiffness(): number;
  104538. /**
  104539. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  104540. */
  104541. set stiffness(value: number);
  104542. /**
  104543. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  104544. */
  104545. get velocityIterations(): number;
  104546. /**
  104547. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  104548. */
  104549. set velocityIterations(value: number);
  104550. /**
  104551. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  104552. */
  104553. get positionIterations(): number;
  104554. /**
  104555. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  104556. */
  104557. set positionIterations(value: number);
  104558. /**
  104559. * The unique id of the physics imposter
  104560. * set by the physics engine when adding this impostor to the array
  104561. */
  104562. uniqueId: number;
  104563. /**
  104564. * @hidden
  104565. */
  104566. soft: boolean;
  104567. /**
  104568. * @hidden
  104569. */
  104570. segments: number;
  104571. private _joints;
  104572. /**
  104573. * Initializes the physics imposter
  104574. * @param object The physics-enabled object used as the physics imposter
  104575. * @param type The type of the physics imposter
  104576. * @param _options The options for the physics imposter
  104577. * @param _scene The Babylon scene
  104578. */
  104579. constructor(
  104580. /**
  104581. * The physics-enabled object used as the physics imposter
  104582. */
  104583. object: IPhysicsEnabledObject,
  104584. /**
  104585. * The type of the physics imposter
  104586. */
  104587. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  104588. /**
  104589. * This function will completly initialize this impostor.
  104590. * It will create a new body - but only if this mesh has no parent.
  104591. * If it has, this impostor will not be used other than to define the impostor
  104592. * of the child mesh.
  104593. * @hidden
  104594. */
  104595. _init(): void;
  104596. private _getPhysicsParent;
  104597. /**
  104598. * Should a new body be generated.
  104599. * @returns boolean specifying if body initialization is required
  104600. */
  104601. isBodyInitRequired(): boolean;
  104602. /**
  104603. * Sets the updated scaling
  104604. * @param updated Specifies if the scaling is updated
  104605. */
  104606. setScalingUpdated(): void;
  104607. /**
  104608. * Force a regeneration of this or the parent's impostor's body.
  104609. * Use under cautious - This will remove all joints already implemented.
  104610. */
  104611. forceUpdate(): void;
  104612. /**
  104613. * Gets the body that holds this impostor. Either its own, or its parent.
  104614. */
  104615. get physicsBody(): any;
  104616. /**
  104617. * Get the parent of the physics imposter
  104618. * @returns Physics imposter or null
  104619. */
  104620. get parent(): Nullable<PhysicsImpostor>;
  104621. /**
  104622. * Sets the parent of the physics imposter
  104623. */
  104624. set parent(value: Nullable<PhysicsImpostor>);
  104625. /**
  104626. * Set the physics body. Used mainly by the physics engine/plugin
  104627. */
  104628. set physicsBody(physicsBody: any);
  104629. /**
  104630. * Resets the update flags
  104631. */
  104632. resetUpdateFlags(): void;
  104633. /**
  104634. * Gets the object extend size
  104635. * @returns the object extend size
  104636. */
  104637. getObjectExtendSize(): Vector3;
  104638. /**
  104639. * Gets the object center
  104640. * @returns The object center
  104641. */
  104642. getObjectCenter(): Vector3;
  104643. /**
  104644. * Get a specific parameter from the options parameters
  104645. * @param paramName The object parameter name
  104646. * @returns The object parameter
  104647. */
  104648. getParam(paramName: string): any;
  104649. /**
  104650. * Sets a specific parameter in the options given to the physics plugin
  104651. * @param paramName The parameter name
  104652. * @param value The value of the parameter
  104653. */
  104654. setParam(paramName: string, value: number): void;
  104655. /**
  104656. * Specifically change the body's mass option. Won't recreate the physics body object
  104657. * @param mass The mass of the physics imposter
  104658. */
  104659. setMass(mass: number): void;
  104660. /**
  104661. * Gets the linear velocity
  104662. * @returns linear velocity or null
  104663. */
  104664. getLinearVelocity(): Nullable<Vector3>;
  104665. /**
  104666. * Sets the linear velocity
  104667. * @param velocity linear velocity or null
  104668. */
  104669. setLinearVelocity(velocity: Nullable<Vector3>): void;
  104670. /**
  104671. * Gets the angular velocity
  104672. * @returns angular velocity or null
  104673. */
  104674. getAngularVelocity(): Nullable<Vector3>;
  104675. /**
  104676. * Sets the angular velocity
  104677. * @param velocity The velocity or null
  104678. */
  104679. setAngularVelocity(velocity: Nullable<Vector3>): void;
  104680. /**
  104681. * Execute a function with the physics plugin native code
  104682. * Provide a function the will have two variables - the world object and the physics body object
  104683. * @param func The function to execute with the physics plugin native code
  104684. */
  104685. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  104686. /**
  104687. * Register a function that will be executed before the physics world is stepping forward
  104688. * @param func The function to execute before the physics world is stepped forward
  104689. */
  104690. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104691. /**
  104692. * Unregister a function that will be executed before the physics world is stepping forward
  104693. * @param func The function to execute before the physics world is stepped forward
  104694. */
  104695. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104696. /**
  104697. * Register a function that will be executed after the physics step
  104698. * @param func The function to execute after physics step
  104699. */
  104700. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104701. /**
  104702. * Unregisters a function that will be executed after the physics step
  104703. * @param func The function to execute after physics step
  104704. */
  104705. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104706. /**
  104707. * register a function that will be executed when this impostor collides against a different body
  104708. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  104709. * @param func Callback that is executed on collision
  104710. */
  104711. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  104712. /**
  104713. * Unregisters the physics imposter on contact
  104714. * @param collideAgainst The physics object to collide against
  104715. * @param func Callback to execute on collision
  104716. */
  104717. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  104718. private _tmpQuat;
  104719. private _tmpQuat2;
  104720. /**
  104721. * Get the parent rotation
  104722. * @returns The parent rotation
  104723. */
  104724. getParentsRotation(): Quaternion;
  104725. /**
  104726. * this function is executed by the physics engine.
  104727. */
  104728. beforeStep: () => void;
  104729. /**
  104730. * this function is executed by the physics engine
  104731. */
  104732. afterStep: () => void;
  104733. /**
  104734. * Legacy collision detection event support
  104735. */
  104736. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  104737. /**
  104738. * event and body object due to cannon's event-based architecture.
  104739. */
  104740. onCollide: (e: {
  104741. body: any;
  104742. }) => void;
  104743. /**
  104744. * Apply a force
  104745. * @param force The force to apply
  104746. * @param contactPoint The contact point for the force
  104747. * @returns The physics imposter
  104748. */
  104749. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  104750. /**
  104751. * Apply an impulse
  104752. * @param force The impulse force
  104753. * @param contactPoint The contact point for the impulse force
  104754. * @returns The physics imposter
  104755. */
  104756. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  104757. /**
  104758. * A help function to create a joint
  104759. * @param otherImpostor A physics imposter used to create a joint
  104760. * @param jointType The type of joint
  104761. * @param jointData The data for the joint
  104762. * @returns The physics imposter
  104763. */
  104764. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  104765. /**
  104766. * Add a joint to this impostor with a different impostor
  104767. * @param otherImpostor A physics imposter used to add a joint
  104768. * @param joint The joint to add
  104769. * @returns The physics imposter
  104770. */
  104771. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  104772. /**
  104773. * Add an anchor to a cloth impostor
  104774. * @param otherImpostor rigid impostor to anchor to
  104775. * @param width ratio across width from 0 to 1
  104776. * @param height ratio up height from 0 to 1
  104777. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  104778. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  104779. * @returns impostor the soft imposter
  104780. */
  104781. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  104782. /**
  104783. * Add a hook to a rope impostor
  104784. * @param otherImpostor rigid impostor to anchor to
  104785. * @param length ratio across rope from 0 to 1
  104786. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  104787. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  104788. * @returns impostor the rope imposter
  104789. */
  104790. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  104791. /**
  104792. * Will keep this body still, in a sleep mode.
  104793. * @returns the physics imposter
  104794. */
  104795. sleep(): PhysicsImpostor;
  104796. /**
  104797. * Wake the body up.
  104798. * @returns The physics imposter
  104799. */
  104800. wakeUp(): PhysicsImpostor;
  104801. /**
  104802. * Clones the physics imposter
  104803. * @param newObject The physics imposter clones to this physics-enabled object
  104804. * @returns A nullable physics imposter
  104805. */
  104806. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104807. /**
  104808. * Disposes the physics imposter
  104809. */
  104810. dispose(): void;
  104811. /**
  104812. * Sets the delta position
  104813. * @param position The delta position amount
  104814. */
  104815. setDeltaPosition(position: Vector3): void;
  104816. /**
  104817. * Sets the delta rotation
  104818. * @param rotation The delta rotation amount
  104819. */
  104820. setDeltaRotation(rotation: Quaternion): void;
  104821. /**
  104822. * Gets the box size of the physics imposter and stores the result in the input parameter
  104823. * @param result Stores the box size
  104824. * @returns The physics imposter
  104825. */
  104826. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  104827. /**
  104828. * Gets the radius of the physics imposter
  104829. * @returns Radius of the physics imposter
  104830. */
  104831. getRadius(): number;
  104832. /**
  104833. * Sync a bone with this impostor
  104834. * @param bone The bone to sync to the impostor.
  104835. * @param boneMesh The mesh that the bone is influencing.
  104836. * @param jointPivot The pivot of the joint / bone in local space.
  104837. * @param distToJoint Optional distance from the impostor to the joint.
  104838. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  104839. */
  104840. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  104841. /**
  104842. * Sync impostor to a bone
  104843. * @param bone The bone that the impostor will be synced to.
  104844. * @param boneMesh The mesh that the bone is influencing.
  104845. * @param jointPivot The pivot of the joint / bone in local space.
  104846. * @param distToJoint Optional distance from the impostor to the joint.
  104847. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  104848. * @param boneAxis Optional vector3 axis the bone is aligned with
  104849. */
  104850. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  104851. /**
  104852. * No-Imposter type
  104853. */
  104854. static NoImpostor: number;
  104855. /**
  104856. * Sphere-Imposter type
  104857. */
  104858. static SphereImpostor: number;
  104859. /**
  104860. * Box-Imposter type
  104861. */
  104862. static BoxImpostor: number;
  104863. /**
  104864. * Plane-Imposter type
  104865. */
  104866. static PlaneImpostor: number;
  104867. /**
  104868. * Mesh-imposter type
  104869. */
  104870. static MeshImpostor: number;
  104871. /**
  104872. * Capsule-Impostor type (Ammo.js plugin only)
  104873. */
  104874. static CapsuleImpostor: number;
  104875. /**
  104876. * Cylinder-Imposter type
  104877. */
  104878. static CylinderImpostor: number;
  104879. /**
  104880. * Particle-Imposter type
  104881. */
  104882. static ParticleImpostor: number;
  104883. /**
  104884. * Heightmap-Imposter type
  104885. */
  104886. static HeightmapImpostor: number;
  104887. /**
  104888. * ConvexHull-Impostor type (Ammo.js plugin only)
  104889. */
  104890. static ConvexHullImpostor: number;
  104891. /**
  104892. * Custom-Imposter type (Ammo.js plugin only)
  104893. */
  104894. static CustomImpostor: number;
  104895. /**
  104896. * Rope-Imposter type
  104897. */
  104898. static RopeImpostor: number;
  104899. /**
  104900. * Cloth-Imposter type
  104901. */
  104902. static ClothImpostor: number;
  104903. /**
  104904. * Softbody-Imposter type
  104905. */
  104906. static SoftbodyImpostor: number;
  104907. }
  104908. }
  104909. declare module BABYLON {
  104910. /**
  104911. * @hidden
  104912. **/
  104913. export class _CreationDataStorage {
  104914. closePath?: boolean;
  104915. closeArray?: boolean;
  104916. idx: number[];
  104917. dashSize: number;
  104918. gapSize: number;
  104919. path3D: Path3D;
  104920. pathArray: Vector3[][];
  104921. arc: number;
  104922. radius: number;
  104923. cap: number;
  104924. tessellation: number;
  104925. }
  104926. /**
  104927. * @hidden
  104928. **/
  104929. class _InstanceDataStorage {
  104930. visibleInstances: any;
  104931. batchCache: _InstancesBatch;
  104932. instancesBufferSize: number;
  104933. instancesBuffer: Nullable<Buffer>;
  104934. instancesData: Float32Array;
  104935. overridenInstanceCount: number;
  104936. isFrozen: boolean;
  104937. previousBatch: Nullable<_InstancesBatch>;
  104938. hardwareInstancedRendering: boolean;
  104939. sideOrientation: number;
  104940. manualUpdate: boolean;
  104941. }
  104942. /**
  104943. * @hidden
  104944. **/
  104945. export class _InstancesBatch {
  104946. mustReturn: boolean;
  104947. visibleInstances: Nullable<InstancedMesh[]>[];
  104948. renderSelf: boolean[];
  104949. hardwareInstancedRendering: boolean[];
  104950. }
  104951. /**
  104952. * @hidden
  104953. **/
  104954. class _ThinInstanceDataStorage {
  104955. instancesCount: number;
  104956. matrixBuffer: Nullable<Buffer>;
  104957. matrixBufferSize: number;
  104958. matrixData: Nullable<Float32Array>;
  104959. boundingVectors: Array<Vector3>;
  104960. }
  104961. /**
  104962. * Class used to represent renderable models
  104963. */
  104964. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  104965. /**
  104966. * Mesh side orientation : usually the external or front surface
  104967. */
  104968. static readonly FRONTSIDE: number;
  104969. /**
  104970. * Mesh side orientation : usually the internal or back surface
  104971. */
  104972. static readonly BACKSIDE: number;
  104973. /**
  104974. * Mesh side orientation : both internal and external or front and back surfaces
  104975. */
  104976. static readonly DOUBLESIDE: number;
  104977. /**
  104978. * Mesh side orientation : by default, `FRONTSIDE`
  104979. */
  104980. static readonly DEFAULTSIDE: number;
  104981. /**
  104982. * Mesh cap setting : no cap
  104983. */
  104984. static readonly NO_CAP: number;
  104985. /**
  104986. * Mesh cap setting : one cap at the beginning of the mesh
  104987. */
  104988. static readonly CAP_START: number;
  104989. /**
  104990. * Mesh cap setting : one cap at the end of the mesh
  104991. */
  104992. static readonly CAP_END: number;
  104993. /**
  104994. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  104995. */
  104996. static readonly CAP_ALL: number;
  104997. /**
  104998. * Mesh pattern setting : no flip or rotate
  104999. */
  105000. static readonly NO_FLIP: number;
  105001. /**
  105002. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  105003. */
  105004. static readonly FLIP_TILE: number;
  105005. /**
  105006. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  105007. */
  105008. static readonly ROTATE_TILE: number;
  105009. /**
  105010. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  105011. */
  105012. static readonly FLIP_ROW: number;
  105013. /**
  105014. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  105015. */
  105016. static readonly ROTATE_ROW: number;
  105017. /**
  105018. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  105019. */
  105020. static readonly FLIP_N_ROTATE_TILE: number;
  105021. /**
  105022. * Mesh pattern setting : rotate pattern and rotate
  105023. */
  105024. static readonly FLIP_N_ROTATE_ROW: number;
  105025. /**
  105026. * Mesh tile positioning : part tiles same on left/right or top/bottom
  105027. */
  105028. static readonly CENTER: number;
  105029. /**
  105030. * Mesh tile positioning : part tiles on left
  105031. */
  105032. static readonly LEFT: number;
  105033. /**
  105034. * Mesh tile positioning : part tiles on right
  105035. */
  105036. static readonly RIGHT: number;
  105037. /**
  105038. * Mesh tile positioning : part tiles on top
  105039. */
  105040. static readonly TOP: number;
  105041. /**
  105042. * Mesh tile positioning : part tiles on bottom
  105043. */
  105044. static readonly BOTTOM: number;
  105045. /**
  105046. * Gets the default side orientation.
  105047. * @param orientation the orientation to value to attempt to get
  105048. * @returns the default orientation
  105049. * @hidden
  105050. */
  105051. static _GetDefaultSideOrientation(orientation?: number): number;
  105052. private _internalMeshDataInfo;
  105053. /**
  105054. * An event triggered before rendering the mesh
  105055. */
  105056. get onBeforeRenderObservable(): Observable<Mesh>;
  105057. /**
  105058. * An event triggered before binding the mesh
  105059. */
  105060. get onBeforeBindObservable(): Observable<Mesh>;
  105061. /**
  105062. * An event triggered after rendering the mesh
  105063. */
  105064. get onAfterRenderObservable(): Observable<Mesh>;
  105065. /**
  105066. * An event triggered before drawing the mesh
  105067. */
  105068. get onBeforeDrawObservable(): Observable<Mesh>;
  105069. private _onBeforeDrawObserver;
  105070. /**
  105071. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  105072. */
  105073. set onBeforeDraw(callback: () => void);
  105074. get hasInstances(): boolean;
  105075. get hasThinInstances(): boolean;
  105076. /**
  105077. * Gets the delay loading state of the mesh (when delay loading is turned on)
  105078. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  105079. */
  105080. delayLoadState: number;
  105081. /**
  105082. * Gets the list of instances created from this mesh
  105083. * it is not supposed to be modified manually.
  105084. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  105085. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  105086. */
  105087. instances: InstancedMesh[];
  105088. /**
  105089. * Gets the file containing delay loading data for this mesh
  105090. */
  105091. delayLoadingFile: string;
  105092. /** @hidden */
  105093. _binaryInfo: any;
  105094. /**
  105095. * User defined function used to change how LOD level selection is done
  105096. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  105097. */
  105098. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  105099. /**
  105100. * Gets or sets the morph target manager
  105101. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105102. */
  105103. get morphTargetManager(): Nullable<MorphTargetManager>;
  105104. set morphTargetManager(value: Nullable<MorphTargetManager>);
  105105. /** @hidden */
  105106. _creationDataStorage: Nullable<_CreationDataStorage>;
  105107. /** @hidden */
  105108. _geometry: Nullable<Geometry>;
  105109. /** @hidden */
  105110. _delayInfo: Array<string>;
  105111. /** @hidden */
  105112. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  105113. /** @hidden */
  105114. _instanceDataStorage: _InstanceDataStorage;
  105115. /** @hidden */
  105116. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  105117. private _effectiveMaterial;
  105118. /** @hidden */
  105119. _shouldGenerateFlatShading: boolean;
  105120. /** @hidden */
  105121. _originalBuilderSideOrientation: number;
  105122. /**
  105123. * Use this property to change the original side orientation defined at construction time
  105124. */
  105125. overrideMaterialSideOrientation: Nullable<number>;
  105126. /**
  105127. * Gets the source mesh (the one used to clone this one from)
  105128. */
  105129. get source(): Nullable<Mesh>;
  105130. /**
  105131. * Gets or sets a boolean indicating that this mesh does not use index buffer
  105132. */
  105133. get isUnIndexed(): boolean;
  105134. set isUnIndexed(value: boolean);
  105135. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  105136. get worldMatrixInstancedBuffer(): Float32Array;
  105137. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  105138. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  105139. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  105140. /**
  105141. * @constructor
  105142. * @param name The value used by scene.getMeshByName() to do a lookup.
  105143. * @param scene The scene to add this mesh to.
  105144. * @param parent The parent of this mesh, if it has one
  105145. * @param source An optional Mesh from which geometry is shared, cloned.
  105146. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  105147. * When false, achieved by calling a clone(), also passing False.
  105148. * This will make creation of children, recursive.
  105149. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  105150. */
  105151. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  105152. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  105153. doNotInstantiate: boolean;
  105154. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  105155. /**
  105156. * Gets the class name
  105157. * @returns the string "Mesh".
  105158. */
  105159. getClassName(): string;
  105160. /** @hidden */
  105161. get _isMesh(): boolean;
  105162. /**
  105163. * Returns a description of this mesh
  105164. * @param fullDetails define if full details about this mesh must be used
  105165. * @returns a descriptive string representing this mesh
  105166. */
  105167. toString(fullDetails?: boolean): string;
  105168. /** @hidden */
  105169. _unBindEffect(): void;
  105170. /**
  105171. * Gets a boolean indicating if this mesh has LOD
  105172. */
  105173. get hasLODLevels(): boolean;
  105174. /**
  105175. * Gets the list of MeshLODLevel associated with the current mesh
  105176. * @returns an array of MeshLODLevel
  105177. */
  105178. getLODLevels(): MeshLODLevel[];
  105179. private _sortLODLevels;
  105180. /**
  105181. * Add a mesh as LOD level triggered at the given distance.
  105182. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105183. * @param distance The distance from the center of the object to show this level
  105184. * @param mesh The mesh to be added as LOD level (can be null)
  105185. * @return This mesh (for chaining)
  105186. */
  105187. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  105188. /**
  105189. * Returns the LOD level mesh at the passed distance or null if not found.
  105190. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105191. * @param distance The distance from the center of the object to show this level
  105192. * @returns a Mesh or `null`
  105193. */
  105194. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  105195. /**
  105196. * Remove a mesh from the LOD array
  105197. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105198. * @param mesh defines the mesh to be removed
  105199. * @return This mesh (for chaining)
  105200. */
  105201. removeLODLevel(mesh: Mesh): Mesh;
  105202. /**
  105203. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  105204. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105205. * @param camera defines the camera to use to compute distance
  105206. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  105207. * @return This mesh (for chaining)
  105208. */
  105209. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  105210. /**
  105211. * Gets the mesh internal Geometry object
  105212. */
  105213. get geometry(): Nullable<Geometry>;
  105214. /**
  105215. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  105216. * @returns the total number of vertices
  105217. */
  105218. getTotalVertices(): number;
  105219. /**
  105220. * Returns the content of an associated vertex buffer
  105221. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105222. * - VertexBuffer.PositionKind
  105223. * - VertexBuffer.UVKind
  105224. * - VertexBuffer.UV2Kind
  105225. * - VertexBuffer.UV3Kind
  105226. * - VertexBuffer.UV4Kind
  105227. * - VertexBuffer.UV5Kind
  105228. * - VertexBuffer.UV6Kind
  105229. * - VertexBuffer.ColorKind
  105230. * - VertexBuffer.MatricesIndicesKind
  105231. * - VertexBuffer.MatricesIndicesExtraKind
  105232. * - VertexBuffer.MatricesWeightsKind
  105233. * - VertexBuffer.MatricesWeightsExtraKind
  105234. * @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
  105235. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  105236. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  105237. */
  105238. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105239. /**
  105240. * Returns the mesh VertexBuffer object from the requested `kind`
  105241. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105242. * - VertexBuffer.PositionKind
  105243. * - VertexBuffer.NormalKind
  105244. * - VertexBuffer.UVKind
  105245. * - VertexBuffer.UV2Kind
  105246. * - VertexBuffer.UV3Kind
  105247. * - VertexBuffer.UV4Kind
  105248. * - VertexBuffer.UV5Kind
  105249. * - VertexBuffer.UV6Kind
  105250. * - VertexBuffer.ColorKind
  105251. * - VertexBuffer.MatricesIndicesKind
  105252. * - VertexBuffer.MatricesIndicesExtraKind
  105253. * - VertexBuffer.MatricesWeightsKind
  105254. * - VertexBuffer.MatricesWeightsExtraKind
  105255. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  105256. */
  105257. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  105258. /**
  105259. * Tests if a specific vertex buffer is associated with this mesh
  105260. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  105261. * - VertexBuffer.PositionKind
  105262. * - VertexBuffer.NormalKind
  105263. * - VertexBuffer.UVKind
  105264. * - VertexBuffer.UV2Kind
  105265. * - VertexBuffer.UV3Kind
  105266. * - VertexBuffer.UV4Kind
  105267. * - VertexBuffer.UV5Kind
  105268. * - VertexBuffer.UV6Kind
  105269. * - VertexBuffer.ColorKind
  105270. * - VertexBuffer.MatricesIndicesKind
  105271. * - VertexBuffer.MatricesIndicesExtraKind
  105272. * - VertexBuffer.MatricesWeightsKind
  105273. * - VertexBuffer.MatricesWeightsExtraKind
  105274. * @returns a boolean
  105275. */
  105276. isVerticesDataPresent(kind: string): boolean;
  105277. /**
  105278. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  105279. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  105280. * - VertexBuffer.PositionKind
  105281. * - VertexBuffer.UVKind
  105282. * - VertexBuffer.UV2Kind
  105283. * - VertexBuffer.UV3Kind
  105284. * - VertexBuffer.UV4Kind
  105285. * - VertexBuffer.UV5Kind
  105286. * - VertexBuffer.UV6Kind
  105287. * - VertexBuffer.ColorKind
  105288. * - VertexBuffer.MatricesIndicesKind
  105289. * - VertexBuffer.MatricesIndicesExtraKind
  105290. * - VertexBuffer.MatricesWeightsKind
  105291. * - VertexBuffer.MatricesWeightsExtraKind
  105292. * @returns a boolean
  105293. */
  105294. isVertexBufferUpdatable(kind: string): boolean;
  105295. /**
  105296. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  105297. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105298. * - VertexBuffer.PositionKind
  105299. * - VertexBuffer.NormalKind
  105300. * - VertexBuffer.UVKind
  105301. * - VertexBuffer.UV2Kind
  105302. * - VertexBuffer.UV3Kind
  105303. * - VertexBuffer.UV4Kind
  105304. * - VertexBuffer.UV5Kind
  105305. * - VertexBuffer.UV6Kind
  105306. * - VertexBuffer.ColorKind
  105307. * - VertexBuffer.MatricesIndicesKind
  105308. * - VertexBuffer.MatricesIndicesExtraKind
  105309. * - VertexBuffer.MatricesWeightsKind
  105310. * - VertexBuffer.MatricesWeightsExtraKind
  105311. * @returns an array of strings
  105312. */
  105313. getVerticesDataKinds(): string[];
  105314. /**
  105315. * Returns a positive integer : the total number of indices in this mesh geometry.
  105316. * @returns the numner of indices or zero if the mesh has no geometry.
  105317. */
  105318. getTotalIndices(): number;
  105319. /**
  105320. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  105321. * @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.
  105322. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105323. * @returns the indices array or an empty array if the mesh has no geometry
  105324. */
  105325. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105326. get isBlocked(): boolean;
  105327. /**
  105328. * Determine if the current mesh is ready to be rendered
  105329. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  105330. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  105331. * @returns true if all associated assets are ready (material, textures, shaders)
  105332. */
  105333. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  105334. /**
  105335. * 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.
  105336. */
  105337. get areNormalsFrozen(): boolean;
  105338. /**
  105339. * 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.
  105340. * @returns the current mesh
  105341. */
  105342. freezeNormals(): Mesh;
  105343. /**
  105344. * 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
  105345. * @returns the current mesh
  105346. */
  105347. unfreezeNormals(): Mesh;
  105348. /**
  105349. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  105350. */
  105351. set overridenInstanceCount(count: number);
  105352. /** @hidden */
  105353. _preActivate(): Mesh;
  105354. /** @hidden */
  105355. _preActivateForIntermediateRendering(renderId: number): Mesh;
  105356. /** @hidden */
  105357. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  105358. protected _afterComputeWorldMatrix(): void;
  105359. /** @hidden */
  105360. _postActivate(): void;
  105361. /**
  105362. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  105363. * This means the mesh underlying bounding box and sphere are recomputed.
  105364. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  105365. * @returns the current mesh
  105366. */
  105367. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  105368. /** @hidden */
  105369. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  105370. /**
  105371. * This function will subdivide the mesh into multiple submeshes
  105372. * @param count defines the expected number of submeshes
  105373. */
  105374. subdivide(count: number): void;
  105375. /**
  105376. * Copy a FloatArray into a specific associated vertex buffer
  105377. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105378. * - VertexBuffer.PositionKind
  105379. * - VertexBuffer.UVKind
  105380. * - VertexBuffer.UV2Kind
  105381. * - VertexBuffer.UV3Kind
  105382. * - VertexBuffer.UV4Kind
  105383. * - VertexBuffer.UV5Kind
  105384. * - VertexBuffer.UV6Kind
  105385. * - VertexBuffer.ColorKind
  105386. * - VertexBuffer.MatricesIndicesKind
  105387. * - VertexBuffer.MatricesIndicesExtraKind
  105388. * - VertexBuffer.MatricesWeightsKind
  105389. * - VertexBuffer.MatricesWeightsExtraKind
  105390. * @param data defines the data source
  105391. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  105392. * @param stride defines the data stride size (can be null)
  105393. * @returns the current mesh
  105394. */
  105395. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  105396. /**
  105397. * Delete a vertex buffer associated with this mesh
  105398. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  105399. * - VertexBuffer.PositionKind
  105400. * - VertexBuffer.UVKind
  105401. * - VertexBuffer.UV2Kind
  105402. * - VertexBuffer.UV3Kind
  105403. * - VertexBuffer.UV4Kind
  105404. * - VertexBuffer.UV5Kind
  105405. * - VertexBuffer.UV6Kind
  105406. * - VertexBuffer.ColorKind
  105407. * - VertexBuffer.MatricesIndicesKind
  105408. * - VertexBuffer.MatricesIndicesExtraKind
  105409. * - VertexBuffer.MatricesWeightsKind
  105410. * - VertexBuffer.MatricesWeightsExtraKind
  105411. */
  105412. removeVerticesData(kind: string): void;
  105413. /**
  105414. * Flags an associated vertex buffer as updatable
  105415. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  105416. * - VertexBuffer.PositionKind
  105417. * - VertexBuffer.UVKind
  105418. * - VertexBuffer.UV2Kind
  105419. * - VertexBuffer.UV3Kind
  105420. * - VertexBuffer.UV4Kind
  105421. * - VertexBuffer.UV5Kind
  105422. * - VertexBuffer.UV6Kind
  105423. * - VertexBuffer.ColorKind
  105424. * - VertexBuffer.MatricesIndicesKind
  105425. * - VertexBuffer.MatricesIndicesExtraKind
  105426. * - VertexBuffer.MatricesWeightsKind
  105427. * - VertexBuffer.MatricesWeightsExtraKind
  105428. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  105429. */
  105430. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  105431. /**
  105432. * Sets the mesh global Vertex Buffer
  105433. * @param buffer defines the buffer to use
  105434. * @returns the current mesh
  105435. */
  105436. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  105437. /**
  105438. * Update a specific associated vertex buffer
  105439. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105440. * - VertexBuffer.PositionKind
  105441. * - VertexBuffer.UVKind
  105442. * - VertexBuffer.UV2Kind
  105443. * - VertexBuffer.UV3Kind
  105444. * - VertexBuffer.UV4Kind
  105445. * - VertexBuffer.UV5Kind
  105446. * - VertexBuffer.UV6Kind
  105447. * - VertexBuffer.ColorKind
  105448. * - VertexBuffer.MatricesIndicesKind
  105449. * - VertexBuffer.MatricesIndicesExtraKind
  105450. * - VertexBuffer.MatricesWeightsKind
  105451. * - VertexBuffer.MatricesWeightsExtraKind
  105452. * @param data defines the data source
  105453. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  105454. * @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)
  105455. * @returns the current mesh
  105456. */
  105457. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  105458. /**
  105459. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  105460. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  105461. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  105462. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  105463. * @returns the current mesh
  105464. */
  105465. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  105466. /**
  105467. * Creates a un-shared specific occurence of the geometry for the mesh.
  105468. * @returns the current mesh
  105469. */
  105470. makeGeometryUnique(): Mesh;
  105471. /**
  105472. * Set the index buffer of this mesh
  105473. * @param indices defines the source data
  105474. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  105475. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  105476. * @returns the current mesh
  105477. */
  105478. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  105479. /**
  105480. * Update the current index buffer
  105481. * @param indices defines the source data
  105482. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  105483. * @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)
  105484. * @returns the current mesh
  105485. */
  105486. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  105487. /**
  105488. * Invert the geometry to move from a right handed system to a left handed one.
  105489. * @returns the current mesh
  105490. */
  105491. toLeftHanded(): Mesh;
  105492. /** @hidden */
  105493. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  105494. /** @hidden */
  105495. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  105496. /**
  105497. * Registers for this mesh a javascript function called just before the rendering process
  105498. * @param func defines the function to call before rendering this mesh
  105499. * @returns the current mesh
  105500. */
  105501. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  105502. /**
  105503. * Disposes a previously registered javascript function called before the rendering
  105504. * @param func defines the function to remove
  105505. * @returns the current mesh
  105506. */
  105507. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  105508. /**
  105509. * Registers for this mesh a javascript function called just after the rendering is complete
  105510. * @param func defines the function to call after rendering this mesh
  105511. * @returns the current mesh
  105512. */
  105513. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  105514. /**
  105515. * Disposes a previously registered javascript function called after the rendering.
  105516. * @param func defines the function to remove
  105517. * @returns the current mesh
  105518. */
  105519. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  105520. /** @hidden */
  105521. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  105522. /** @hidden */
  105523. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  105524. /** @hidden */
  105525. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  105526. /** @hidden */
  105527. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  105528. /** @hidden */
  105529. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  105530. /** @hidden */
  105531. _rebuild(): void;
  105532. /** @hidden */
  105533. _freeze(): void;
  105534. /** @hidden */
  105535. _unFreeze(): void;
  105536. /**
  105537. * 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
  105538. * @param subMesh defines the subMesh to render
  105539. * @param enableAlphaMode defines if alpha mode can be changed
  105540. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  105541. * @returns the current mesh
  105542. */
  105543. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  105544. private _onBeforeDraw;
  105545. /**
  105546. * Renormalize the mesh and patch it up if there are no weights
  105547. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  105548. * However in the case of zero weights then we set just a single influence to 1.
  105549. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  105550. */
  105551. cleanMatrixWeights(): void;
  105552. private normalizeSkinFourWeights;
  105553. private normalizeSkinWeightsAndExtra;
  105554. /**
  105555. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  105556. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  105557. * the user know there was an issue with importing the mesh
  105558. * @returns a validation object with skinned, valid and report string
  105559. */
  105560. validateSkinning(): {
  105561. skinned: boolean;
  105562. valid: boolean;
  105563. report: string;
  105564. };
  105565. /** @hidden */
  105566. _checkDelayState(): Mesh;
  105567. private _queueLoad;
  105568. /**
  105569. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  105570. * A mesh is in the frustum if its bounding box intersects the frustum
  105571. * @param frustumPlanes defines the frustum to test
  105572. * @returns true if the mesh is in the frustum planes
  105573. */
  105574. isInFrustum(frustumPlanes: Plane[]): boolean;
  105575. /**
  105576. * Sets the mesh material by the material or multiMaterial `id` property
  105577. * @param id is a string identifying the material or the multiMaterial
  105578. * @returns the current mesh
  105579. */
  105580. setMaterialByID(id: string): Mesh;
  105581. /**
  105582. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  105583. * @returns an array of IAnimatable
  105584. */
  105585. getAnimatables(): IAnimatable[];
  105586. /**
  105587. * Modifies the mesh geometry according to the passed transformation matrix.
  105588. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  105589. * The mesh normals are modified using the same transformation.
  105590. * Note that, under the hood, this method sets a new VertexBuffer each call.
  105591. * @param transform defines the transform matrix to use
  105592. * @see http://doc.babylonjs.com/resources/baking_transformations
  105593. * @returns the current mesh
  105594. */
  105595. bakeTransformIntoVertices(transform: Matrix): Mesh;
  105596. /**
  105597. * Modifies the mesh geometry according to its own current World Matrix.
  105598. * The mesh World Matrix is then reset.
  105599. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  105600. * Note that, under the hood, this method sets a new VertexBuffer each call.
  105601. * @see http://doc.babylonjs.com/resources/baking_transformations
  105602. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  105603. * @returns the current mesh
  105604. */
  105605. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  105606. /** @hidden */
  105607. get _positions(): Nullable<Vector3[]>;
  105608. /** @hidden */
  105609. _resetPointsArrayCache(): Mesh;
  105610. /** @hidden */
  105611. _generatePointsArray(): boolean;
  105612. /**
  105613. * Returns a new Mesh object generated from the current mesh properties.
  105614. * This method must not get confused with createInstance()
  105615. * @param name is a string, the name given to the new mesh
  105616. * @param newParent can be any Node object (default `null`)
  105617. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  105618. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  105619. * @returns a new mesh
  105620. */
  105621. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  105622. /**
  105623. * Releases resources associated with this mesh.
  105624. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105625. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105626. */
  105627. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105628. /** @hidden */
  105629. _disposeInstanceSpecificData(): void;
  105630. /** @hidden */
  105631. _disposeThinInstanceSpecificData(): void;
  105632. /**
  105633. * Modifies the mesh geometry according to a displacement map.
  105634. * 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.
  105635. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  105636. * @param url is a string, the URL from the image file is to be downloaded.
  105637. * @param minHeight is the lower limit of the displacement.
  105638. * @param maxHeight is the upper limit of the displacement.
  105639. * @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.
  105640. * @param uvOffset is an optional vector2 used to offset UV.
  105641. * @param uvScale is an optional vector2 used to scale UV.
  105642. * @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.
  105643. * @returns the Mesh.
  105644. */
  105645. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  105646. /**
  105647. * Modifies the mesh geometry according to a displacementMap buffer.
  105648. * 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.
  105649. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  105650. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  105651. * @param heightMapWidth is the width of the buffer image.
  105652. * @param heightMapHeight is the height of the buffer image.
  105653. * @param minHeight is the lower limit of the displacement.
  105654. * @param maxHeight is the upper limit of the displacement.
  105655. * @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.
  105656. * @param uvOffset is an optional vector2 used to offset UV.
  105657. * @param uvScale is an optional vector2 used to scale UV.
  105658. * @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.
  105659. * @returns the Mesh.
  105660. */
  105661. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  105662. /**
  105663. * Modify the mesh to get a flat shading rendering.
  105664. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  105665. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  105666. * @returns current mesh
  105667. */
  105668. convertToFlatShadedMesh(): Mesh;
  105669. /**
  105670. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  105671. * In other words, more vertices, no more indices and a single bigger VBO.
  105672. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  105673. * @returns current mesh
  105674. */
  105675. convertToUnIndexedMesh(): Mesh;
  105676. /**
  105677. * Inverses facet orientations.
  105678. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105679. * @param flipNormals will also inverts the normals
  105680. * @returns current mesh
  105681. */
  105682. flipFaces(flipNormals?: boolean): Mesh;
  105683. /**
  105684. * Increase the number of facets and hence vertices in a mesh
  105685. * Vertex normals are interpolated from existing vertex normals
  105686. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105687. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  105688. */
  105689. increaseVertices(numberPerEdge: number): void;
  105690. /**
  105691. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  105692. * This will undo any application of covertToFlatShadedMesh
  105693. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105694. */
  105695. forceSharedVertices(): void;
  105696. /** @hidden */
  105697. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  105698. /** @hidden */
  105699. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  105700. /**
  105701. * Creates a new InstancedMesh object from the mesh model.
  105702. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  105703. * @param name defines the name of the new instance
  105704. * @returns a new InstancedMesh
  105705. */
  105706. createInstance(name: string): InstancedMesh;
  105707. /**
  105708. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  105709. * After this call, all the mesh instances have the same submeshes than the current mesh.
  105710. * @returns the current mesh
  105711. */
  105712. synchronizeInstances(): Mesh;
  105713. /**
  105714. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  105715. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  105716. * This should be used together with the simplification to avoid disappearing triangles.
  105717. * @param successCallback an optional success callback to be called after the optimization finished.
  105718. * @returns the current mesh
  105719. */
  105720. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  105721. /**
  105722. * Serialize current mesh
  105723. * @param serializationObject defines the object which will receive the serialization data
  105724. */
  105725. serialize(serializationObject: any): void;
  105726. /** @hidden */
  105727. _syncGeometryWithMorphTargetManager(): void;
  105728. /** @hidden */
  105729. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  105730. /**
  105731. * Returns a new Mesh object parsed from the source provided.
  105732. * @param parsedMesh is the source
  105733. * @param scene defines the hosting scene
  105734. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  105735. * @returns a new Mesh
  105736. */
  105737. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  105738. /**
  105739. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  105740. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105741. * @param name defines the name of the mesh to create
  105742. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  105743. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  105744. * @param closePath creates a seam between the first and the last points of each path of the path array
  105745. * @param offset is taken in account only if the `pathArray` is containing a single path
  105746. * @param scene defines the hosting scene
  105747. * @param updatable defines if the mesh must be flagged as updatable
  105748. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105749. * @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)
  105750. * @returns a new Mesh
  105751. */
  105752. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105753. /**
  105754. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  105755. * @param name defines the name of the mesh to create
  105756. * @param radius sets the radius size (float) of the polygon (default 0.5)
  105757. * @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
  105758. * @param scene defines the hosting scene
  105759. * @param updatable defines if the mesh must be flagged as updatable
  105760. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105761. * @returns a new Mesh
  105762. */
  105763. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  105764. /**
  105765. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  105766. * @param name defines the name of the mesh to create
  105767. * @param size sets the size (float) of each box side (default 1)
  105768. * @param scene defines the hosting scene
  105769. * @param updatable defines if the mesh must be flagged as updatable
  105770. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105771. * @returns a new Mesh
  105772. */
  105773. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  105774. /**
  105775. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  105776. * @param name defines the name of the mesh to create
  105777. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  105778. * @param diameter sets the diameter size (float) of the sphere (default 1)
  105779. * @param scene defines the hosting scene
  105780. * @param updatable defines if the mesh must be flagged as updatable
  105781. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105782. * @returns a new Mesh
  105783. */
  105784. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105785. /**
  105786. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  105787. * @param name defines the name of the mesh to create
  105788. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  105789. * @param diameter sets the diameter size (float) of the sphere (default 1)
  105790. * @param scene defines the hosting scene
  105791. * @returns a new Mesh
  105792. */
  105793. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  105794. /**
  105795. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  105796. * @param name defines the name of the mesh to create
  105797. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  105798. * @param diameterTop set the top cap diameter (floats, default 1)
  105799. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  105800. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  105801. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  105802. * @param scene defines the hosting scene
  105803. * @param updatable defines if the mesh must be flagged as updatable
  105804. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105805. * @returns a new Mesh
  105806. */
  105807. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  105808. /**
  105809. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  105810. * @param name defines the name of the mesh to create
  105811. * @param diameter sets the diameter size (float) of the torus (default 1)
  105812. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  105813. * @param tessellation sets the number of torus sides (postive integer, default 16)
  105814. * @param scene defines the hosting scene
  105815. * @param updatable defines if the mesh must be flagged as updatable
  105816. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105817. * @returns a new Mesh
  105818. */
  105819. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105820. /**
  105821. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  105822. * @param name defines the name of the mesh to create
  105823. * @param radius sets the global radius size (float) of the torus knot (default 2)
  105824. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  105825. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  105826. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  105827. * @param p the number of windings on X axis (positive integers, default 2)
  105828. * @param q the number of windings on Y axis (positive integers, default 3)
  105829. * @param scene defines the hosting scene
  105830. * @param updatable defines if the mesh must be flagged as updatable
  105831. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105832. * @returns a new Mesh
  105833. */
  105834. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105835. /**
  105836. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  105837. * @param name defines the name of the mesh to create
  105838. * @param points is an array successive Vector3
  105839. * @param scene defines the hosting scene
  105840. * @param updatable defines if the mesh must be flagged as updatable
  105841. * @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).
  105842. * @returns a new Mesh
  105843. */
  105844. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  105845. /**
  105846. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  105847. * @param name defines the name of the mesh to create
  105848. * @param points is an array successive Vector3
  105849. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  105850. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  105851. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  105852. * @param scene defines the hosting scene
  105853. * @param updatable defines if the mesh must be flagged as updatable
  105854. * @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)
  105855. * @returns a new Mesh
  105856. */
  105857. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  105858. /**
  105859. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  105860. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  105861. * 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.
  105862. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105863. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105864. * Remember you can only change the shape positions, not their number when updating a polygon.
  105865. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105866. * @param name defines the name of the mesh to create
  105867. * @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
  105868. * @param scene defines the hosting scene
  105869. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  105870. * @param updatable defines if the mesh must be flagged as updatable
  105871. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105872. * @param earcutInjection can be used to inject your own earcut reference
  105873. * @returns a new Mesh
  105874. */
  105875. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  105876. /**
  105877. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  105878. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  105879. * @param name defines the name of the mesh to create
  105880. * @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
  105881. * @param depth defines the height of extrusion
  105882. * @param scene defines the hosting scene
  105883. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  105884. * @param updatable defines if the mesh must be flagged as updatable
  105885. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105886. * @param earcutInjection can be used to inject your own earcut reference
  105887. * @returns a new Mesh
  105888. */
  105889. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  105890. /**
  105891. * Creates an extruded shape mesh.
  105892. * 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
  105893. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105894. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105895. * @param name defines the name of the mesh to create
  105896. * @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
  105897. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  105898. * @param scale is the value to scale the shape
  105899. * @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
  105900. * @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
  105901. * @param scene defines the hosting scene
  105902. * @param updatable defines if the mesh must be flagged as updatable
  105903. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105904. * @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)
  105905. * @returns a new Mesh
  105906. */
  105907. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105908. /**
  105909. * Creates an custom extruded shape mesh.
  105910. * The custom extrusion is a parametric shape.
  105911. * It has no predefined shape. Its final shape will depend on the input parameters.
  105912. * Please consider using the same method from the MeshBuilder class instead
  105913. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105914. * @param name defines the name of the mesh to create
  105915. * @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
  105916. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  105917. * @param scaleFunction is a custom Javascript function called on each path point
  105918. * @param rotationFunction is a custom Javascript function called on each path point
  105919. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105920. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  105921. * @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
  105922. * @param scene defines the hosting scene
  105923. * @param updatable defines if the mesh must be flagged as updatable
  105924. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105925. * @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)
  105926. * @returns a new Mesh
  105927. */
  105928. 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;
  105929. /**
  105930. * Creates lathe mesh.
  105931. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  105932. * Please consider using the same method from the MeshBuilder class instead
  105933. * @param name defines the name of the mesh to create
  105934. * @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
  105935. * @param radius is the radius value of the lathe
  105936. * @param tessellation is the side number of the lathe.
  105937. * @param scene defines the hosting scene
  105938. * @param updatable defines if the mesh must be flagged as updatable
  105939. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105940. * @returns a new Mesh
  105941. */
  105942. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105943. /**
  105944. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  105945. * @param name defines the name of the mesh to create
  105946. * @param size sets the size (float) of both sides of the plane at once (default 1)
  105947. * @param scene defines the hosting scene
  105948. * @param updatable defines if the mesh must be flagged as updatable
  105949. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105950. * @returns a new Mesh
  105951. */
  105952. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105953. /**
  105954. * Creates a ground mesh.
  105955. * Please consider using the same method from the MeshBuilder class instead
  105956. * @param name defines the name of the mesh to create
  105957. * @param width set the width of the ground
  105958. * @param height set the height of the ground
  105959. * @param subdivisions sets the number of subdivisions per side
  105960. * @param scene defines the hosting scene
  105961. * @param updatable defines if the mesh must be flagged as updatable
  105962. * @returns a new Mesh
  105963. */
  105964. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  105965. /**
  105966. * Creates a tiled ground mesh.
  105967. * Please consider using the same method from the MeshBuilder class instead
  105968. * @param name defines the name of the mesh to create
  105969. * @param xmin set the ground minimum X coordinate
  105970. * @param zmin set the ground minimum Y coordinate
  105971. * @param xmax set the ground maximum X coordinate
  105972. * @param zmax set the ground maximum Z coordinate
  105973. * @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
  105974. * @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
  105975. * @param scene defines the hosting scene
  105976. * @param updatable defines if the mesh must be flagged as updatable
  105977. * @returns a new Mesh
  105978. */
  105979. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  105980. w: number;
  105981. h: number;
  105982. }, precision: {
  105983. w: number;
  105984. h: number;
  105985. }, scene: Scene, updatable?: boolean): Mesh;
  105986. /**
  105987. * Creates a ground mesh from a height map.
  105988. * Please consider using the same method from the MeshBuilder class instead
  105989. * @see http://doc.babylonjs.com/babylon101/height_map
  105990. * @param name defines the name of the mesh to create
  105991. * @param url sets the URL of the height map image resource
  105992. * @param width set the ground width size
  105993. * @param height set the ground height size
  105994. * @param subdivisions sets the number of subdivision per side
  105995. * @param minHeight is the minimum altitude on the ground
  105996. * @param maxHeight is the maximum altitude on the ground
  105997. * @param scene defines the hosting scene
  105998. * @param updatable defines if the mesh must be flagged as updatable
  105999. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  106000. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106001. * @returns a new Mesh
  106002. */
  106003. 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;
  106004. /**
  106005. * Creates a tube mesh.
  106006. * The tube is a parametric shape.
  106007. * It has no predefined shape. Its final shape will depend on the input parameters.
  106008. * Please consider using the same method from the MeshBuilder class instead
  106009. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  106010. * @param name defines the name of the mesh to create
  106011. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  106012. * @param radius sets the tube radius size
  106013. * @param tessellation is the number of sides on the tubular surface
  106014. * @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
  106015. * @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
  106016. * @param scene defines the hosting scene
  106017. * @param updatable defines if the mesh must be flagged as updatable
  106018. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106019. * @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)
  106020. * @returns a new Mesh
  106021. */
  106022. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  106023. (i: number, distance: number): number;
  106024. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106025. /**
  106026. * Creates a polyhedron mesh.
  106027. * Please consider using the same method from the MeshBuilder class instead.
  106028. * * 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
  106029. * * The parameter `size` (positive float, default 1) sets the polygon size
  106030. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106031. * * 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`
  106032. * * 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
  106033. * * 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)`)
  106034. * * 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
  106035. * * 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
  106036. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106037. * * If you create a double-sided mesh, you can choose what parts of 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
  106038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106039. * @param name defines the name of the mesh to create
  106040. * @param options defines the options used to create the mesh
  106041. * @param scene defines the hosting scene
  106042. * @returns a new Mesh
  106043. */
  106044. static CreatePolyhedron(name: string, options: {
  106045. type?: number;
  106046. size?: number;
  106047. sizeX?: number;
  106048. sizeY?: number;
  106049. sizeZ?: number;
  106050. custom?: any;
  106051. faceUV?: Vector4[];
  106052. faceColors?: Color4[];
  106053. updatable?: boolean;
  106054. sideOrientation?: number;
  106055. }, scene: Scene): Mesh;
  106056. /**
  106057. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  106058. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  106059. * * 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`)
  106060. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  106061. * * 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
  106062. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106063. * * If you create a double-sided mesh, you can choose what parts of 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
  106064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106065. * @param name defines the name of the mesh
  106066. * @param options defines the options used to create the mesh
  106067. * @param scene defines the hosting scene
  106068. * @returns a new Mesh
  106069. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  106070. */
  106071. static CreateIcoSphere(name: string, options: {
  106072. radius?: number;
  106073. flat?: boolean;
  106074. subdivisions?: number;
  106075. sideOrientation?: number;
  106076. updatable?: boolean;
  106077. }, scene: Scene): Mesh;
  106078. /**
  106079. * Creates a decal mesh.
  106080. * Please consider using the same method from the MeshBuilder class instead.
  106081. * A decal is a mesh usually applied as a model onto the surface of another mesh
  106082. * @param name defines the name of the mesh
  106083. * @param sourceMesh defines the mesh receiving the decal
  106084. * @param position sets the position of the decal in world coordinates
  106085. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  106086. * @param size sets the decal scaling
  106087. * @param angle sets the angle to rotate the decal
  106088. * @returns a new Mesh
  106089. */
  106090. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  106091. /**
  106092. * Prepare internal position array for software CPU skinning
  106093. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  106094. */
  106095. setPositionsForCPUSkinning(): Float32Array;
  106096. /**
  106097. * Prepare internal normal array for software CPU skinning
  106098. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  106099. */
  106100. setNormalsForCPUSkinning(): Float32Array;
  106101. /**
  106102. * Updates the vertex buffer by applying transformation from the bones
  106103. * @param skeleton defines the skeleton to apply to current mesh
  106104. * @returns the current mesh
  106105. */
  106106. applySkeleton(skeleton: Skeleton): Mesh;
  106107. /**
  106108. * 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
  106109. * @param meshes defines the list of meshes to scan
  106110. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  106111. */
  106112. static MinMax(meshes: AbstractMesh[]): {
  106113. min: Vector3;
  106114. max: Vector3;
  106115. };
  106116. /**
  106117. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  106118. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  106119. * @returns a vector3
  106120. */
  106121. static Center(meshesOrMinMaxVector: {
  106122. min: Vector3;
  106123. max: Vector3;
  106124. } | AbstractMesh[]): Vector3;
  106125. /**
  106126. * Merge the array of meshes into a single mesh for performance reasons.
  106127. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  106128. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  106129. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  106130. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  106131. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  106132. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  106133. * @returns a new mesh
  106134. */
  106135. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  106136. /** @hidden */
  106137. addInstance(instance: InstancedMesh): void;
  106138. /** @hidden */
  106139. removeInstance(instance: InstancedMesh): void;
  106140. }
  106141. }
  106142. declare module BABYLON {
  106143. /**
  106144. * This is the base class of all the camera used in the application.
  106145. * @see http://doc.babylonjs.com/features/cameras
  106146. */
  106147. export class Camera extends Node {
  106148. /** @hidden */
  106149. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  106150. /**
  106151. * This is the default projection mode used by the cameras.
  106152. * It helps recreating a feeling of perspective and better appreciate depth.
  106153. * This is the best way to simulate real life cameras.
  106154. */
  106155. static readonly PERSPECTIVE_CAMERA: number;
  106156. /**
  106157. * This helps creating camera with an orthographic mode.
  106158. * 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.
  106159. */
  106160. static readonly ORTHOGRAPHIC_CAMERA: number;
  106161. /**
  106162. * This is the default FOV mode for perspective cameras.
  106163. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  106164. */
  106165. static readonly FOVMODE_VERTICAL_FIXED: number;
  106166. /**
  106167. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  106168. */
  106169. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  106170. /**
  106171. * This specifies ther is no need for a camera rig.
  106172. * Basically only one eye is rendered corresponding to the camera.
  106173. */
  106174. static readonly RIG_MODE_NONE: number;
  106175. /**
  106176. * Simulates a camera Rig with one blue eye and one red eye.
  106177. * This can be use with 3d blue and red glasses.
  106178. */
  106179. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  106180. /**
  106181. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  106182. */
  106183. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  106184. /**
  106185. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  106186. */
  106187. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  106188. /**
  106189. * Defines that both eyes of the camera will be rendered over under each other.
  106190. */
  106191. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  106192. /**
  106193. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  106194. */
  106195. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  106196. /**
  106197. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  106198. */
  106199. static readonly RIG_MODE_VR: number;
  106200. /**
  106201. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  106202. */
  106203. static readonly RIG_MODE_WEBVR: number;
  106204. /**
  106205. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  106206. */
  106207. static readonly RIG_MODE_CUSTOM: number;
  106208. /**
  106209. * Defines if by default attaching controls should prevent the default javascript event to continue.
  106210. */
  106211. static ForceAttachControlToAlwaysPreventDefault: boolean;
  106212. /**
  106213. * Define the input manager associated with the camera.
  106214. */
  106215. inputs: CameraInputsManager<Camera>;
  106216. /** @hidden */
  106217. _position: Vector3;
  106218. /**
  106219. * Define the current local position of the camera in the scene
  106220. */
  106221. get position(): Vector3;
  106222. set position(newPosition: Vector3);
  106223. /**
  106224. * The vector the camera should consider as up.
  106225. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  106226. */
  106227. upVector: Vector3;
  106228. /**
  106229. * Define the current limit on the left side for an orthographic camera
  106230. * In scene unit
  106231. */
  106232. orthoLeft: Nullable<number>;
  106233. /**
  106234. * Define the current limit on the right side for an orthographic camera
  106235. * In scene unit
  106236. */
  106237. orthoRight: Nullable<number>;
  106238. /**
  106239. * Define the current limit on the bottom side for an orthographic camera
  106240. * In scene unit
  106241. */
  106242. orthoBottom: Nullable<number>;
  106243. /**
  106244. * Define the current limit on the top side for an orthographic camera
  106245. * In scene unit
  106246. */
  106247. orthoTop: Nullable<number>;
  106248. /**
  106249. * Field Of View is set in Radians. (default is 0.8)
  106250. */
  106251. fov: number;
  106252. /**
  106253. * Define the minimum distance the camera can see from.
  106254. * This is important to note that the depth buffer are not infinite and the closer it starts
  106255. * the more your scene might encounter depth fighting issue.
  106256. */
  106257. minZ: number;
  106258. /**
  106259. * Define the maximum distance the camera can see to.
  106260. * This is important to note that the depth buffer are not infinite and the further it end
  106261. * the more your scene might encounter depth fighting issue.
  106262. */
  106263. maxZ: number;
  106264. /**
  106265. * Define the default inertia of the camera.
  106266. * This helps giving a smooth feeling to the camera movement.
  106267. */
  106268. inertia: number;
  106269. /**
  106270. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  106271. */
  106272. mode: number;
  106273. /**
  106274. * Define whether the camera is intermediate.
  106275. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  106276. */
  106277. isIntermediate: boolean;
  106278. /**
  106279. * Define the viewport of the camera.
  106280. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  106281. */
  106282. viewport: Viewport;
  106283. /**
  106284. * Restricts the camera to viewing objects with the same layerMask.
  106285. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  106286. */
  106287. layerMask: number;
  106288. /**
  106289. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  106290. */
  106291. fovMode: number;
  106292. /**
  106293. * Rig mode of the camera.
  106294. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  106295. * This is normally controlled byt the camera themselves as internal use.
  106296. */
  106297. cameraRigMode: number;
  106298. /**
  106299. * Defines the distance between both "eyes" in case of a RIG
  106300. */
  106301. interaxialDistance: number;
  106302. /**
  106303. * Defines if stereoscopic rendering is done side by side or over under.
  106304. */
  106305. isStereoscopicSideBySide: boolean;
  106306. /**
  106307. * 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
  106308. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  106309. * else in the scene. (Eg. security camera)
  106310. *
  106311. * 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)
  106312. */
  106313. customRenderTargets: RenderTargetTexture[];
  106314. /**
  106315. * When set, the camera will render to this render target instead of the default canvas
  106316. *
  106317. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  106318. */
  106319. outputRenderTarget: Nullable<RenderTargetTexture>;
  106320. /**
  106321. * Observable triggered when the camera view matrix has changed.
  106322. */
  106323. onViewMatrixChangedObservable: Observable<Camera>;
  106324. /**
  106325. * Observable triggered when the camera Projection matrix has changed.
  106326. */
  106327. onProjectionMatrixChangedObservable: Observable<Camera>;
  106328. /**
  106329. * Observable triggered when the inputs have been processed.
  106330. */
  106331. onAfterCheckInputsObservable: Observable<Camera>;
  106332. /**
  106333. * Observable triggered when reset has been called and applied to the camera.
  106334. */
  106335. onRestoreStateObservable: Observable<Camera>;
  106336. /**
  106337. * Is this camera a part of a rig system?
  106338. */
  106339. isRigCamera: boolean;
  106340. /**
  106341. * If isRigCamera set to true this will be set with the parent camera.
  106342. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  106343. */
  106344. rigParent?: Camera;
  106345. /** @hidden */
  106346. _cameraRigParams: any;
  106347. /** @hidden */
  106348. _rigCameras: Camera[];
  106349. /** @hidden */
  106350. _rigPostProcess: Nullable<PostProcess>;
  106351. protected _webvrViewMatrix: Matrix;
  106352. /** @hidden */
  106353. _skipRendering: boolean;
  106354. /** @hidden */
  106355. _projectionMatrix: Matrix;
  106356. /** @hidden */
  106357. _postProcesses: Nullable<PostProcess>[];
  106358. /** @hidden */
  106359. _activeMeshes: SmartArray<AbstractMesh>;
  106360. protected _globalPosition: Vector3;
  106361. /** @hidden */
  106362. _computedViewMatrix: Matrix;
  106363. private _doNotComputeProjectionMatrix;
  106364. private _transformMatrix;
  106365. private _frustumPlanes;
  106366. private _refreshFrustumPlanes;
  106367. private _storedFov;
  106368. private _stateStored;
  106369. /**
  106370. * Instantiates a new camera object.
  106371. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  106372. * @see http://doc.babylonjs.com/features/cameras
  106373. * @param name Defines the name of the camera in the scene
  106374. * @param position Defines the position of the camera
  106375. * @param scene Defines the scene the camera belongs too
  106376. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  106377. */
  106378. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106379. /**
  106380. * Store current camera state (fov, position, etc..)
  106381. * @returns the camera
  106382. */
  106383. storeState(): Camera;
  106384. /**
  106385. * Restores the camera state values if it has been stored. You must call storeState() first
  106386. */
  106387. protected _restoreStateValues(): boolean;
  106388. /**
  106389. * Restored camera state. You must call storeState() first.
  106390. * @returns true if restored and false otherwise
  106391. */
  106392. restoreState(): boolean;
  106393. /**
  106394. * Gets the class name of the camera.
  106395. * @returns the class name
  106396. */
  106397. getClassName(): string;
  106398. /** @hidden */
  106399. readonly _isCamera: boolean;
  106400. /**
  106401. * Gets a string representation of the camera useful for debug purpose.
  106402. * @param fullDetails Defines that a more verboe level of logging is required
  106403. * @returns the string representation
  106404. */
  106405. toString(fullDetails?: boolean): string;
  106406. /**
  106407. * Gets the current world space position of the camera.
  106408. */
  106409. get globalPosition(): Vector3;
  106410. /**
  106411. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  106412. * @returns the active meshe list
  106413. */
  106414. getActiveMeshes(): SmartArray<AbstractMesh>;
  106415. /**
  106416. * Check whether a mesh is part of the current active mesh list of the camera
  106417. * @param mesh Defines the mesh to check
  106418. * @returns true if active, false otherwise
  106419. */
  106420. isActiveMesh(mesh: Mesh): boolean;
  106421. /**
  106422. * Is this camera ready to be used/rendered
  106423. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  106424. * @return true if the camera is ready
  106425. */
  106426. isReady(completeCheck?: boolean): boolean;
  106427. /** @hidden */
  106428. _initCache(): void;
  106429. /** @hidden */
  106430. _updateCache(ignoreParentClass?: boolean): void;
  106431. /** @hidden */
  106432. _isSynchronized(): boolean;
  106433. /** @hidden */
  106434. _isSynchronizedViewMatrix(): boolean;
  106435. /** @hidden */
  106436. _isSynchronizedProjectionMatrix(): boolean;
  106437. /**
  106438. * Attach the input controls to a specific dom element to get the input from.
  106439. * @param element Defines the element the controls should be listened from
  106440. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106441. */
  106442. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106443. /**
  106444. * Detach the current controls from the specified dom element.
  106445. * @param element Defines the element to stop listening the inputs from
  106446. */
  106447. detachControl(element: HTMLElement): void;
  106448. /**
  106449. * Update the camera state according to the different inputs gathered during the frame.
  106450. */
  106451. update(): void;
  106452. /** @hidden */
  106453. _checkInputs(): void;
  106454. /** @hidden */
  106455. get rigCameras(): Camera[];
  106456. /**
  106457. * Gets the post process used by the rig cameras
  106458. */
  106459. get rigPostProcess(): Nullable<PostProcess>;
  106460. /**
  106461. * Internal, gets the first post proces.
  106462. * @returns the first post process to be run on this camera.
  106463. */
  106464. _getFirstPostProcess(): Nullable<PostProcess>;
  106465. private _cascadePostProcessesToRigCams;
  106466. /**
  106467. * Attach a post process to the camera.
  106468. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  106469. * @param postProcess The post process to attach to the camera
  106470. * @param insertAt The position of the post process in case several of them are in use in the scene
  106471. * @returns the position the post process has been inserted at
  106472. */
  106473. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  106474. /**
  106475. * Detach a post process to the camera.
  106476. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  106477. * @param postProcess The post process to detach from the camera
  106478. */
  106479. detachPostProcess(postProcess: PostProcess): void;
  106480. /**
  106481. * Gets the current world matrix of the camera
  106482. */
  106483. getWorldMatrix(): Matrix;
  106484. /** @hidden */
  106485. _getViewMatrix(): Matrix;
  106486. /**
  106487. * Gets the current view matrix of the camera.
  106488. * @param force forces the camera to recompute the matrix without looking at the cached state
  106489. * @returns the view matrix
  106490. */
  106491. getViewMatrix(force?: boolean): Matrix;
  106492. /**
  106493. * Freeze the projection matrix.
  106494. * It will prevent the cache check of the camera projection compute and can speed up perf
  106495. * if no parameter of the camera are meant to change
  106496. * @param projection Defines manually a projection if necessary
  106497. */
  106498. freezeProjectionMatrix(projection?: Matrix): void;
  106499. /**
  106500. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  106501. */
  106502. unfreezeProjectionMatrix(): void;
  106503. /**
  106504. * Gets the current projection matrix of the camera.
  106505. * @param force forces the camera to recompute the matrix without looking at the cached state
  106506. * @returns the projection matrix
  106507. */
  106508. getProjectionMatrix(force?: boolean): Matrix;
  106509. /**
  106510. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  106511. * @returns a Matrix
  106512. */
  106513. getTransformationMatrix(): Matrix;
  106514. private _updateFrustumPlanes;
  106515. /**
  106516. * Checks if a cullable object (mesh...) is in the camera frustum
  106517. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  106518. * @param target The object to check
  106519. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  106520. * @returns true if the object is in frustum otherwise false
  106521. */
  106522. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  106523. /**
  106524. * Checks if a cullable object (mesh...) is in the camera frustum
  106525. * Unlike isInFrustum this cheks the full bounding box
  106526. * @param target The object to check
  106527. * @returns true if the object is in frustum otherwise false
  106528. */
  106529. isCompletelyInFrustum(target: ICullable): boolean;
  106530. /**
  106531. * Gets a ray in the forward direction from the camera.
  106532. * @param length Defines the length of the ray to create
  106533. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  106534. * @param origin Defines the start point of the ray which defaults to the camera position
  106535. * @returns the forward ray
  106536. */
  106537. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  106538. /**
  106539. * Releases resources associated with this node.
  106540. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106541. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106542. */
  106543. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106544. /** @hidden */
  106545. _isLeftCamera: boolean;
  106546. /**
  106547. * Gets the left camera of a rig setup in case of Rigged Camera
  106548. */
  106549. get isLeftCamera(): boolean;
  106550. /** @hidden */
  106551. _isRightCamera: boolean;
  106552. /**
  106553. * Gets the right camera of a rig setup in case of Rigged Camera
  106554. */
  106555. get isRightCamera(): boolean;
  106556. /**
  106557. * Gets the left camera of a rig setup in case of Rigged Camera
  106558. */
  106559. get leftCamera(): Nullable<FreeCamera>;
  106560. /**
  106561. * Gets the right camera of a rig setup in case of Rigged Camera
  106562. */
  106563. get rightCamera(): Nullable<FreeCamera>;
  106564. /**
  106565. * Gets the left camera target of a rig setup in case of Rigged Camera
  106566. * @returns the target position
  106567. */
  106568. getLeftTarget(): Nullable<Vector3>;
  106569. /**
  106570. * Gets the right camera target of a rig setup in case of Rigged Camera
  106571. * @returns the target position
  106572. */
  106573. getRightTarget(): Nullable<Vector3>;
  106574. /**
  106575. * @hidden
  106576. */
  106577. setCameraRigMode(mode: number, rigParams: any): void;
  106578. /** @hidden */
  106579. static _setStereoscopicRigMode(camera: Camera): void;
  106580. /** @hidden */
  106581. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  106582. /** @hidden */
  106583. static _setVRRigMode(camera: Camera, rigParams: any): void;
  106584. /** @hidden */
  106585. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  106586. /** @hidden */
  106587. _getVRProjectionMatrix(): Matrix;
  106588. protected _updateCameraRotationMatrix(): void;
  106589. protected _updateWebVRCameraRotationMatrix(): void;
  106590. /**
  106591. * This function MUST be overwritten by the different WebVR cameras available.
  106592. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  106593. * @hidden
  106594. */
  106595. _getWebVRProjectionMatrix(): Matrix;
  106596. /**
  106597. * This function MUST be overwritten by the different WebVR cameras available.
  106598. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  106599. * @hidden
  106600. */
  106601. _getWebVRViewMatrix(): Matrix;
  106602. /** @hidden */
  106603. setCameraRigParameter(name: string, value: any): void;
  106604. /**
  106605. * needs to be overridden by children so sub has required properties to be copied
  106606. * @hidden
  106607. */
  106608. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  106609. /**
  106610. * May need to be overridden by children
  106611. * @hidden
  106612. */
  106613. _updateRigCameras(): void;
  106614. /** @hidden */
  106615. _setupInputs(): void;
  106616. /**
  106617. * Serialiaze the camera setup to a json represention
  106618. * @returns the JSON representation
  106619. */
  106620. serialize(): any;
  106621. /**
  106622. * Clones the current camera.
  106623. * @param name The cloned camera name
  106624. * @returns the cloned camera
  106625. */
  106626. clone(name: string): Camera;
  106627. /**
  106628. * Gets the direction of the camera relative to a given local axis.
  106629. * @param localAxis Defines the reference axis to provide a relative direction.
  106630. * @return the direction
  106631. */
  106632. getDirection(localAxis: Vector3): Vector3;
  106633. /**
  106634. * Returns the current camera absolute rotation
  106635. */
  106636. get absoluteRotation(): Quaternion;
  106637. /**
  106638. * Gets the direction of the camera relative to a given local axis into a passed vector.
  106639. * @param localAxis Defines the reference axis to provide a relative direction.
  106640. * @param result Defines the vector to store the result in
  106641. */
  106642. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  106643. /**
  106644. * Gets a camera constructor for a given camera type
  106645. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  106646. * @param name The name of the camera the result will be able to instantiate
  106647. * @param scene The scene the result will construct the camera in
  106648. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  106649. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  106650. * @returns a factory method to construc the camera
  106651. */
  106652. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  106653. /**
  106654. * Compute the world matrix of the camera.
  106655. * @returns the camera world matrix
  106656. */
  106657. computeWorldMatrix(): Matrix;
  106658. /**
  106659. * Parse a JSON and creates the camera from the parsed information
  106660. * @param parsedCamera The JSON to parse
  106661. * @param scene The scene to instantiate the camera in
  106662. * @returns the newly constructed camera
  106663. */
  106664. static Parse(parsedCamera: any, scene: Scene): Camera;
  106665. }
  106666. }
  106667. declare module BABYLON {
  106668. /**
  106669. * Class containing static functions to help procedurally build meshes
  106670. */
  106671. export class DiscBuilder {
  106672. /**
  106673. * Creates a plane polygonal mesh. By default, this is a disc
  106674. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  106675. * * 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
  106676. * * 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
  106677. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106678. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106680. * @param name defines the name of the mesh
  106681. * @param options defines the options used to create the mesh
  106682. * @param scene defines the hosting scene
  106683. * @returns the plane polygonal mesh
  106684. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  106685. */
  106686. static CreateDisc(name: string, options: {
  106687. radius?: number;
  106688. tessellation?: number;
  106689. arc?: number;
  106690. updatable?: boolean;
  106691. sideOrientation?: number;
  106692. frontUVs?: Vector4;
  106693. backUVs?: Vector4;
  106694. }, scene?: Nullable<Scene>): Mesh;
  106695. }
  106696. }
  106697. declare module BABYLON {
  106698. /**
  106699. * Options to be used when creating a FresnelParameters.
  106700. */
  106701. export type IFresnelParametersCreationOptions = {
  106702. /**
  106703. * Define the color used on edges (grazing angle)
  106704. */
  106705. leftColor?: Color3;
  106706. /**
  106707. * Define the color used on center
  106708. */
  106709. rightColor?: Color3;
  106710. /**
  106711. * Define bias applied to computed fresnel term
  106712. */
  106713. bias?: number;
  106714. /**
  106715. * Defined the power exponent applied to fresnel term
  106716. */
  106717. power?: number;
  106718. /**
  106719. * Define if the fresnel effect is enable or not.
  106720. */
  106721. isEnabled?: boolean;
  106722. };
  106723. /**
  106724. * Serialized format for FresnelParameters.
  106725. */
  106726. export type IFresnelParametersSerialized = {
  106727. /**
  106728. * Define the color used on edges (grazing angle) [as an array]
  106729. */
  106730. leftColor: number[];
  106731. /**
  106732. * Define the color used on center [as an array]
  106733. */
  106734. rightColor: number[];
  106735. /**
  106736. * Define bias applied to computed fresnel term
  106737. */
  106738. bias: number;
  106739. /**
  106740. * Defined the power exponent applied to fresnel term
  106741. */
  106742. power?: number;
  106743. /**
  106744. * Define if the fresnel effect is enable or not.
  106745. */
  106746. isEnabled: boolean;
  106747. };
  106748. /**
  106749. * This represents all the required information to add a fresnel effect on a material:
  106750. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106751. */
  106752. export class FresnelParameters {
  106753. private _isEnabled;
  106754. /**
  106755. * Define if the fresnel effect is enable or not.
  106756. */
  106757. get isEnabled(): boolean;
  106758. set isEnabled(value: boolean);
  106759. /**
  106760. * Define the color used on edges (grazing angle)
  106761. */
  106762. leftColor: Color3;
  106763. /**
  106764. * Define the color used on center
  106765. */
  106766. rightColor: Color3;
  106767. /**
  106768. * Define bias applied to computed fresnel term
  106769. */
  106770. bias: number;
  106771. /**
  106772. * Defined the power exponent applied to fresnel term
  106773. */
  106774. power: number;
  106775. /**
  106776. * Creates a new FresnelParameters object.
  106777. *
  106778. * @param options provide your own settings to optionally to override defaults
  106779. */
  106780. constructor(options?: IFresnelParametersCreationOptions);
  106781. /**
  106782. * Clones the current fresnel and its valuues
  106783. * @returns a clone fresnel configuration
  106784. */
  106785. clone(): FresnelParameters;
  106786. /**
  106787. * Determines equality between FresnelParameters objects
  106788. * @param otherFresnelParameters defines the second operand
  106789. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  106790. */
  106791. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  106792. /**
  106793. * Serializes the current fresnel parameters to a JSON representation.
  106794. * @return the JSON serialization
  106795. */
  106796. serialize(): IFresnelParametersSerialized;
  106797. /**
  106798. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  106799. * @param parsedFresnelParameters Define the JSON representation
  106800. * @returns the parsed parameters
  106801. */
  106802. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  106803. }
  106804. }
  106805. declare module BABYLON {
  106806. /**
  106807. * This groups all the flags used to control the materials channel.
  106808. */
  106809. export class MaterialFlags {
  106810. private static _DiffuseTextureEnabled;
  106811. /**
  106812. * Are diffuse textures enabled in the application.
  106813. */
  106814. static get DiffuseTextureEnabled(): boolean;
  106815. static set DiffuseTextureEnabled(value: boolean);
  106816. private static _DetailTextureEnabled;
  106817. /**
  106818. * Are detail textures enabled in the application.
  106819. */
  106820. static get DetailTextureEnabled(): boolean;
  106821. static set DetailTextureEnabled(value: boolean);
  106822. private static _AmbientTextureEnabled;
  106823. /**
  106824. * Are ambient textures enabled in the application.
  106825. */
  106826. static get AmbientTextureEnabled(): boolean;
  106827. static set AmbientTextureEnabled(value: boolean);
  106828. private static _OpacityTextureEnabled;
  106829. /**
  106830. * Are opacity textures enabled in the application.
  106831. */
  106832. static get OpacityTextureEnabled(): boolean;
  106833. static set OpacityTextureEnabled(value: boolean);
  106834. private static _ReflectionTextureEnabled;
  106835. /**
  106836. * Are reflection textures enabled in the application.
  106837. */
  106838. static get ReflectionTextureEnabled(): boolean;
  106839. static set ReflectionTextureEnabled(value: boolean);
  106840. private static _EmissiveTextureEnabled;
  106841. /**
  106842. * Are emissive textures enabled in the application.
  106843. */
  106844. static get EmissiveTextureEnabled(): boolean;
  106845. static set EmissiveTextureEnabled(value: boolean);
  106846. private static _SpecularTextureEnabled;
  106847. /**
  106848. * Are specular textures enabled in the application.
  106849. */
  106850. static get SpecularTextureEnabled(): boolean;
  106851. static set SpecularTextureEnabled(value: boolean);
  106852. private static _BumpTextureEnabled;
  106853. /**
  106854. * Are bump textures enabled in the application.
  106855. */
  106856. static get BumpTextureEnabled(): boolean;
  106857. static set BumpTextureEnabled(value: boolean);
  106858. private static _LightmapTextureEnabled;
  106859. /**
  106860. * Are lightmap textures enabled in the application.
  106861. */
  106862. static get LightmapTextureEnabled(): boolean;
  106863. static set LightmapTextureEnabled(value: boolean);
  106864. private static _RefractionTextureEnabled;
  106865. /**
  106866. * Are refraction textures enabled in the application.
  106867. */
  106868. static get RefractionTextureEnabled(): boolean;
  106869. static set RefractionTextureEnabled(value: boolean);
  106870. private static _ColorGradingTextureEnabled;
  106871. /**
  106872. * Are color grading textures enabled in the application.
  106873. */
  106874. static get ColorGradingTextureEnabled(): boolean;
  106875. static set ColorGradingTextureEnabled(value: boolean);
  106876. private static _FresnelEnabled;
  106877. /**
  106878. * Are fresnels enabled in the application.
  106879. */
  106880. static get FresnelEnabled(): boolean;
  106881. static set FresnelEnabled(value: boolean);
  106882. private static _ClearCoatTextureEnabled;
  106883. /**
  106884. * Are clear coat textures enabled in the application.
  106885. */
  106886. static get ClearCoatTextureEnabled(): boolean;
  106887. static set ClearCoatTextureEnabled(value: boolean);
  106888. private static _ClearCoatBumpTextureEnabled;
  106889. /**
  106890. * Are clear coat bump textures enabled in the application.
  106891. */
  106892. static get ClearCoatBumpTextureEnabled(): boolean;
  106893. static set ClearCoatBumpTextureEnabled(value: boolean);
  106894. private static _ClearCoatTintTextureEnabled;
  106895. /**
  106896. * Are clear coat tint textures enabled in the application.
  106897. */
  106898. static get ClearCoatTintTextureEnabled(): boolean;
  106899. static set ClearCoatTintTextureEnabled(value: boolean);
  106900. private static _SheenTextureEnabled;
  106901. /**
  106902. * Are sheen textures enabled in the application.
  106903. */
  106904. static get SheenTextureEnabled(): boolean;
  106905. static set SheenTextureEnabled(value: boolean);
  106906. private static _AnisotropicTextureEnabled;
  106907. /**
  106908. * Are anisotropic textures enabled in the application.
  106909. */
  106910. static get AnisotropicTextureEnabled(): boolean;
  106911. static set AnisotropicTextureEnabled(value: boolean);
  106912. private static _ThicknessTextureEnabled;
  106913. /**
  106914. * Are thickness textures enabled in the application.
  106915. */
  106916. static get ThicknessTextureEnabled(): boolean;
  106917. static set ThicknessTextureEnabled(value: boolean);
  106918. }
  106919. }
  106920. declare module BABYLON {
  106921. /** @hidden */
  106922. export var defaultFragmentDeclaration: {
  106923. name: string;
  106924. shader: string;
  106925. };
  106926. }
  106927. declare module BABYLON {
  106928. /** @hidden */
  106929. export var defaultUboDeclaration: {
  106930. name: string;
  106931. shader: string;
  106932. };
  106933. }
  106934. declare module BABYLON {
  106935. /** @hidden */
  106936. export var lightFragmentDeclaration: {
  106937. name: string;
  106938. shader: string;
  106939. };
  106940. }
  106941. declare module BABYLON {
  106942. /** @hidden */
  106943. export var lightUboDeclaration: {
  106944. name: string;
  106945. shader: string;
  106946. };
  106947. }
  106948. declare module BABYLON {
  106949. /** @hidden */
  106950. export var lightsFragmentFunctions: {
  106951. name: string;
  106952. shader: string;
  106953. };
  106954. }
  106955. declare module BABYLON {
  106956. /** @hidden */
  106957. export var shadowsFragmentFunctions: {
  106958. name: string;
  106959. shader: string;
  106960. };
  106961. }
  106962. declare module BABYLON {
  106963. /** @hidden */
  106964. export var fresnelFunction: {
  106965. name: string;
  106966. shader: string;
  106967. };
  106968. }
  106969. declare module BABYLON {
  106970. /** @hidden */
  106971. export var bumpFragmentMainFunctions: {
  106972. name: string;
  106973. shader: string;
  106974. };
  106975. }
  106976. declare module BABYLON {
  106977. /** @hidden */
  106978. export var bumpFragmentFunctions: {
  106979. name: string;
  106980. shader: string;
  106981. };
  106982. }
  106983. declare module BABYLON {
  106984. /** @hidden */
  106985. export var logDepthDeclaration: {
  106986. name: string;
  106987. shader: string;
  106988. };
  106989. }
  106990. declare module BABYLON {
  106991. /** @hidden */
  106992. export var bumpFragment: {
  106993. name: string;
  106994. shader: string;
  106995. };
  106996. }
  106997. declare module BABYLON {
  106998. /** @hidden */
  106999. export var depthPrePass: {
  107000. name: string;
  107001. shader: string;
  107002. };
  107003. }
  107004. declare module BABYLON {
  107005. /** @hidden */
  107006. export var lightFragment: {
  107007. name: string;
  107008. shader: string;
  107009. };
  107010. }
  107011. declare module BABYLON {
  107012. /** @hidden */
  107013. export var logDepthFragment: {
  107014. name: string;
  107015. shader: string;
  107016. };
  107017. }
  107018. declare module BABYLON {
  107019. /** @hidden */
  107020. export var defaultPixelShader: {
  107021. name: string;
  107022. shader: string;
  107023. };
  107024. }
  107025. declare module BABYLON {
  107026. /** @hidden */
  107027. export var defaultVertexDeclaration: {
  107028. name: string;
  107029. shader: string;
  107030. };
  107031. }
  107032. declare module BABYLON {
  107033. /** @hidden */
  107034. export var bumpVertexDeclaration: {
  107035. name: string;
  107036. shader: string;
  107037. };
  107038. }
  107039. declare module BABYLON {
  107040. /** @hidden */
  107041. export var bumpVertex: {
  107042. name: string;
  107043. shader: string;
  107044. };
  107045. }
  107046. declare module BABYLON {
  107047. /** @hidden */
  107048. export var fogVertex: {
  107049. name: string;
  107050. shader: string;
  107051. };
  107052. }
  107053. declare module BABYLON {
  107054. /** @hidden */
  107055. export var shadowsVertex: {
  107056. name: string;
  107057. shader: string;
  107058. };
  107059. }
  107060. declare module BABYLON {
  107061. /** @hidden */
  107062. export var pointCloudVertex: {
  107063. name: string;
  107064. shader: string;
  107065. };
  107066. }
  107067. declare module BABYLON {
  107068. /** @hidden */
  107069. export var logDepthVertex: {
  107070. name: string;
  107071. shader: string;
  107072. };
  107073. }
  107074. declare module BABYLON {
  107075. /** @hidden */
  107076. export var defaultVertexShader: {
  107077. name: string;
  107078. shader: string;
  107079. };
  107080. }
  107081. declare module BABYLON {
  107082. /**
  107083. * @hidden
  107084. */
  107085. export interface IMaterialDetailMapDefines {
  107086. DETAIL: boolean;
  107087. DETAILDIRECTUV: number;
  107088. DETAIL_NORMALBLENDMETHOD: number;
  107089. /** @hidden */
  107090. _areTexturesDirty: boolean;
  107091. }
  107092. /**
  107093. * Define the code related to the detail map parameters of a material
  107094. *
  107095. * Inspired from:
  107096. * 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
  107097. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  107098. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  107099. */
  107100. export class DetailMapConfiguration {
  107101. private _texture;
  107102. /**
  107103. * The detail texture of the material.
  107104. */
  107105. texture: Nullable<BaseTexture>;
  107106. /**
  107107. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  107108. * Bigger values mean stronger blending
  107109. */
  107110. diffuseBlendLevel: number;
  107111. /**
  107112. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  107113. * Bigger values mean stronger blending. Only used with PBR materials
  107114. */
  107115. roughnessBlendLevel: number;
  107116. /**
  107117. * Defines how strong the bump effect from the detail map is
  107118. * Bigger values mean stronger effect
  107119. */
  107120. bumpLevel: number;
  107121. private _normalBlendMethod;
  107122. /**
  107123. * The method used to blend the bump and detail normals together
  107124. */
  107125. normalBlendMethod: number;
  107126. private _isEnabled;
  107127. /**
  107128. * Enable or disable the detail map on this material
  107129. */
  107130. isEnabled: boolean;
  107131. /** @hidden */
  107132. private _internalMarkAllSubMeshesAsTexturesDirty;
  107133. /** @hidden */
  107134. _markAllSubMeshesAsTexturesDirty(): void;
  107135. /**
  107136. * Instantiate a new detail map
  107137. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107138. */
  107139. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107140. /**
  107141. * Gets whether the submesh is ready to be used or not.
  107142. * @param defines the list of "defines" to update.
  107143. * @param scene defines the scene the material belongs to.
  107144. * @returns - boolean indicating that the submesh is ready or not.
  107145. */
  107146. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  107147. /**
  107148. * Update the defines for detail map usage
  107149. * @param defines the list of "defines" to update.
  107150. * @param scene defines the scene the material belongs to.
  107151. */
  107152. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  107153. /**
  107154. * Binds the material data.
  107155. * @param uniformBuffer defines the Uniform buffer to fill in.
  107156. * @param scene defines the scene the material belongs to.
  107157. * @param isFrozen defines whether the material is frozen or not.
  107158. */
  107159. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107160. /**
  107161. * Checks to see if a texture is used in the material.
  107162. * @param texture - Base texture to use.
  107163. * @returns - Boolean specifying if a texture is used in the material.
  107164. */
  107165. hasTexture(texture: BaseTexture): boolean;
  107166. /**
  107167. * Returns an array of the actively used textures.
  107168. * @param activeTextures Array of BaseTextures
  107169. */
  107170. getActiveTextures(activeTextures: BaseTexture[]): void;
  107171. /**
  107172. * Returns the animatable textures.
  107173. * @param animatables Array of animatable textures.
  107174. */
  107175. getAnimatables(animatables: IAnimatable[]): void;
  107176. /**
  107177. * Disposes the resources of the material.
  107178. * @param forceDisposeTextures - Forces the disposal of all textures.
  107179. */
  107180. dispose(forceDisposeTextures?: boolean): void;
  107181. /**
  107182. * Get the current class name useful for serialization or dynamic coding.
  107183. * @returns "DetailMap"
  107184. */
  107185. getClassName(): string;
  107186. /**
  107187. * Add the required uniforms to the current list.
  107188. * @param uniforms defines the current uniform list.
  107189. */
  107190. static AddUniforms(uniforms: string[]): void;
  107191. /**
  107192. * Add the required samplers to the current list.
  107193. * @param samplers defines the current sampler list.
  107194. */
  107195. static AddSamplers(samplers: string[]): void;
  107196. /**
  107197. * Add the required uniforms to the current buffer.
  107198. * @param uniformBuffer defines the current uniform buffer.
  107199. */
  107200. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107201. /**
  107202. * Makes a duplicate of the current instance into another one.
  107203. * @param detailMap define the instance where to copy the info
  107204. */
  107205. copyTo(detailMap: DetailMapConfiguration): void;
  107206. /**
  107207. * Serializes this detail map instance
  107208. * @returns - An object with the serialized instance.
  107209. */
  107210. serialize(): any;
  107211. /**
  107212. * Parses a detail map setting from a serialized object.
  107213. * @param source - Serialized object.
  107214. * @param scene Defines the scene we are parsing for
  107215. * @param rootUrl Defines the rootUrl to load from
  107216. */
  107217. parse(source: any, scene: Scene, rootUrl: string): void;
  107218. }
  107219. }
  107220. declare module BABYLON {
  107221. /** @hidden */
  107222. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  107223. MAINUV1: boolean;
  107224. MAINUV2: boolean;
  107225. DIFFUSE: boolean;
  107226. DIFFUSEDIRECTUV: number;
  107227. DETAIL: boolean;
  107228. DETAILDIRECTUV: number;
  107229. DETAIL_NORMALBLENDMETHOD: number;
  107230. AMBIENT: boolean;
  107231. AMBIENTDIRECTUV: number;
  107232. OPACITY: boolean;
  107233. OPACITYDIRECTUV: number;
  107234. OPACITYRGB: boolean;
  107235. REFLECTION: boolean;
  107236. EMISSIVE: boolean;
  107237. EMISSIVEDIRECTUV: number;
  107238. SPECULAR: boolean;
  107239. SPECULARDIRECTUV: number;
  107240. BUMP: boolean;
  107241. BUMPDIRECTUV: number;
  107242. PARALLAX: boolean;
  107243. PARALLAXOCCLUSION: boolean;
  107244. SPECULAROVERALPHA: boolean;
  107245. CLIPPLANE: boolean;
  107246. CLIPPLANE2: boolean;
  107247. CLIPPLANE3: boolean;
  107248. CLIPPLANE4: boolean;
  107249. CLIPPLANE5: boolean;
  107250. CLIPPLANE6: boolean;
  107251. ALPHATEST: boolean;
  107252. DEPTHPREPASS: boolean;
  107253. ALPHAFROMDIFFUSE: boolean;
  107254. POINTSIZE: boolean;
  107255. FOG: boolean;
  107256. SPECULARTERM: boolean;
  107257. DIFFUSEFRESNEL: boolean;
  107258. OPACITYFRESNEL: boolean;
  107259. REFLECTIONFRESNEL: boolean;
  107260. REFRACTIONFRESNEL: boolean;
  107261. EMISSIVEFRESNEL: boolean;
  107262. FRESNEL: boolean;
  107263. NORMAL: boolean;
  107264. UV1: boolean;
  107265. UV2: boolean;
  107266. VERTEXCOLOR: boolean;
  107267. VERTEXALPHA: boolean;
  107268. NUM_BONE_INFLUENCERS: number;
  107269. BonesPerMesh: number;
  107270. BONETEXTURE: boolean;
  107271. INSTANCES: boolean;
  107272. THIN_INSTANCES: boolean;
  107273. GLOSSINESS: boolean;
  107274. ROUGHNESS: boolean;
  107275. EMISSIVEASILLUMINATION: boolean;
  107276. LINKEMISSIVEWITHDIFFUSE: boolean;
  107277. REFLECTIONFRESNELFROMSPECULAR: boolean;
  107278. LIGHTMAP: boolean;
  107279. LIGHTMAPDIRECTUV: number;
  107280. OBJECTSPACE_NORMALMAP: boolean;
  107281. USELIGHTMAPASSHADOWMAP: boolean;
  107282. REFLECTIONMAP_3D: boolean;
  107283. REFLECTIONMAP_SPHERICAL: boolean;
  107284. REFLECTIONMAP_PLANAR: boolean;
  107285. REFLECTIONMAP_CUBIC: boolean;
  107286. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107287. REFLECTIONMAP_PROJECTION: boolean;
  107288. REFLECTIONMAP_SKYBOX: boolean;
  107289. REFLECTIONMAP_EXPLICIT: boolean;
  107290. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107291. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107292. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107293. INVERTCUBICMAP: boolean;
  107294. LOGARITHMICDEPTH: boolean;
  107295. REFRACTION: boolean;
  107296. REFRACTIONMAP_3D: boolean;
  107297. REFLECTIONOVERALPHA: boolean;
  107298. TWOSIDEDLIGHTING: boolean;
  107299. SHADOWFLOAT: boolean;
  107300. MORPHTARGETS: boolean;
  107301. MORPHTARGETS_NORMAL: boolean;
  107302. MORPHTARGETS_TANGENT: boolean;
  107303. MORPHTARGETS_UV: boolean;
  107304. NUM_MORPH_INFLUENCERS: number;
  107305. NONUNIFORMSCALING: boolean;
  107306. PREMULTIPLYALPHA: boolean;
  107307. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  107308. ALPHABLEND: boolean;
  107309. RGBDLIGHTMAP: boolean;
  107310. RGBDREFLECTION: boolean;
  107311. RGBDREFRACTION: boolean;
  107312. IMAGEPROCESSING: boolean;
  107313. VIGNETTE: boolean;
  107314. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107315. VIGNETTEBLENDMODEOPAQUE: boolean;
  107316. TONEMAPPING: boolean;
  107317. TONEMAPPING_ACES: boolean;
  107318. CONTRAST: boolean;
  107319. COLORCURVES: boolean;
  107320. COLORGRADING: boolean;
  107321. COLORGRADING3D: boolean;
  107322. SAMPLER3DGREENDEPTH: boolean;
  107323. SAMPLER3DBGRMAP: boolean;
  107324. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107325. MULTIVIEW: boolean;
  107326. /**
  107327. * If the reflection texture on this material is in linear color space
  107328. * @hidden
  107329. */
  107330. IS_REFLECTION_LINEAR: boolean;
  107331. /**
  107332. * If the refraction texture on this material is in linear color space
  107333. * @hidden
  107334. */
  107335. IS_REFRACTION_LINEAR: boolean;
  107336. EXPOSURE: boolean;
  107337. constructor();
  107338. setReflectionMode(modeToEnable: string): void;
  107339. }
  107340. /**
  107341. * This is the default material used in Babylon. It is the best trade off between quality
  107342. * and performances.
  107343. * @see http://doc.babylonjs.com/babylon101/materials
  107344. */
  107345. export class StandardMaterial extends PushMaterial {
  107346. private _diffuseTexture;
  107347. /**
  107348. * The basic texture of the material as viewed under a light.
  107349. */
  107350. diffuseTexture: Nullable<BaseTexture>;
  107351. private _ambientTexture;
  107352. /**
  107353. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107354. */
  107355. ambientTexture: Nullable<BaseTexture>;
  107356. private _opacityTexture;
  107357. /**
  107358. * Define the transparency of the material from a texture.
  107359. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107360. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107361. */
  107362. opacityTexture: Nullable<BaseTexture>;
  107363. private _reflectionTexture;
  107364. /**
  107365. * Define the texture used to display the reflection.
  107366. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107367. */
  107368. reflectionTexture: Nullable<BaseTexture>;
  107369. private _emissiveTexture;
  107370. /**
  107371. * Define texture of the material as if self lit.
  107372. * This will be mixed in the final result even in the absence of light.
  107373. */
  107374. emissiveTexture: Nullable<BaseTexture>;
  107375. private _specularTexture;
  107376. /**
  107377. * Define how the color and intensity of the highlight given by the light in the material.
  107378. */
  107379. specularTexture: Nullable<BaseTexture>;
  107380. private _bumpTexture;
  107381. /**
  107382. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107383. * 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.
  107384. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  107385. */
  107386. bumpTexture: Nullable<BaseTexture>;
  107387. private _lightmapTexture;
  107388. /**
  107389. * Complex lighting can be computationally expensive to compute at runtime.
  107390. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107391. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  107392. */
  107393. lightmapTexture: Nullable<BaseTexture>;
  107394. private _refractionTexture;
  107395. /**
  107396. * Define the texture used to display the refraction.
  107397. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107398. */
  107399. refractionTexture: Nullable<BaseTexture>;
  107400. /**
  107401. * The color of the material lit by the environmental background lighting.
  107402. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107403. */
  107404. ambientColor: Color3;
  107405. /**
  107406. * The basic color of the material as viewed under a light.
  107407. */
  107408. diffuseColor: Color3;
  107409. /**
  107410. * Define how the color and intensity of the highlight given by the light in the material.
  107411. */
  107412. specularColor: Color3;
  107413. /**
  107414. * Define the color of the material as if self lit.
  107415. * This will be mixed in the final result even in the absence of light.
  107416. */
  107417. emissiveColor: Color3;
  107418. /**
  107419. * Defines how sharp are the highlights in the material.
  107420. * The bigger the value the sharper giving a more glossy feeling to the result.
  107421. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107422. */
  107423. specularPower: number;
  107424. private _useAlphaFromDiffuseTexture;
  107425. /**
  107426. * Does the transparency come from the diffuse texture alpha channel.
  107427. */
  107428. useAlphaFromDiffuseTexture: boolean;
  107429. private _useEmissiveAsIllumination;
  107430. /**
  107431. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107432. */
  107433. useEmissiveAsIllumination: boolean;
  107434. private _linkEmissiveWithDiffuse;
  107435. /**
  107436. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107437. * the emissive level when the final color is close to one.
  107438. */
  107439. linkEmissiveWithDiffuse: boolean;
  107440. private _useSpecularOverAlpha;
  107441. /**
  107442. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107443. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107444. */
  107445. useSpecularOverAlpha: boolean;
  107446. private _useReflectionOverAlpha;
  107447. /**
  107448. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107449. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107450. */
  107451. useReflectionOverAlpha: boolean;
  107452. private _disableLighting;
  107453. /**
  107454. * Does lights from the scene impacts this material.
  107455. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107456. */
  107457. disableLighting: boolean;
  107458. private _useObjectSpaceNormalMap;
  107459. /**
  107460. * Allows using an object space normal map (instead of tangent space).
  107461. */
  107462. useObjectSpaceNormalMap: boolean;
  107463. private _useParallax;
  107464. /**
  107465. * Is parallax enabled or not.
  107466. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107467. */
  107468. useParallax: boolean;
  107469. private _useParallaxOcclusion;
  107470. /**
  107471. * Is parallax occlusion enabled or not.
  107472. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107473. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107474. */
  107475. useParallaxOcclusion: boolean;
  107476. /**
  107477. * 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.
  107478. */
  107479. parallaxScaleBias: number;
  107480. private _roughness;
  107481. /**
  107482. * Helps to define how blurry the reflections should appears in the material.
  107483. */
  107484. roughness: number;
  107485. /**
  107486. * In case of refraction, define the value of the index of refraction.
  107487. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107488. */
  107489. indexOfRefraction: number;
  107490. /**
  107491. * Invert the refraction texture alongside the y axis.
  107492. * It can be useful with procedural textures or probe for instance.
  107493. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107494. */
  107495. invertRefractionY: boolean;
  107496. /**
  107497. * Defines the alpha limits in alpha test mode.
  107498. */
  107499. alphaCutOff: number;
  107500. private _useLightmapAsShadowmap;
  107501. /**
  107502. * In case of light mapping, define whether the map contains light or shadow informations.
  107503. */
  107504. useLightmapAsShadowmap: boolean;
  107505. private _diffuseFresnelParameters;
  107506. /**
  107507. * Define the diffuse fresnel parameters of the material.
  107508. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107509. */
  107510. diffuseFresnelParameters: FresnelParameters;
  107511. private _opacityFresnelParameters;
  107512. /**
  107513. * Define the opacity fresnel parameters of the material.
  107514. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107515. */
  107516. opacityFresnelParameters: FresnelParameters;
  107517. private _reflectionFresnelParameters;
  107518. /**
  107519. * Define the reflection fresnel parameters of the material.
  107520. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107521. */
  107522. reflectionFresnelParameters: FresnelParameters;
  107523. private _refractionFresnelParameters;
  107524. /**
  107525. * Define the refraction fresnel parameters of the material.
  107526. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107527. */
  107528. refractionFresnelParameters: FresnelParameters;
  107529. private _emissiveFresnelParameters;
  107530. /**
  107531. * Define the emissive fresnel parameters of the material.
  107532. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107533. */
  107534. emissiveFresnelParameters: FresnelParameters;
  107535. private _useReflectionFresnelFromSpecular;
  107536. /**
  107537. * If true automatically deducts the fresnels values from the material specularity.
  107538. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107539. */
  107540. useReflectionFresnelFromSpecular: boolean;
  107541. private _useGlossinessFromSpecularMapAlpha;
  107542. /**
  107543. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107544. */
  107545. useGlossinessFromSpecularMapAlpha: boolean;
  107546. private _maxSimultaneousLights;
  107547. /**
  107548. * Defines the maximum number of lights that can be used in the material
  107549. */
  107550. maxSimultaneousLights: number;
  107551. private _invertNormalMapX;
  107552. /**
  107553. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107554. */
  107555. invertNormalMapX: boolean;
  107556. private _invertNormalMapY;
  107557. /**
  107558. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107559. */
  107560. invertNormalMapY: boolean;
  107561. private _twoSidedLighting;
  107562. /**
  107563. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107564. */
  107565. twoSidedLighting: boolean;
  107566. /**
  107567. * Default configuration related to image processing available in the standard Material.
  107568. */
  107569. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107570. /**
  107571. * Gets the image processing configuration used either in this material.
  107572. */
  107573. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107574. /**
  107575. * Sets the Default image processing configuration used either in the this material.
  107576. *
  107577. * If sets to null, the scene one is in use.
  107578. */
  107579. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  107580. /**
  107581. * Keep track of the image processing observer to allow dispose and replace.
  107582. */
  107583. private _imageProcessingObserver;
  107584. /**
  107585. * Attaches a new image processing configuration to the Standard Material.
  107586. * @param configuration
  107587. */
  107588. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107589. /**
  107590. * Gets wether the color curves effect is enabled.
  107591. */
  107592. get cameraColorCurvesEnabled(): boolean;
  107593. /**
  107594. * Sets wether the color curves effect is enabled.
  107595. */
  107596. set cameraColorCurvesEnabled(value: boolean);
  107597. /**
  107598. * Gets wether the color grading effect is enabled.
  107599. */
  107600. get cameraColorGradingEnabled(): boolean;
  107601. /**
  107602. * Gets wether the color grading effect is enabled.
  107603. */
  107604. set cameraColorGradingEnabled(value: boolean);
  107605. /**
  107606. * Gets wether tonemapping is enabled or not.
  107607. */
  107608. get cameraToneMappingEnabled(): boolean;
  107609. /**
  107610. * Sets wether tonemapping is enabled or not
  107611. */
  107612. set cameraToneMappingEnabled(value: boolean);
  107613. /**
  107614. * The camera exposure used on this material.
  107615. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107616. * This corresponds to a photographic exposure.
  107617. */
  107618. get cameraExposure(): number;
  107619. /**
  107620. * The camera exposure used on this material.
  107621. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107622. * This corresponds to a photographic exposure.
  107623. */
  107624. set cameraExposure(value: number);
  107625. /**
  107626. * Gets The camera contrast used on this material.
  107627. */
  107628. get cameraContrast(): number;
  107629. /**
  107630. * Sets The camera contrast used on this material.
  107631. */
  107632. set cameraContrast(value: number);
  107633. /**
  107634. * Gets the Color Grading 2D Lookup Texture.
  107635. */
  107636. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  107637. /**
  107638. * Sets the Color Grading 2D Lookup Texture.
  107639. */
  107640. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  107641. /**
  107642. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107643. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107644. * 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;
  107645. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107646. */
  107647. get cameraColorCurves(): Nullable<ColorCurves>;
  107648. /**
  107649. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107650. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107651. * 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;
  107652. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107653. */
  107654. set cameraColorCurves(value: Nullable<ColorCurves>);
  107655. /**
  107656. * Defines the detail map parameters for the material.
  107657. */
  107658. readonly detailMap: DetailMapConfiguration;
  107659. protected _renderTargets: SmartArray<RenderTargetTexture>;
  107660. protected _worldViewProjectionMatrix: Matrix;
  107661. protected _globalAmbientColor: Color3;
  107662. protected _useLogarithmicDepth: boolean;
  107663. protected _rebuildInParallel: boolean;
  107664. /**
  107665. * Instantiates a new standard material.
  107666. * This is the default material used in Babylon. It is the best trade off between quality
  107667. * and performances.
  107668. * @see http://doc.babylonjs.com/babylon101/materials
  107669. * @param name Define the name of the material in the scene
  107670. * @param scene Define the scene the material belong to
  107671. */
  107672. constructor(name: string, scene: Scene);
  107673. /**
  107674. * Gets a boolean indicating that current material needs to register RTT
  107675. */
  107676. get hasRenderTargetTextures(): boolean;
  107677. /**
  107678. * Gets the current class name of the material e.g. "StandardMaterial"
  107679. * Mainly use in serialization.
  107680. * @returns the class name
  107681. */
  107682. getClassName(): string;
  107683. /**
  107684. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  107685. * You can try switching to logarithmic depth.
  107686. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  107687. */
  107688. get useLogarithmicDepth(): boolean;
  107689. set useLogarithmicDepth(value: boolean);
  107690. /**
  107691. * Specifies if the material will require alpha blending
  107692. * @returns a boolean specifying if alpha blending is needed
  107693. */
  107694. needAlphaBlending(): boolean;
  107695. /**
  107696. * Specifies if this material should be rendered in alpha test mode
  107697. * @returns a boolean specifying if an alpha test is needed.
  107698. */
  107699. needAlphaTesting(): boolean;
  107700. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  107701. /**
  107702. * Get the texture used for alpha test purpose.
  107703. * @returns the diffuse texture in case of the standard material.
  107704. */
  107705. getAlphaTestTexture(): Nullable<BaseTexture>;
  107706. /**
  107707. * Get if the submesh is ready to be used and all its information available.
  107708. * Child classes can use it to update shaders
  107709. * @param mesh defines the mesh to check
  107710. * @param subMesh defines which submesh to check
  107711. * @param useInstances specifies that instances should be used
  107712. * @returns a boolean indicating that the submesh is ready or not
  107713. */
  107714. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107715. /**
  107716. * Builds the material UBO layouts.
  107717. * Used internally during the effect preparation.
  107718. */
  107719. buildUniformLayout(): void;
  107720. /**
  107721. * Unbinds the material from the mesh
  107722. */
  107723. unbind(): void;
  107724. /**
  107725. * Binds the submesh to this material by preparing the effect and shader to draw
  107726. * @param world defines the world transformation matrix
  107727. * @param mesh defines the mesh containing the submesh
  107728. * @param subMesh defines the submesh to bind the material to
  107729. */
  107730. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107731. /**
  107732. * Get the list of animatables in the material.
  107733. * @returns the list of animatables object used in the material
  107734. */
  107735. getAnimatables(): IAnimatable[];
  107736. /**
  107737. * Gets the active textures from the material
  107738. * @returns an array of textures
  107739. */
  107740. getActiveTextures(): BaseTexture[];
  107741. /**
  107742. * Specifies if the material uses a texture
  107743. * @param texture defines the texture to check against the material
  107744. * @returns a boolean specifying if the material uses the texture
  107745. */
  107746. hasTexture(texture: BaseTexture): boolean;
  107747. /**
  107748. * Disposes the material
  107749. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  107750. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  107751. */
  107752. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107753. /**
  107754. * Makes a duplicate of the material, and gives it a new name
  107755. * @param name defines the new name for the duplicated material
  107756. * @returns the cloned material
  107757. */
  107758. clone(name: string): StandardMaterial;
  107759. /**
  107760. * Serializes this material in a JSON representation
  107761. * @returns the serialized material object
  107762. */
  107763. serialize(): any;
  107764. /**
  107765. * Creates a standard material from parsed material data
  107766. * @param source defines the JSON representation of the material
  107767. * @param scene defines the hosting scene
  107768. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107769. * @returns a new standard material
  107770. */
  107771. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107772. /**
  107773. * Are diffuse textures enabled in the application.
  107774. */
  107775. static get DiffuseTextureEnabled(): boolean;
  107776. static set DiffuseTextureEnabled(value: boolean);
  107777. /**
  107778. * Are detail textures enabled in the application.
  107779. */
  107780. static get DetailTextureEnabled(): boolean;
  107781. static set DetailTextureEnabled(value: boolean);
  107782. /**
  107783. * Are ambient textures enabled in the application.
  107784. */
  107785. static get AmbientTextureEnabled(): boolean;
  107786. static set AmbientTextureEnabled(value: boolean);
  107787. /**
  107788. * Are opacity textures enabled in the application.
  107789. */
  107790. static get OpacityTextureEnabled(): boolean;
  107791. static set OpacityTextureEnabled(value: boolean);
  107792. /**
  107793. * Are reflection textures enabled in the application.
  107794. */
  107795. static get ReflectionTextureEnabled(): boolean;
  107796. static set ReflectionTextureEnabled(value: boolean);
  107797. /**
  107798. * Are emissive textures enabled in the application.
  107799. */
  107800. static get EmissiveTextureEnabled(): boolean;
  107801. static set EmissiveTextureEnabled(value: boolean);
  107802. /**
  107803. * Are specular textures enabled in the application.
  107804. */
  107805. static get SpecularTextureEnabled(): boolean;
  107806. static set SpecularTextureEnabled(value: boolean);
  107807. /**
  107808. * Are bump textures enabled in the application.
  107809. */
  107810. static get BumpTextureEnabled(): boolean;
  107811. static set BumpTextureEnabled(value: boolean);
  107812. /**
  107813. * Are lightmap textures enabled in the application.
  107814. */
  107815. static get LightmapTextureEnabled(): boolean;
  107816. static set LightmapTextureEnabled(value: boolean);
  107817. /**
  107818. * Are refraction textures enabled in the application.
  107819. */
  107820. static get RefractionTextureEnabled(): boolean;
  107821. static set RefractionTextureEnabled(value: boolean);
  107822. /**
  107823. * Are color grading textures enabled in the application.
  107824. */
  107825. static get ColorGradingTextureEnabled(): boolean;
  107826. static set ColorGradingTextureEnabled(value: boolean);
  107827. /**
  107828. * Are fresnels enabled in the application.
  107829. */
  107830. static get FresnelEnabled(): boolean;
  107831. static set FresnelEnabled(value: boolean);
  107832. }
  107833. }
  107834. declare module BABYLON {
  107835. /**
  107836. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  107837. *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.
  107838. * The SPS is also a particle system. It provides some methods to manage the particles.
  107839. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  107840. *
  107841. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  107842. */
  107843. export class SolidParticleSystem implements IDisposable {
  107844. /**
  107845. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  107846. * Example : var p = SPS.particles[i];
  107847. */
  107848. particles: SolidParticle[];
  107849. /**
  107850. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  107851. */
  107852. nbParticles: number;
  107853. /**
  107854. * If the particles must ever face the camera (default false). Useful for planar particles.
  107855. */
  107856. billboard: boolean;
  107857. /**
  107858. * Recompute normals when adding a shape
  107859. */
  107860. recomputeNormals: boolean;
  107861. /**
  107862. * This a counter ofr your own usage. It's not set by any SPS functions.
  107863. */
  107864. counter: number;
  107865. /**
  107866. * The SPS name. This name is also given to the underlying mesh.
  107867. */
  107868. name: string;
  107869. /**
  107870. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  107871. */
  107872. mesh: Mesh;
  107873. /**
  107874. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  107875. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  107876. */
  107877. vars: any;
  107878. /**
  107879. * This array is populated when the SPS is set as 'pickable'.
  107880. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  107881. * Each element of this array is an object `{idx: int, faceId: int}`.
  107882. * `idx` is the picked particle index in the `SPS.particles` array
  107883. * `faceId` is the picked face index counted within this particle.
  107884. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  107885. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  107886. * Use the method SPS.pickedParticle(pickingInfo) instead.
  107887. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  107888. */
  107889. pickedParticles: {
  107890. idx: number;
  107891. faceId: number;
  107892. }[];
  107893. /**
  107894. * This array is populated when the SPS is set as 'pickable'
  107895. * Each key of this array is a submesh index.
  107896. * Each element of this array is a second array defined like this :
  107897. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  107898. * Each element of this second array is an object `{idx: int, faceId: int}`.
  107899. * `idx` is the picked particle index in the `SPS.particles` array
  107900. * `faceId` is the picked face index counted within this particle.
  107901. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  107902. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  107903. */
  107904. pickedBySubMesh: {
  107905. idx: number;
  107906. faceId: number;
  107907. }[][];
  107908. /**
  107909. * This array is populated when `enableDepthSort` is set to true.
  107910. * Each element of this array is an instance of the class DepthSortedParticle.
  107911. */
  107912. depthSortedParticles: DepthSortedParticle[];
  107913. /**
  107914. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  107915. * @hidden
  107916. */
  107917. _bSphereOnly: boolean;
  107918. /**
  107919. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  107920. * @hidden
  107921. */
  107922. _bSphereRadiusFactor: number;
  107923. private _scene;
  107924. private _positions;
  107925. private _indices;
  107926. private _normals;
  107927. private _colors;
  107928. private _uvs;
  107929. private _indices32;
  107930. private _positions32;
  107931. private _normals32;
  107932. private _fixedNormal32;
  107933. private _colors32;
  107934. private _uvs32;
  107935. private _index;
  107936. private _updatable;
  107937. private _pickable;
  107938. private _isVisibilityBoxLocked;
  107939. private _alwaysVisible;
  107940. private _depthSort;
  107941. private _expandable;
  107942. private _shapeCounter;
  107943. private _copy;
  107944. private _color;
  107945. private _computeParticleColor;
  107946. private _computeParticleTexture;
  107947. private _computeParticleRotation;
  107948. private _computeParticleVertex;
  107949. private _computeBoundingBox;
  107950. private _depthSortParticles;
  107951. private _camera;
  107952. private _mustUnrotateFixedNormals;
  107953. private _particlesIntersect;
  107954. private _needs32Bits;
  107955. private _isNotBuilt;
  107956. private _lastParticleId;
  107957. private _idxOfId;
  107958. private _multimaterialEnabled;
  107959. private _useModelMaterial;
  107960. private _indicesByMaterial;
  107961. private _materialIndexes;
  107962. private _depthSortFunction;
  107963. private _materialSortFunction;
  107964. private _materials;
  107965. private _multimaterial;
  107966. private _materialIndexesById;
  107967. private _defaultMaterial;
  107968. private _autoUpdateSubMeshes;
  107969. private _tmpVertex;
  107970. /**
  107971. * Creates a SPS (Solid Particle System) object.
  107972. * @param name (String) is the SPS name, this will be the underlying mesh name.
  107973. * @param scene (Scene) is the scene in which the SPS is added.
  107974. * @param options defines the options of the sps e.g.
  107975. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  107976. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  107977. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  107978. * * 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.
  107979. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  107980. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  107981. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  107982. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  107983. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  107984. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  107985. */
  107986. constructor(name: string, scene: Scene, options?: {
  107987. updatable?: boolean;
  107988. isPickable?: boolean;
  107989. enableDepthSort?: boolean;
  107990. particleIntersection?: boolean;
  107991. boundingSphereOnly?: boolean;
  107992. bSphereRadiusFactor?: number;
  107993. expandable?: boolean;
  107994. useModelMaterial?: boolean;
  107995. enableMultiMaterial?: boolean;
  107996. });
  107997. /**
  107998. * Builds the SPS underlying mesh. Returns a standard Mesh.
  107999. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  108000. * @returns the created mesh
  108001. */
  108002. buildMesh(): Mesh;
  108003. /**
  108004. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  108005. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  108006. * Thus the particles generated from `digest()` have their property `position` set yet.
  108007. * @param mesh ( Mesh ) is the mesh to be digested
  108008. * @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
  108009. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  108010. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  108011. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  108012. * @returns the current SPS
  108013. */
  108014. digest(mesh: Mesh, options?: {
  108015. facetNb?: number;
  108016. number?: number;
  108017. delta?: number;
  108018. storage?: [];
  108019. }): SolidParticleSystem;
  108020. /**
  108021. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  108022. * @hidden
  108023. */
  108024. private _unrotateFixedNormals;
  108025. /**
  108026. * Resets the temporary working copy particle
  108027. * @hidden
  108028. */
  108029. private _resetCopy;
  108030. /**
  108031. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  108032. * @param p the current index in the positions array to be updated
  108033. * @param ind the current index in the indices array
  108034. * @param shape a Vector3 array, the shape geometry
  108035. * @param positions the positions array to be updated
  108036. * @param meshInd the shape indices array
  108037. * @param indices the indices array to be updated
  108038. * @param meshUV the shape uv array
  108039. * @param uvs the uv array to be updated
  108040. * @param meshCol the shape color array
  108041. * @param colors the color array to be updated
  108042. * @param meshNor the shape normals array
  108043. * @param normals the normals array to be updated
  108044. * @param idx the particle index
  108045. * @param idxInShape the particle index in its shape
  108046. * @param options the addShape() method passed options
  108047. * @model the particle model
  108048. * @hidden
  108049. */
  108050. private _meshBuilder;
  108051. /**
  108052. * Returns a shape Vector3 array from positions float array
  108053. * @param positions float array
  108054. * @returns a vector3 array
  108055. * @hidden
  108056. */
  108057. private _posToShape;
  108058. /**
  108059. * Returns a shapeUV array from a float uvs (array deep copy)
  108060. * @param uvs as a float array
  108061. * @returns a shapeUV array
  108062. * @hidden
  108063. */
  108064. private _uvsToShapeUV;
  108065. /**
  108066. * Adds a new particle object in the particles array
  108067. * @param idx particle index in particles array
  108068. * @param id particle id
  108069. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  108070. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  108071. * @param model particle ModelShape object
  108072. * @param shapeId model shape identifier
  108073. * @param idxInShape index of the particle in the current model
  108074. * @param bInfo model bounding info object
  108075. * @param storage target storage array, if any
  108076. * @hidden
  108077. */
  108078. private _addParticle;
  108079. /**
  108080. * Adds some particles to the SPS from the model shape. Returns the shape id.
  108081. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  108082. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  108083. * @param nb (positive integer) the number of particles to be created from this model
  108084. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  108085. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  108086. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  108087. * @returns the number of shapes in the system
  108088. */
  108089. addShape(mesh: Mesh, nb: number, options?: {
  108090. positionFunction?: any;
  108091. vertexFunction?: any;
  108092. storage?: [];
  108093. }): number;
  108094. /**
  108095. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  108096. * @hidden
  108097. */
  108098. private _rebuildParticle;
  108099. /**
  108100. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  108101. * @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.
  108102. * @returns the SPS.
  108103. */
  108104. rebuildMesh(reset?: boolean): SolidParticleSystem;
  108105. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  108106. * Returns an array with the removed particles.
  108107. * 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.
  108108. * The SPS can't be empty so at least one particle needs to remain in place.
  108109. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  108110. * @param start index of the first particle to remove
  108111. * @param end index of the last particle to remove (included)
  108112. * @returns an array populated with the removed particles
  108113. */
  108114. removeParticles(start: number, end: number): SolidParticle[];
  108115. /**
  108116. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  108117. * @param solidParticleArray an array populated with Solid Particles objects
  108118. * @returns the SPS
  108119. */
  108120. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  108121. /**
  108122. * Creates a new particle and modifies the SPS mesh geometry :
  108123. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  108124. * - calls _addParticle() to populate the particle array
  108125. * factorized code from addShape() and insertParticlesFromArray()
  108126. * @param idx particle index in the particles array
  108127. * @param i particle index in its shape
  108128. * @param modelShape particle ModelShape object
  108129. * @param shape shape vertex array
  108130. * @param meshInd shape indices array
  108131. * @param meshUV shape uv array
  108132. * @param meshCol shape color array
  108133. * @param meshNor shape normals array
  108134. * @param bbInfo shape bounding info
  108135. * @param storage target particle storage
  108136. * @options addShape() passed options
  108137. * @hidden
  108138. */
  108139. private _insertNewParticle;
  108140. /**
  108141. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  108142. * This method calls `updateParticle()` for each particle of the SPS.
  108143. * For an animated SPS, it is usually called within the render loop.
  108144. * 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.
  108145. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  108146. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  108147. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  108148. * @returns the SPS.
  108149. */
  108150. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  108151. /**
  108152. * Disposes the SPS.
  108153. */
  108154. dispose(): void;
  108155. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  108156. * idx is the particle index in the SPS
  108157. * faceId is the picked face index counted within this particle.
  108158. * Returns null if the pickInfo can't identify a picked particle.
  108159. * @param pickingInfo (PickingInfo object)
  108160. * @returns {idx: number, faceId: number} or null
  108161. */
  108162. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  108163. idx: number;
  108164. faceId: number;
  108165. }>;
  108166. /**
  108167. * Returns a SolidParticle object from its identifier : particle.id
  108168. * @param id (integer) the particle Id
  108169. * @returns the searched particle or null if not found in the SPS.
  108170. */
  108171. getParticleById(id: number): Nullable<SolidParticle>;
  108172. /**
  108173. * Returns a new array populated with the particles having the passed shapeId.
  108174. * @param shapeId (integer) the shape identifier
  108175. * @returns a new solid particle array
  108176. */
  108177. getParticlesByShapeId(shapeId: number): SolidParticle[];
  108178. /**
  108179. * Populates the passed array "ref" with the particles having the passed shapeId.
  108180. * @param shapeId the shape identifier
  108181. * @returns the SPS
  108182. * @param ref
  108183. */
  108184. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  108185. /**
  108186. * Computes the required SubMeshes according the materials assigned to the particles.
  108187. * @returns the solid particle system.
  108188. * Does nothing if called before the SPS mesh is built.
  108189. */
  108190. computeSubMeshes(): SolidParticleSystem;
  108191. /**
  108192. * Sorts the solid particles by material when MultiMaterial is enabled.
  108193. * Updates the indices32 array.
  108194. * Updates the indicesByMaterial array.
  108195. * Updates the mesh indices array.
  108196. * @returns the SPS
  108197. * @hidden
  108198. */
  108199. private _sortParticlesByMaterial;
  108200. /**
  108201. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  108202. * @hidden
  108203. */
  108204. private _setMaterialIndexesById;
  108205. /**
  108206. * Returns an array with unique values of Materials from the passed array
  108207. * @param array the material array to be checked and filtered
  108208. * @hidden
  108209. */
  108210. private _filterUniqueMaterialId;
  108211. /**
  108212. * Sets a new Standard Material as _defaultMaterial if not already set.
  108213. * @hidden
  108214. */
  108215. private _setDefaultMaterial;
  108216. /**
  108217. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  108218. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108219. * @returns the SPS.
  108220. */
  108221. refreshVisibleSize(): SolidParticleSystem;
  108222. /**
  108223. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  108224. * @param size the size (float) of the visibility box
  108225. * note : this doesn't lock the SPS mesh bounding box.
  108226. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108227. */
  108228. setVisibilityBox(size: number): void;
  108229. /**
  108230. * Gets whether the SPS as always visible or not
  108231. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108232. */
  108233. get isAlwaysVisible(): boolean;
  108234. /**
  108235. * Sets the SPS as always visible or not
  108236. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108237. */
  108238. set isAlwaysVisible(val: boolean);
  108239. /**
  108240. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108241. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108242. */
  108243. set isVisibilityBoxLocked(val: boolean);
  108244. /**
  108245. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108246. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108247. */
  108248. get isVisibilityBoxLocked(): boolean;
  108249. /**
  108250. * Tells to `setParticles()` to compute the particle rotations or not.
  108251. * Default value : true. The SPS is faster when it's set to false.
  108252. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108253. */
  108254. set computeParticleRotation(val: boolean);
  108255. /**
  108256. * Tells to `setParticles()` to compute the particle colors or not.
  108257. * Default value : true. The SPS is faster when it's set to false.
  108258. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108259. */
  108260. set computeParticleColor(val: boolean);
  108261. set computeParticleTexture(val: boolean);
  108262. /**
  108263. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  108264. * Default value : false. The SPS is faster when it's set to false.
  108265. * Note : the particle custom vertex positions aren't stored values.
  108266. */
  108267. set computeParticleVertex(val: boolean);
  108268. /**
  108269. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  108270. */
  108271. set computeBoundingBox(val: boolean);
  108272. /**
  108273. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  108274. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108275. * Default : `true`
  108276. */
  108277. set depthSortParticles(val: boolean);
  108278. /**
  108279. * Gets if `setParticles()` computes the particle rotations or not.
  108280. * Default value : true. The SPS is faster when it's set to false.
  108281. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108282. */
  108283. get computeParticleRotation(): boolean;
  108284. /**
  108285. * Gets if `setParticles()` computes the particle colors or not.
  108286. * Default value : true. The SPS is faster when it's set to false.
  108287. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108288. */
  108289. get computeParticleColor(): boolean;
  108290. /**
  108291. * Gets if `setParticles()` computes the particle textures or not.
  108292. * Default value : true. The SPS is faster when it's set to false.
  108293. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  108294. */
  108295. get computeParticleTexture(): boolean;
  108296. /**
  108297. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  108298. * Default value : false. The SPS is faster when it's set to false.
  108299. * Note : the particle custom vertex positions aren't stored values.
  108300. */
  108301. get computeParticleVertex(): boolean;
  108302. /**
  108303. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  108304. */
  108305. get computeBoundingBox(): boolean;
  108306. /**
  108307. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  108308. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108309. * Default : `true`
  108310. */
  108311. get depthSortParticles(): boolean;
  108312. /**
  108313. * Gets if the SPS is created as expandable at construction time.
  108314. * Default : `false`
  108315. */
  108316. get expandable(): boolean;
  108317. /**
  108318. * Gets if the SPS supports the Multi Materials
  108319. */
  108320. get multimaterialEnabled(): boolean;
  108321. /**
  108322. * Gets if the SPS uses the model materials for its own multimaterial.
  108323. */
  108324. get useModelMaterial(): boolean;
  108325. /**
  108326. * The SPS used material array.
  108327. */
  108328. get materials(): Material[];
  108329. /**
  108330. * Sets the SPS MultiMaterial from the passed materials.
  108331. * Note : the passed array is internally copied and not used then by reference.
  108332. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  108333. */
  108334. setMultiMaterial(materials: Material[]): void;
  108335. /**
  108336. * The SPS computed multimaterial object
  108337. */
  108338. get multimaterial(): MultiMaterial;
  108339. set multimaterial(mm: MultiMaterial);
  108340. /**
  108341. * If the subMeshes must be updated on the next call to setParticles()
  108342. */
  108343. get autoUpdateSubMeshes(): boolean;
  108344. set autoUpdateSubMeshes(val: boolean);
  108345. /**
  108346. * This function does nothing. It may be overwritten to set all the particle first values.
  108347. * The SPS doesn't call this function, you may have to call it by your own.
  108348. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108349. */
  108350. initParticles(): void;
  108351. /**
  108352. * This function does nothing. It may be overwritten to recycle a particle.
  108353. * The SPS doesn't call this function, you may have to call it by your own.
  108354. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108355. * @param particle The particle to recycle
  108356. * @returns the recycled particle
  108357. */
  108358. recycleParticle(particle: SolidParticle): SolidParticle;
  108359. /**
  108360. * Updates a particle : this function should be overwritten by the user.
  108361. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  108362. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108363. * @example : just set a particle position or velocity and recycle conditions
  108364. * @param particle The particle to update
  108365. * @returns the updated particle
  108366. */
  108367. updateParticle(particle: SolidParticle): SolidParticle;
  108368. /**
  108369. * Updates a vertex of a particle : it can be overwritten by the user.
  108370. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  108371. * @param particle the current particle
  108372. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  108373. * @param pt the index of the current vertex in the particle shape
  108374. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  108375. * @example : just set a vertex particle position or color
  108376. * @returns the sps
  108377. */
  108378. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  108379. /**
  108380. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  108381. * This does nothing and may be overwritten by the user.
  108382. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108383. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108384. * @param update the boolean update value actually passed to setParticles()
  108385. */
  108386. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  108387. /**
  108388. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  108389. * This will be passed three parameters.
  108390. * This does nothing and may be overwritten by the user.
  108391. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108392. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108393. * @param update the boolean update value actually passed to setParticles()
  108394. */
  108395. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  108396. }
  108397. }
  108398. declare module BABYLON {
  108399. /**
  108400. * Represents one particle of a solid particle system.
  108401. */
  108402. export class SolidParticle {
  108403. /**
  108404. * particle global index
  108405. */
  108406. idx: number;
  108407. /**
  108408. * particle identifier
  108409. */
  108410. id: number;
  108411. /**
  108412. * The color of the particle
  108413. */
  108414. color: Nullable<Color4>;
  108415. /**
  108416. * The world space position of the particle.
  108417. */
  108418. position: Vector3;
  108419. /**
  108420. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  108421. */
  108422. rotation: Vector3;
  108423. /**
  108424. * The world space rotation quaternion of the particle.
  108425. */
  108426. rotationQuaternion: Nullable<Quaternion>;
  108427. /**
  108428. * The scaling of the particle.
  108429. */
  108430. scaling: Vector3;
  108431. /**
  108432. * The uvs of the particle.
  108433. */
  108434. uvs: Vector4;
  108435. /**
  108436. * The current speed of the particle.
  108437. */
  108438. velocity: Vector3;
  108439. /**
  108440. * The pivot point in the particle local space.
  108441. */
  108442. pivot: Vector3;
  108443. /**
  108444. * Must the particle be translated from its pivot point in its local space ?
  108445. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  108446. * Default : false
  108447. */
  108448. translateFromPivot: boolean;
  108449. /**
  108450. * Is the particle active or not ?
  108451. */
  108452. alive: boolean;
  108453. /**
  108454. * Is the particle visible or not ?
  108455. */
  108456. isVisible: boolean;
  108457. /**
  108458. * Index of this particle in the global "positions" array (Internal use)
  108459. * @hidden
  108460. */
  108461. _pos: number;
  108462. /**
  108463. * @hidden Index of this particle in the global "indices" array (Internal use)
  108464. */
  108465. _ind: number;
  108466. /**
  108467. * @hidden ModelShape of this particle (Internal use)
  108468. */
  108469. _model: ModelShape;
  108470. /**
  108471. * ModelShape id of this particle
  108472. */
  108473. shapeId: number;
  108474. /**
  108475. * Index of the particle in its shape id
  108476. */
  108477. idxInShape: number;
  108478. /**
  108479. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  108480. */
  108481. _modelBoundingInfo: BoundingInfo;
  108482. /**
  108483. * @hidden Particle BoundingInfo object (Internal use)
  108484. */
  108485. _boundingInfo: BoundingInfo;
  108486. /**
  108487. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  108488. */
  108489. _sps: SolidParticleSystem;
  108490. /**
  108491. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  108492. */
  108493. _stillInvisible: boolean;
  108494. /**
  108495. * @hidden Last computed particle rotation matrix
  108496. */
  108497. _rotationMatrix: number[];
  108498. /**
  108499. * Parent particle Id, if any.
  108500. * Default null.
  108501. */
  108502. parentId: Nullable<number>;
  108503. /**
  108504. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  108505. */
  108506. materialIndex: Nullable<number>;
  108507. /**
  108508. * Custom object or properties.
  108509. */
  108510. props: Nullable<any>;
  108511. /**
  108512. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  108513. * The possible values are :
  108514. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  108515. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108516. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  108517. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  108518. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108519. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  108520. * */
  108521. cullingStrategy: number;
  108522. /**
  108523. * @hidden Internal global position in the SPS.
  108524. */
  108525. _globalPosition: Vector3;
  108526. /**
  108527. * Creates a Solid Particle object.
  108528. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  108529. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  108530. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  108531. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  108532. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  108533. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  108534. * @param shapeId (integer) is the model shape identifier in the SPS.
  108535. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  108536. * @param sps defines the sps it is associated to
  108537. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  108538. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  108539. */
  108540. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  108541. /**
  108542. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  108543. * @param target the particle target
  108544. * @returns the current particle
  108545. */
  108546. copyToRef(target: SolidParticle): SolidParticle;
  108547. /**
  108548. * Legacy support, changed scale to scaling
  108549. */
  108550. get scale(): Vector3;
  108551. /**
  108552. * Legacy support, changed scale to scaling
  108553. */
  108554. set scale(scale: Vector3);
  108555. /**
  108556. * Legacy support, changed quaternion to rotationQuaternion
  108557. */
  108558. get quaternion(): Nullable<Quaternion>;
  108559. /**
  108560. * Legacy support, changed quaternion to rotationQuaternion
  108561. */
  108562. set quaternion(q: Nullable<Quaternion>);
  108563. /**
  108564. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  108565. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  108566. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  108567. * @returns true if it intersects
  108568. */
  108569. intersectsMesh(target: Mesh | SolidParticle): boolean;
  108570. /**
  108571. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  108572. * A particle is in the frustum if its bounding box intersects the frustum
  108573. * @param frustumPlanes defines the frustum to test
  108574. * @returns true if the particle is in the frustum planes
  108575. */
  108576. isInFrustum(frustumPlanes: Plane[]): boolean;
  108577. /**
  108578. * get the rotation matrix of the particle
  108579. * @hidden
  108580. */
  108581. getRotationMatrix(m: Matrix): void;
  108582. }
  108583. /**
  108584. * Represents the shape of the model used by one particle of a solid particle system.
  108585. * SPS internal tool, don't use it manually.
  108586. */
  108587. export class ModelShape {
  108588. /**
  108589. * The shape id
  108590. * @hidden
  108591. */
  108592. shapeID: number;
  108593. /**
  108594. * flat array of model positions (internal use)
  108595. * @hidden
  108596. */
  108597. _shape: Vector3[];
  108598. /**
  108599. * flat array of model UVs (internal use)
  108600. * @hidden
  108601. */
  108602. _shapeUV: number[];
  108603. /**
  108604. * color array of the model
  108605. * @hidden
  108606. */
  108607. _shapeColors: number[];
  108608. /**
  108609. * indices array of the model
  108610. * @hidden
  108611. */
  108612. _indices: number[];
  108613. /**
  108614. * normals array of the model
  108615. * @hidden
  108616. */
  108617. _normals: number[];
  108618. /**
  108619. * length of the shape in the model indices array (internal use)
  108620. * @hidden
  108621. */
  108622. _indicesLength: number;
  108623. /**
  108624. * Custom position function (internal use)
  108625. * @hidden
  108626. */
  108627. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  108628. /**
  108629. * Custom vertex function (internal use)
  108630. * @hidden
  108631. */
  108632. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  108633. /**
  108634. * Model material (internal use)
  108635. * @hidden
  108636. */
  108637. _material: Nullable<Material>;
  108638. /**
  108639. * 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.
  108640. * SPS internal tool, don't use it manually.
  108641. * @hidden
  108642. */
  108643. 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>);
  108644. }
  108645. /**
  108646. * Represents a Depth Sorted Particle in the solid particle system.
  108647. * @hidden
  108648. */
  108649. export class DepthSortedParticle {
  108650. /**
  108651. * Particle index
  108652. */
  108653. idx: number;
  108654. /**
  108655. * Index of the particle in the "indices" array
  108656. */
  108657. ind: number;
  108658. /**
  108659. * Length of the particle shape in the "indices" array
  108660. */
  108661. indicesLength: number;
  108662. /**
  108663. * Squared distance from the particle to the camera
  108664. */
  108665. sqDistance: number;
  108666. /**
  108667. * Material index when used with MultiMaterials
  108668. */
  108669. materialIndex: number;
  108670. /**
  108671. * Creates a new sorted particle
  108672. * @param materialIndex
  108673. */
  108674. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  108675. }
  108676. /**
  108677. * Represents a solid particle vertex
  108678. */
  108679. export class SolidParticleVertex {
  108680. /**
  108681. * Vertex position
  108682. */
  108683. position: Vector3;
  108684. /**
  108685. * Vertex color
  108686. */
  108687. color: Color4;
  108688. /**
  108689. * Vertex UV
  108690. */
  108691. uv: Vector2;
  108692. /**
  108693. * Creates a new solid particle vertex
  108694. */
  108695. constructor();
  108696. /** Vertex x coordinate */
  108697. get x(): number;
  108698. set x(val: number);
  108699. /** Vertex y coordinate */
  108700. get y(): number;
  108701. set y(val: number);
  108702. /** Vertex z coordinate */
  108703. get z(): number;
  108704. set z(val: number);
  108705. }
  108706. }
  108707. declare module BABYLON {
  108708. /**
  108709. * @hidden
  108710. */
  108711. export class _MeshCollisionData {
  108712. _checkCollisions: boolean;
  108713. _collisionMask: number;
  108714. _collisionGroup: number;
  108715. _surroundingMeshes: Nullable<AbstractMesh[]>;
  108716. _collider: Nullable<Collider>;
  108717. _oldPositionForCollisions: Vector3;
  108718. _diffPositionForCollisions: Vector3;
  108719. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  108720. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  108721. }
  108722. }
  108723. declare module BABYLON {
  108724. /** @hidden */
  108725. class _FacetDataStorage {
  108726. facetPositions: Vector3[];
  108727. facetNormals: Vector3[];
  108728. facetPartitioning: number[][];
  108729. facetNb: number;
  108730. partitioningSubdivisions: number;
  108731. partitioningBBoxRatio: number;
  108732. facetDataEnabled: boolean;
  108733. facetParameters: any;
  108734. bbSize: Vector3;
  108735. subDiv: {
  108736. max: number;
  108737. X: number;
  108738. Y: number;
  108739. Z: number;
  108740. };
  108741. facetDepthSort: boolean;
  108742. facetDepthSortEnabled: boolean;
  108743. depthSortedIndices: IndicesArray;
  108744. depthSortedFacets: {
  108745. ind: number;
  108746. sqDistance: number;
  108747. }[];
  108748. facetDepthSortFunction: (f1: {
  108749. ind: number;
  108750. sqDistance: number;
  108751. }, f2: {
  108752. ind: number;
  108753. sqDistance: number;
  108754. }) => number;
  108755. facetDepthSortFrom: Vector3;
  108756. facetDepthSortOrigin: Vector3;
  108757. invertedMatrix: Matrix;
  108758. }
  108759. /**
  108760. * @hidden
  108761. **/
  108762. class _InternalAbstractMeshDataInfo {
  108763. _hasVertexAlpha: boolean;
  108764. _useVertexColors: boolean;
  108765. _numBoneInfluencers: number;
  108766. _applyFog: boolean;
  108767. _receiveShadows: boolean;
  108768. _facetData: _FacetDataStorage;
  108769. _visibility: number;
  108770. _skeleton: Nullable<Skeleton>;
  108771. _layerMask: number;
  108772. _computeBonesUsingShaders: boolean;
  108773. _isActive: boolean;
  108774. _onlyForInstances: boolean;
  108775. _isActiveIntermediate: boolean;
  108776. _onlyForInstancesIntermediate: boolean;
  108777. _actAsRegularMesh: boolean;
  108778. }
  108779. /**
  108780. * Class used to store all common mesh properties
  108781. */
  108782. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  108783. /** No occlusion */
  108784. static OCCLUSION_TYPE_NONE: number;
  108785. /** Occlusion set to optimisitic */
  108786. static OCCLUSION_TYPE_OPTIMISTIC: number;
  108787. /** Occlusion set to strict */
  108788. static OCCLUSION_TYPE_STRICT: number;
  108789. /** Use an accurante occlusion algorithm */
  108790. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  108791. /** Use a conservative occlusion algorithm */
  108792. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  108793. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  108794. * Test order :
  108795. * Is the bounding sphere outside the frustum ?
  108796. * If not, are the bounding box vertices outside the frustum ?
  108797. * It not, then the cullable object is in the frustum.
  108798. */
  108799. static readonly CULLINGSTRATEGY_STANDARD: number;
  108800. /** Culling strategy : Bounding Sphere Only.
  108801. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  108802. * It's also less accurate than the standard because some not visible objects can still be selected.
  108803. * Test : is the bounding sphere outside the frustum ?
  108804. * If not, then the cullable object is in the frustum.
  108805. */
  108806. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  108807. /** Culling strategy : Optimistic Inclusion.
  108808. * This in an inclusion test first, then the standard exclusion test.
  108809. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  108810. * 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.
  108811. * Anyway, it's as accurate as the standard strategy.
  108812. * Test :
  108813. * Is the cullable object bounding sphere center in the frustum ?
  108814. * If not, apply the default culling strategy.
  108815. */
  108816. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  108817. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  108818. * This in an inclusion test first, then the bounding sphere only exclusion test.
  108819. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  108820. * 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.
  108821. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  108822. * Test :
  108823. * Is the cullable object bounding sphere center in the frustum ?
  108824. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  108825. */
  108826. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  108827. /**
  108828. * No billboard
  108829. */
  108830. static get BILLBOARDMODE_NONE(): number;
  108831. /** Billboard on X axis */
  108832. static get BILLBOARDMODE_X(): number;
  108833. /** Billboard on Y axis */
  108834. static get BILLBOARDMODE_Y(): number;
  108835. /** Billboard on Z axis */
  108836. static get BILLBOARDMODE_Z(): number;
  108837. /** Billboard on all axes */
  108838. static get BILLBOARDMODE_ALL(): number;
  108839. /** Billboard on using position instead of orientation */
  108840. static get BILLBOARDMODE_USE_POSITION(): number;
  108841. /** @hidden */
  108842. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  108843. /**
  108844. * The culling strategy to use to check whether the mesh must be rendered or not.
  108845. * This value can be changed at any time and will be used on the next render mesh selection.
  108846. * The possible values are :
  108847. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  108848. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108849. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  108850. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  108851. * Please read each static variable documentation to get details about the culling process.
  108852. * */
  108853. cullingStrategy: number;
  108854. /**
  108855. * Gets the number of facets in the mesh
  108856. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  108857. */
  108858. get facetNb(): number;
  108859. /**
  108860. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  108861. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  108862. */
  108863. get partitioningSubdivisions(): number;
  108864. set partitioningSubdivisions(nb: number);
  108865. /**
  108866. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  108867. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  108868. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  108869. */
  108870. get partitioningBBoxRatio(): number;
  108871. set partitioningBBoxRatio(ratio: number);
  108872. /**
  108873. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  108874. * Works only for updatable meshes.
  108875. * Doesn't work with multi-materials
  108876. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  108877. */
  108878. get mustDepthSortFacets(): boolean;
  108879. set mustDepthSortFacets(sort: boolean);
  108880. /**
  108881. * The location (Vector3) where the facet depth sort must be computed from.
  108882. * By default, the active camera position.
  108883. * Used only when facet depth sort is enabled
  108884. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  108885. */
  108886. get facetDepthSortFrom(): Vector3;
  108887. set facetDepthSortFrom(location: Vector3);
  108888. /**
  108889. * gets a boolean indicating if facetData is enabled
  108890. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  108891. */
  108892. get isFacetDataEnabled(): boolean;
  108893. /** @hidden */
  108894. _updateNonUniformScalingState(value: boolean): boolean;
  108895. /**
  108896. * An event triggered when this mesh collides with another one
  108897. */
  108898. onCollideObservable: Observable<AbstractMesh>;
  108899. /** Set a function to call when this mesh collides with another one */
  108900. set onCollide(callback: () => void);
  108901. /**
  108902. * An event triggered when the collision's position changes
  108903. */
  108904. onCollisionPositionChangeObservable: Observable<Vector3>;
  108905. /** Set a function to call when the collision's position changes */
  108906. set onCollisionPositionChange(callback: () => void);
  108907. /**
  108908. * An event triggered when material is changed
  108909. */
  108910. onMaterialChangedObservable: Observable<AbstractMesh>;
  108911. /**
  108912. * Gets or sets the orientation for POV movement & rotation
  108913. */
  108914. definedFacingForward: boolean;
  108915. /** @hidden */
  108916. _occlusionQuery: Nullable<WebGLQuery>;
  108917. /** @hidden */
  108918. _renderingGroup: Nullable<RenderingGroup>;
  108919. /**
  108920. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  108921. */
  108922. get visibility(): number;
  108923. /**
  108924. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  108925. */
  108926. set visibility(value: number);
  108927. /** Gets or sets the alpha index used to sort transparent meshes
  108928. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  108929. */
  108930. alphaIndex: number;
  108931. /**
  108932. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  108933. */
  108934. isVisible: boolean;
  108935. /**
  108936. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  108937. */
  108938. isPickable: boolean;
  108939. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  108940. showSubMeshesBoundingBox: boolean;
  108941. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  108942. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  108943. */
  108944. isBlocker: boolean;
  108945. /**
  108946. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  108947. */
  108948. enablePointerMoveEvents: boolean;
  108949. /**
  108950. * Specifies the rendering group id for this mesh (0 by default)
  108951. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  108952. */
  108953. renderingGroupId: number;
  108954. private _material;
  108955. /** Gets or sets current material */
  108956. get material(): Nullable<Material>;
  108957. set material(value: Nullable<Material>);
  108958. /**
  108959. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  108960. * @see http://doc.babylonjs.com/babylon101/shadows
  108961. */
  108962. get receiveShadows(): boolean;
  108963. set receiveShadows(value: boolean);
  108964. /** Defines color to use when rendering outline */
  108965. outlineColor: Color3;
  108966. /** Define width to use when rendering outline */
  108967. outlineWidth: number;
  108968. /** Defines color to use when rendering overlay */
  108969. overlayColor: Color3;
  108970. /** Defines alpha to use when rendering overlay */
  108971. overlayAlpha: number;
  108972. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  108973. get hasVertexAlpha(): boolean;
  108974. set hasVertexAlpha(value: boolean);
  108975. /** 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) */
  108976. get useVertexColors(): boolean;
  108977. set useVertexColors(value: boolean);
  108978. /**
  108979. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  108980. */
  108981. get computeBonesUsingShaders(): boolean;
  108982. set computeBonesUsingShaders(value: boolean);
  108983. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  108984. get numBoneInfluencers(): number;
  108985. set numBoneInfluencers(value: number);
  108986. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  108987. get applyFog(): boolean;
  108988. set applyFog(value: boolean);
  108989. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  108990. useOctreeForRenderingSelection: boolean;
  108991. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  108992. useOctreeForPicking: boolean;
  108993. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  108994. useOctreeForCollisions: boolean;
  108995. /**
  108996. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  108997. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  108998. */
  108999. get layerMask(): number;
  109000. set layerMask(value: number);
  109001. /**
  109002. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  109003. */
  109004. alwaysSelectAsActiveMesh: boolean;
  109005. /**
  109006. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  109007. */
  109008. doNotSyncBoundingInfo: boolean;
  109009. /**
  109010. * Gets or sets the current action manager
  109011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  109012. */
  109013. actionManager: Nullable<AbstractActionManager>;
  109014. private _meshCollisionData;
  109015. /**
  109016. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  109017. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109018. */
  109019. ellipsoid: Vector3;
  109020. /**
  109021. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  109022. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109023. */
  109024. ellipsoidOffset: Vector3;
  109025. /**
  109026. * Gets or sets a collision mask used to mask collisions (default is -1).
  109027. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  109028. */
  109029. get collisionMask(): number;
  109030. set collisionMask(mask: number);
  109031. /**
  109032. * Gets or sets the current collision group mask (-1 by default).
  109033. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  109034. */
  109035. get collisionGroup(): number;
  109036. set collisionGroup(mask: number);
  109037. /**
  109038. * Gets or sets current surrounding meshes (null by default).
  109039. *
  109040. * By default collision detection is tested against every mesh in the scene.
  109041. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  109042. * meshes will be tested for the collision.
  109043. *
  109044. * Note: if set to an empty array no collision will happen when this mesh is moved.
  109045. */
  109046. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  109047. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  109048. /**
  109049. * Defines edge width used when edgesRenderer is enabled
  109050. * @see https://www.babylonjs-playground.com/#10OJSG#13
  109051. */
  109052. edgesWidth: number;
  109053. /**
  109054. * Defines edge color used when edgesRenderer is enabled
  109055. * @see https://www.babylonjs-playground.com/#10OJSG#13
  109056. */
  109057. edgesColor: Color4;
  109058. /** @hidden */
  109059. _edgesRenderer: Nullable<IEdgesRenderer>;
  109060. /** @hidden */
  109061. _masterMesh: Nullable<AbstractMesh>;
  109062. /** @hidden */
  109063. _boundingInfo: Nullable<BoundingInfo>;
  109064. /** @hidden */
  109065. _renderId: number;
  109066. /**
  109067. * Gets or sets the list of subMeshes
  109068. * @see http://doc.babylonjs.com/how_to/multi_materials
  109069. */
  109070. subMeshes: SubMesh[];
  109071. /** @hidden */
  109072. _intersectionsInProgress: AbstractMesh[];
  109073. /** @hidden */
  109074. _unIndexed: boolean;
  109075. /** @hidden */
  109076. _lightSources: Light[];
  109077. /** Gets the list of lights affecting that mesh */
  109078. get lightSources(): Light[];
  109079. /** @hidden */
  109080. get _positions(): Nullable<Vector3[]>;
  109081. /** @hidden */
  109082. _waitingData: {
  109083. lods: Nullable<any>;
  109084. actions: Nullable<any>;
  109085. freezeWorldMatrix: Nullable<boolean>;
  109086. };
  109087. /** @hidden */
  109088. _bonesTransformMatrices: Nullable<Float32Array>;
  109089. /** @hidden */
  109090. _transformMatrixTexture: Nullable<RawTexture>;
  109091. /**
  109092. * Gets or sets a skeleton to apply skining transformations
  109093. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  109094. */
  109095. set skeleton(value: Nullable<Skeleton>);
  109096. get skeleton(): Nullable<Skeleton>;
  109097. /**
  109098. * An event triggered when the mesh is rebuilt.
  109099. */
  109100. onRebuildObservable: Observable<AbstractMesh>;
  109101. /**
  109102. * Creates a new AbstractMesh
  109103. * @param name defines the name of the mesh
  109104. * @param scene defines the hosting scene
  109105. */
  109106. constructor(name: string, scene?: Nullable<Scene>);
  109107. /**
  109108. * Returns the string "AbstractMesh"
  109109. * @returns "AbstractMesh"
  109110. */
  109111. getClassName(): string;
  109112. /**
  109113. * Gets a string representation of the current mesh
  109114. * @param fullDetails defines a boolean indicating if full details must be included
  109115. * @returns a string representation of the current mesh
  109116. */
  109117. toString(fullDetails?: boolean): string;
  109118. /**
  109119. * @hidden
  109120. */
  109121. protected _getEffectiveParent(): Nullable<Node>;
  109122. /** @hidden */
  109123. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  109124. /** @hidden */
  109125. _rebuild(): void;
  109126. /** @hidden */
  109127. _resyncLightSources(): void;
  109128. /** @hidden */
  109129. _resyncLightSource(light: Light): void;
  109130. /** @hidden */
  109131. _unBindEffect(): void;
  109132. /** @hidden */
  109133. _removeLightSource(light: Light, dispose: boolean): void;
  109134. private _markSubMeshesAsDirty;
  109135. /** @hidden */
  109136. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  109137. /** @hidden */
  109138. _markSubMeshesAsAttributesDirty(): void;
  109139. /** @hidden */
  109140. _markSubMeshesAsMiscDirty(): void;
  109141. /**
  109142. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  109143. */
  109144. get scaling(): Vector3;
  109145. set scaling(newScaling: Vector3);
  109146. /**
  109147. * Returns true if the mesh is blocked. Implemented by child classes
  109148. */
  109149. get isBlocked(): boolean;
  109150. /**
  109151. * Returns the mesh itself by default. Implemented by child classes
  109152. * @param camera defines the camera to use to pick the right LOD level
  109153. * @returns the currentAbstractMesh
  109154. */
  109155. getLOD(camera: Camera): Nullable<AbstractMesh>;
  109156. /**
  109157. * Returns 0 by default. Implemented by child classes
  109158. * @returns an integer
  109159. */
  109160. getTotalVertices(): number;
  109161. /**
  109162. * Returns a positive integer : the total number of indices in this mesh geometry.
  109163. * @returns the numner of indices or zero if the mesh has no geometry.
  109164. */
  109165. getTotalIndices(): number;
  109166. /**
  109167. * Returns null by default. Implemented by child classes
  109168. * @returns null
  109169. */
  109170. getIndices(): Nullable<IndicesArray>;
  109171. /**
  109172. * Returns the array of the requested vertex data kind. Implemented by child classes
  109173. * @param kind defines the vertex data kind to use
  109174. * @returns null
  109175. */
  109176. getVerticesData(kind: string): Nullable<FloatArray>;
  109177. /**
  109178. * Sets the vertex data of the mesh geometry for the requested `kind`.
  109179. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  109180. * Note that a new underlying VertexBuffer object is created each call.
  109181. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  109182. * @param kind defines vertex data kind:
  109183. * * VertexBuffer.PositionKind
  109184. * * VertexBuffer.UVKind
  109185. * * VertexBuffer.UV2Kind
  109186. * * VertexBuffer.UV3Kind
  109187. * * VertexBuffer.UV4Kind
  109188. * * VertexBuffer.UV5Kind
  109189. * * VertexBuffer.UV6Kind
  109190. * * VertexBuffer.ColorKind
  109191. * * VertexBuffer.MatricesIndicesKind
  109192. * * VertexBuffer.MatricesIndicesExtraKind
  109193. * * VertexBuffer.MatricesWeightsKind
  109194. * * VertexBuffer.MatricesWeightsExtraKind
  109195. * @param data defines the data source
  109196. * @param updatable defines if the data must be flagged as updatable (or static)
  109197. * @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
  109198. * @returns the current mesh
  109199. */
  109200. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  109201. /**
  109202. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  109203. * If the mesh has no geometry, it is simply returned as it is.
  109204. * @param kind defines vertex data kind:
  109205. * * VertexBuffer.PositionKind
  109206. * * VertexBuffer.UVKind
  109207. * * VertexBuffer.UV2Kind
  109208. * * VertexBuffer.UV3Kind
  109209. * * VertexBuffer.UV4Kind
  109210. * * VertexBuffer.UV5Kind
  109211. * * VertexBuffer.UV6Kind
  109212. * * VertexBuffer.ColorKind
  109213. * * VertexBuffer.MatricesIndicesKind
  109214. * * VertexBuffer.MatricesIndicesExtraKind
  109215. * * VertexBuffer.MatricesWeightsKind
  109216. * * VertexBuffer.MatricesWeightsExtraKind
  109217. * @param data defines the data source
  109218. * @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
  109219. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  109220. * @returns the current mesh
  109221. */
  109222. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  109223. /**
  109224. * Sets the mesh indices,
  109225. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  109226. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  109227. * @param totalVertices Defines the total number of vertices
  109228. * @returns the current mesh
  109229. */
  109230. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  109231. /**
  109232. * Gets a boolean indicating if specific vertex data is present
  109233. * @param kind defines the vertex data kind to use
  109234. * @returns true is data kind is present
  109235. */
  109236. isVerticesDataPresent(kind: string): boolean;
  109237. /**
  109238. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  109239. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  109240. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  109241. * @returns a BoundingInfo
  109242. */
  109243. getBoundingInfo(): BoundingInfo;
  109244. /**
  109245. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  109246. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  109247. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  109248. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  109249. * @returns the current mesh
  109250. */
  109251. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  109252. /**
  109253. * Overwrite the current bounding info
  109254. * @param boundingInfo defines the new bounding info
  109255. * @returns the current mesh
  109256. */
  109257. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  109258. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  109259. get useBones(): boolean;
  109260. /** @hidden */
  109261. _preActivate(): void;
  109262. /** @hidden */
  109263. _preActivateForIntermediateRendering(renderId: number): void;
  109264. /** @hidden */
  109265. _activate(renderId: number, intermediateRendering: boolean): boolean;
  109266. /** @hidden */
  109267. _postActivate(): void;
  109268. /** @hidden */
  109269. _freeze(): void;
  109270. /** @hidden */
  109271. _unFreeze(): void;
  109272. /**
  109273. * Gets the current world matrix
  109274. * @returns a Matrix
  109275. */
  109276. getWorldMatrix(): Matrix;
  109277. /** @hidden */
  109278. _getWorldMatrixDeterminant(): number;
  109279. /**
  109280. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  109281. */
  109282. get isAnInstance(): boolean;
  109283. /**
  109284. * Gets a boolean indicating if this mesh has instances
  109285. */
  109286. get hasInstances(): boolean;
  109287. /**
  109288. * Gets a boolean indicating if this mesh has thin instances
  109289. */
  109290. get hasThinInstances(): boolean;
  109291. /**
  109292. * Perform relative position change from the point of view of behind the front of the mesh.
  109293. * This is performed taking into account the meshes current rotation, so you do not have to care.
  109294. * Supports definition of mesh facing forward or backward
  109295. * @param amountRight defines the distance on the right axis
  109296. * @param amountUp defines the distance on the up axis
  109297. * @param amountForward defines the distance on the forward axis
  109298. * @returns the current mesh
  109299. */
  109300. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  109301. /**
  109302. * Calculate relative position change from the point of view of behind the front of the mesh.
  109303. * This is performed taking into account the meshes current rotation, so you do not have to care.
  109304. * Supports definition of mesh facing forward or backward
  109305. * @param amountRight defines the distance on the right axis
  109306. * @param amountUp defines the distance on the up axis
  109307. * @param amountForward defines the distance on the forward axis
  109308. * @returns the new displacement vector
  109309. */
  109310. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  109311. /**
  109312. * Perform relative rotation change from the point of view of behind the front of the mesh.
  109313. * Supports definition of mesh facing forward or backward
  109314. * @param flipBack defines the flip
  109315. * @param twirlClockwise defines the twirl
  109316. * @param tiltRight defines the tilt
  109317. * @returns the current mesh
  109318. */
  109319. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  109320. /**
  109321. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  109322. * Supports definition of mesh facing forward or backward.
  109323. * @param flipBack defines the flip
  109324. * @param twirlClockwise defines the twirl
  109325. * @param tiltRight defines the tilt
  109326. * @returns the new rotation vector
  109327. */
  109328. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  109329. /**
  109330. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  109331. * This means the mesh underlying bounding box and sphere are recomputed.
  109332. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  109333. * @returns the current mesh
  109334. */
  109335. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  109336. /** @hidden */
  109337. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  109338. /** @hidden */
  109339. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  109340. /** @hidden */
  109341. _updateBoundingInfo(): AbstractMesh;
  109342. /** @hidden */
  109343. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  109344. /** @hidden */
  109345. protected _afterComputeWorldMatrix(): void;
  109346. /** @hidden */
  109347. get _effectiveMesh(): AbstractMesh;
  109348. /**
  109349. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  109350. * A mesh is in the frustum if its bounding box intersects the frustum
  109351. * @param frustumPlanes defines the frustum to test
  109352. * @returns true if the mesh is in the frustum planes
  109353. */
  109354. isInFrustum(frustumPlanes: Plane[]): boolean;
  109355. /**
  109356. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  109357. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  109358. * @param frustumPlanes defines the frustum to test
  109359. * @returns true if the mesh is completely in the frustum planes
  109360. */
  109361. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  109362. /**
  109363. * True if the mesh intersects another mesh or a SolidParticle object
  109364. * @param mesh defines a target mesh or SolidParticle to test
  109365. * @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)
  109366. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  109367. * @returns true if there is an intersection
  109368. */
  109369. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  109370. /**
  109371. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  109372. * @param point defines the point to test
  109373. * @returns true if there is an intersection
  109374. */
  109375. intersectsPoint(point: Vector3): boolean;
  109376. /**
  109377. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  109378. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109379. */
  109380. get checkCollisions(): boolean;
  109381. set checkCollisions(collisionEnabled: boolean);
  109382. /**
  109383. * Gets Collider object used to compute collisions (not physics)
  109384. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109385. */
  109386. get collider(): Nullable<Collider>;
  109387. /**
  109388. * Move the mesh using collision engine
  109389. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109390. * @param displacement defines the requested displacement vector
  109391. * @returns the current mesh
  109392. */
  109393. moveWithCollisions(displacement: Vector3): AbstractMesh;
  109394. private _onCollisionPositionChange;
  109395. /** @hidden */
  109396. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  109397. /** @hidden */
  109398. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  109399. /** @hidden */
  109400. _checkCollision(collider: Collider): AbstractMesh;
  109401. /** @hidden */
  109402. _generatePointsArray(): boolean;
  109403. /**
  109404. * Checks if the passed Ray intersects with the mesh
  109405. * @param ray defines the ray to use
  109406. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  109407. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109408. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  109409. * @returns the picking info
  109410. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  109411. */
  109412. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  109413. /**
  109414. * Clones the current mesh
  109415. * @param name defines the mesh name
  109416. * @param newParent defines the new mesh parent
  109417. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  109418. * @returns the new mesh
  109419. */
  109420. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  109421. /**
  109422. * Disposes all the submeshes of the current meshnp
  109423. * @returns the current mesh
  109424. */
  109425. releaseSubMeshes(): AbstractMesh;
  109426. /**
  109427. * Releases resources associated with this abstract mesh.
  109428. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109429. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109430. */
  109431. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109432. /**
  109433. * Adds the passed mesh as a child to the current mesh
  109434. * @param mesh defines the child mesh
  109435. * @returns the current mesh
  109436. */
  109437. addChild(mesh: AbstractMesh): AbstractMesh;
  109438. /**
  109439. * Removes the passed mesh from the current mesh children list
  109440. * @param mesh defines the child mesh
  109441. * @returns the current mesh
  109442. */
  109443. removeChild(mesh: AbstractMesh): AbstractMesh;
  109444. /** @hidden */
  109445. private _initFacetData;
  109446. /**
  109447. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  109448. * This method can be called within the render loop.
  109449. * 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
  109450. * @returns the current mesh
  109451. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109452. */
  109453. updateFacetData(): AbstractMesh;
  109454. /**
  109455. * Returns the facetLocalNormals array.
  109456. * The normals are expressed in the mesh local spac
  109457. * @returns an array of Vector3
  109458. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109459. */
  109460. getFacetLocalNormals(): Vector3[];
  109461. /**
  109462. * Returns the facetLocalPositions array.
  109463. * The facet positions are expressed in the mesh local space
  109464. * @returns an array of Vector3
  109465. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109466. */
  109467. getFacetLocalPositions(): Vector3[];
  109468. /**
  109469. * Returns the facetLocalPartioning array
  109470. * @returns an array of array of numbers
  109471. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109472. */
  109473. getFacetLocalPartitioning(): number[][];
  109474. /**
  109475. * Returns the i-th facet position in the world system.
  109476. * This method allocates a new Vector3 per call
  109477. * @param i defines the facet index
  109478. * @returns a new Vector3
  109479. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109480. */
  109481. getFacetPosition(i: number): Vector3;
  109482. /**
  109483. * Sets the reference Vector3 with the i-th facet position in the world system
  109484. * @param i defines the facet index
  109485. * @param ref defines the target vector
  109486. * @returns the current mesh
  109487. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109488. */
  109489. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  109490. /**
  109491. * Returns the i-th facet normal in the world system.
  109492. * This method allocates a new Vector3 per call
  109493. * @param i defines the facet index
  109494. * @returns a new Vector3
  109495. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109496. */
  109497. getFacetNormal(i: number): Vector3;
  109498. /**
  109499. * Sets the reference Vector3 with the i-th facet normal in the world system
  109500. * @param i defines the facet index
  109501. * @param ref defines the target vector
  109502. * @returns the current mesh
  109503. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109504. */
  109505. getFacetNormalToRef(i: number, ref: Vector3): this;
  109506. /**
  109507. * 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)
  109508. * @param x defines x coordinate
  109509. * @param y defines y coordinate
  109510. * @param z defines z coordinate
  109511. * @returns the array of facet indexes
  109512. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109513. */
  109514. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  109515. /**
  109516. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  109517. * @param projected sets as the (x,y,z) world projection on the facet
  109518. * @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
  109519. * @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
  109520. * @param x defines x coordinate
  109521. * @param y defines y coordinate
  109522. * @param z defines z coordinate
  109523. * @returns the face index if found (or null instead)
  109524. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109525. */
  109526. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  109527. /**
  109528. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  109529. * @param projected sets as the (x,y,z) local projection on the facet
  109530. * @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
  109531. * @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
  109532. * @param x defines x coordinate
  109533. * @param y defines y coordinate
  109534. * @param z defines z coordinate
  109535. * @returns the face index if found (or null instead)
  109536. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109537. */
  109538. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  109539. /**
  109540. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  109541. * @returns the parameters
  109542. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109543. */
  109544. getFacetDataParameters(): any;
  109545. /**
  109546. * Disables the feature FacetData and frees the related memory
  109547. * @returns the current mesh
  109548. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109549. */
  109550. disableFacetData(): AbstractMesh;
  109551. /**
  109552. * Updates the AbstractMesh indices array
  109553. * @param indices defines the data source
  109554. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  109555. * @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)
  109556. * @returns the current mesh
  109557. */
  109558. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  109559. /**
  109560. * Creates new normals data for the mesh
  109561. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  109562. * @returns the current mesh
  109563. */
  109564. createNormals(updatable: boolean): AbstractMesh;
  109565. /**
  109566. * Align the mesh with a normal
  109567. * @param normal defines the normal to use
  109568. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  109569. * @returns the current mesh
  109570. */
  109571. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  109572. /** @hidden */
  109573. _checkOcclusionQuery(): boolean;
  109574. /**
  109575. * Disables the mesh edge rendering mode
  109576. * @returns the currentAbstractMesh
  109577. */
  109578. disableEdgesRendering(): AbstractMesh;
  109579. /**
  109580. * Enables the edge rendering mode on the mesh.
  109581. * This mode makes the mesh edges visible
  109582. * @param epsilon defines the maximal distance between two angles to detect a face
  109583. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  109584. * @returns the currentAbstractMesh
  109585. * @see https://www.babylonjs-playground.com/#19O9TU#0
  109586. */
  109587. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  109588. }
  109589. }
  109590. declare module BABYLON {
  109591. /**
  109592. * Interface used to define ActionEvent
  109593. */
  109594. export interface IActionEvent {
  109595. /** The mesh or sprite that triggered the action */
  109596. source: any;
  109597. /** The X mouse cursor position at the time of the event */
  109598. pointerX: number;
  109599. /** The Y mouse cursor position at the time of the event */
  109600. pointerY: number;
  109601. /** The mesh that is currently pointed at (can be null) */
  109602. meshUnderPointer: Nullable<AbstractMesh>;
  109603. /** the original (browser) event that triggered the ActionEvent */
  109604. sourceEvent?: any;
  109605. /** additional data for the event */
  109606. additionalData?: any;
  109607. }
  109608. /**
  109609. * ActionEvent is the event being sent when an action is triggered.
  109610. */
  109611. export class ActionEvent implements IActionEvent {
  109612. /** The mesh or sprite that triggered the action */
  109613. source: any;
  109614. /** The X mouse cursor position at the time of the event */
  109615. pointerX: number;
  109616. /** The Y mouse cursor position at the time of the event */
  109617. pointerY: number;
  109618. /** The mesh that is currently pointed at (can be null) */
  109619. meshUnderPointer: Nullable<AbstractMesh>;
  109620. /** the original (browser) event that triggered the ActionEvent */
  109621. sourceEvent?: any;
  109622. /** additional data for the event */
  109623. additionalData?: any;
  109624. /**
  109625. * Creates a new ActionEvent
  109626. * @param source The mesh or sprite that triggered the action
  109627. * @param pointerX The X mouse cursor position at the time of the event
  109628. * @param pointerY The Y mouse cursor position at the time of the event
  109629. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  109630. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  109631. * @param additionalData additional data for the event
  109632. */
  109633. constructor(
  109634. /** The mesh or sprite that triggered the action */
  109635. source: any,
  109636. /** The X mouse cursor position at the time of the event */
  109637. pointerX: number,
  109638. /** The Y mouse cursor position at the time of the event */
  109639. pointerY: number,
  109640. /** The mesh that is currently pointed at (can be null) */
  109641. meshUnderPointer: Nullable<AbstractMesh>,
  109642. /** the original (browser) event that triggered the ActionEvent */
  109643. sourceEvent?: any,
  109644. /** additional data for the event */
  109645. additionalData?: any);
  109646. /**
  109647. * Helper function to auto-create an ActionEvent from a source mesh.
  109648. * @param source The source mesh that triggered the event
  109649. * @param evt The original (browser) event
  109650. * @param additionalData additional data for the event
  109651. * @returns the new ActionEvent
  109652. */
  109653. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  109654. /**
  109655. * Helper function to auto-create an ActionEvent from a source sprite
  109656. * @param source The source sprite that triggered the event
  109657. * @param scene Scene associated with the sprite
  109658. * @param evt The original (browser) event
  109659. * @param additionalData additional data for the event
  109660. * @returns the new ActionEvent
  109661. */
  109662. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  109663. /**
  109664. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  109665. * @param scene the scene where the event occurred
  109666. * @param evt The original (browser) event
  109667. * @returns the new ActionEvent
  109668. */
  109669. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  109670. /**
  109671. * Helper function to auto-create an ActionEvent from a primitive
  109672. * @param prim defines the target primitive
  109673. * @param pointerPos defines the pointer position
  109674. * @param evt The original (browser) event
  109675. * @param additionalData additional data for the event
  109676. * @returns the new ActionEvent
  109677. */
  109678. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  109679. }
  109680. }
  109681. declare module BABYLON {
  109682. /**
  109683. * Abstract class used to decouple action Manager from scene and meshes.
  109684. * Do not instantiate.
  109685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  109686. */
  109687. export abstract class AbstractActionManager implements IDisposable {
  109688. /** Gets the list of active triggers */
  109689. static Triggers: {
  109690. [key: string]: number;
  109691. };
  109692. /** Gets the cursor to use when hovering items */
  109693. hoverCursor: string;
  109694. /** Gets the list of actions */
  109695. actions: IAction[];
  109696. /**
  109697. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  109698. */
  109699. isRecursive: boolean;
  109700. /**
  109701. * Releases all associated resources
  109702. */
  109703. abstract dispose(): void;
  109704. /**
  109705. * Does this action manager has pointer triggers
  109706. */
  109707. abstract get hasPointerTriggers(): boolean;
  109708. /**
  109709. * Does this action manager has pick triggers
  109710. */
  109711. abstract get hasPickTriggers(): boolean;
  109712. /**
  109713. * Process a specific trigger
  109714. * @param trigger defines the trigger to process
  109715. * @param evt defines the event details to be processed
  109716. */
  109717. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  109718. /**
  109719. * Does this action manager handles actions of any of the given triggers
  109720. * @param triggers defines the triggers to be tested
  109721. * @return a boolean indicating whether one (or more) of the triggers is handled
  109722. */
  109723. abstract hasSpecificTriggers(triggers: number[]): boolean;
  109724. /**
  109725. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  109726. * speed.
  109727. * @param triggerA defines the trigger to be tested
  109728. * @param triggerB defines the trigger to be tested
  109729. * @return a boolean indicating whether one (or more) of the triggers is handled
  109730. */
  109731. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  109732. /**
  109733. * Does this action manager handles actions of a given trigger
  109734. * @param trigger defines the trigger to be tested
  109735. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  109736. * @return whether the trigger is handled
  109737. */
  109738. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  109739. /**
  109740. * Serialize this manager to a JSON object
  109741. * @param name defines the property name to store this manager
  109742. * @returns a JSON representation of this manager
  109743. */
  109744. abstract serialize(name: string): any;
  109745. /**
  109746. * Registers an action to this action manager
  109747. * @param action defines the action to be registered
  109748. * @return the action amended (prepared) after registration
  109749. */
  109750. abstract registerAction(action: IAction): Nullable<IAction>;
  109751. /**
  109752. * Unregisters an action to this action manager
  109753. * @param action defines the action to be unregistered
  109754. * @return a boolean indicating whether the action has been unregistered
  109755. */
  109756. abstract unregisterAction(action: IAction): Boolean;
  109757. /**
  109758. * Does exist one action manager with at least one trigger
  109759. **/
  109760. static get HasTriggers(): boolean;
  109761. /**
  109762. * Does exist one action manager with at least one pick trigger
  109763. **/
  109764. static get HasPickTriggers(): boolean;
  109765. /**
  109766. * Does exist one action manager that handles actions of a given trigger
  109767. * @param trigger defines the trigger to be tested
  109768. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  109769. **/
  109770. static HasSpecificTrigger(trigger: number): boolean;
  109771. }
  109772. }
  109773. declare module BABYLON {
  109774. /**
  109775. * Defines how a node can be built from a string name.
  109776. */
  109777. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  109778. /**
  109779. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  109780. */
  109781. export class Node implements IBehaviorAware<Node> {
  109782. /** @hidden */
  109783. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  109784. private static _NodeConstructors;
  109785. /**
  109786. * Add a new node constructor
  109787. * @param type defines the type name of the node to construct
  109788. * @param constructorFunc defines the constructor function
  109789. */
  109790. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  109791. /**
  109792. * Returns a node constructor based on type name
  109793. * @param type defines the type name
  109794. * @param name defines the new node name
  109795. * @param scene defines the hosting scene
  109796. * @param options defines optional options to transmit to constructors
  109797. * @returns the new constructor or null
  109798. */
  109799. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  109800. /**
  109801. * Gets or sets the name of the node
  109802. */
  109803. name: string;
  109804. /**
  109805. * Gets or sets the id of the node
  109806. */
  109807. id: string;
  109808. /**
  109809. * Gets or sets the unique id of the node
  109810. */
  109811. uniqueId: number;
  109812. /**
  109813. * Gets or sets a string used to store user defined state for the node
  109814. */
  109815. state: string;
  109816. /**
  109817. * Gets or sets an object used to store user defined information for the node
  109818. */
  109819. metadata: any;
  109820. /**
  109821. * For internal use only. Please do not use.
  109822. */
  109823. reservedDataStore: any;
  109824. /**
  109825. * List of inspectable custom properties (used by the Inspector)
  109826. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109827. */
  109828. inspectableCustomProperties: IInspectable[];
  109829. private _doNotSerialize;
  109830. /**
  109831. * Gets or sets a boolean used to define if the node must be serialized
  109832. */
  109833. get doNotSerialize(): boolean;
  109834. set doNotSerialize(value: boolean);
  109835. /** @hidden */
  109836. _isDisposed: boolean;
  109837. /**
  109838. * Gets a list of Animations associated with the node
  109839. */
  109840. animations: Animation[];
  109841. protected _ranges: {
  109842. [name: string]: Nullable<AnimationRange>;
  109843. };
  109844. /**
  109845. * Callback raised when the node is ready to be used
  109846. */
  109847. onReady: Nullable<(node: Node) => void>;
  109848. private _isEnabled;
  109849. private _isParentEnabled;
  109850. private _isReady;
  109851. /** @hidden */
  109852. _currentRenderId: number;
  109853. private _parentUpdateId;
  109854. /** @hidden */
  109855. _childUpdateId: number;
  109856. /** @hidden */
  109857. _waitingParentId: Nullable<string>;
  109858. /** @hidden */
  109859. _scene: Scene;
  109860. /** @hidden */
  109861. _cache: any;
  109862. private _parentNode;
  109863. private _children;
  109864. /** @hidden */
  109865. _worldMatrix: Matrix;
  109866. /** @hidden */
  109867. _worldMatrixDeterminant: number;
  109868. /** @hidden */
  109869. _worldMatrixDeterminantIsDirty: boolean;
  109870. /** @hidden */
  109871. private _sceneRootNodesIndex;
  109872. /**
  109873. * Gets a boolean indicating if the node has been disposed
  109874. * @returns true if the node was disposed
  109875. */
  109876. isDisposed(): boolean;
  109877. /**
  109878. * Gets or sets the parent of the node (without keeping the current position in the scene)
  109879. * @see https://doc.babylonjs.com/how_to/parenting
  109880. */
  109881. set parent(parent: Nullable<Node>);
  109882. get parent(): Nullable<Node>;
  109883. /** @hidden */
  109884. _addToSceneRootNodes(): void;
  109885. /** @hidden */
  109886. _removeFromSceneRootNodes(): void;
  109887. private _animationPropertiesOverride;
  109888. /**
  109889. * Gets or sets the animation properties override
  109890. */
  109891. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  109892. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  109893. /**
  109894. * Gets a string idenfifying the name of the class
  109895. * @returns "Node" string
  109896. */
  109897. getClassName(): string;
  109898. /** @hidden */
  109899. readonly _isNode: boolean;
  109900. /**
  109901. * An event triggered when the mesh is disposed
  109902. */
  109903. onDisposeObservable: Observable<Node>;
  109904. private _onDisposeObserver;
  109905. /**
  109906. * Sets a callback that will be raised when the node will be disposed
  109907. */
  109908. set onDispose(callback: () => void);
  109909. /**
  109910. * Creates a new Node
  109911. * @param name the name and id to be given to this node
  109912. * @param scene the scene this node will be added to
  109913. */
  109914. constructor(name: string, scene?: Nullable<Scene>);
  109915. /**
  109916. * Gets the scene of the node
  109917. * @returns a scene
  109918. */
  109919. getScene(): Scene;
  109920. /**
  109921. * Gets the engine of the node
  109922. * @returns a Engine
  109923. */
  109924. getEngine(): Engine;
  109925. private _behaviors;
  109926. /**
  109927. * Attach a behavior to the node
  109928. * @see http://doc.babylonjs.com/features/behaviour
  109929. * @param behavior defines the behavior to attach
  109930. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  109931. * @returns the current Node
  109932. */
  109933. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  109934. /**
  109935. * Remove an attached behavior
  109936. * @see http://doc.babylonjs.com/features/behaviour
  109937. * @param behavior defines the behavior to attach
  109938. * @returns the current Node
  109939. */
  109940. removeBehavior(behavior: Behavior<Node>): Node;
  109941. /**
  109942. * Gets the list of attached behaviors
  109943. * @see http://doc.babylonjs.com/features/behaviour
  109944. */
  109945. get behaviors(): Behavior<Node>[];
  109946. /**
  109947. * Gets an attached behavior by name
  109948. * @param name defines the name of the behavior to look for
  109949. * @see http://doc.babylonjs.com/features/behaviour
  109950. * @returns null if behavior was not found else the requested behavior
  109951. */
  109952. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  109953. /**
  109954. * Returns the latest update of the World matrix
  109955. * @returns a Matrix
  109956. */
  109957. getWorldMatrix(): Matrix;
  109958. /** @hidden */
  109959. _getWorldMatrixDeterminant(): number;
  109960. /**
  109961. * Returns directly the latest state of the mesh World matrix.
  109962. * A Matrix is returned.
  109963. */
  109964. get worldMatrixFromCache(): Matrix;
  109965. /** @hidden */
  109966. _initCache(): void;
  109967. /** @hidden */
  109968. updateCache(force?: boolean): void;
  109969. /** @hidden */
  109970. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  109971. /** @hidden */
  109972. _updateCache(ignoreParentClass?: boolean): void;
  109973. /** @hidden */
  109974. _isSynchronized(): boolean;
  109975. /** @hidden */
  109976. _markSyncedWithParent(): void;
  109977. /** @hidden */
  109978. isSynchronizedWithParent(): boolean;
  109979. /** @hidden */
  109980. isSynchronized(): boolean;
  109981. /**
  109982. * Is this node ready to be used/rendered
  109983. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  109984. * @return true if the node is ready
  109985. */
  109986. isReady(completeCheck?: boolean): boolean;
  109987. /**
  109988. * Is this node enabled?
  109989. * 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
  109990. * @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
  109991. * @return whether this node (and its parent) is enabled
  109992. */
  109993. isEnabled(checkAncestors?: boolean): boolean;
  109994. /** @hidden */
  109995. protected _syncParentEnabledState(): void;
  109996. /**
  109997. * Set the enabled state of this node
  109998. * @param value defines the new enabled state
  109999. */
  110000. setEnabled(value: boolean): void;
  110001. /**
  110002. * Is this node a descendant of the given node?
  110003. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  110004. * @param ancestor defines the parent node to inspect
  110005. * @returns a boolean indicating if this node is a descendant of the given node
  110006. */
  110007. isDescendantOf(ancestor: Node): boolean;
  110008. /** @hidden */
  110009. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  110010. /**
  110011. * Will return all nodes that have this node as ascendant
  110012. * @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
  110013. * @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
  110014. * @return all children nodes of all types
  110015. */
  110016. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  110017. /**
  110018. * Get all child-meshes of this node
  110019. * @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)
  110020. * @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
  110021. * @returns an array of AbstractMesh
  110022. */
  110023. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  110024. /**
  110025. * Get all direct children of this node
  110026. * @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
  110027. * @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)
  110028. * @returns an array of Node
  110029. */
  110030. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  110031. /** @hidden */
  110032. _setReady(state: boolean): void;
  110033. /**
  110034. * Get an animation by name
  110035. * @param name defines the name of the animation to look for
  110036. * @returns null if not found else the requested animation
  110037. */
  110038. getAnimationByName(name: string): Nullable<Animation>;
  110039. /**
  110040. * Creates an animation range for this node
  110041. * @param name defines the name of the range
  110042. * @param from defines the starting key
  110043. * @param to defines the end key
  110044. */
  110045. createAnimationRange(name: string, from: number, to: number): void;
  110046. /**
  110047. * Delete a specific animation range
  110048. * @param name defines the name of the range to delete
  110049. * @param deleteFrames defines if animation frames from the range must be deleted as well
  110050. */
  110051. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  110052. /**
  110053. * Get an animation range by name
  110054. * @param name defines the name of the animation range to look for
  110055. * @returns null if not found else the requested animation range
  110056. */
  110057. getAnimationRange(name: string): Nullable<AnimationRange>;
  110058. /**
  110059. * Gets the list of all animation ranges defined on this node
  110060. * @returns an array
  110061. */
  110062. getAnimationRanges(): Nullable<AnimationRange>[];
  110063. /**
  110064. * Will start the animation sequence
  110065. * @param name defines the range frames for animation sequence
  110066. * @param loop defines if the animation should loop (false by default)
  110067. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  110068. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  110069. * @returns the object created for this animation. If range does not exist, it will return null
  110070. */
  110071. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  110072. /**
  110073. * Serialize animation ranges into a JSON compatible object
  110074. * @returns serialization object
  110075. */
  110076. serializeAnimationRanges(): any;
  110077. /**
  110078. * Computes the world matrix of the node
  110079. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  110080. * @returns the world matrix
  110081. */
  110082. computeWorldMatrix(force?: boolean): Matrix;
  110083. /**
  110084. * Releases resources associated with this node.
  110085. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110086. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110087. */
  110088. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110089. /**
  110090. * Parse animation range data from a serialization object and store them into a given node
  110091. * @param node defines where to store the animation ranges
  110092. * @param parsedNode defines the serialization object to read data from
  110093. * @param scene defines the hosting scene
  110094. */
  110095. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  110096. /**
  110097. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  110098. * @param includeDescendants Include bounding info from descendants as well (true by default)
  110099. * @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
  110100. * @returns the new bounding vectors
  110101. */
  110102. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  110103. min: Vector3;
  110104. max: Vector3;
  110105. };
  110106. }
  110107. }
  110108. declare module BABYLON {
  110109. /**
  110110. * @hidden
  110111. */
  110112. export class _IAnimationState {
  110113. key: number;
  110114. repeatCount: number;
  110115. workValue?: any;
  110116. loopMode?: number;
  110117. offsetValue?: any;
  110118. highLimitValue?: any;
  110119. }
  110120. /**
  110121. * Class used to store any kind of animation
  110122. */
  110123. export class Animation {
  110124. /**Name of the animation */
  110125. name: string;
  110126. /**Property to animate */
  110127. targetProperty: string;
  110128. /**The frames per second of the animation */
  110129. framePerSecond: number;
  110130. /**The data type of the animation */
  110131. dataType: number;
  110132. /**The loop mode of the animation */
  110133. loopMode?: number | undefined;
  110134. /**Specifies if blending should be enabled */
  110135. enableBlending?: boolean | undefined;
  110136. /**
  110137. * Use matrix interpolation instead of using direct key value when animating matrices
  110138. */
  110139. static AllowMatricesInterpolation: boolean;
  110140. /**
  110141. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  110142. */
  110143. static AllowMatrixDecomposeForInterpolation: boolean;
  110144. /** Define the Url to load snippets */
  110145. static SnippetUrl: string;
  110146. /** Snippet ID if the animation was created from the snippet server */
  110147. snippetId: string;
  110148. /**
  110149. * Stores the key frames of the animation
  110150. */
  110151. private _keys;
  110152. /**
  110153. * Stores the easing function of the animation
  110154. */
  110155. private _easingFunction;
  110156. /**
  110157. * @hidden Internal use only
  110158. */
  110159. _runtimeAnimations: RuntimeAnimation[];
  110160. /**
  110161. * The set of event that will be linked to this animation
  110162. */
  110163. private _events;
  110164. /**
  110165. * Stores an array of target property paths
  110166. */
  110167. targetPropertyPath: string[];
  110168. /**
  110169. * Stores the blending speed of the animation
  110170. */
  110171. blendingSpeed: number;
  110172. /**
  110173. * Stores the animation ranges for the animation
  110174. */
  110175. private _ranges;
  110176. /**
  110177. * @hidden Internal use
  110178. */
  110179. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  110180. /**
  110181. * Sets up an animation
  110182. * @param property The property to animate
  110183. * @param animationType The animation type to apply
  110184. * @param framePerSecond The frames per second of the animation
  110185. * @param easingFunction The easing function used in the animation
  110186. * @returns The created animation
  110187. */
  110188. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  110189. /**
  110190. * Create and start an animation on a node
  110191. * @param name defines the name of the global animation that will be run on all nodes
  110192. * @param node defines the root node where the animation will take place
  110193. * @param targetProperty defines property to animate
  110194. * @param framePerSecond defines the number of frame per second yo use
  110195. * @param totalFrame defines the number of frames in total
  110196. * @param from defines the initial value
  110197. * @param to defines the final value
  110198. * @param loopMode defines which loop mode you want to use (off by default)
  110199. * @param easingFunction defines the easing function to use (linear by default)
  110200. * @param onAnimationEnd defines the callback to call when animation end
  110201. * @returns the animatable created for this animation
  110202. */
  110203. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  110204. /**
  110205. * Create and start an animation on a node and its descendants
  110206. * @param name defines the name of the global animation that will be run on all nodes
  110207. * @param node defines the root node where the animation will take place
  110208. * @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
  110209. * @param targetProperty defines property to animate
  110210. * @param framePerSecond defines the number of frame per second to use
  110211. * @param totalFrame defines the number of frames in total
  110212. * @param from defines the initial value
  110213. * @param to defines the final value
  110214. * @param loopMode defines which loop mode you want to use (off by default)
  110215. * @param easingFunction defines the easing function to use (linear by default)
  110216. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  110217. * @returns the list of animatables created for all nodes
  110218. * @example https://www.babylonjs-playground.com/#MH0VLI
  110219. */
  110220. 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[]>;
  110221. /**
  110222. * Creates a new animation, merges it with the existing animations and starts it
  110223. * @param name Name of the animation
  110224. * @param node Node which contains the scene that begins the animations
  110225. * @param targetProperty Specifies which property to animate
  110226. * @param framePerSecond The frames per second of the animation
  110227. * @param totalFrame The total number of frames
  110228. * @param from The frame at the beginning of the animation
  110229. * @param to The frame at the end of the animation
  110230. * @param loopMode Specifies the loop mode of the animation
  110231. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  110232. * @param onAnimationEnd Callback to run once the animation is complete
  110233. * @returns Nullable animation
  110234. */
  110235. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  110236. /**
  110237. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  110238. * @param sourceAnimation defines the Animation containing keyframes to convert
  110239. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  110240. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  110241. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  110242. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  110243. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  110244. */
  110245. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  110246. /**
  110247. * Transition property of an host to the target Value
  110248. * @param property The property to transition
  110249. * @param targetValue The target Value of the property
  110250. * @param host The object where the property to animate belongs
  110251. * @param scene Scene used to run the animation
  110252. * @param frameRate Framerate (in frame/s) to use
  110253. * @param transition The transition type we want to use
  110254. * @param duration The duration of the animation, in milliseconds
  110255. * @param onAnimationEnd Callback trigger at the end of the animation
  110256. * @returns Nullable animation
  110257. */
  110258. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  110259. /**
  110260. * Return the array of runtime animations currently using this animation
  110261. */
  110262. get runtimeAnimations(): RuntimeAnimation[];
  110263. /**
  110264. * Specifies if any of the runtime animations are currently running
  110265. */
  110266. get hasRunningRuntimeAnimations(): boolean;
  110267. /**
  110268. * Initializes the animation
  110269. * @param name Name of the animation
  110270. * @param targetProperty Property to animate
  110271. * @param framePerSecond The frames per second of the animation
  110272. * @param dataType The data type of the animation
  110273. * @param loopMode The loop mode of the animation
  110274. * @param enableBlending Specifies if blending should be enabled
  110275. */
  110276. constructor(
  110277. /**Name of the animation */
  110278. name: string,
  110279. /**Property to animate */
  110280. targetProperty: string,
  110281. /**The frames per second of the animation */
  110282. framePerSecond: number,
  110283. /**The data type of the animation */
  110284. dataType: number,
  110285. /**The loop mode of the animation */
  110286. loopMode?: number | undefined,
  110287. /**Specifies if blending should be enabled */
  110288. enableBlending?: boolean | undefined);
  110289. /**
  110290. * Converts the animation to a string
  110291. * @param fullDetails support for multiple levels of logging within scene loading
  110292. * @returns String form of the animation
  110293. */
  110294. toString(fullDetails?: boolean): string;
  110295. /**
  110296. * Add an event to this animation
  110297. * @param event Event to add
  110298. */
  110299. addEvent(event: AnimationEvent): void;
  110300. /**
  110301. * Remove all events found at the given frame
  110302. * @param frame The frame to remove events from
  110303. */
  110304. removeEvents(frame: number): void;
  110305. /**
  110306. * Retrieves all the events from the animation
  110307. * @returns Events from the animation
  110308. */
  110309. getEvents(): AnimationEvent[];
  110310. /**
  110311. * Creates an animation range
  110312. * @param name Name of the animation range
  110313. * @param from Starting frame of the animation range
  110314. * @param to Ending frame of the animation
  110315. */
  110316. createRange(name: string, from: number, to: number): void;
  110317. /**
  110318. * Deletes an animation range by name
  110319. * @param name Name of the animation range to delete
  110320. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  110321. */
  110322. deleteRange(name: string, deleteFrames?: boolean): void;
  110323. /**
  110324. * Gets the animation range by name, or null if not defined
  110325. * @param name Name of the animation range
  110326. * @returns Nullable animation range
  110327. */
  110328. getRange(name: string): Nullable<AnimationRange>;
  110329. /**
  110330. * Gets the key frames from the animation
  110331. * @returns The key frames of the animation
  110332. */
  110333. getKeys(): Array<IAnimationKey>;
  110334. /**
  110335. * Gets the highest frame rate of the animation
  110336. * @returns Highest frame rate of the animation
  110337. */
  110338. getHighestFrame(): number;
  110339. /**
  110340. * Gets the easing function of the animation
  110341. * @returns Easing function of the animation
  110342. */
  110343. getEasingFunction(): IEasingFunction;
  110344. /**
  110345. * Sets the easing function of the animation
  110346. * @param easingFunction A custom mathematical formula for animation
  110347. */
  110348. setEasingFunction(easingFunction: EasingFunction): void;
  110349. /**
  110350. * Interpolates a scalar linearly
  110351. * @param startValue Start value of the animation curve
  110352. * @param endValue End value of the animation curve
  110353. * @param gradient Scalar amount to interpolate
  110354. * @returns Interpolated scalar value
  110355. */
  110356. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  110357. /**
  110358. * Interpolates a scalar cubically
  110359. * @param startValue Start value of the animation curve
  110360. * @param outTangent End tangent of the animation
  110361. * @param endValue End value of the animation curve
  110362. * @param inTangent Start tangent of the animation curve
  110363. * @param gradient Scalar amount to interpolate
  110364. * @returns Interpolated scalar value
  110365. */
  110366. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  110367. /**
  110368. * Interpolates a quaternion using a spherical linear interpolation
  110369. * @param startValue Start value of the animation curve
  110370. * @param endValue End value of the animation curve
  110371. * @param gradient Scalar amount to interpolate
  110372. * @returns Interpolated quaternion value
  110373. */
  110374. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  110375. /**
  110376. * Interpolates a quaternion cubically
  110377. * @param startValue Start value of the animation curve
  110378. * @param outTangent End tangent of the animation curve
  110379. * @param endValue End value of the animation curve
  110380. * @param inTangent Start tangent of the animation curve
  110381. * @param gradient Scalar amount to interpolate
  110382. * @returns Interpolated quaternion value
  110383. */
  110384. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  110385. /**
  110386. * Interpolates a Vector3 linearl
  110387. * @param startValue Start value of the animation curve
  110388. * @param endValue End value of the animation curve
  110389. * @param gradient Scalar amount to interpolate
  110390. * @returns Interpolated scalar value
  110391. */
  110392. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  110393. /**
  110394. * Interpolates a Vector3 cubically
  110395. * @param startValue Start value of the animation curve
  110396. * @param outTangent End tangent of the animation
  110397. * @param endValue End value of the animation curve
  110398. * @param inTangent Start tangent of the animation curve
  110399. * @param gradient Scalar amount to interpolate
  110400. * @returns InterpolatedVector3 value
  110401. */
  110402. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  110403. /**
  110404. * Interpolates a Vector2 linearly
  110405. * @param startValue Start value of the animation curve
  110406. * @param endValue End value of the animation curve
  110407. * @param gradient Scalar amount to interpolate
  110408. * @returns Interpolated Vector2 value
  110409. */
  110410. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  110411. /**
  110412. * Interpolates a Vector2 cubically
  110413. * @param startValue Start value of the animation curve
  110414. * @param outTangent End tangent of the animation
  110415. * @param endValue End value of the animation curve
  110416. * @param inTangent Start tangent of the animation curve
  110417. * @param gradient Scalar amount to interpolate
  110418. * @returns Interpolated Vector2 value
  110419. */
  110420. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  110421. /**
  110422. * Interpolates a size linearly
  110423. * @param startValue Start value of the animation curve
  110424. * @param endValue End value of the animation curve
  110425. * @param gradient Scalar amount to interpolate
  110426. * @returns Interpolated Size value
  110427. */
  110428. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  110429. /**
  110430. * Interpolates a Color3 linearly
  110431. * @param startValue Start value of the animation curve
  110432. * @param endValue End value of the animation curve
  110433. * @param gradient Scalar amount to interpolate
  110434. * @returns Interpolated Color3 value
  110435. */
  110436. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  110437. /**
  110438. * Interpolates a Color4 linearly
  110439. * @param startValue Start value of the animation curve
  110440. * @param endValue End value of the animation curve
  110441. * @param gradient Scalar amount to interpolate
  110442. * @returns Interpolated Color3 value
  110443. */
  110444. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  110445. /**
  110446. * @hidden Internal use only
  110447. */
  110448. _getKeyValue(value: any): any;
  110449. /**
  110450. * @hidden Internal use only
  110451. */
  110452. _interpolate(currentFrame: number, state: _IAnimationState): any;
  110453. /**
  110454. * Defines the function to use to interpolate matrices
  110455. * @param startValue defines the start matrix
  110456. * @param endValue defines the end matrix
  110457. * @param gradient defines the gradient between both matrices
  110458. * @param result defines an optional target matrix where to store the interpolation
  110459. * @returns the interpolated matrix
  110460. */
  110461. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  110462. /**
  110463. * Makes a copy of the animation
  110464. * @returns Cloned animation
  110465. */
  110466. clone(): Animation;
  110467. /**
  110468. * Sets the key frames of the animation
  110469. * @param values The animation key frames to set
  110470. */
  110471. setKeys(values: Array<IAnimationKey>): void;
  110472. /**
  110473. * Serializes the animation to an object
  110474. * @returns Serialized object
  110475. */
  110476. serialize(): any;
  110477. /**
  110478. * Float animation type
  110479. */
  110480. static readonly ANIMATIONTYPE_FLOAT: number;
  110481. /**
  110482. * Vector3 animation type
  110483. */
  110484. static readonly ANIMATIONTYPE_VECTOR3: number;
  110485. /**
  110486. * Quaternion animation type
  110487. */
  110488. static readonly ANIMATIONTYPE_QUATERNION: number;
  110489. /**
  110490. * Matrix animation type
  110491. */
  110492. static readonly ANIMATIONTYPE_MATRIX: number;
  110493. /**
  110494. * Color3 animation type
  110495. */
  110496. static readonly ANIMATIONTYPE_COLOR3: number;
  110497. /**
  110498. * Color3 animation type
  110499. */
  110500. static readonly ANIMATIONTYPE_COLOR4: number;
  110501. /**
  110502. * Vector2 animation type
  110503. */
  110504. static readonly ANIMATIONTYPE_VECTOR2: number;
  110505. /**
  110506. * Size animation type
  110507. */
  110508. static readonly ANIMATIONTYPE_SIZE: number;
  110509. /**
  110510. * Relative Loop Mode
  110511. */
  110512. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  110513. /**
  110514. * Cycle Loop Mode
  110515. */
  110516. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  110517. /**
  110518. * Constant Loop Mode
  110519. */
  110520. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  110521. /** @hidden */
  110522. static _UniversalLerp(left: any, right: any, amount: number): any;
  110523. /**
  110524. * Parses an animation object and creates an animation
  110525. * @param parsedAnimation Parsed animation object
  110526. * @returns Animation object
  110527. */
  110528. static Parse(parsedAnimation: any): Animation;
  110529. /**
  110530. * Appends the serialized animations from the source animations
  110531. * @param source Source containing the animations
  110532. * @param destination Target to store the animations
  110533. */
  110534. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  110535. /**
  110536. * Creates a new animation or an array of animations from a snippet saved in a remote file
  110537. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  110538. * @param url defines the url to load from
  110539. * @returns a promise that will resolve to the new animation or an array of animations
  110540. */
  110541. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  110542. /**
  110543. * Creates an animation or an array of animations from a snippet saved by the Inspector
  110544. * @param snippetId defines the snippet to load
  110545. * @returns a promise that will resolve to the new animation or a new array of animations
  110546. */
  110547. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  110548. }
  110549. }
  110550. declare module BABYLON {
  110551. /**
  110552. * Interface containing an array of animations
  110553. */
  110554. export interface IAnimatable {
  110555. /**
  110556. * Array of animations
  110557. */
  110558. animations: Nullable<Array<Animation>>;
  110559. }
  110560. }
  110561. declare module BABYLON {
  110562. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  110563. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110564. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110565. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110566. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110567. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110568. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110569. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110570. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110571. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110572. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110573. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110574. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110575. /**
  110576. * Decorator used to define property that can be serialized as reference to a camera
  110577. * @param sourceName defines the name of the property to decorate
  110578. */
  110579. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110580. /**
  110581. * Class used to help serialization objects
  110582. */
  110583. export class SerializationHelper {
  110584. /** @hidden */
  110585. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  110586. /** @hidden */
  110587. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  110588. /** @hidden */
  110589. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  110590. /** @hidden */
  110591. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  110592. /**
  110593. * Appends the serialized animations from the source animations
  110594. * @param source Source containing the animations
  110595. * @param destination Target to store the animations
  110596. */
  110597. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  110598. /**
  110599. * Static function used to serialized a specific entity
  110600. * @param entity defines the entity to serialize
  110601. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  110602. * @returns a JSON compatible object representing the serialization of the entity
  110603. */
  110604. static Serialize<T>(entity: T, serializationObject?: any): any;
  110605. /**
  110606. * Creates a new entity from a serialization data object
  110607. * @param creationFunction defines a function used to instanciated the new entity
  110608. * @param source defines the source serialization data
  110609. * @param scene defines the hosting scene
  110610. * @param rootUrl defines the root url for resources
  110611. * @returns a new entity
  110612. */
  110613. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  110614. /**
  110615. * Clones an object
  110616. * @param creationFunction defines the function used to instanciate the new object
  110617. * @param source defines the source object
  110618. * @returns the cloned object
  110619. */
  110620. static Clone<T>(creationFunction: () => T, source: T): T;
  110621. /**
  110622. * Instanciates a new object based on a source one (some data will be shared between both object)
  110623. * @param creationFunction defines the function used to instanciate the new object
  110624. * @param source defines the source object
  110625. * @returns the new object
  110626. */
  110627. static Instanciate<T>(creationFunction: () => T, source: T): T;
  110628. }
  110629. }
  110630. declare module BABYLON {
  110631. /**
  110632. * Base class of all the textures in babylon.
  110633. * It groups all the common properties the materials, post process, lights... might need
  110634. * in order to make a correct use of the texture.
  110635. */
  110636. export class BaseTexture implements IAnimatable {
  110637. /**
  110638. * Default anisotropic filtering level for the application.
  110639. * It is set to 4 as a good tradeoff between perf and quality.
  110640. */
  110641. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  110642. /**
  110643. * Gets or sets the unique id of the texture
  110644. */
  110645. uniqueId: number;
  110646. /**
  110647. * Define the name of the texture.
  110648. */
  110649. name: string;
  110650. /**
  110651. * Gets or sets an object used to store user defined information.
  110652. */
  110653. metadata: any;
  110654. /**
  110655. * For internal use only. Please do not use.
  110656. */
  110657. reservedDataStore: any;
  110658. private _hasAlpha;
  110659. /**
  110660. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  110661. */
  110662. set hasAlpha(value: boolean);
  110663. get hasAlpha(): boolean;
  110664. /**
  110665. * Defines if the alpha value should be determined via the rgb values.
  110666. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  110667. */
  110668. getAlphaFromRGB: boolean;
  110669. /**
  110670. * Intensity or strength of the texture.
  110671. * It is commonly used by materials to fine tune the intensity of the texture
  110672. */
  110673. level: number;
  110674. /**
  110675. * Define the UV chanel to use starting from 0 and defaulting to 0.
  110676. * This is part of the texture as textures usually maps to one uv set.
  110677. */
  110678. coordinatesIndex: number;
  110679. private _coordinatesMode;
  110680. /**
  110681. * How a texture is mapped.
  110682. *
  110683. * | Value | Type | Description |
  110684. * | ----- | ----------------------------------- | ----------- |
  110685. * | 0 | EXPLICIT_MODE | |
  110686. * | 1 | SPHERICAL_MODE | |
  110687. * | 2 | PLANAR_MODE | |
  110688. * | 3 | CUBIC_MODE | |
  110689. * | 4 | PROJECTION_MODE | |
  110690. * | 5 | SKYBOX_MODE | |
  110691. * | 6 | INVCUBIC_MODE | |
  110692. * | 7 | EQUIRECTANGULAR_MODE | |
  110693. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  110694. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  110695. */
  110696. set coordinatesMode(value: number);
  110697. get coordinatesMode(): number;
  110698. /**
  110699. * | Value | Type | Description |
  110700. * | ----- | ------------------ | ----------- |
  110701. * | 0 | CLAMP_ADDRESSMODE | |
  110702. * | 1 | WRAP_ADDRESSMODE | |
  110703. * | 2 | MIRROR_ADDRESSMODE | |
  110704. */
  110705. wrapU: number;
  110706. /**
  110707. * | Value | Type | Description |
  110708. * | ----- | ------------------ | ----------- |
  110709. * | 0 | CLAMP_ADDRESSMODE | |
  110710. * | 1 | WRAP_ADDRESSMODE | |
  110711. * | 2 | MIRROR_ADDRESSMODE | |
  110712. */
  110713. wrapV: number;
  110714. /**
  110715. * | Value | Type | Description |
  110716. * | ----- | ------------------ | ----------- |
  110717. * | 0 | CLAMP_ADDRESSMODE | |
  110718. * | 1 | WRAP_ADDRESSMODE | |
  110719. * | 2 | MIRROR_ADDRESSMODE | |
  110720. */
  110721. wrapR: number;
  110722. /**
  110723. * With compliant hardware and browser (supporting anisotropic filtering)
  110724. * this defines the level of anisotropic filtering in the texture.
  110725. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  110726. */
  110727. anisotropicFilteringLevel: number;
  110728. /**
  110729. * Define if the texture is a cube texture or if false a 2d texture.
  110730. */
  110731. get isCube(): boolean;
  110732. set isCube(value: boolean);
  110733. /**
  110734. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  110735. */
  110736. get is3D(): boolean;
  110737. set is3D(value: boolean);
  110738. /**
  110739. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  110740. */
  110741. get is2DArray(): boolean;
  110742. set is2DArray(value: boolean);
  110743. /**
  110744. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  110745. * HDR texture are usually stored in linear space.
  110746. * This only impacts the PBR and Background materials
  110747. */
  110748. gammaSpace: boolean;
  110749. /**
  110750. * Gets or sets whether or not the texture contains RGBD data.
  110751. */
  110752. get isRGBD(): boolean;
  110753. set isRGBD(value: boolean);
  110754. /**
  110755. * Is Z inverted in the texture (useful in a cube texture).
  110756. */
  110757. invertZ: boolean;
  110758. /**
  110759. * Are mip maps generated for this texture or not.
  110760. */
  110761. get noMipmap(): boolean;
  110762. /**
  110763. * @hidden
  110764. */
  110765. lodLevelInAlpha: boolean;
  110766. /**
  110767. * With prefiltered texture, defined the offset used during the prefiltering steps.
  110768. */
  110769. get lodGenerationOffset(): number;
  110770. set lodGenerationOffset(value: number);
  110771. /**
  110772. * With prefiltered texture, defined the scale used during the prefiltering steps.
  110773. */
  110774. get lodGenerationScale(): number;
  110775. set lodGenerationScale(value: number);
  110776. /**
  110777. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  110778. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  110779. * average roughness values.
  110780. */
  110781. get linearSpecularLOD(): boolean;
  110782. set linearSpecularLOD(value: boolean);
  110783. /**
  110784. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  110785. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  110786. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  110787. */
  110788. get irradianceTexture(): Nullable<BaseTexture>;
  110789. set irradianceTexture(value: Nullable<BaseTexture>);
  110790. /**
  110791. * Define if the texture is a render target.
  110792. */
  110793. isRenderTarget: boolean;
  110794. /**
  110795. * Define the unique id of the texture in the scene.
  110796. */
  110797. get uid(): string;
  110798. /** @hidden */
  110799. _prefiltered: boolean;
  110800. /**
  110801. * Return a string representation of the texture.
  110802. * @returns the texture as a string
  110803. */
  110804. toString(): string;
  110805. /**
  110806. * Get the class name of the texture.
  110807. * @returns "BaseTexture"
  110808. */
  110809. getClassName(): string;
  110810. /**
  110811. * Define the list of animation attached to the texture.
  110812. */
  110813. animations: Animation[];
  110814. /**
  110815. * An event triggered when the texture is disposed.
  110816. */
  110817. onDisposeObservable: Observable<BaseTexture>;
  110818. private _onDisposeObserver;
  110819. /**
  110820. * Callback triggered when the texture has been disposed.
  110821. * Kept for back compatibility, you can use the onDisposeObservable instead.
  110822. */
  110823. set onDispose(callback: () => void);
  110824. /**
  110825. * Define the current state of the loading sequence when in delayed load mode.
  110826. */
  110827. delayLoadState: number;
  110828. private _scene;
  110829. private _engine;
  110830. /** @hidden */
  110831. _texture: Nullable<InternalTexture>;
  110832. private _uid;
  110833. /**
  110834. * Define if the texture is preventinga material to render or not.
  110835. * If not and the texture is not ready, the engine will use a default black texture instead.
  110836. */
  110837. get isBlocking(): boolean;
  110838. /**
  110839. * Instantiates a new BaseTexture.
  110840. * Base class of all the textures in babylon.
  110841. * It groups all the common properties the materials, post process, lights... might need
  110842. * in order to make a correct use of the texture.
  110843. * @param sceneOrEngine Define the scene or engine the texture blongs to
  110844. */
  110845. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  110846. /**
  110847. * Get the scene the texture belongs to.
  110848. * @returns the scene or null if undefined
  110849. */
  110850. getScene(): Nullable<Scene>;
  110851. /** @hidden */
  110852. protected _getEngine(): Nullable<ThinEngine>;
  110853. /**
  110854. * Get the texture transform matrix used to offset tile the texture for istance.
  110855. * @returns the transformation matrix
  110856. */
  110857. getTextureMatrix(): Matrix;
  110858. /**
  110859. * Get the texture reflection matrix used to rotate/transform the reflection.
  110860. * @returns the reflection matrix
  110861. */
  110862. getReflectionTextureMatrix(): Matrix;
  110863. /**
  110864. * Get the underlying lower level texture from Babylon.
  110865. * @returns the insternal texture
  110866. */
  110867. getInternalTexture(): Nullable<InternalTexture>;
  110868. /**
  110869. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  110870. * @returns true if ready or not blocking
  110871. */
  110872. isReadyOrNotBlocking(): boolean;
  110873. /**
  110874. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  110875. * @returns true if fully ready
  110876. */
  110877. isReady(): boolean;
  110878. private _cachedSize;
  110879. /**
  110880. * Get the size of the texture.
  110881. * @returns the texture size.
  110882. */
  110883. getSize(): ISize;
  110884. /**
  110885. * Get the base size of the texture.
  110886. * It can be different from the size if the texture has been resized for POT for instance
  110887. * @returns the base size
  110888. */
  110889. getBaseSize(): ISize;
  110890. /**
  110891. * Update the sampling mode of the texture.
  110892. * Default is Trilinear mode.
  110893. *
  110894. * | Value | Type | Description |
  110895. * | ----- | ------------------ | ----------- |
  110896. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  110897. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  110898. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  110899. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  110900. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  110901. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  110902. * | 7 | NEAREST_LINEAR | |
  110903. * | 8 | NEAREST_NEAREST | |
  110904. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  110905. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  110906. * | 11 | LINEAR_LINEAR | |
  110907. * | 12 | LINEAR_NEAREST | |
  110908. *
  110909. * > _mag_: magnification filter (close to the viewer)
  110910. * > _min_: minification filter (far from the viewer)
  110911. * > _mip_: filter used between mip map levels
  110912. *@param samplingMode Define the new sampling mode of the texture
  110913. */
  110914. updateSamplingMode(samplingMode: number): void;
  110915. /**
  110916. * Scales the texture if is `canRescale()`
  110917. * @param ratio the resize factor we want to use to rescale
  110918. */
  110919. scale(ratio: number): void;
  110920. /**
  110921. * Get if the texture can rescale.
  110922. */
  110923. get canRescale(): boolean;
  110924. /** @hidden */
  110925. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  110926. /** @hidden */
  110927. _rebuild(): void;
  110928. /**
  110929. * Triggers the load sequence in delayed load mode.
  110930. */
  110931. delayLoad(): void;
  110932. /**
  110933. * Clones the texture.
  110934. * @returns the cloned texture
  110935. */
  110936. clone(): Nullable<BaseTexture>;
  110937. /**
  110938. * Get the texture underlying type (INT, FLOAT...)
  110939. */
  110940. get textureType(): number;
  110941. /**
  110942. * Get the texture underlying format (RGB, RGBA...)
  110943. */
  110944. get textureFormat(): number;
  110945. /**
  110946. * Indicates that textures need to be re-calculated for all materials
  110947. */
  110948. protected _markAllSubMeshesAsTexturesDirty(): void;
  110949. /**
  110950. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  110951. * This will returns an RGBA array buffer containing either in values (0-255) or
  110952. * float values (0-1) depending of the underlying buffer type.
  110953. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  110954. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  110955. * @param buffer defines a user defined buffer to fill with data (can be null)
  110956. * @returns The Array buffer containing the pixels data.
  110957. */
  110958. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  110959. /**
  110960. * Release and destroy the underlying lower level texture aka internalTexture.
  110961. */
  110962. releaseInternalTexture(): void;
  110963. /** @hidden */
  110964. get _lodTextureHigh(): Nullable<BaseTexture>;
  110965. /** @hidden */
  110966. get _lodTextureMid(): Nullable<BaseTexture>;
  110967. /** @hidden */
  110968. get _lodTextureLow(): Nullable<BaseTexture>;
  110969. /**
  110970. * Dispose the texture and release its associated resources.
  110971. */
  110972. dispose(): void;
  110973. /**
  110974. * Serialize the texture into a JSON representation that can be parsed later on.
  110975. * @returns the JSON representation of the texture
  110976. */
  110977. serialize(): any;
  110978. /**
  110979. * Helper function to be called back once a list of texture contains only ready textures.
  110980. * @param textures Define the list of textures to wait for
  110981. * @param callback Define the callback triggered once the entire list will be ready
  110982. */
  110983. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  110984. private static _isScene;
  110985. }
  110986. }
  110987. declare module BABYLON {
  110988. /**
  110989. * Options to be used when creating an effect.
  110990. */
  110991. export interface IEffectCreationOptions {
  110992. /**
  110993. * Atrributes that will be used in the shader.
  110994. */
  110995. attributes: string[];
  110996. /**
  110997. * Uniform varible names that will be set in the shader.
  110998. */
  110999. uniformsNames: string[];
  111000. /**
  111001. * Uniform buffer variable names that will be set in the shader.
  111002. */
  111003. uniformBuffersNames: string[];
  111004. /**
  111005. * Sampler texture variable names that will be set in the shader.
  111006. */
  111007. samplers: string[];
  111008. /**
  111009. * Define statements that will be set in the shader.
  111010. */
  111011. defines: any;
  111012. /**
  111013. * Possible fallbacks for this effect to improve performance when needed.
  111014. */
  111015. fallbacks: Nullable<IEffectFallbacks>;
  111016. /**
  111017. * Callback that will be called when the shader is compiled.
  111018. */
  111019. onCompiled: Nullable<(effect: Effect) => void>;
  111020. /**
  111021. * Callback that will be called if an error occurs during shader compilation.
  111022. */
  111023. onError: Nullable<(effect: Effect, errors: string) => void>;
  111024. /**
  111025. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  111026. */
  111027. indexParameters?: any;
  111028. /**
  111029. * Max number of lights that can be used in the shader.
  111030. */
  111031. maxSimultaneousLights?: number;
  111032. /**
  111033. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  111034. */
  111035. transformFeedbackVaryings?: Nullable<string[]>;
  111036. /**
  111037. * 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
  111038. */
  111039. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  111040. }
  111041. /**
  111042. * Effect containing vertex and fragment shader that can be executed on an object.
  111043. */
  111044. export class Effect implements IDisposable {
  111045. /**
  111046. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  111047. */
  111048. static ShadersRepository: string;
  111049. /**
  111050. * Enable logging of the shader code when a compilation error occurs
  111051. */
  111052. static LogShaderCodeOnCompilationError: boolean;
  111053. /**
  111054. * Name of the effect.
  111055. */
  111056. name: any;
  111057. /**
  111058. * String container all the define statements that should be set on the shader.
  111059. */
  111060. defines: string;
  111061. /**
  111062. * Callback that will be called when the shader is compiled.
  111063. */
  111064. onCompiled: Nullable<(effect: Effect) => void>;
  111065. /**
  111066. * Callback that will be called if an error occurs during shader compilation.
  111067. */
  111068. onError: Nullable<(effect: Effect, errors: string) => void>;
  111069. /**
  111070. * Callback that will be called when effect is bound.
  111071. */
  111072. onBind: Nullable<(effect: Effect) => void>;
  111073. /**
  111074. * Unique ID of the effect.
  111075. */
  111076. uniqueId: number;
  111077. /**
  111078. * Observable that will be called when the shader is compiled.
  111079. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  111080. */
  111081. onCompileObservable: Observable<Effect>;
  111082. /**
  111083. * Observable that will be called if an error occurs during shader compilation.
  111084. */
  111085. onErrorObservable: Observable<Effect>;
  111086. /** @hidden */
  111087. _onBindObservable: Nullable<Observable<Effect>>;
  111088. /**
  111089. * @hidden
  111090. * Specifies if the effect was previously ready
  111091. */
  111092. _wasPreviouslyReady: boolean;
  111093. /**
  111094. * Observable that will be called when effect is bound.
  111095. */
  111096. get onBindObservable(): Observable<Effect>;
  111097. /** @hidden */
  111098. _bonesComputationForcedToCPU: boolean;
  111099. private static _uniqueIdSeed;
  111100. private _engine;
  111101. private _uniformBuffersNames;
  111102. private _uniformBuffersNamesList;
  111103. private _uniformsNames;
  111104. private _samplerList;
  111105. private _samplers;
  111106. private _isReady;
  111107. private _compilationError;
  111108. private _allFallbacksProcessed;
  111109. private _attributesNames;
  111110. private _attributes;
  111111. private _attributeLocationByName;
  111112. private _uniforms;
  111113. /**
  111114. * Key for the effect.
  111115. * @hidden
  111116. */
  111117. _key: string;
  111118. private _indexParameters;
  111119. private _fallbacks;
  111120. private _vertexSourceCode;
  111121. private _fragmentSourceCode;
  111122. private _vertexSourceCodeOverride;
  111123. private _fragmentSourceCodeOverride;
  111124. private _transformFeedbackVaryings;
  111125. /**
  111126. * Compiled shader to webGL program.
  111127. * @hidden
  111128. */
  111129. _pipelineContext: Nullable<IPipelineContext>;
  111130. private _valueCache;
  111131. private static _baseCache;
  111132. /**
  111133. * Instantiates an effect.
  111134. * An effect can be used to create/manage/execute vertex and fragment shaders.
  111135. * @param baseName Name of the effect.
  111136. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  111137. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  111138. * @param samplers List of sampler variables that will be passed to the shader.
  111139. * @param engine Engine to be used to render the effect
  111140. * @param defines Define statements to be added to the shader.
  111141. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  111142. * @param onCompiled Callback that will be called when the shader is compiled.
  111143. * @param onError Callback that will be called if an error occurs during shader compilation.
  111144. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  111145. */
  111146. 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);
  111147. private _useFinalCode;
  111148. /**
  111149. * Unique key for this effect
  111150. */
  111151. get key(): string;
  111152. /**
  111153. * If the effect has been compiled and prepared.
  111154. * @returns if the effect is compiled and prepared.
  111155. */
  111156. isReady(): boolean;
  111157. private _isReadyInternal;
  111158. /**
  111159. * The engine the effect was initialized with.
  111160. * @returns the engine.
  111161. */
  111162. getEngine(): Engine;
  111163. /**
  111164. * The pipeline context for this effect
  111165. * @returns the associated pipeline context
  111166. */
  111167. getPipelineContext(): Nullable<IPipelineContext>;
  111168. /**
  111169. * The set of names of attribute variables for the shader.
  111170. * @returns An array of attribute names.
  111171. */
  111172. getAttributesNames(): string[];
  111173. /**
  111174. * Returns the attribute at the given index.
  111175. * @param index The index of the attribute.
  111176. * @returns The location of the attribute.
  111177. */
  111178. getAttributeLocation(index: number): number;
  111179. /**
  111180. * Returns the attribute based on the name of the variable.
  111181. * @param name of the attribute to look up.
  111182. * @returns the attribute location.
  111183. */
  111184. getAttributeLocationByName(name: string): number;
  111185. /**
  111186. * The number of attributes.
  111187. * @returns the numnber of attributes.
  111188. */
  111189. getAttributesCount(): number;
  111190. /**
  111191. * Gets the index of a uniform variable.
  111192. * @param uniformName of the uniform to look up.
  111193. * @returns the index.
  111194. */
  111195. getUniformIndex(uniformName: string): number;
  111196. /**
  111197. * Returns the attribute based on the name of the variable.
  111198. * @param uniformName of the uniform to look up.
  111199. * @returns the location of the uniform.
  111200. */
  111201. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  111202. /**
  111203. * Returns an array of sampler variable names
  111204. * @returns The array of sampler variable names.
  111205. */
  111206. getSamplers(): string[];
  111207. /**
  111208. * Returns an array of uniform variable names
  111209. * @returns The array of uniform variable names.
  111210. */
  111211. getUniformNames(): string[];
  111212. /**
  111213. * Returns an array of uniform buffer variable names
  111214. * @returns The array of uniform buffer variable names.
  111215. */
  111216. getUniformBuffersNames(): string[];
  111217. /**
  111218. * Returns the index parameters used to create the effect
  111219. * @returns The index parameters object
  111220. */
  111221. getIndexParameters(): any;
  111222. /**
  111223. * The error from the last compilation.
  111224. * @returns the error string.
  111225. */
  111226. getCompilationError(): string;
  111227. /**
  111228. * Gets a boolean indicating that all fallbacks were used during compilation
  111229. * @returns true if all fallbacks were used
  111230. */
  111231. allFallbacksProcessed(): boolean;
  111232. /**
  111233. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  111234. * @param func The callback to be used.
  111235. */
  111236. executeWhenCompiled(func: (effect: Effect) => void): void;
  111237. private _checkIsReady;
  111238. private _loadShader;
  111239. /**
  111240. * Gets the vertex shader source code of this effect
  111241. */
  111242. get vertexSourceCode(): string;
  111243. /**
  111244. * Gets the fragment shader source code of this effect
  111245. */
  111246. get fragmentSourceCode(): string;
  111247. /**
  111248. * Recompiles the webGL program
  111249. * @param vertexSourceCode The source code for the vertex shader.
  111250. * @param fragmentSourceCode The source code for the fragment shader.
  111251. * @param onCompiled Callback called when completed.
  111252. * @param onError Callback called on error.
  111253. * @hidden
  111254. */
  111255. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  111256. /**
  111257. * Prepares the effect
  111258. * @hidden
  111259. */
  111260. _prepareEffect(): void;
  111261. private _getShaderCodeAndErrorLine;
  111262. private _processCompilationErrors;
  111263. /**
  111264. * Checks if the effect is supported. (Must be called after compilation)
  111265. */
  111266. get isSupported(): boolean;
  111267. /**
  111268. * Binds a texture to the engine to be used as output of the shader.
  111269. * @param channel Name of the output variable.
  111270. * @param texture Texture to bind.
  111271. * @hidden
  111272. */
  111273. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  111274. /**
  111275. * Sets a texture on the engine to be used in the shader.
  111276. * @param channel Name of the sampler variable.
  111277. * @param texture Texture to set.
  111278. */
  111279. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  111280. /**
  111281. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  111282. * @param channel Name of the sampler variable.
  111283. * @param texture Texture to set.
  111284. */
  111285. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  111286. /**
  111287. * Sets an array of textures on the engine to be used in the shader.
  111288. * @param channel Name of the variable.
  111289. * @param textures Textures to set.
  111290. */
  111291. setTextureArray(channel: string, textures: BaseTexture[]): void;
  111292. /**
  111293. * 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)
  111294. * @param channel Name of the sampler variable.
  111295. * @param postProcess Post process to get the input texture from.
  111296. */
  111297. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  111298. /**
  111299. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  111300. * 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)
  111301. * @param channel Name of the sampler variable.
  111302. * @param postProcess Post process to get the output texture from.
  111303. */
  111304. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  111305. /** @hidden */
  111306. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  111307. /** @hidden */
  111308. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  111309. /** @hidden */
  111310. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  111311. /** @hidden */
  111312. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  111313. /**
  111314. * Binds a buffer to a uniform.
  111315. * @param buffer Buffer to bind.
  111316. * @param name Name of the uniform variable to bind to.
  111317. */
  111318. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  111319. /**
  111320. * Binds block to a uniform.
  111321. * @param blockName Name of the block to bind.
  111322. * @param index Index to bind.
  111323. */
  111324. bindUniformBlock(blockName: string, index: number): void;
  111325. /**
  111326. * Sets an interger value on a uniform variable.
  111327. * @param uniformName Name of the variable.
  111328. * @param value Value to be set.
  111329. * @returns this effect.
  111330. */
  111331. setInt(uniformName: string, value: number): Effect;
  111332. /**
  111333. * Sets an int array on a uniform variable.
  111334. * @param uniformName Name of the variable.
  111335. * @param array array to be set.
  111336. * @returns this effect.
  111337. */
  111338. setIntArray(uniformName: string, array: Int32Array): Effect;
  111339. /**
  111340. * 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)
  111341. * @param uniformName Name of the variable.
  111342. * @param array array to be set.
  111343. * @returns this effect.
  111344. */
  111345. setIntArray2(uniformName: string, array: Int32Array): Effect;
  111346. /**
  111347. * 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)
  111348. * @param uniformName Name of the variable.
  111349. * @param array array to be set.
  111350. * @returns this effect.
  111351. */
  111352. setIntArray3(uniformName: string, array: Int32Array): Effect;
  111353. /**
  111354. * 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)
  111355. * @param uniformName Name of the variable.
  111356. * @param array array to be set.
  111357. * @returns this effect.
  111358. */
  111359. setIntArray4(uniformName: string, array: Int32Array): Effect;
  111360. /**
  111361. * Sets an float array on a uniform variable.
  111362. * @param uniformName Name of the variable.
  111363. * @param array array to be set.
  111364. * @returns this effect.
  111365. */
  111366. setFloatArray(uniformName: string, array: Float32Array): Effect;
  111367. /**
  111368. * 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)
  111369. * @param uniformName Name of the variable.
  111370. * @param array array to be set.
  111371. * @returns this effect.
  111372. */
  111373. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  111374. /**
  111375. * 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)
  111376. * @param uniformName Name of the variable.
  111377. * @param array array to be set.
  111378. * @returns this effect.
  111379. */
  111380. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  111381. /**
  111382. * 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)
  111383. * @param uniformName Name of the variable.
  111384. * @param array array to be set.
  111385. * @returns this effect.
  111386. */
  111387. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  111388. /**
  111389. * Sets an array on a uniform variable.
  111390. * @param uniformName Name of the variable.
  111391. * @param array array to be set.
  111392. * @returns this effect.
  111393. */
  111394. setArray(uniformName: string, array: number[]): Effect;
  111395. /**
  111396. * 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)
  111397. * @param uniformName Name of the variable.
  111398. * @param array array to be set.
  111399. * @returns this effect.
  111400. */
  111401. setArray2(uniformName: string, array: number[]): Effect;
  111402. /**
  111403. * 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)
  111404. * @param uniformName Name of the variable.
  111405. * @param array array to be set.
  111406. * @returns this effect.
  111407. */
  111408. setArray3(uniformName: string, array: number[]): Effect;
  111409. /**
  111410. * 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)
  111411. * @param uniformName Name of the variable.
  111412. * @param array array to be set.
  111413. * @returns this effect.
  111414. */
  111415. setArray4(uniformName: string, array: number[]): Effect;
  111416. /**
  111417. * Sets matrices on a uniform variable.
  111418. * @param uniformName Name of the variable.
  111419. * @param matrices matrices to be set.
  111420. * @returns this effect.
  111421. */
  111422. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  111423. /**
  111424. * Sets matrix on a uniform variable.
  111425. * @param uniformName Name of the variable.
  111426. * @param matrix matrix to be set.
  111427. * @returns this effect.
  111428. */
  111429. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  111430. /**
  111431. * 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)
  111432. * @param uniformName Name of the variable.
  111433. * @param matrix matrix to be set.
  111434. * @returns this effect.
  111435. */
  111436. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  111437. /**
  111438. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  111439. * @param uniformName Name of the variable.
  111440. * @param matrix matrix to be set.
  111441. * @returns this effect.
  111442. */
  111443. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  111444. /**
  111445. * Sets a float on a uniform variable.
  111446. * @param uniformName Name of the variable.
  111447. * @param value value to be set.
  111448. * @returns this effect.
  111449. */
  111450. setFloat(uniformName: string, value: number): Effect;
  111451. /**
  111452. * Sets a boolean on a uniform variable.
  111453. * @param uniformName Name of the variable.
  111454. * @param bool value to be set.
  111455. * @returns this effect.
  111456. */
  111457. setBool(uniformName: string, bool: boolean): Effect;
  111458. /**
  111459. * Sets a Vector2 on a uniform variable.
  111460. * @param uniformName Name of the variable.
  111461. * @param vector2 vector2 to be set.
  111462. * @returns this effect.
  111463. */
  111464. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  111465. /**
  111466. * Sets a float2 on a uniform variable.
  111467. * @param uniformName Name of the variable.
  111468. * @param x First float in float2.
  111469. * @param y Second float in float2.
  111470. * @returns this effect.
  111471. */
  111472. setFloat2(uniformName: string, x: number, y: number): Effect;
  111473. /**
  111474. * Sets a Vector3 on a uniform variable.
  111475. * @param uniformName Name of the variable.
  111476. * @param vector3 Value to be set.
  111477. * @returns this effect.
  111478. */
  111479. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  111480. /**
  111481. * Sets a float3 on a uniform variable.
  111482. * @param uniformName Name of the variable.
  111483. * @param x First float in float3.
  111484. * @param y Second float in float3.
  111485. * @param z Third float in float3.
  111486. * @returns this effect.
  111487. */
  111488. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  111489. /**
  111490. * Sets a Vector4 on a uniform variable.
  111491. * @param uniformName Name of the variable.
  111492. * @param vector4 Value to be set.
  111493. * @returns this effect.
  111494. */
  111495. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  111496. /**
  111497. * Sets a float4 on a uniform variable.
  111498. * @param uniformName Name of the variable.
  111499. * @param x First float in float4.
  111500. * @param y Second float in float4.
  111501. * @param z Third float in float4.
  111502. * @param w Fourth float in float4.
  111503. * @returns this effect.
  111504. */
  111505. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  111506. /**
  111507. * Sets a Color3 on a uniform variable.
  111508. * @param uniformName Name of the variable.
  111509. * @param color3 Value to be set.
  111510. * @returns this effect.
  111511. */
  111512. setColor3(uniformName: string, color3: IColor3Like): Effect;
  111513. /**
  111514. * Sets a Color4 on a uniform variable.
  111515. * @param uniformName Name of the variable.
  111516. * @param color3 Value to be set.
  111517. * @param alpha Alpha value to be set.
  111518. * @returns this effect.
  111519. */
  111520. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  111521. /**
  111522. * Sets a Color4 on a uniform variable
  111523. * @param uniformName defines the name of the variable
  111524. * @param color4 defines the value to be set
  111525. * @returns this effect.
  111526. */
  111527. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  111528. /** Release all associated resources */
  111529. dispose(): void;
  111530. /**
  111531. * This function will add a new shader to the shader store
  111532. * @param name the name of the shader
  111533. * @param pixelShader optional pixel shader content
  111534. * @param vertexShader optional vertex shader content
  111535. */
  111536. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  111537. /**
  111538. * Store of each shader (The can be looked up using effect.key)
  111539. */
  111540. static ShadersStore: {
  111541. [key: string]: string;
  111542. };
  111543. /**
  111544. * Store of each included file for a shader (The can be looked up using effect.key)
  111545. */
  111546. static IncludesShadersStore: {
  111547. [key: string]: string;
  111548. };
  111549. /**
  111550. * Resets the cache of effects.
  111551. */
  111552. static ResetCache(): void;
  111553. }
  111554. }
  111555. declare module BABYLON {
  111556. /**
  111557. * Interface used to describe the capabilities of the engine relatively to the current browser
  111558. */
  111559. export interface EngineCapabilities {
  111560. /** Maximum textures units per fragment shader */
  111561. maxTexturesImageUnits: number;
  111562. /** Maximum texture units per vertex shader */
  111563. maxVertexTextureImageUnits: number;
  111564. /** Maximum textures units in the entire pipeline */
  111565. maxCombinedTexturesImageUnits: number;
  111566. /** Maximum texture size */
  111567. maxTextureSize: number;
  111568. /** Maximum texture samples */
  111569. maxSamples?: number;
  111570. /** Maximum cube texture size */
  111571. maxCubemapTextureSize: number;
  111572. /** Maximum render texture size */
  111573. maxRenderTextureSize: number;
  111574. /** Maximum number of vertex attributes */
  111575. maxVertexAttribs: number;
  111576. /** Maximum number of varyings */
  111577. maxVaryingVectors: number;
  111578. /** Maximum number of uniforms per vertex shader */
  111579. maxVertexUniformVectors: number;
  111580. /** Maximum number of uniforms per fragment shader */
  111581. maxFragmentUniformVectors: number;
  111582. /** Defines if standard derivates (dx/dy) are supported */
  111583. standardDerivatives: boolean;
  111584. /** Defines if s3tc texture compression is supported */
  111585. s3tc?: WEBGL_compressed_texture_s3tc;
  111586. /** Defines if pvrtc texture compression is supported */
  111587. pvrtc: any;
  111588. /** Defines if etc1 texture compression is supported */
  111589. etc1: any;
  111590. /** Defines if etc2 texture compression is supported */
  111591. etc2: any;
  111592. /** Defines if astc texture compression is supported */
  111593. astc: any;
  111594. /** Defines if float textures are supported */
  111595. textureFloat: boolean;
  111596. /** Defines if vertex array objects are supported */
  111597. vertexArrayObject: boolean;
  111598. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  111599. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  111600. /** Gets the maximum level of anisotropy supported */
  111601. maxAnisotropy: number;
  111602. /** Defines if instancing is supported */
  111603. instancedArrays: boolean;
  111604. /** Defines if 32 bits indices are supported */
  111605. uintIndices: boolean;
  111606. /** Defines if high precision shaders are supported */
  111607. highPrecisionShaderSupported: boolean;
  111608. /** Defines if depth reading in the fragment shader is supported */
  111609. fragmentDepthSupported: boolean;
  111610. /** Defines if float texture linear filtering is supported*/
  111611. textureFloatLinearFiltering: boolean;
  111612. /** Defines if rendering to float textures is supported */
  111613. textureFloatRender: boolean;
  111614. /** Defines if half float textures are supported*/
  111615. textureHalfFloat: boolean;
  111616. /** Defines if half float texture linear filtering is supported*/
  111617. textureHalfFloatLinearFiltering: boolean;
  111618. /** Defines if rendering to half float textures is supported */
  111619. textureHalfFloatRender: boolean;
  111620. /** Defines if textureLOD shader command is supported */
  111621. textureLOD: boolean;
  111622. /** Defines if draw buffers extension is supported */
  111623. drawBuffersExtension: boolean;
  111624. /** Defines if depth textures are supported */
  111625. depthTextureExtension: boolean;
  111626. /** Defines if float color buffer are supported */
  111627. colorBufferFloat: boolean;
  111628. /** Gets disjoint timer query extension (null if not supported) */
  111629. timerQuery?: EXT_disjoint_timer_query;
  111630. /** Defines if timestamp can be used with timer query */
  111631. canUseTimestampForTimerQuery: boolean;
  111632. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  111633. multiview?: any;
  111634. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  111635. oculusMultiview?: any;
  111636. /** Function used to let the system compiles shaders in background */
  111637. parallelShaderCompile?: {
  111638. COMPLETION_STATUS_KHR: number;
  111639. };
  111640. /** Max number of texture samples for MSAA */
  111641. maxMSAASamples: number;
  111642. /** Defines if the blend min max extension is supported */
  111643. blendMinMax: boolean;
  111644. }
  111645. }
  111646. declare module BABYLON {
  111647. /**
  111648. * @hidden
  111649. **/
  111650. export class DepthCullingState {
  111651. private _isDepthTestDirty;
  111652. private _isDepthMaskDirty;
  111653. private _isDepthFuncDirty;
  111654. private _isCullFaceDirty;
  111655. private _isCullDirty;
  111656. private _isZOffsetDirty;
  111657. private _isFrontFaceDirty;
  111658. private _depthTest;
  111659. private _depthMask;
  111660. private _depthFunc;
  111661. private _cull;
  111662. private _cullFace;
  111663. private _zOffset;
  111664. private _frontFace;
  111665. /**
  111666. * Initializes the state.
  111667. */
  111668. constructor();
  111669. get isDirty(): boolean;
  111670. get zOffset(): number;
  111671. set zOffset(value: number);
  111672. get cullFace(): Nullable<number>;
  111673. set cullFace(value: Nullable<number>);
  111674. get cull(): Nullable<boolean>;
  111675. set cull(value: Nullable<boolean>);
  111676. get depthFunc(): Nullable<number>;
  111677. set depthFunc(value: Nullable<number>);
  111678. get depthMask(): boolean;
  111679. set depthMask(value: boolean);
  111680. get depthTest(): boolean;
  111681. set depthTest(value: boolean);
  111682. get frontFace(): Nullable<number>;
  111683. set frontFace(value: Nullable<number>);
  111684. reset(): void;
  111685. apply(gl: WebGLRenderingContext): void;
  111686. }
  111687. }
  111688. declare module BABYLON {
  111689. /**
  111690. * @hidden
  111691. **/
  111692. export class StencilState {
  111693. /** 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 */
  111694. static readonly ALWAYS: number;
  111695. /** Passed to stencilOperation to specify that stencil value must be kept */
  111696. static readonly KEEP: number;
  111697. /** Passed to stencilOperation to specify that stencil value must be replaced */
  111698. static readonly REPLACE: number;
  111699. private _isStencilTestDirty;
  111700. private _isStencilMaskDirty;
  111701. private _isStencilFuncDirty;
  111702. private _isStencilOpDirty;
  111703. private _stencilTest;
  111704. private _stencilMask;
  111705. private _stencilFunc;
  111706. private _stencilFuncRef;
  111707. private _stencilFuncMask;
  111708. private _stencilOpStencilFail;
  111709. private _stencilOpDepthFail;
  111710. private _stencilOpStencilDepthPass;
  111711. get isDirty(): boolean;
  111712. get stencilFunc(): number;
  111713. set stencilFunc(value: number);
  111714. get stencilFuncRef(): number;
  111715. set stencilFuncRef(value: number);
  111716. get stencilFuncMask(): number;
  111717. set stencilFuncMask(value: number);
  111718. get stencilOpStencilFail(): number;
  111719. set stencilOpStencilFail(value: number);
  111720. get stencilOpDepthFail(): number;
  111721. set stencilOpDepthFail(value: number);
  111722. get stencilOpStencilDepthPass(): number;
  111723. set stencilOpStencilDepthPass(value: number);
  111724. get stencilMask(): number;
  111725. set stencilMask(value: number);
  111726. get stencilTest(): boolean;
  111727. set stencilTest(value: boolean);
  111728. constructor();
  111729. reset(): void;
  111730. apply(gl: WebGLRenderingContext): void;
  111731. }
  111732. }
  111733. declare module BABYLON {
  111734. /**
  111735. * @hidden
  111736. **/
  111737. export class AlphaState {
  111738. private _isAlphaBlendDirty;
  111739. private _isBlendFunctionParametersDirty;
  111740. private _isBlendEquationParametersDirty;
  111741. private _isBlendConstantsDirty;
  111742. private _alphaBlend;
  111743. private _blendFunctionParameters;
  111744. private _blendEquationParameters;
  111745. private _blendConstants;
  111746. /**
  111747. * Initializes the state.
  111748. */
  111749. constructor();
  111750. get isDirty(): boolean;
  111751. get alphaBlend(): boolean;
  111752. set alphaBlend(value: boolean);
  111753. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  111754. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  111755. setAlphaEquationParameters(rgb: number, alpha: number): void;
  111756. reset(): void;
  111757. apply(gl: WebGLRenderingContext): void;
  111758. }
  111759. }
  111760. declare module BABYLON {
  111761. /** @hidden */
  111762. export class WebGL2ShaderProcessor implements IShaderProcessor {
  111763. attributeProcessor(attribute: string): string;
  111764. varyingProcessor(varying: string, isFragment: boolean): string;
  111765. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  111766. }
  111767. }
  111768. declare module BABYLON {
  111769. /**
  111770. * Interface for attribute information associated with buffer instanciation
  111771. */
  111772. export interface InstancingAttributeInfo {
  111773. /**
  111774. * Name of the GLSL attribute
  111775. * if attribute index is not specified, this is used to retrieve the index from the effect
  111776. */
  111777. attributeName: string;
  111778. /**
  111779. * Index/offset of the attribute in the vertex shader
  111780. * if not specified, this will be computes from the name.
  111781. */
  111782. index?: number;
  111783. /**
  111784. * size of the attribute, 1, 2, 3 or 4
  111785. */
  111786. attributeSize: number;
  111787. /**
  111788. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  111789. */
  111790. offset: number;
  111791. /**
  111792. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  111793. * default to 1
  111794. */
  111795. divisor?: number;
  111796. /**
  111797. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  111798. * default is FLOAT
  111799. */
  111800. attributeType?: number;
  111801. /**
  111802. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  111803. */
  111804. normalized?: boolean;
  111805. }
  111806. }
  111807. declare module BABYLON {
  111808. interface ThinEngine {
  111809. /**
  111810. * Update a video texture
  111811. * @param texture defines the texture to update
  111812. * @param video defines the video element to use
  111813. * @param invertY defines if data must be stored with Y axis inverted
  111814. */
  111815. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  111816. }
  111817. }
  111818. declare module BABYLON {
  111819. /**
  111820. * Settings for finer control over video usage
  111821. */
  111822. export interface VideoTextureSettings {
  111823. /**
  111824. * Applies `autoplay` to video, if specified
  111825. */
  111826. autoPlay?: boolean;
  111827. /**
  111828. * Applies `loop` to video, if specified
  111829. */
  111830. loop?: boolean;
  111831. /**
  111832. * Automatically updates internal texture from video at every frame in the render loop
  111833. */
  111834. autoUpdateTexture: boolean;
  111835. /**
  111836. * Image src displayed during the video loading or until the user interacts with the video.
  111837. */
  111838. poster?: string;
  111839. }
  111840. /**
  111841. * If you want to display a video in your scene, this is the special texture for that.
  111842. * This special texture works similar to other textures, with the exception of a few parameters.
  111843. * @see https://doc.babylonjs.com/how_to/video_texture
  111844. */
  111845. export class VideoTexture extends Texture {
  111846. /**
  111847. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  111848. */
  111849. readonly autoUpdateTexture: boolean;
  111850. /**
  111851. * The video instance used by the texture internally
  111852. */
  111853. readonly video: HTMLVideoElement;
  111854. private _onUserActionRequestedObservable;
  111855. /**
  111856. * Event triggerd when a dom action is required by the user to play the video.
  111857. * This happens due to recent changes in browser policies preventing video to auto start.
  111858. */
  111859. get onUserActionRequestedObservable(): Observable<Texture>;
  111860. private _generateMipMaps;
  111861. private _stillImageCaptured;
  111862. private _displayingPosterTexture;
  111863. private _settings;
  111864. private _createInternalTextureOnEvent;
  111865. private _frameId;
  111866. private _currentSrc;
  111867. /**
  111868. * Creates a video texture.
  111869. * If you want to display a video in your scene, this is the special texture for that.
  111870. * This special texture works similar to other textures, with the exception of a few parameters.
  111871. * @see https://doc.babylonjs.com/how_to/video_texture
  111872. * @param name optional name, will detect from video source, if not defined
  111873. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  111874. * @param scene is obviously the current scene.
  111875. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  111876. * @param invertY is false by default but can be used to invert video on Y axis
  111877. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  111878. * @param settings allows finer control over video usage
  111879. */
  111880. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  111881. private _getName;
  111882. private _getVideo;
  111883. private _createInternalTexture;
  111884. private reset;
  111885. /**
  111886. * @hidden Internal method to initiate `update`.
  111887. */
  111888. _rebuild(): void;
  111889. /**
  111890. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  111891. */
  111892. update(): void;
  111893. /**
  111894. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  111895. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  111896. */
  111897. updateTexture(isVisible: boolean): void;
  111898. protected _updateInternalTexture: () => void;
  111899. /**
  111900. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  111901. * @param url New url.
  111902. */
  111903. updateURL(url: string): void;
  111904. /**
  111905. * Clones the texture.
  111906. * @returns the cloned texture
  111907. */
  111908. clone(): VideoTexture;
  111909. /**
  111910. * Dispose the texture and release its associated resources.
  111911. */
  111912. dispose(): void;
  111913. /**
  111914. * Creates a video texture straight from a stream.
  111915. * @param scene Define the scene the texture should be created in
  111916. * @param stream Define the stream the texture should be created from
  111917. * @returns The created video texture as a promise
  111918. */
  111919. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  111920. /**
  111921. * Creates a video texture straight from your WebCam video feed.
  111922. * @param scene Define the scene the texture should be created in
  111923. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  111924. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  111925. * @returns The created video texture as a promise
  111926. */
  111927. static CreateFromWebCamAsync(scene: Scene, constraints: {
  111928. minWidth: number;
  111929. maxWidth: number;
  111930. minHeight: number;
  111931. maxHeight: number;
  111932. deviceId: string;
  111933. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  111934. /**
  111935. * Creates a video texture straight from your WebCam video feed.
  111936. * @param scene Define the scene the texture should be created in
  111937. * @param onReady Define a callback to triggered once the texture will be ready
  111938. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  111939. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  111940. */
  111941. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  111942. minWidth: number;
  111943. maxWidth: number;
  111944. minHeight: number;
  111945. maxHeight: number;
  111946. deviceId: string;
  111947. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  111948. }
  111949. }
  111950. declare module BABYLON {
  111951. /**
  111952. * Defines the interface used by objects working like Scene
  111953. * @hidden
  111954. */
  111955. export interface ISceneLike {
  111956. _addPendingData(data: any): void;
  111957. _removePendingData(data: any): void;
  111958. offlineProvider: IOfflineProvider;
  111959. }
  111960. /** Interface defining initialization parameters for Engine class */
  111961. export interface EngineOptions extends WebGLContextAttributes {
  111962. /**
  111963. * Defines if the engine should no exceed a specified device ratio
  111964. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  111965. */
  111966. limitDeviceRatio?: number;
  111967. /**
  111968. * Defines if webvr should be enabled automatically
  111969. * @see http://doc.babylonjs.com/how_to/webvr_camera
  111970. */
  111971. autoEnableWebVR?: boolean;
  111972. /**
  111973. * Defines if webgl2 should be turned off even if supported
  111974. * @see http://doc.babylonjs.com/features/webgl2
  111975. */
  111976. disableWebGL2Support?: boolean;
  111977. /**
  111978. * Defines if webaudio should be initialized as well
  111979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111980. */
  111981. audioEngine?: boolean;
  111982. /**
  111983. * Defines if animations should run using a deterministic lock step
  111984. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111985. */
  111986. deterministicLockstep?: boolean;
  111987. /** Defines the maximum steps to use with deterministic lock step mode */
  111988. lockstepMaxSteps?: number;
  111989. /** Defines the seconds between each deterministic lock step */
  111990. timeStep?: number;
  111991. /**
  111992. * Defines that engine should ignore context lost events
  111993. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  111994. */
  111995. doNotHandleContextLost?: boolean;
  111996. /**
  111997. * Defines that engine should ignore modifying touch action attribute and style
  111998. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  111999. */
  112000. doNotHandleTouchAction?: boolean;
  112001. /**
  112002. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  112003. */
  112004. useHighPrecisionFloats?: boolean;
  112005. /**
  112006. * Make the canvas XR Compatible for XR sessions
  112007. */
  112008. xrCompatible?: boolean;
  112009. }
  112010. /**
  112011. * The base engine class (root of all engines)
  112012. */
  112013. export class ThinEngine {
  112014. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  112015. static ExceptionList: ({
  112016. key: string;
  112017. capture: string;
  112018. captureConstraint: number;
  112019. targets: string[];
  112020. } | {
  112021. key: string;
  112022. capture: null;
  112023. captureConstraint: null;
  112024. targets: string[];
  112025. })[];
  112026. /** @hidden */
  112027. static _TextureLoaders: IInternalTextureLoader[];
  112028. /**
  112029. * Returns the current npm package of the sdk
  112030. */
  112031. static get NpmPackage(): string;
  112032. /**
  112033. * Returns the current version of the framework
  112034. */
  112035. static get Version(): string;
  112036. /**
  112037. * Returns a string describing the current engine
  112038. */
  112039. get description(): string;
  112040. /**
  112041. * Gets or sets the epsilon value used by collision engine
  112042. */
  112043. static CollisionsEpsilon: number;
  112044. /**
  112045. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  112046. */
  112047. static get ShadersRepository(): string;
  112048. static set ShadersRepository(value: string);
  112049. /** @hidden */
  112050. _shaderProcessor: IShaderProcessor;
  112051. /**
  112052. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  112053. */
  112054. forcePOTTextures: boolean;
  112055. /**
  112056. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  112057. */
  112058. isFullscreen: boolean;
  112059. /**
  112060. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  112061. */
  112062. cullBackFaces: boolean;
  112063. /**
  112064. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  112065. */
  112066. renderEvenInBackground: boolean;
  112067. /**
  112068. * Gets or sets a boolean indicating that cache can be kept between frames
  112069. */
  112070. preventCacheWipeBetweenFrames: boolean;
  112071. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  112072. validateShaderPrograms: boolean;
  112073. /**
  112074. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  112075. * This can provide greater z depth for distant objects.
  112076. */
  112077. useReverseDepthBuffer: boolean;
  112078. /**
  112079. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  112080. */
  112081. disableUniformBuffers: boolean;
  112082. /** @hidden */
  112083. _uniformBuffers: UniformBuffer[];
  112084. /**
  112085. * Gets a boolean indicating that the engine supports uniform buffers
  112086. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  112087. */
  112088. get supportsUniformBuffers(): boolean;
  112089. /** @hidden */
  112090. _gl: WebGLRenderingContext;
  112091. /** @hidden */
  112092. _webGLVersion: number;
  112093. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  112094. protected _windowIsBackground: boolean;
  112095. protected _creationOptions: EngineOptions;
  112096. protected _highPrecisionShadersAllowed: boolean;
  112097. /** @hidden */
  112098. get _shouldUseHighPrecisionShader(): boolean;
  112099. /**
  112100. * Gets a boolean indicating that only power of 2 textures are supported
  112101. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  112102. */
  112103. get needPOTTextures(): boolean;
  112104. /** @hidden */
  112105. _badOS: boolean;
  112106. /** @hidden */
  112107. _badDesktopOS: boolean;
  112108. private _hardwareScalingLevel;
  112109. /** @hidden */
  112110. _caps: EngineCapabilities;
  112111. private _isStencilEnable;
  112112. private _glVersion;
  112113. private _glRenderer;
  112114. private _glVendor;
  112115. /** @hidden */
  112116. _videoTextureSupported: boolean;
  112117. protected _renderingQueueLaunched: boolean;
  112118. protected _activeRenderLoops: (() => void)[];
  112119. /**
  112120. * Observable signaled when a context lost event is raised
  112121. */
  112122. onContextLostObservable: Observable<ThinEngine>;
  112123. /**
  112124. * Observable signaled when a context restored event is raised
  112125. */
  112126. onContextRestoredObservable: Observable<ThinEngine>;
  112127. private _onContextLost;
  112128. private _onContextRestored;
  112129. protected _contextWasLost: boolean;
  112130. /** @hidden */
  112131. _doNotHandleContextLost: boolean;
  112132. /**
  112133. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  112134. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  112135. */
  112136. get doNotHandleContextLost(): boolean;
  112137. set doNotHandleContextLost(value: boolean);
  112138. /**
  112139. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  112140. */
  112141. disableVertexArrayObjects: boolean;
  112142. /** @hidden */
  112143. protected _colorWrite: boolean;
  112144. /** @hidden */
  112145. protected _colorWriteChanged: boolean;
  112146. /** @hidden */
  112147. protected _depthCullingState: DepthCullingState;
  112148. /** @hidden */
  112149. protected _stencilState: StencilState;
  112150. /** @hidden */
  112151. _alphaState: AlphaState;
  112152. /** @hidden */
  112153. _alphaMode: number;
  112154. /** @hidden */
  112155. _alphaEquation: number;
  112156. /** @hidden */
  112157. _internalTexturesCache: InternalTexture[];
  112158. /** @hidden */
  112159. protected _activeChannel: number;
  112160. private _currentTextureChannel;
  112161. /** @hidden */
  112162. protected _boundTexturesCache: {
  112163. [key: string]: Nullable<InternalTexture>;
  112164. };
  112165. /** @hidden */
  112166. protected _currentEffect: Nullable<Effect>;
  112167. /** @hidden */
  112168. protected _currentProgram: Nullable<WebGLProgram>;
  112169. private _compiledEffects;
  112170. private _vertexAttribArraysEnabled;
  112171. /** @hidden */
  112172. protected _cachedViewport: Nullable<IViewportLike>;
  112173. private _cachedVertexArrayObject;
  112174. /** @hidden */
  112175. protected _cachedVertexBuffers: any;
  112176. /** @hidden */
  112177. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  112178. /** @hidden */
  112179. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  112180. /** @hidden */
  112181. _currentRenderTarget: Nullable<InternalTexture>;
  112182. private _uintIndicesCurrentlySet;
  112183. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  112184. /** @hidden */
  112185. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  112186. /** @hidden */
  112187. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  112188. private _currentBufferPointers;
  112189. private _currentInstanceLocations;
  112190. private _currentInstanceBuffers;
  112191. private _textureUnits;
  112192. /** @hidden */
  112193. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  112194. /** @hidden */
  112195. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  112196. /** @hidden */
  112197. _boundRenderFunction: any;
  112198. private _vaoRecordInProgress;
  112199. private _mustWipeVertexAttributes;
  112200. private _emptyTexture;
  112201. private _emptyCubeTexture;
  112202. private _emptyTexture3D;
  112203. private _emptyTexture2DArray;
  112204. /** @hidden */
  112205. _frameHandler: number;
  112206. private _nextFreeTextureSlots;
  112207. private _maxSimultaneousTextures;
  112208. private _activeRequests;
  112209. /** @hidden */
  112210. _transformTextureUrl: Nullable<(url: string) => string>;
  112211. protected get _supportsHardwareTextureRescaling(): boolean;
  112212. private _framebufferDimensionsObject;
  112213. /**
  112214. * sets the object from which width and height will be taken from when getting render width and height
  112215. * Will fallback to the gl object
  112216. * @param dimensions the framebuffer width and height that will be used.
  112217. */
  112218. set framebufferDimensionsObject(dimensions: Nullable<{
  112219. framebufferWidth: number;
  112220. framebufferHeight: number;
  112221. }>);
  112222. /**
  112223. * Gets the current viewport
  112224. */
  112225. get currentViewport(): Nullable<IViewportLike>;
  112226. /**
  112227. * Gets the default empty texture
  112228. */
  112229. get emptyTexture(): InternalTexture;
  112230. /**
  112231. * Gets the default empty 3D texture
  112232. */
  112233. get emptyTexture3D(): InternalTexture;
  112234. /**
  112235. * Gets the default empty 2D array texture
  112236. */
  112237. get emptyTexture2DArray(): InternalTexture;
  112238. /**
  112239. * Gets the default empty cube texture
  112240. */
  112241. get emptyCubeTexture(): InternalTexture;
  112242. /**
  112243. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  112244. */
  112245. readonly premultipliedAlpha: boolean;
  112246. /**
  112247. * Observable event triggered before each texture is initialized
  112248. */
  112249. onBeforeTextureInitObservable: Observable<Texture>;
  112250. /**
  112251. * Creates a new engine
  112252. * @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
  112253. * @param antialias defines enable antialiasing (default: false)
  112254. * @param options defines further options to be sent to the getContext() function
  112255. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  112256. */
  112257. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  112258. private _rebuildInternalTextures;
  112259. private _rebuildEffects;
  112260. /**
  112261. * Gets a boolean indicating if all created effects are ready
  112262. * @returns true if all effects are ready
  112263. */
  112264. areAllEffectsReady(): boolean;
  112265. protected _rebuildBuffers(): void;
  112266. protected _initGLContext(): void;
  112267. /**
  112268. * Gets version of the current webGL context
  112269. */
  112270. get webGLVersion(): number;
  112271. /**
  112272. * Gets a string idenfifying the name of the class
  112273. * @returns "Engine" string
  112274. */
  112275. getClassName(): string;
  112276. /**
  112277. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  112278. */
  112279. get isStencilEnable(): boolean;
  112280. /** @hidden */
  112281. _prepareWorkingCanvas(): void;
  112282. /**
  112283. * Reset the texture cache to empty state
  112284. */
  112285. resetTextureCache(): void;
  112286. /**
  112287. * Gets an object containing information about the current webGL context
  112288. * @returns an object containing the vender, the renderer and the version of the current webGL context
  112289. */
  112290. getGlInfo(): {
  112291. vendor: string;
  112292. renderer: string;
  112293. version: string;
  112294. };
  112295. /**
  112296. * Defines the hardware scaling level.
  112297. * By default the hardware scaling level is computed from the window device ratio.
  112298. * 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.
  112299. * @param level defines the level to use
  112300. */
  112301. setHardwareScalingLevel(level: number): void;
  112302. /**
  112303. * Gets the current hardware scaling level.
  112304. * By default the hardware scaling level is computed from the window device ratio.
  112305. * 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.
  112306. * @returns a number indicating the current hardware scaling level
  112307. */
  112308. getHardwareScalingLevel(): number;
  112309. /**
  112310. * Gets the list of loaded textures
  112311. * @returns an array containing all loaded textures
  112312. */
  112313. getLoadedTexturesCache(): InternalTexture[];
  112314. /**
  112315. * Gets the object containing all engine capabilities
  112316. * @returns the EngineCapabilities object
  112317. */
  112318. getCaps(): EngineCapabilities;
  112319. /**
  112320. * stop executing a render loop function and remove it from the execution array
  112321. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  112322. */
  112323. stopRenderLoop(renderFunction?: () => void): void;
  112324. /** @hidden */
  112325. _renderLoop(): void;
  112326. /**
  112327. * Gets the HTML canvas attached with the current webGL context
  112328. * @returns a HTML canvas
  112329. */
  112330. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  112331. /**
  112332. * Gets host window
  112333. * @returns the host window object
  112334. */
  112335. getHostWindow(): Nullable<Window>;
  112336. /**
  112337. * Gets the current render width
  112338. * @param useScreen defines if screen size must be used (or the current render target if any)
  112339. * @returns a number defining the current render width
  112340. */
  112341. getRenderWidth(useScreen?: boolean): number;
  112342. /**
  112343. * Gets the current render height
  112344. * @param useScreen defines if screen size must be used (or the current render target if any)
  112345. * @returns a number defining the current render height
  112346. */
  112347. getRenderHeight(useScreen?: boolean): number;
  112348. /**
  112349. * Can be used to override the current requestAnimationFrame requester.
  112350. * @hidden
  112351. */
  112352. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  112353. /**
  112354. * Register and execute a render loop. The engine can have more than one render function
  112355. * @param renderFunction defines the function to continuously execute
  112356. */
  112357. runRenderLoop(renderFunction: () => void): void;
  112358. /**
  112359. * Clear the current render buffer or the current render target (if any is set up)
  112360. * @param color defines the color to use
  112361. * @param backBuffer defines if the back buffer must be cleared
  112362. * @param depth defines if the depth buffer must be cleared
  112363. * @param stencil defines if the stencil buffer must be cleared
  112364. */
  112365. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112366. private _viewportCached;
  112367. /** @hidden */
  112368. _viewport(x: number, y: number, width: number, height: number): void;
  112369. /**
  112370. * Set the WebGL's viewport
  112371. * @param viewport defines the viewport element to be used
  112372. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  112373. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  112374. */
  112375. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  112376. /**
  112377. * Begin a new frame
  112378. */
  112379. beginFrame(): void;
  112380. /**
  112381. * Enf the current frame
  112382. */
  112383. endFrame(): void;
  112384. /**
  112385. * Resize the view according to the canvas' size
  112386. */
  112387. resize(): void;
  112388. /**
  112389. * Force a specific size of the canvas
  112390. * @param width defines the new canvas' width
  112391. * @param height defines the new canvas' height
  112392. */
  112393. setSize(width: number, height: number): void;
  112394. /**
  112395. * Binds the frame buffer to the specified texture.
  112396. * @param texture The texture to render to or null for the default canvas
  112397. * @param faceIndex The face of the texture to render to in case of cube texture
  112398. * @param requiredWidth The width of the target to render to
  112399. * @param requiredHeight The height of the target to render to
  112400. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  112401. * @param lodLevel defines the lod level to bind to the frame buffer
  112402. * @param layer defines the 2d array index to bind to frame buffer to
  112403. */
  112404. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  112405. /** @hidden */
  112406. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  112407. /**
  112408. * Unbind the current render target texture from the webGL context
  112409. * @param texture defines the render target texture to unbind
  112410. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112411. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112412. */
  112413. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112414. /**
  112415. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  112416. */
  112417. flushFramebuffer(): void;
  112418. /**
  112419. * Unbind the current render target and bind the default framebuffer
  112420. */
  112421. restoreDefaultFramebuffer(): void;
  112422. /** @hidden */
  112423. protected _resetVertexBufferBinding(): void;
  112424. /**
  112425. * Creates a vertex buffer
  112426. * @param data the data for the vertex buffer
  112427. * @returns the new WebGL static buffer
  112428. */
  112429. createVertexBuffer(data: DataArray): DataBuffer;
  112430. private _createVertexBuffer;
  112431. /**
  112432. * Creates a dynamic vertex buffer
  112433. * @param data the data for the dynamic vertex buffer
  112434. * @returns the new WebGL dynamic buffer
  112435. */
  112436. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  112437. protected _resetIndexBufferBinding(): void;
  112438. /**
  112439. * Creates a new index buffer
  112440. * @param indices defines the content of the index buffer
  112441. * @param updatable defines if the index buffer must be updatable
  112442. * @returns a new webGL buffer
  112443. */
  112444. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  112445. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  112446. /**
  112447. * Bind a webGL buffer to the webGL context
  112448. * @param buffer defines the buffer to bind
  112449. */
  112450. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  112451. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  112452. private bindBuffer;
  112453. /**
  112454. * update the bound buffer with the given data
  112455. * @param data defines the data to update
  112456. */
  112457. updateArrayBuffer(data: Float32Array): void;
  112458. private _vertexAttribPointer;
  112459. /** @hidden */
  112460. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  112461. private _bindVertexBuffersAttributes;
  112462. /**
  112463. * Records a vertex array object
  112464. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  112465. * @param vertexBuffers defines the list of vertex buffers to store
  112466. * @param indexBuffer defines the index buffer to store
  112467. * @param effect defines the effect to store
  112468. * @returns the new vertex array object
  112469. */
  112470. recordVertexArrayObject(vertexBuffers: {
  112471. [key: string]: VertexBuffer;
  112472. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  112473. /**
  112474. * Bind a specific vertex array object
  112475. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  112476. * @param vertexArrayObject defines the vertex array object to bind
  112477. * @param indexBuffer defines the index buffer to bind
  112478. */
  112479. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  112480. /**
  112481. * Bind webGl buffers directly to the webGL context
  112482. * @param vertexBuffer defines the vertex buffer to bind
  112483. * @param indexBuffer defines the index buffer to bind
  112484. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  112485. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  112486. * @param effect defines the effect associated with the vertex buffer
  112487. */
  112488. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  112489. private _unbindVertexArrayObject;
  112490. /**
  112491. * Bind a list of vertex buffers to the webGL context
  112492. * @param vertexBuffers defines the list of vertex buffers to bind
  112493. * @param indexBuffer defines the index buffer to bind
  112494. * @param effect defines the effect associated with the vertex buffers
  112495. */
  112496. bindBuffers(vertexBuffers: {
  112497. [key: string]: Nullable<VertexBuffer>;
  112498. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  112499. /**
  112500. * Unbind all instance attributes
  112501. */
  112502. unbindInstanceAttributes(): void;
  112503. /**
  112504. * Release and free the memory of a vertex array object
  112505. * @param vao defines the vertex array object to delete
  112506. */
  112507. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  112508. /** @hidden */
  112509. _releaseBuffer(buffer: DataBuffer): boolean;
  112510. protected _deleteBuffer(buffer: DataBuffer): void;
  112511. /**
  112512. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  112513. * @param instancesBuffer defines the webGL buffer to update and bind
  112514. * @param data defines the data to store in the buffer
  112515. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  112516. */
  112517. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  112518. /**
  112519. * Bind the content of a webGL buffer used with instantiation
  112520. * @param instancesBuffer defines the webGL buffer to bind
  112521. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  112522. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  112523. */
  112524. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  112525. /**
  112526. * Disable the instance attribute corresponding to the name in parameter
  112527. * @param name defines the name of the attribute to disable
  112528. */
  112529. disableInstanceAttributeByName(name: string): void;
  112530. /**
  112531. * Disable the instance attribute corresponding to the location in parameter
  112532. * @param attributeLocation defines the attribute location of the attribute to disable
  112533. */
  112534. disableInstanceAttribute(attributeLocation: number): void;
  112535. /**
  112536. * Disable the attribute corresponding to the location in parameter
  112537. * @param attributeLocation defines the attribute location of the attribute to disable
  112538. */
  112539. disableAttributeByIndex(attributeLocation: number): void;
  112540. /**
  112541. * Send a draw order
  112542. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  112543. * @param indexStart defines the starting index
  112544. * @param indexCount defines the number of index to draw
  112545. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112546. */
  112547. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  112548. /**
  112549. * Draw a list of points
  112550. * @param verticesStart defines the index of first vertex to draw
  112551. * @param verticesCount defines the count of vertices to draw
  112552. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112553. */
  112554. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112555. /**
  112556. * Draw a list of unindexed primitives
  112557. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  112558. * @param verticesStart defines the index of first vertex to draw
  112559. * @param verticesCount defines the count of vertices to draw
  112560. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112561. */
  112562. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112563. /**
  112564. * Draw a list of indexed primitives
  112565. * @param fillMode defines the primitive to use
  112566. * @param indexStart defines the starting index
  112567. * @param indexCount defines the number of index to draw
  112568. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112569. */
  112570. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112571. /**
  112572. * Draw a list of unindexed primitives
  112573. * @param fillMode defines the primitive to use
  112574. * @param verticesStart defines the index of first vertex to draw
  112575. * @param verticesCount defines the count of vertices to draw
  112576. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112577. */
  112578. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112579. private _drawMode;
  112580. /** @hidden */
  112581. protected _reportDrawCall(): void;
  112582. /** @hidden */
  112583. _releaseEffect(effect: Effect): void;
  112584. /** @hidden */
  112585. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  112586. /**
  112587. * Create a new effect (used to store vertex/fragment shaders)
  112588. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  112589. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  112590. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  112591. * @param samplers defines an array of string used to represent textures
  112592. * @param defines defines the string containing the defines to use to compile the shaders
  112593. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  112594. * @param onCompiled defines a function to call when the effect creation is successful
  112595. * @param onError defines a function to call when the effect creation has failed
  112596. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  112597. * @returns the new Effect
  112598. */
  112599. 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;
  112600. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  112601. private _compileShader;
  112602. private _compileRawShader;
  112603. /** @hidden */
  112604. _getShaderSource(shader: WebGLShader): Nullable<string>;
  112605. /**
  112606. * Directly creates a webGL program
  112607. * @param pipelineContext defines the pipeline context to attach to
  112608. * @param vertexCode defines the vertex shader code to use
  112609. * @param fragmentCode defines the fragment shader code to use
  112610. * @param context defines the webGL context to use (if not set, the current one will be used)
  112611. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  112612. * @returns the new webGL program
  112613. */
  112614. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  112615. /**
  112616. * Creates a webGL program
  112617. * @param pipelineContext defines the pipeline context to attach to
  112618. * @param vertexCode defines the vertex shader code to use
  112619. * @param fragmentCode defines the fragment shader code to use
  112620. * @param defines defines the string containing the defines to use to compile the shaders
  112621. * @param context defines the webGL context to use (if not set, the current one will be used)
  112622. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  112623. * @returns the new webGL program
  112624. */
  112625. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  112626. /**
  112627. * Creates a new pipeline context
  112628. * @returns the new pipeline
  112629. */
  112630. createPipelineContext(): IPipelineContext;
  112631. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  112632. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  112633. /** @hidden */
  112634. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  112635. /** @hidden */
  112636. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  112637. /** @hidden */
  112638. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  112639. /**
  112640. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  112641. * @param pipelineContext defines the pipeline context to use
  112642. * @param uniformsNames defines the list of uniform names
  112643. * @returns an array of webGL uniform locations
  112644. */
  112645. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  112646. /**
  112647. * Gets the lsit of active attributes for a given webGL program
  112648. * @param pipelineContext defines the pipeline context to use
  112649. * @param attributesNames defines the list of attribute names to get
  112650. * @returns an array of indices indicating the offset of each attribute
  112651. */
  112652. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112653. /**
  112654. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  112655. * @param effect defines the effect to activate
  112656. */
  112657. enableEffect(effect: Nullable<Effect>): void;
  112658. /**
  112659. * Set the value of an uniform to a number (int)
  112660. * @param uniform defines the webGL uniform location where to store the value
  112661. * @param value defines the int number to store
  112662. */
  112663. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  112664. /**
  112665. * Set the value of an uniform to an array of int32
  112666. * @param uniform defines the webGL uniform location where to store the value
  112667. * @param array defines the array of int32 to store
  112668. */
  112669. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112670. /**
  112671. * Set the value of an uniform to an array of int32 (stored as vec2)
  112672. * @param uniform defines the webGL uniform location where to store the value
  112673. * @param array defines the array of int32 to store
  112674. */
  112675. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112676. /**
  112677. * Set the value of an uniform to an array of int32 (stored as vec3)
  112678. * @param uniform defines the webGL uniform location where to store the value
  112679. * @param array defines the array of int32 to store
  112680. */
  112681. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112682. /**
  112683. * Set the value of an uniform to an array of int32 (stored as vec4)
  112684. * @param uniform defines the webGL uniform location where to store the value
  112685. * @param array defines the array of int32 to store
  112686. */
  112687. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112688. /**
  112689. * Set the value of an uniform to an array of number
  112690. * @param uniform defines the webGL uniform location where to store the value
  112691. * @param array defines the array of number to store
  112692. */
  112693. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112694. /**
  112695. * Set the value of an uniform to an array of number (stored as vec2)
  112696. * @param uniform defines the webGL uniform location where to store the value
  112697. * @param array defines the array of number to store
  112698. */
  112699. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112700. /**
  112701. * Set the value of an uniform to an array of number (stored as vec3)
  112702. * @param uniform defines the webGL uniform location where to store the value
  112703. * @param array defines the array of number to store
  112704. */
  112705. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112706. /**
  112707. * Set the value of an uniform to an array of number (stored as vec4)
  112708. * @param uniform defines the webGL uniform location where to store the value
  112709. * @param array defines the array of number to store
  112710. */
  112711. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112712. /**
  112713. * Set the value of an uniform to an array of float32 (stored as matrices)
  112714. * @param uniform defines the webGL uniform location where to store the value
  112715. * @param matrices defines the array of float32 to store
  112716. */
  112717. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  112718. /**
  112719. * Set the value of an uniform to a matrix (3x3)
  112720. * @param uniform defines the webGL uniform location where to store the value
  112721. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  112722. */
  112723. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  112724. /**
  112725. * Set the value of an uniform to a matrix (2x2)
  112726. * @param uniform defines the webGL uniform location where to store the value
  112727. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  112728. */
  112729. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  112730. /**
  112731. * Set the value of an uniform to a number (float)
  112732. * @param uniform defines the webGL uniform location where to store the value
  112733. * @param value defines the float number to store
  112734. */
  112735. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  112736. /**
  112737. * Set the value of an uniform to a vec2
  112738. * @param uniform defines the webGL uniform location where to store the value
  112739. * @param x defines the 1st component of the value
  112740. * @param y defines the 2nd component of the value
  112741. */
  112742. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  112743. /**
  112744. * Set the value of an uniform to a vec3
  112745. * @param uniform defines the webGL uniform location where to store the value
  112746. * @param x defines the 1st component of the value
  112747. * @param y defines the 2nd component of the value
  112748. * @param z defines the 3rd component of the value
  112749. */
  112750. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  112751. /**
  112752. * Set the value of an uniform to a vec4
  112753. * @param uniform defines the webGL uniform location where to store the value
  112754. * @param x defines the 1st component of the value
  112755. * @param y defines the 2nd component of the value
  112756. * @param z defines the 3rd component of the value
  112757. * @param w defines the 4th component of the value
  112758. */
  112759. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  112760. /**
  112761. * Apply all cached states (depth, culling, stencil and alpha)
  112762. */
  112763. applyStates(): void;
  112764. /**
  112765. * Enable or disable color writing
  112766. * @param enable defines the state to set
  112767. */
  112768. setColorWrite(enable: boolean): void;
  112769. /**
  112770. * Gets a boolean indicating if color writing is enabled
  112771. * @returns the current color writing state
  112772. */
  112773. getColorWrite(): boolean;
  112774. /**
  112775. * Gets the depth culling state manager
  112776. */
  112777. get depthCullingState(): DepthCullingState;
  112778. /**
  112779. * Gets the alpha state manager
  112780. */
  112781. get alphaState(): AlphaState;
  112782. /**
  112783. * Gets the stencil state manager
  112784. */
  112785. get stencilState(): StencilState;
  112786. /**
  112787. * Clears the list of texture accessible through engine.
  112788. * This can help preventing texture load conflict due to name collision.
  112789. */
  112790. clearInternalTexturesCache(): void;
  112791. /**
  112792. * Force the entire cache to be cleared
  112793. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  112794. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  112795. */
  112796. wipeCaches(bruteForce?: boolean): void;
  112797. /** @hidden */
  112798. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  112799. min: number;
  112800. mag: number;
  112801. };
  112802. /** @hidden */
  112803. _createTexture(): WebGLTexture;
  112804. /**
  112805. * Usually called from Texture.ts.
  112806. * Passed information to create a WebGLTexture
  112807. * @param url defines a value which contains one of the following:
  112808. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112809. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112810. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112811. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112812. * @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)
  112813. * @param scene needed for loading to the correct scene
  112814. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  112815. * @param onLoad optional callback to be called upon successful completion
  112816. * @param onError optional callback to be called upon failure
  112817. * @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
  112818. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112819. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112820. * @param forcedExtension defines the extension to use to pick the right loader
  112821. * @param mimeType defines an optional mime type
  112822. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112823. */
  112824. 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;
  112825. /**
  112826. * Loads an image as an HTMLImageElement.
  112827. * @param input url string, ArrayBuffer, or Blob to load
  112828. * @param onLoad callback called when the image successfully loads
  112829. * @param onError callback called when the image fails to load
  112830. * @param offlineProvider offline provider for caching
  112831. * @param mimeType optional mime type
  112832. * @returns the HTMLImageElement of the loaded image
  112833. * @hidden
  112834. */
  112835. 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>;
  112836. /**
  112837. * @hidden
  112838. */
  112839. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  112840. private _unpackFlipYCached;
  112841. /**
  112842. * In case you are sharing the context with other applications, it might
  112843. * be interested to not cache the unpack flip y state to ensure a consistent
  112844. * value would be set.
  112845. */
  112846. enableUnpackFlipYCached: boolean;
  112847. /** @hidden */
  112848. _unpackFlipY(value: boolean): void;
  112849. /** @hidden */
  112850. _getUnpackAlignement(): number;
  112851. private _getTextureTarget;
  112852. /**
  112853. * Update the sampling mode of a given texture
  112854. * @param samplingMode defines the required sampling mode
  112855. * @param texture defines the texture to update
  112856. * @param generateMipMaps defines whether to generate mipmaps for the texture
  112857. */
  112858. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  112859. /**
  112860. * Update the sampling mode of a given texture
  112861. * @param texture defines the texture to update
  112862. * @param wrapU defines the texture wrap mode of the u coordinates
  112863. * @param wrapV defines the texture wrap mode of the v coordinates
  112864. * @param wrapR defines the texture wrap mode of the r coordinates
  112865. */
  112866. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  112867. /** @hidden */
  112868. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  112869. width: number;
  112870. height: number;
  112871. layers?: number;
  112872. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  112873. /** @hidden */
  112874. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112875. /** @hidden */
  112876. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  112877. /**
  112878. * Update a portion of an internal texture
  112879. * @param texture defines the texture to update
  112880. * @param imageData defines the data to store into the texture
  112881. * @param xOffset defines the x coordinates of the update rectangle
  112882. * @param yOffset defines the y coordinates of the update rectangle
  112883. * @param width defines the width of the update rectangle
  112884. * @param height defines the height of the update rectangle
  112885. * @param faceIndex defines the face index if texture is a cube (0 by default)
  112886. * @param lod defines the lod level to update (0 by default)
  112887. */
  112888. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  112889. /** @hidden */
  112890. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112891. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  112892. private _prepareWebGLTexture;
  112893. /** @hidden */
  112894. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  112895. private _getDepthStencilBuffer;
  112896. /** @hidden */
  112897. _releaseFramebufferObjects(texture: InternalTexture): void;
  112898. /** @hidden */
  112899. _releaseTexture(texture: InternalTexture): void;
  112900. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  112901. protected _setProgram(program: WebGLProgram): void;
  112902. protected _boundUniforms: {
  112903. [key: number]: WebGLUniformLocation;
  112904. };
  112905. /**
  112906. * Binds an effect to the webGL context
  112907. * @param effect defines the effect to bind
  112908. */
  112909. bindSamplers(effect: Effect): void;
  112910. private _activateCurrentTexture;
  112911. /** @hidden */
  112912. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  112913. /** @hidden */
  112914. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  112915. /**
  112916. * Unbind all textures from the webGL context
  112917. */
  112918. unbindAllTextures(): void;
  112919. /**
  112920. * Sets a texture to the according uniform.
  112921. * @param channel The texture channel
  112922. * @param uniform The uniform to set
  112923. * @param texture The texture to apply
  112924. */
  112925. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  112926. private _bindSamplerUniformToChannel;
  112927. private _getTextureWrapMode;
  112928. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  112929. /**
  112930. * Sets an array of texture to the webGL context
  112931. * @param channel defines the channel where the texture array must be set
  112932. * @param uniform defines the associated uniform location
  112933. * @param textures defines the array of textures to bind
  112934. */
  112935. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  112936. /** @hidden */
  112937. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  112938. private _setTextureParameterFloat;
  112939. private _setTextureParameterInteger;
  112940. /**
  112941. * Unbind all vertex attributes from the webGL context
  112942. */
  112943. unbindAllAttributes(): void;
  112944. /**
  112945. * 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
  112946. */
  112947. releaseEffects(): void;
  112948. /**
  112949. * Dispose and release all associated resources
  112950. */
  112951. dispose(): void;
  112952. /**
  112953. * Attach a new callback raised when context lost event is fired
  112954. * @param callback defines the callback to call
  112955. */
  112956. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  112957. /**
  112958. * Attach a new callback raised when context restored event is fired
  112959. * @param callback defines the callback to call
  112960. */
  112961. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  112962. /**
  112963. * Get the current error code of the webGL context
  112964. * @returns the error code
  112965. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  112966. */
  112967. getError(): number;
  112968. private _canRenderToFloatFramebuffer;
  112969. private _canRenderToHalfFloatFramebuffer;
  112970. private _canRenderToFramebuffer;
  112971. /** @hidden */
  112972. _getWebGLTextureType(type: number): number;
  112973. /** @hidden */
  112974. _getInternalFormat(format: number): number;
  112975. /** @hidden */
  112976. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  112977. /** @hidden */
  112978. _getRGBAMultiSampleBufferFormat(type: number): number;
  112979. /** @hidden */
  112980. _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;
  112981. /**
  112982. * Loads a file from a url
  112983. * @param url url to load
  112984. * @param onSuccess callback called when the file successfully loads
  112985. * @param onProgress callback called while file is loading (if the server supports this mode)
  112986. * @param offlineProvider defines the offline provider for caching
  112987. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  112988. * @param onError callback called when the file fails to load
  112989. * @returns a file request object
  112990. * @hidden
  112991. */
  112992. 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;
  112993. /**
  112994. * Reads pixels from the current frame buffer. Please note that this function can be slow
  112995. * @param x defines the x coordinate of the rectangle where pixels must be read
  112996. * @param y defines the y coordinate of the rectangle where pixels must be read
  112997. * @param width defines the width of the rectangle where pixels must be read
  112998. * @param height defines the height of the rectangle where pixels must be read
  112999. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  113000. * @returns a Uint8Array containing RGBA colors
  113001. */
  113002. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  113003. private static _isSupported;
  113004. /**
  113005. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  113006. * @returns true if the engine can be created
  113007. * @ignorenaming
  113008. */
  113009. static isSupported(): boolean;
  113010. /**
  113011. * Find the next highest power of two.
  113012. * @param x Number to start search from.
  113013. * @return Next highest power of two.
  113014. */
  113015. static CeilingPOT(x: number): number;
  113016. /**
  113017. * Find the next lowest power of two.
  113018. * @param x Number to start search from.
  113019. * @return Next lowest power of two.
  113020. */
  113021. static FloorPOT(x: number): number;
  113022. /**
  113023. * Find the nearest power of two.
  113024. * @param x Number to start search from.
  113025. * @return Next nearest power of two.
  113026. */
  113027. static NearestPOT(x: number): number;
  113028. /**
  113029. * Get the closest exponent of two
  113030. * @param value defines the value to approximate
  113031. * @param max defines the maximum value to return
  113032. * @param mode defines how to define the closest value
  113033. * @returns closest exponent of two of the given value
  113034. */
  113035. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  113036. /**
  113037. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  113038. * @param func - the function to be called
  113039. * @param requester - the object that will request the next frame. Falls back to window.
  113040. * @returns frame number
  113041. */
  113042. static QueueNewFrame(func: () => void, requester?: any): number;
  113043. /**
  113044. * Gets host document
  113045. * @returns the host document object
  113046. */
  113047. getHostDocument(): Nullable<Document>;
  113048. }
  113049. }
  113050. declare module BABYLON {
  113051. /**
  113052. * Class representing spherical harmonics coefficients to the 3rd degree
  113053. */
  113054. export class SphericalHarmonics {
  113055. /**
  113056. * Defines whether or not the harmonics have been prescaled for rendering.
  113057. */
  113058. preScaled: boolean;
  113059. /**
  113060. * The l0,0 coefficients of the spherical harmonics
  113061. */
  113062. l00: Vector3;
  113063. /**
  113064. * The l1,-1 coefficients of the spherical harmonics
  113065. */
  113066. l1_1: Vector3;
  113067. /**
  113068. * The l1,0 coefficients of the spherical harmonics
  113069. */
  113070. l10: Vector3;
  113071. /**
  113072. * The l1,1 coefficients of the spherical harmonics
  113073. */
  113074. l11: Vector3;
  113075. /**
  113076. * The l2,-2 coefficients of the spherical harmonics
  113077. */
  113078. l2_2: Vector3;
  113079. /**
  113080. * The l2,-1 coefficients of the spherical harmonics
  113081. */
  113082. l2_1: Vector3;
  113083. /**
  113084. * The l2,0 coefficients of the spherical harmonics
  113085. */
  113086. l20: Vector3;
  113087. /**
  113088. * The l2,1 coefficients of the spherical harmonics
  113089. */
  113090. l21: Vector3;
  113091. /**
  113092. * The l2,2 coefficients of the spherical harmonics
  113093. */
  113094. l22: Vector3;
  113095. /**
  113096. * Adds a light to the spherical harmonics
  113097. * @param direction the direction of the light
  113098. * @param color the color of the light
  113099. * @param deltaSolidAngle the delta solid angle of the light
  113100. */
  113101. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  113102. /**
  113103. * Scales the spherical harmonics by the given amount
  113104. * @param scale the amount to scale
  113105. */
  113106. scaleInPlace(scale: number): void;
  113107. /**
  113108. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  113109. *
  113110. * ```
  113111. * E_lm = A_l * L_lm
  113112. * ```
  113113. *
  113114. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  113115. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  113116. * the scaling factors are given in equation 9.
  113117. */
  113118. convertIncidentRadianceToIrradiance(): void;
  113119. /**
  113120. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  113121. *
  113122. * ```
  113123. * L = (1/pi) * E * rho
  113124. * ```
  113125. *
  113126. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  113127. */
  113128. convertIrradianceToLambertianRadiance(): void;
  113129. /**
  113130. * Integrates the reconstruction coefficients directly in to the SH preventing further
  113131. * required operations at run time.
  113132. *
  113133. * This is simply done by scaling back the SH with Ylm constants parameter.
  113134. * The trigonometric part being applied by the shader at run time.
  113135. */
  113136. preScaleForRendering(): void;
  113137. /**
  113138. * Constructs a spherical harmonics from an array.
  113139. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  113140. * @returns the spherical harmonics
  113141. */
  113142. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  113143. /**
  113144. * Gets the spherical harmonics from polynomial
  113145. * @param polynomial the spherical polynomial
  113146. * @returns the spherical harmonics
  113147. */
  113148. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  113149. }
  113150. /**
  113151. * Class representing spherical polynomial coefficients to the 3rd degree
  113152. */
  113153. export class SphericalPolynomial {
  113154. private _harmonics;
  113155. /**
  113156. * The spherical harmonics used to create the polynomials.
  113157. */
  113158. get preScaledHarmonics(): SphericalHarmonics;
  113159. /**
  113160. * The x coefficients of the spherical polynomial
  113161. */
  113162. x: Vector3;
  113163. /**
  113164. * The y coefficients of the spherical polynomial
  113165. */
  113166. y: Vector3;
  113167. /**
  113168. * The z coefficients of the spherical polynomial
  113169. */
  113170. z: Vector3;
  113171. /**
  113172. * The xx coefficients of the spherical polynomial
  113173. */
  113174. xx: Vector3;
  113175. /**
  113176. * The yy coefficients of the spherical polynomial
  113177. */
  113178. yy: Vector3;
  113179. /**
  113180. * The zz coefficients of the spherical polynomial
  113181. */
  113182. zz: Vector3;
  113183. /**
  113184. * The xy coefficients of the spherical polynomial
  113185. */
  113186. xy: Vector3;
  113187. /**
  113188. * The yz coefficients of the spherical polynomial
  113189. */
  113190. yz: Vector3;
  113191. /**
  113192. * The zx coefficients of the spherical polynomial
  113193. */
  113194. zx: Vector3;
  113195. /**
  113196. * Adds an ambient color to the spherical polynomial
  113197. * @param color the color to add
  113198. */
  113199. addAmbient(color: Color3): void;
  113200. /**
  113201. * Scales the spherical polynomial by the given amount
  113202. * @param scale the amount to scale
  113203. */
  113204. scaleInPlace(scale: number): void;
  113205. /**
  113206. * Gets the spherical polynomial from harmonics
  113207. * @param harmonics the spherical harmonics
  113208. * @returns the spherical polynomial
  113209. */
  113210. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  113211. /**
  113212. * Constructs a spherical polynomial from an array.
  113213. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  113214. * @returns the spherical polynomial
  113215. */
  113216. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  113217. }
  113218. }
  113219. declare module BABYLON {
  113220. /**
  113221. * Defines the source of the internal texture
  113222. */
  113223. export enum InternalTextureSource {
  113224. /**
  113225. * The source of the texture data is unknown
  113226. */
  113227. Unknown = 0,
  113228. /**
  113229. * Texture data comes from an URL
  113230. */
  113231. Url = 1,
  113232. /**
  113233. * Texture data is only used for temporary storage
  113234. */
  113235. Temp = 2,
  113236. /**
  113237. * Texture data comes from raw data (ArrayBuffer)
  113238. */
  113239. Raw = 3,
  113240. /**
  113241. * Texture content is dynamic (video or dynamic texture)
  113242. */
  113243. Dynamic = 4,
  113244. /**
  113245. * Texture content is generated by rendering to it
  113246. */
  113247. RenderTarget = 5,
  113248. /**
  113249. * Texture content is part of a multi render target process
  113250. */
  113251. MultiRenderTarget = 6,
  113252. /**
  113253. * Texture data comes from a cube data file
  113254. */
  113255. Cube = 7,
  113256. /**
  113257. * Texture data comes from a raw cube data
  113258. */
  113259. CubeRaw = 8,
  113260. /**
  113261. * Texture data come from a prefiltered cube data file
  113262. */
  113263. CubePrefiltered = 9,
  113264. /**
  113265. * Texture content is raw 3D data
  113266. */
  113267. Raw3D = 10,
  113268. /**
  113269. * Texture content is raw 2D array data
  113270. */
  113271. Raw2DArray = 11,
  113272. /**
  113273. * Texture content is a depth texture
  113274. */
  113275. Depth = 12,
  113276. /**
  113277. * Texture data comes from a raw cube data encoded with RGBD
  113278. */
  113279. CubeRawRGBD = 13
  113280. }
  113281. /**
  113282. * Class used to store data associated with WebGL texture data for the engine
  113283. * This class should not be used directly
  113284. */
  113285. export class InternalTexture {
  113286. /** @hidden */
  113287. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  113288. /**
  113289. * Defines if the texture is ready
  113290. */
  113291. isReady: boolean;
  113292. /**
  113293. * Defines if the texture is a cube texture
  113294. */
  113295. isCube: boolean;
  113296. /**
  113297. * Defines if the texture contains 3D data
  113298. */
  113299. is3D: boolean;
  113300. /**
  113301. * Defines if the texture contains 2D array data
  113302. */
  113303. is2DArray: boolean;
  113304. /**
  113305. * Defines if the texture contains multiview data
  113306. */
  113307. isMultiview: boolean;
  113308. /**
  113309. * Gets the URL used to load this texture
  113310. */
  113311. url: string;
  113312. /**
  113313. * Gets the sampling mode of the texture
  113314. */
  113315. samplingMode: number;
  113316. /**
  113317. * Gets a boolean indicating if the texture needs mipmaps generation
  113318. */
  113319. generateMipMaps: boolean;
  113320. /**
  113321. * Gets the number of samples used by the texture (WebGL2+ only)
  113322. */
  113323. samples: number;
  113324. /**
  113325. * Gets the type of the texture (int, float...)
  113326. */
  113327. type: number;
  113328. /**
  113329. * Gets the format of the texture (RGB, RGBA...)
  113330. */
  113331. format: number;
  113332. /**
  113333. * Observable called when the texture is loaded
  113334. */
  113335. onLoadedObservable: Observable<InternalTexture>;
  113336. /**
  113337. * Gets the width of the texture
  113338. */
  113339. width: number;
  113340. /**
  113341. * Gets the height of the texture
  113342. */
  113343. height: number;
  113344. /**
  113345. * Gets the depth of the texture
  113346. */
  113347. depth: number;
  113348. /**
  113349. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  113350. */
  113351. baseWidth: number;
  113352. /**
  113353. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  113354. */
  113355. baseHeight: number;
  113356. /**
  113357. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  113358. */
  113359. baseDepth: number;
  113360. /**
  113361. * Gets a boolean indicating if the texture is inverted on Y axis
  113362. */
  113363. invertY: boolean;
  113364. /** @hidden */
  113365. _invertVScale: boolean;
  113366. /** @hidden */
  113367. _associatedChannel: number;
  113368. /** @hidden */
  113369. _source: InternalTextureSource;
  113370. /** @hidden */
  113371. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  113372. /** @hidden */
  113373. _bufferView: Nullable<ArrayBufferView>;
  113374. /** @hidden */
  113375. _bufferViewArray: Nullable<ArrayBufferView[]>;
  113376. /** @hidden */
  113377. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  113378. /** @hidden */
  113379. _size: number;
  113380. /** @hidden */
  113381. _extension: string;
  113382. /** @hidden */
  113383. _files: Nullable<string[]>;
  113384. /** @hidden */
  113385. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  113386. /** @hidden */
  113387. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  113388. /** @hidden */
  113389. _framebuffer: Nullable<WebGLFramebuffer>;
  113390. /** @hidden */
  113391. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  113392. /** @hidden */
  113393. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  113394. /** @hidden */
  113395. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  113396. /** @hidden */
  113397. _attachments: Nullable<number[]>;
  113398. /** @hidden */
  113399. _cachedCoordinatesMode: Nullable<number>;
  113400. /** @hidden */
  113401. _cachedWrapU: Nullable<number>;
  113402. /** @hidden */
  113403. _cachedWrapV: Nullable<number>;
  113404. /** @hidden */
  113405. _cachedWrapR: Nullable<number>;
  113406. /** @hidden */
  113407. _cachedAnisotropicFilteringLevel: Nullable<number>;
  113408. /** @hidden */
  113409. _isDisabled: boolean;
  113410. /** @hidden */
  113411. _compression: Nullable<string>;
  113412. /** @hidden */
  113413. _generateStencilBuffer: boolean;
  113414. /** @hidden */
  113415. _generateDepthBuffer: boolean;
  113416. /** @hidden */
  113417. _comparisonFunction: number;
  113418. /** @hidden */
  113419. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  113420. /** @hidden */
  113421. _lodGenerationScale: number;
  113422. /** @hidden */
  113423. _lodGenerationOffset: number;
  113424. /** @hidden */
  113425. _depthStencilTexture: Nullable<InternalTexture>;
  113426. /** @hidden */
  113427. _colorTextureArray: Nullable<WebGLTexture>;
  113428. /** @hidden */
  113429. _depthStencilTextureArray: Nullable<WebGLTexture>;
  113430. /** @hidden */
  113431. _lodTextureHigh: Nullable<BaseTexture>;
  113432. /** @hidden */
  113433. _lodTextureMid: Nullable<BaseTexture>;
  113434. /** @hidden */
  113435. _lodTextureLow: Nullable<BaseTexture>;
  113436. /** @hidden */
  113437. _isRGBD: boolean;
  113438. /** @hidden */
  113439. _linearSpecularLOD: boolean;
  113440. /** @hidden */
  113441. _irradianceTexture: Nullable<BaseTexture>;
  113442. /** @hidden */
  113443. _webGLTexture: Nullable<WebGLTexture>;
  113444. /** @hidden */
  113445. _references: number;
  113446. private _engine;
  113447. /**
  113448. * Gets the Engine the texture belongs to.
  113449. * @returns The babylon engine
  113450. */
  113451. getEngine(): ThinEngine;
  113452. /**
  113453. * Gets the data source type of the texture
  113454. */
  113455. get source(): InternalTextureSource;
  113456. /**
  113457. * Creates a new InternalTexture
  113458. * @param engine defines the engine to use
  113459. * @param source defines the type of data that will be used
  113460. * @param delayAllocation if the texture allocation should be delayed (default: false)
  113461. */
  113462. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  113463. /**
  113464. * Increments the number of references (ie. the number of Texture that point to it)
  113465. */
  113466. incrementReferences(): void;
  113467. /**
  113468. * Change the size of the texture (not the size of the content)
  113469. * @param width defines the new width
  113470. * @param height defines the new height
  113471. * @param depth defines the new depth (1 by default)
  113472. */
  113473. updateSize(width: int, height: int, depth?: int): void;
  113474. /** @hidden */
  113475. _rebuild(): void;
  113476. /** @hidden */
  113477. _swapAndDie(target: InternalTexture): void;
  113478. /**
  113479. * Dispose the current allocated resources
  113480. */
  113481. dispose(): void;
  113482. }
  113483. }
  113484. declare module BABYLON {
  113485. /**
  113486. * Class used to work with sound analyzer using fast fourier transform (FFT)
  113487. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113488. */
  113489. export class Analyser {
  113490. /**
  113491. * Gets or sets the smoothing
  113492. * @ignorenaming
  113493. */
  113494. SMOOTHING: number;
  113495. /**
  113496. * Gets or sets the FFT table size
  113497. * @ignorenaming
  113498. */
  113499. FFT_SIZE: number;
  113500. /**
  113501. * Gets or sets the bar graph amplitude
  113502. * @ignorenaming
  113503. */
  113504. BARGRAPHAMPLITUDE: number;
  113505. /**
  113506. * Gets or sets the position of the debug canvas
  113507. * @ignorenaming
  113508. */
  113509. DEBUGCANVASPOS: {
  113510. x: number;
  113511. y: number;
  113512. };
  113513. /**
  113514. * Gets or sets the debug canvas size
  113515. * @ignorenaming
  113516. */
  113517. DEBUGCANVASSIZE: {
  113518. width: number;
  113519. height: number;
  113520. };
  113521. private _byteFreqs;
  113522. private _byteTime;
  113523. private _floatFreqs;
  113524. private _webAudioAnalyser;
  113525. private _debugCanvas;
  113526. private _debugCanvasContext;
  113527. private _scene;
  113528. private _registerFunc;
  113529. private _audioEngine;
  113530. /**
  113531. * Creates a new analyser
  113532. * @param scene defines hosting scene
  113533. */
  113534. constructor(scene: Scene);
  113535. /**
  113536. * Get the number of data values you will have to play with for the visualization
  113537. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  113538. * @returns a number
  113539. */
  113540. getFrequencyBinCount(): number;
  113541. /**
  113542. * Gets the current frequency data as a byte array
  113543. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  113544. * @returns a Uint8Array
  113545. */
  113546. getByteFrequencyData(): Uint8Array;
  113547. /**
  113548. * Gets the current waveform as a byte array
  113549. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  113550. * @returns a Uint8Array
  113551. */
  113552. getByteTimeDomainData(): Uint8Array;
  113553. /**
  113554. * Gets the current frequency data as a float array
  113555. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  113556. * @returns a Float32Array
  113557. */
  113558. getFloatFrequencyData(): Float32Array;
  113559. /**
  113560. * Renders the debug canvas
  113561. */
  113562. drawDebugCanvas(): void;
  113563. /**
  113564. * Stops rendering the debug canvas and removes it
  113565. */
  113566. stopDebugCanvas(): void;
  113567. /**
  113568. * Connects two audio nodes
  113569. * @param inputAudioNode defines first node to connect
  113570. * @param outputAudioNode defines second node to connect
  113571. */
  113572. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  113573. /**
  113574. * Releases all associated resources
  113575. */
  113576. dispose(): void;
  113577. }
  113578. }
  113579. declare module BABYLON {
  113580. /**
  113581. * This represents an audio engine and it is responsible
  113582. * to play, synchronize and analyse sounds throughout the application.
  113583. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113584. */
  113585. export interface IAudioEngine extends IDisposable {
  113586. /**
  113587. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  113588. */
  113589. readonly canUseWebAudio: boolean;
  113590. /**
  113591. * Gets the current AudioContext if available.
  113592. */
  113593. readonly audioContext: Nullable<AudioContext>;
  113594. /**
  113595. * The master gain node defines the global audio volume of your audio engine.
  113596. */
  113597. readonly masterGain: GainNode;
  113598. /**
  113599. * Gets whether or not mp3 are supported by your browser.
  113600. */
  113601. readonly isMP3supported: boolean;
  113602. /**
  113603. * Gets whether or not ogg are supported by your browser.
  113604. */
  113605. readonly isOGGsupported: boolean;
  113606. /**
  113607. * Defines if Babylon should emit a warning if WebAudio is not supported.
  113608. * @ignoreNaming
  113609. */
  113610. WarnedWebAudioUnsupported: boolean;
  113611. /**
  113612. * Defines if the audio engine relies on a custom unlocked button.
  113613. * In this case, the embedded button will not be displayed.
  113614. */
  113615. useCustomUnlockedButton: boolean;
  113616. /**
  113617. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  113618. */
  113619. readonly unlocked: boolean;
  113620. /**
  113621. * Event raised when audio has been unlocked on the browser.
  113622. */
  113623. onAudioUnlockedObservable: Observable<AudioEngine>;
  113624. /**
  113625. * Event raised when audio has been locked on the browser.
  113626. */
  113627. onAudioLockedObservable: Observable<AudioEngine>;
  113628. /**
  113629. * Flags the audio engine in Locked state.
  113630. * This happens due to new browser policies preventing audio to autoplay.
  113631. */
  113632. lock(): void;
  113633. /**
  113634. * Unlocks the audio engine once a user action has been done on the dom.
  113635. * This is helpful to resume play once browser policies have been satisfied.
  113636. */
  113637. unlock(): void;
  113638. /**
  113639. * Gets the global volume sets on the master gain.
  113640. * @returns the global volume if set or -1 otherwise
  113641. */
  113642. getGlobalVolume(): number;
  113643. /**
  113644. * Sets the global volume of your experience (sets on the master gain).
  113645. * @param newVolume Defines the new global volume of the application
  113646. */
  113647. setGlobalVolume(newVolume: number): void;
  113648. /**
  113649. * Connect the audio engine to an audio analyser allowing some amazing
  113650. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  113651. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  113652. * @param analyser The analyser to connect to the engine
  113653. */
  113654. connectToAnalyser(analyser: Analyser): void;
  113655. }
  113656. /**
  113657. * This represents the default audio engine used in babylon.
  113658. * It is responsible to play, synchronize and analyse sounds throughout the application.
  113659. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113660. */
  113661. export class AudioEngine implements IAudioEngine {
  113662. private _audioContext;
  113663. private _audioContextInitialized;
  113664. private _muteButton;
  113665. private _hostElement;
  113666. /**
  113667. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  113668. */
  113669. canUseWebAudio: boolean;
  113670. /**
  113671. * The master gain node defines the global audio volume of your audio engine.
  113672. */
  113673. masterGain: GainNode;
  113674. /**
  113675. * Defines if Babylon should emit a warning if WebAudio is not supported.
  113676. * @ignoreNaming
  113677. */
  113678. WarnedWebAudioUnsupported: boolean;
  113679. /**
  113680. * Gets whether or not mp3 are supported by your browser.
  113681. */
  113682. isMP3supported: boolean;
  113683. /**
  113684. * Gets whether or not ogg are supported by your browser.
  113685. */
  113686. isOGGsupported: boolean;
  113687. /**
  113688. * Gets whether audio has been unlocked on the device.
  113689. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  113690. * a user interaction has happened.
  113691. */
  113692. unlocked: boolean;
  113693. /**
  113694. * Defines if the audio engine relies on a custom unlocked button.
  113695. * In this case, the embedded button will not be displayed.
  113696. */
  113697. useCustomUnlockedButton: boolean;
  113698. /**
  113699. * Event raised when audio has been unlocked on the browser.
  113700. */
  113701. onAudioUnlockedObservable: Observable<AudioEngine>;
  113702. /**
  113703. * Event raised when audio has been locked on the browser.
  113704. */
  113705. onAudioLockedObservable: Observable<AudioEngine>;
  113706. /**
  113707. * Gets the current AudioContext if available.
  113708. */
  113709. get audioContext(): Nullable<AudioContext>;
  113710. private _connectedAnalyser;
  113711. /**
  113712. * Instantiates a new audio engine.
  113713. *
  113714. * There should be only one per page as some browsers restrict the number
  113715. * of audio contexts you can create.
  113716. * @param hostElement defines the host element where to display the mute icon if necessary
  113717. */
  113718. constructor(hostElement?: Nullable<HTMLElement>);
  113719. /**
  113720. * Flags the audio engine in Locked state.
  113721. * This happens due to new browser policies preventing audio to autoplay.
  113722. */
  113723. lock(): void;
  113724. /**
  113725. * Unlocks the audio engine once a user action has been done on the dom.
  113726. * This is helpful to resume play once browser policies have been satisfied.
  113727. */
  113728. unlock(): void;
  113729. private _resumeAudioContext;
  113730. private _initializeAudioContext;
  113731. private _tryToRun;
  113732. private _triggerRunningState;
  113733. private _triggerSuspendedState;
  113734. private _displayMuteButton;
  113735. private _moveButtonToTopLeft;
  113736. private _onResize;
  113737. private _hideMuteButton;
  113738. /**
  113739. * Destroy and release the resources associated with the audio ccontext.
  113740. */
  113741. dispose(): void;
  113742. /**
  113743. * Gets the global volume sets on the master gain.
  113744. * @returns the global volume if set or -1 otherwise
  113745. */
  113746. getGlobalVolume(): number;
  113747. /**
  113748. * Sets the global volume of your experience (sets on the master gain).
  113749. * @param newVolume Defines the new global volume of the application
  113750. */
  113751. setGlobalVolume(newVolume: number): void;
  113752. /**
  113753. * Connect the audio engine to an audio analyser allowing some amazing
  113754. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  113755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  113756. * @param analyser The analyser to connect to the engine
  113757. */
  113758. connectToAnalyser(analyser: Analyser): void;
  113759. }
  113760. }
  113761. declare module BABYLON {
  113762. /**
  113763. * Interface used to present a loading screen while loading a scene
  113764. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113765. */
  113766. export interface ILoadingScreen {
  113767. /**
  113768. * Function called to display the loading screen
  113769. */
  113770. displayLoadingUI: () => void;
  113771. /**
  113772. * Function called to hide the loading screen
  113773. */
  113774. hideLoadingUI: () => void;
  113775. /**
  113776. * Gets or sets the color to use for the background
  113777. */
  113778. loadingUIBackgroundColor: string;
  113779. /**
  113780. * Gets or sets the text to display while loading
  113781. */
  113782. loadingUIText: string;
  113783. }
  113784. /**
  113785. * Class used for the default loading screen
  113786. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113787. */
  113788. export class DefaultLoadingScreen implements ILoadingScreen {
  113789. private _renderingCanvas;
  113790. private _loadingText;
  113791. private _loadingDivBackgroundColor;
  113792. private _loadingDiv;
  113793. private _loadingTextDiv;
  113794. /** Gets or sets the logo url to use for the default loading screen */
  113795. static DefaultLogoUrl: string;
  113796. /** Gets or sets the spinner url to use for the default loading screen */
  113797. static DefaultSpinnerUrl: string;
  113798. /**
  113799. * Creates a new default loading screen
  113800. * @param _renderingCanvas defines the canvas used to render the scene
  113801. * @param _loadingText defines the default text to display
  113802. * @param _loadingDivBackgroundColor defines the default background color
  113803. */
  113804. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  113805. /**
  113806. * Function called to display the loading screen
  113807. */
  113808. displayLoadingUI(): void;
  113809. /**
  113810. * Function called to hide the loading screen
  113811. */
  113812. hideLoadingUI(): void;
  113813. /**
  113814. * Gets or sets the text to display while loading
  113815. */
  113816. set loadingUIText(text: string);
  113817. get loadingUIText(): string;
  113818. /**
  113819. * Gets or sets the color to use for the background
  113820. */
  113821. get loadingUIBackgroundColor(): string;
  113822. set loadingUIBackgroundColor(color: string);
  113823. private _resizeLoadingUI;
  113824. }
  113825. }
  113826. declare module BABYLON {
  113827. /**
  113828. * Interface for any object that can request an animation frame
  113829. */
  113830. export interface ICustomAnimationFrameRequester {
  113831. /**
  113832. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  113833. */
  113834. renderFunction?: Function;
  113835. /**
  113836. * Called to request the next frame to render to
  113837. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  113838. */
  113839. requestAnimationFrame: Function;
  113840. /**
  113841. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  113842. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  113843. */
  113844. requestID?: number;
  113845. }
  113846. }
  113847. declare module BABYLON {
  113848. /**
  113849. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  113850. */
  113851. export class PerformanceMonitor {
  113852. private _enabled;
  113853. private _rollingFrameTime;
  113854. private _lastFrameTimeMs;
  113855. /**
  113856. * constructor
  113857. * @param frameSampleSize The number of samples required to saturate the sliding window
  113858. */
  113859. constructor(frameSampleSize?: number);
  113860. /**
  113861. * Samples current frame
  113862. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  113863. */
  113864. sampleFrame(timeMs?: number): void;
  113865. /**
  113866. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  113867. */
  113868. get averageFrameTime(): number;
  113869. /**
  113870. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  113871. */
  113872. get averageFrameTimeVariance(): number;
  113873. /**
  113874. * Returns the frame time of the most recent frame
  113875. */
  113876. get instantaneousFrameTime(): number;
  113877. /**
  113878. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  113879. */
  113880. get averageFPS(): number;
  113881. /**
  113882. * Returns the average framerate in frames per second using the most recent frame time
  113883. */
  113884. get instantaneousFPS(): number;
  113885. /**
  113886. * Returns true if enough samples have been taken to completely fill the sliding window
  113887. */
  113888. get isSaturated(): boolean;
  113889. /**
  113890. * Enables contributions to the sliding window sample set
  113891. */
  113892. enable(): void;
  113893. /**
  113894. * Disables contributions to the sliding window sample set
  113895. * Samples will not be interpolated over the disabled period
  113896. */
  113897. disable(): void;
  113898. /**
  113899. * Returns true if sampling is enabled
  113900. */
  113901. get isEnabled(): boolean;
  113902. /**
  113903. * Resets performance monitor
  113904. */
  113905. reset(): void;
  113906. }
  113907. /**
  113908. * RollingAverage
  113909. *
  113910. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  113911. */
  113912. export class RollingAverage {
  113913. /**
  113914. * Current average
  113915. */
  113916. average: number;
  113917. /**
  113918. * Current variance
  113919. */
  113920. variance: number;
  113921. protected _samples: Array<number>;
  113922. protected _sampleCount: number;
  113923. protected _pos: number;
  113924. protected _m2: number;
  113925. /**
  113926. * constructor
  113927. * @param length The number of samples required to saturate the sliding window
  113928. */
  113929. constructor(length: number);
  113930. /**
  113931. * Adds a sample to the sample set
  113932. * @param v The sample value
  113933. */
  113934. add(v: number): void;
  113935. /**
  113936. * Returns previously added values or null if outside of history or outside the sliding window domain
  113937. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  113938. * @return Value previously recorded with add() or null if outside of range
  113939. */
  113940. history(i: number): number;
  113941. /**
  113942. * Returns true if enough samples have been taken to completely fill the sliding window
  113943. * @return true if sample-set saturated
  113944. */
  113945. isSaturated(): boolean;
  113946. /**
  113947. * Resets the rolling average (equivalent to 0 samples taken so far)
  113948. */
  113949. reset(): void;
  113950. /**
  113951. * Wraps a value around the sample range boundaries
  113952. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  113953. * @return Wrapped position in sample range
  113954. */
  113955. protected _wrapPosition(i: number): number;
  113956. }
  113957. }
  113958. declare module BABYLON {
  113959. /**
  113960. * This class is used to track a performance counter which is number based.
  113961. * The user has access to many properties which give statistics of different nature.
  113962. *
  113963. * The implementer can track two kinds of Performance Counter: time and count.
  113964. * 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.
  113965. * 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.
  113966. */
  113967. export class PerfCounter {
  113968. /**
  113969. * Gets or sets a global boolean to turn on and off all the counters
  113970. */
  113971. static Enabled: boolean;
  113972. /**
  113973. * Returns the smallest value ever
  113974. */
  113975. get min(): number;
  113976. /**
  113977. * Returns the biggest value ever
  113978. */
  113979. get max(): number;
  113980. /**
  113981. * Returns the average value since the performance counter is running
  113982. */
  113983. get average(): number;
  113984. /**
  113985. * Returns the average value of the last second the counter was monitored
  113986. */
  113987. get lastSecAverage(): number;
  113988. /**
  113989. * Returns the current value
  113990. */
  113991. get current(): number;
  113992. /**
  113993. * Gets the accumulated total
  113994. */
  113995. get total(): number;
  113996. /**
  113997. * Gets the total value count
  113998. */
  113999. get count(): number;
  114000. /**
  114001. * Creates a new counter
  114002. */
  114003. constructor();
  114004. /**
  114005. * Call this method to start monitoring a new frame.
  114006. * 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.
  114007. */
  114008. fetchNewFrame(): void;
  114009. /**
  114010. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  114011. * @param newCount the count value to add to the monitored count
  114012. * @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.
  114013. */
  114014. addCount(newCount: number, fetchResult: boolean): void;
  114015. /**
  114016. * Start monitoring this performance counter
  114017. */
  114018. beginMonitoring(): void;
  114019. /**
  114020. * Compute the time lapsed since the previous beginMonitoring() call.
  114021. * @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
  114022. */
  114023. endMonitoring(newFrame?: boolean): void;
  114024. private _fetchResult;
  114025. private _startMonitoringTime;
  114026. private _min;
  114027. private _max;
  114028. private _average;
  114029. private _current;
  114030. private _totalValueCount;
  114031. private _totalAccumulated;
  114032. private _lastSecAverage;
  114033. private _lastSecAccumulated;
  114034. private _lastSecTime;
  114035. private _lastSecValueCount;
  114036. }
  114037. }
  114038. declare module BABYLON {
  114039. interface ThinEngine {
  114040. /**
  114041. * Sets alpha constants used by some alpha blending modes
  114042. * @param r defines the red component
  114043. * @param g defines the green component
  114044. * @param b defines the blue component
  114045. * @param a defines the alpha component
  114046. */
  114047. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  114048. /**
  114049. * Sets the current alpha mode
  114050. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  114051. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  114052. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114053. */
  114054. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  114055. /**
  114056. * Gets the current alpha mode
  114057. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114058. * @returns the current alpha mode
  114059. */
  114060. getAlphaMode(): number;
  114061. /**
  114062. * Sets the current alpha equation
  114063. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  114064. */
  114065. setAlphaEquation(equation: number): void;
  114066. /**
  114067. * Gets the current alpha equation.
  114068. * @returns the current alpha equation
  114069. */
  114070. getAlphaEquation(): number;
  114071. }
  114072. }
  114073. declare module BABYLON {
  114074. interface ThinEngine {
  114075. /** @hidden */
  114076. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  114077. }
  114078. }
  114079. declare module BABYLON {
  114080. /**
  114081. * Defines the interface used by display changed events
  114082. */
  114083. export interface IDisplayChangedEventArgs {
  114084. /** Gets the vrDisplay object (if any) */
  114085. vrDisplay: Nullable<any>;
  114086. /** Gets a boolean indicating if webVR is supported */
  114087. vrSupported: boolean;
  114088. }
  114089. /**
  114090. * Defines the interface used by objects containing a viewport (like a camera)
  114091. */
  114092. interface IViewportOwnerLike {
  114093. /**
  114094. * Gets or sets the viewport
  114095. */
  114096. viewport: IViewportLike;
  114097. }
  114098. /**
  114099. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  114100. */
  114101. export class Engine extends ThinEngine {
  114102. /** Defines that alpha blending is disabled */
  114103. static readonly ALPHA_DISABLE: number;
  114104. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  114105. static readonly ALPHA_ADD: number;
  114106. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  114107. static readonly ALPHA_COMBINE: number;
  114108. /** Defines that alpha blending to DEST - SRC * DEST */
  114109. static readonly ALPHA_SUBTRACT: number;
  114110. /** Defines that alpha blending to SRC * DEST */
  114111. static readonly ALPHA_MULTIPLY: number;
  114112. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  114113. static readonly ALPHA_MAXIMIZED: number;
  114114. /** Defines that alpha blending to SRC + DEST */
  114115. static readonly ALPHA_ONEONE: number;
  114116. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  114117. static readonly ALPHA_PREMULTIPLIED: number;
  114118. /**
  114119. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  114120. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  114121. */
  114122. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  114123. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  114124. static readonly ALPHA_INTERPOLATE: number;
  114125. /**
  114126. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  114127. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  114128. */
  114129. static readonly ALPHA_SCREENMODE: number;
  114130. /** Defines that the ressource is not delayed*/
  114131. static readonly DELAYLOADSTATE_NONE: number;
  114132. /** Defines that the ressource was successfully delay loaded */
  114133. static readonly DELAYLOADSTATE_LOADED: number;
  114134. /** Defines that the ressource is currently delay loading */
  114135. static readonly DELAYLOADSTATE_LOADING: number;
  114136. /** Defines that the ressource is delayed and has not started loading */
  114137. static readonly DELAYLOADSTATE_NOTLOADED: number;
  114138. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  114139. static readonly NEVER: number;
  114140. /** 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 */
  114141. static readonly ALWAYS: number;
  114142. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  114143. static readonly LESS: number;
  114144. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  114145. static readonly EQUAL: number;
  114146. /** 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 */
  114147. static readonly LEQUAL: number;
  114148. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  114149. static readonly GREATER: number;
  114150. /** 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 */
  114151. static readonly GEQUAL: number;
  114152. /** 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 */
  114153. static readonly NOTEQUAL: number;
  114154. /** Passed to stencilOperation to specify that stencil value must be kept */
  114155. static readonly KEEP: number;
  114156. /** Passed to stencilOperation to specify that stencil value must be replaced */
  114157. static readonly REPLACE: number;
  114158. /** Passed to stencilOperation to specify that stencil value must be incremented */
  114159. static readonly INCR: number;
  114160. /** Passed to stencilOperation to specify that stencil value must be decremented */
  114161. static readonly DECR: number;
  114162. /** Passed to stencilOperation to specify that stencil value must be inverted */
  114163. static readonly INVERT: number;
  114164. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  114165. static readonly INCR_WRAP: number;
  114166. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  114167. static readonly DECR_WRAP: number;
  114168. /** Texture is not repeating outside of 0..1 UVs */
  114169. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  114170. /** Texture is repeating outside of 0..1 UVs */
  114171. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  114172. /** Texture is repeating and mirrored */
  114173. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  114174. /** ALPHA */
  114175. static readonly TEXTUREFORMAT_ALPHA: number;
  114176. /** LUMINANCE */
  114177. static readonly TEXTUREFORMAT_LUMINANCE: number;
  114178. /** LUMINANCE_ALPHA */
  114179. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  114180. /** RGB */
  114181. static readonly TEXTUREFORMAT_RGB: number;
  114182. /** RGBA */
  114183. static readonly TEXTUREFORMAT_RGBA: number;
  114184. /** RED */
  114185. static readonly TEXTUREFORMAT_RED: number;
  114186. /** RED (2nd reference) */
  114187. static readonly TEXTUREFORMAT_R: number;
  114188. /** RG */
  114189. static readonly TEXTUREFORMAT_RG: number;
  114190. /** RED_INTEGER */
  114191. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  114192. /** RED_INTEGER (2nd reference) */
  114193. static readonly TEXTUREFORMAT_R_INTEGER: number;
  114194. /** RG_INTEGER */
  114195. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  114196. /** RGB_INTEGER */
  114197. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  114198. /** RGBA_INTEGER */
  114199. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  114200. /** UNSIGNED_BYTE */
  114201. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  114202. /** UNSIGNED_BYTE (2nd reference) */
  114203. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  114204. /** FLOAT */
  114205. static readonly TEXTURETYPE_FLOAT: number;
  114206. /** HALF_FLOAT */
  114207. static readonly TEXTURETYPE_HALF_FLOAT: number;
  114208. /** BYTE */
  114209. static readonly TEXTURETYPE_BYTE: number;
  114210. /** SHORT */
  114211. static readonly TEXTURETYPE_SHORT: number;
  114212. /** UNSIGNED_SHORT */
  114213. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  114214. /** INT */
  114215. static readonly TEXTURETYPE_INT: number;
  114216. /** UNSIGNED_INT */
  114217. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  114218. /** UNSIGNED_SHORT_4_4_4_4 */
  114219. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  114220. /** UNSIGNED_SHORT_5_5_5_1 */
  114221. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  114222. /** UNSIGNED_SHORT_5_6_5 */
  114223. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  114224. /** UNSIGNED_INT_2_10_10_10_REV */
  114225. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  114226. /** UNSIGNED_INT_24_8 */
  114227. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  114228. /** UNSIGNED_INT_10F_11F_11F_REV */
  114229. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  114230. /** UNSIGNED_INT_5_9_9_9_REV */
  114231. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  114232. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  114233. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  114234. /** nearest is mag = nearest and min = nearest and mip = linear */
  114235. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  114236. /** Bilinear is mag = linear and min = linear and mip = nearest */
  114237. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  114238. /** Trilinear is mag = linear and min = linear and mip = linear */
  114239. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  114240. /** nearest is mag = nearest and min = nearest and mip = linear */
  114241. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  114242. /** Bilinear is mag = linear and min = linear and mip = nearest */
  114243. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  114244. /** Trilinear is mag = linear and min = linear and mip = linear */
  114245. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  114246. /** mag = nearest and min = nearest and mip = nearest */
  114247. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  114248. /** mag = nearest and min = linear and mip = nearest */
  114249. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  114250. /** mag = nearest and min = linear and mip = linear */
  114251. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  114252. /** mag = nearest and min = linear and mip = none */
  114253. static readonly TEXTURE_NEAREST_LINEAR: number;
  114254. /** mag = nearest and min = nearest and mip = none */
  114255. static readonly TEXTURE_NEAREST_NEAREST: number;
  114256. /** mag = linear and min = nearest and mip = nearest */
  114257. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  114258. /** mag = linear and min = nearest and mip = linear */
  114259. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  114260. /** mag = linear and min = linear and mip = none */
  114261. static readonly TEXTURE_LINEAR_LINEAR: number;
  114262. /** mag = linear and min = nearest and mip = none */
  114263. static readonly TEXTURE_LINEAR_NEAREST: number;
  114264. /** Explicit coordinates mode */
  114265. static readonly TEXTURE_EXPLICIT_MODE: number;
  114266. /** Spherical coordinates mode */
  114267. static readonly TEXTURE_SPHERICAL_MODE: number;
  114268. /** Planar coordinates mode */
  114269. static readonly TEXTURE_PLANAR_MODE: number;
  114270. /** Cubic coordinates mode */
  114271. static readonly TEXTURE_CUBIC_MODE: number;
  114272. /** Projection coordinates mode */
  114273. static readonly TEXTURE_PROJECTION_MODE: number;
  114274. /** Skybox coordinates mode */
  114275. static readonly TEXTURE_SKYBOX_MODE: number;
  114276. /** Inverse Cubic coordinates mode */
  114277. static readonly TEXTURE_INVCUBIC_MODE: number;
  114278. /** Equirectangular coordinates mode */
  114279. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  114280. /** Equirectangular Fixed coordinates mode */
  114281. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  114282. /** Equirectangular Fixed Mirrored coordinates mode */
  114283. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  114284. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  114285. static readonly SCALEMODE_FLOOR: number;
  114286. /** Defines that texture rescaling will look for the nearest power of 2 size */
  114287. static readonly SCALEMODE_NEAREST: number;
  114288. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  114289. static readonly SCALEMODE_CEILING: number;
  114290. /**
  114291. * Returns the current npm package of the sdk
  114292. */
  114293. static get NpmPackage(): string;
  114294. /**
  114295. * Returns the current version of the framework
  114296. */
  114297. static get Version(): string;
  114298. /** Gets the list of created engines */
  114299. static get Instances(): Engine[];
  114300. /**
  114301. * Gets the latest created engine
  114302. */
  114303. static get LastCreatedEngine(): Nullable<Engine>;
  114304. /**
  114305. * Gets the latest created scene
  114306. */
  114307. static get LastCreatedScene(): Nullable<Scene>;
  114308. /**
  114309. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  114310. * @param flag defines which part of the materials must be marked as dirty
  114311. * @param predicate defines a predicate used to filter which materials should be affected
  114312. */
  114313. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  114314. /**
  114315. * Method called to create the default loading screen.
  114316. * This can be overriden in your own app.
  114317. * @param canvas The rendering canvas element
  114318. * @returns The loading screen
  114319. */
  114320. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  114321. /**
  114322. * Method called to create the default rescale post process on each engine.
  114323. */
  114324. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  114325. /**
  114326. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  114327. **/
  114328. enableOfflineSupport: boolean;
  114329. /**
  114330. * 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)
  114331. **/
  114332. disableManifestCheck: boolean;
  114333. /**
  114334. * Gets the list of created scenes
  114335. */
  114336. scenes: Scene[];
  114337. /**
  114338. * Event raised when a new scene is created
  114339. */
  114340. onNewSceneAddedObservable: Observable<Scene>;
  114341. /**
  114342. * Gets the list of created postprocesses
  114343. */
  114344. postProcesses: PostProcess[];
  114345. /**
  114346. * Gets a boolean indicating if the pointer is currently locked
  114347. */
  114348. isPointerLock: boolean;
  114349. /**
  114350. * Observable event triggered each time the rendering canvas is resized
  114351. */
  114352. onResizeObservable: Observable<Engine>;
  114353. /**
  114354. * Observable event triggered each time the canvas loses focus
  114355. */
  114356. onCanvasBlurObservable: Observable<Engine>;
  114357. /**
  114358. * Observable event triggered each time the canvas gains focus
  114359. */
  114360. onCanvasFocusObservable: Observable<Engine>;
  114361. /**
  114362. * Observable event triggered each time the canvas receives pointerout event
  114363. */
  114364. onCanvasPointerOutObservable: Observable<PointerEvent>;
  114365. /**
  114366. * Observable raised when the engine begins a new frame
  114367. */
  114368. onBeginFrameObservable: Observable<Engine>;
  114369. /**
  114370. * If set, will be used to request the next animation frame for the render loop
  114371. */
  114372. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  114373. /**
  114374. * Observable raised when the engine ends the current frame
  114375. */
  114376. onEndFrameObservable: Observable<Engine>;
  114377. /**
  114378. * Observable raised when the engine is about to compile a shader
  114379. */
  114380. onBeforeShaderCompilationObservable: Observable<Engine>;
  114381. /**
  114382. * Observable raised when the engine has jsut compiled a shader
  114383. */
  114384. onAfterShaderCompilationObservable: Observable<Engine>;
  114385. /**
  114386. * Gets the audio engine
  114387. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114388. * @ignorenaming
  114389. */
  114390. static audioEngine: IAudioEngine;
  114391. /**
  114392. * Default AudioEngine factory responsible of creating the Audio Engine.
  114393. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  114394. */
  114395. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  114396. /**
  114397. * Default offline support factory responsible of creating a tool used to store data locally.
  114398. * By default, this will create a Database object if the workload has been embedded.
  114399. */
  114400. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  114401. private _loadingScreen;
  114402. private _pointerLockRequested;
  114403. private _rescalePostProcess;
  114404. private _deterministicLockstep;
  114405. private _lockstepMaxSteps;
  114406. private _timeStep;
  114407. protected get _supportsHardwareTextureRescaling(): boolean;
  114408. private _fps;
  114409. private _deltaTime;
  114410. /** @hidden */
  114411. _drawCalls: PerfCounter;
  114412. /** 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 */
  114413. canvasTabIndex: number;
  114414. /**
  114415. * Turn this value on if you want to pause FPS computation when in background
  114416. */
  114417. disablePerformanceMonitorInBackground: boolean;
  114418. private _performanceMonitor;
  114419. /**
  114420. * Gets the performance monitor attached to this engine
  114421. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114422. */
  114423. get performanceMonitor(): PerformanceMonitor;
  114424. private _onFocus;
  114425. private _onBlur;
  114426. private _onCanvasPointerOut;
  114427. private _onCanvasBlur;
  114428. private _onCanvasFocus;
  114429. private _onFullscreenChange;
  114430. private _onPointerLockChange;
  114431. /**
  114432. * Gets the HTML element used to attach event listeners
  114433. * @returns a HTML element
  114434. */
  114435. getInputElement(): Nullable<HTMLElement>;
  114436. /**
  114437. * Creates a new engine
  114438. * @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
  114439. * @param antialias defines enable antialiasing (default: false)
  114440. * @param options defines further options to be sent to the getContext() function
  114441. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  114442. */
  114443. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  114444. /**
  114445. * Gets current aspect ratio
  114446. * @param viewportOwner defines the camera to use to get the aspect ratio
  114447. * @param useScreen defines if screen size must be used (or the current render target if any)
  114448. * @returns a number defining the aspect ratio
  114449. */
  114450. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  114451. /**
  114452. * Gets current screen aspect ratio
  114453. * @returns a number defining the aspect ratio
  114454. */
  114455. getScreenAspectRatio(): number;
  114456. /**
  114457. * Gets the client rect of the HTML canvas attached with the current webGL context
  114458. * @returns a client rectanglee
  114459. */
  114460. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  114461. /**
  114462. * Gets the client rect of the HTML element used for events
  114463. * @returns a client rectanglee
  114464. */
  114465. getInputElementClientRect(): Nullable<ClientRect>;
  114466. /**
  114467. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  114468. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114469. * @returns true if engine is in deterministic lock step mode
  114470. */
  114471. isDeterministicLockStep(): boolean;
  114472. /**
  114473. * Gets the max steps when engine is running in deterministic lock step
  114474. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114475. * @returns the max steps
  114476. */
  114477. getLockstepMaxSteps(): number;
  114478. /**
  114479. * Returns the time in ms between steps when using deterministic lock step.
  114480. * @returns time step in (ms)
  114481. */
  114482. getTimeStep(): number;
  114483. /**
  114484. * Force the mipmap generation for the given render target texture
  114485. * @param texture defines the render target texture to use
  114486. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  114487. */
  114488. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  114489. /** States */
  114490. /**
  114491. * Set various states to the webGL context
  114492. * @param culling defines backface culling state
  114493. * @param zOffset defines the value to apply to zOffset (0 by default)
  114494. * @param force defines if states must be applied even if cache is up to date
  114495. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  114496. */
  114497. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  114498. /**
  114499. * Set the z offset to apply to current rendering
  114500. * @param value defines the offset to apply
  114501. */
  114502. setZOffset(value: number): void;
  114503. /**
  114504. * Gets the current value of the zOffset
  114505. * @returns the current zOffset state
  114506. */
  114507. getZOffset(): number;
  114508. /**
  114509. * Enable or disable depth buffering
  114510. * @param enable defines the state to set
  114511. */
  114512. setDepthBuffer(enable: boolean): void;
  114513. /**
  114514. * Gets a boolean indicating if depth writing is enabled
  114515. * @returns the current depth writing state
  114516. */
  114517. getDepthWrite(): boolean;
  114518. /**
  114519. * Enable or disable depth writing
  114520. * @param enable defines the state to set
  114521. */
  114522. setDepthWrite(enable: boolean): void;
  114523. /**
  114524. * Gets a boolean indicating if stencil buffer is enabled
  114525. * @returns the current stencil buffer state
  114526. */
  114527. getStencilBuffer(): boolean;
  114528. /**
  114529. * Enable or disable the stencil buffer
  114530. * @param enable defines if the stencil buffer must be enabled or disabled
  114531. */
  114532. setStencilBuffer(enable: boolean): void;
  114533. /**
  114534. * Gets the current stencil mask
  114535. * @returns a number defining the new stencil mask to use
  114536. */
  114537. getStencilMask(): number;
  114538. /**
  114539. * Sets the current stencil mask
  114540. * @param mask defines the new stencil mask to use
  114541. */
  114542. setStencilMask(mask: number): void;
  114543. /**
  114544. * Gets the current stencil function
  114545. * @returns a number defining the stencil function to use
  114546. */
  114547. getStencilFunction(): number;
  114548. /**
  114549. * Gets the current stencil reference value
  114550. * @returns a number defining the stencil reference value to use
  114551. */
  114552. getStencilFunctionReference(): number;
  114553. /**
  114554. * Gets the current stencil mask
  114555. * @returns a number defining the stencil mask to use
  114556. */
  114557. getStencilFunctionMask(): number;
  114558. /**
  114559. * Sets the current stencil function
  114560. * @param stencilFunc defines the new stencil function to use
  114561. */
  114562. setStencilFunction(stencilFunc: number): void;
  114563. /**
  114564. * Sets the current stencil reference
  114565. * @param reference defines the new stencil reference to use
  114566. */
  114567. setStencilFunctionReference(reference: number): void;
  114568. /**
  114569. * Sets the current stencil mask
  114570. * @param mask defines the new stencil mask to use
  114571. */
  114572. setStencilFunctionMask(mask: number): void;
  114573. /**
  114574. * Gets the current stencil operation when stencil fails
  114575. * @returns a number defining stencil operation to use when stencil fails
  114576. */
  114577. getStencilOperationFail(): number;
  114578. /**
  114579. * Gets the current stencil operation when depth fails
  114580. * @returns a number defining stencil operation to use when depth fails
  114581. */
  114582. getStencilOperationDepthFail(): number;
  114583. /**
  114584. * Gets the current stencil operation when stencil passes
  114585. * @returns a number defining stencil operation to use when stencil passes
  114586. */
  114587. getStencilOperationPass(): number;
  114588. /**
  114589. * Sets the stencil operation to use when stencil fails
  114590. * @param operation defines the stencil operation to use when stencil fails
  114591. */
  114592. setStencilOperationFail(operation: number): void;
  114593. /**
  114594. * Sets the stencil operation to use when depth fails
  114595. * @param operation defines the stencil operation to use when depth fails
  114596. */
  114597. setStencilOperationDepthFail(operation: number): void;
  114598. /**
  114599. * Sets the stencil operation to use when stencil passes
  114600. * @param operation defines the stencil operation to use when stencil passes
  114601. */
  114602. setStencilOperationPass(operation: number): void;
  114603. /**
  114604. * Sets a boolean indicating if the dithering state is enabled or disabled
  114605. * @param value defines the dithering state
  114606. */
  114607. setDitheringState(value: boolean): void;
  114608. /**
  114609. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  114610. * @param value defines the rasterizer state
  114611. */
  114612. setRasterizerState(value: boolean): void;
  114613. /**
  114614. * Gets the current depth function
  114615. * @returns a number defining the depth function
  114616. */
  114617. getDepthFunction(): Nullable<number>;
  114618. /**
  114619. * Sets the current depth function
  114620. * @param depthFunc defines the function to use
  114621. */
  114622. setDepthFunction(depthFunc: number): void;
  114623. /**
  114624. * Sets the current depth function to GREATER
  114625. */
  114626. setDepthFunctionToGreater(): void;
  114627. /**
  114628. * Sets the current depth function to GEQUAL
  114629. */
  114630. setDepthFunctionToGreaterOrEqual(): void;
  114631. /**
  114632. * Sets the current depth function to LESS
  114633. */
  114634. setDepthFunctionToLess(): void;
  114635. /**
  114636. * Sets the current depth function to LEQUAL
  114637. */
  114638. setDepthFunctionToLessOrEqual(): void;
  114639. private _cachedStencilBuffer;
  114640. private _cachedStencilFunction;
  114641. private _cachedStencilMask;
  114642. private _cachedStencilOperationPass;
  114643. private _cachedStencilOperationFail;
  114644. private _cachedStencilOperationDepthFail;
  114645. private _cachedStencilReference;
  114646. /**
  114647. * Caches the the state of the stencil buffer
  114648. */
  114649. cacheStencilState(): void;
  114650. /**
  114651. * Restores the state of the stencil buffer
  114652. */
  114653. restoreStencilState(): void;
  114654. /**
  114655. * Directly set the WebGL Viewport
  114656. * @param x defines the x coordinate of the viewport (in screen space)
  114657. * @param y defines the y coordinate of the viewport (in screen space)
  114658. * @param width defines the width of the viewport (in screen space)
  114659. * @param height defines the height of the viewport (in screen space)
  114660. * @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
  114661. */
  114662. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  114663. /**
  114664. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  114665. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  114666. * @param y defines the y-coordinate of the corner of the clear rectangle
  114667. * @param width defines the width of the clear rectangle
  114668. * @param height defines the height of the clear rectangle
  114669. * @param clearColor defines the clear color
  114670. */
  114671. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  114672. /**
  114673. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  114674. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  114675. * @param y defines the y-coordinate of the corner of the clear rectangle
  114676. * @param width defines the width of the clear rectangle
  114677. * @param height defines the height of the clear rectangle
  114678. */
  114679. enableScissor(x: number, y: number, width: number, height: number): void;
  114680. /**
  114681. * Disable previously set scissor test rectangle
  114682. */
  114683. disableScissor(): void;
  114684. protected _reportDrawCall(): void;
  114685. /**
  114686. * Initializes a webVR display and starts listening to display change events
  114687. * The onVRDisplayChangedObservable will be notified upon these changes
  114688. * @returns The onVRDisplayChangedObservable
  114689. */
  114690. initWebVR(): Observable<IDisplayChangedEventArgs>;
  114691. /** @hidden */
  114692. _prepareVRComponent(): void;
  114693. /** @hidden */
  114694. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  114695. /** @hidden */
  114696. _submitVRFrame(): void;
  114697. /**
  114698. * Call this function to leave webVR mode
  114699. * Will do nothing if webVR is not supported or if there is no webVR device
  114700. * @see http://doc.babylonjs.com/how_to/webvr_camera
  114701. */
  114702. disableVR(): void;
  114703. /**
  114704. * Gets a boolean indicating that the system is in VR mode and is presenting
  114705. * @returns true if VR mode is engaged
  114706. */
  114707. isVRPresenting(): boolean;
  114708. /** @hidden */
  114709. _requestVRFrame(): void;
  114710. /** @hidden */
  114711. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  114712. /**
  114713. * Gets the source code of the vertex shader associated with a specific webGL program
  114714. * @param program defines the program to use
  114715. * @returns a string containing the source code of the vertex shader associated with the program
  114716. */
  114717. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  114718. /**
  114719. * Gets the source code of the fragment shader associated with a specific webGL program
  114720. * @param program defines the program to use
  114721. * @returns a string containing the source code of the fragment shader associated with the program
  114722. */
  114723. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  114724. /**
  114725. * Sets a depth stencil texture from a render target to the according uniform.
  114726. * @param channel The texture channel
  114727. * @param uniform The uniform to set
  114728. * @param texture The render target texture containing the depth stencil texture to apply
  114729. */
  114730. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  114731. /**
  114732. * Sets a texture to the webGL context from a postprocess
  114733. * @param channel defines the channel to use
  114734. * @param postProcess defines the source postprocess
  114735. */
  114736. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  114737. /**
  114738. * Binds the output of the passed in post process to the texture channel specified
  114739. * @param channel The channel the texture should be bound to
  114740. * @param postProcess The post process which's output should be bound
  114741. */
  114742. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  114743. protected _rebuildBuffers(): void;
  114744. /** @hidden */
  114745. _renderFrame(): void;
  114746. _renderLoop(): void;
  114747. /** @hidden */
  114748. _renderViews(): boolean;
  114749. /**
  114750. * Toggle full screen mode
  114751. * @param requestPointerLock defines if a pointer lock should be requested from the user
  114752. */
  114753. switchFullscreen(requestPointerLock: boolean): void;
  114754. /**
  114755. * Enters full screen mode
  114756. * @param requestPointerLock defines if a pointer lock should be requested from the user
  114757. */
  114758. enterFullscreen(requestPointerLock: boolean): void;
  114759. /**
  114760. * Exits full screen mode
  114761. */
  114762. exitFullscreen(): void;
  114763. /**
  114764. * Enters Pointerlock mode
  114765. */
  114766. enterPointerlock(): void;
  114767. /**
  114768. * Exits Pointerlock mode
  114769. */
  114770. exitPointerlock(): void;
  114771. /**
  114772. * Begin a new frame
  114773. */
  114774. beginFrame(): void;
  114775. /**
  114776. * Enf the current frame
  114777. */
  114778. endFrame(): void;
  114779. resize(): void;
  114780. /**
  114781. * Force a specific size of the canvas
  114782. * @param width defines the new canvas' width
  114783. * @param height defines the new canvas' height
  114784. */
  114785. setSize(width: number, height: number): void;
  114786. /**
  114787. * Updates a dynamic vertex buffer.
  114788. * @param vertexBuffer the vertex buffer to update
  114789. * @param data the data used to update the vertex buffer
  114790. * @param byteOffset the byte offset of the data
  114791. * @param byteLength the byte length of the data
  114792. */
  114793. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  114794. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  114795. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114796. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114797. _releaseTexture(texture: InternalTexture): void;
  114798. /**
  114799. * @hidden
  114800. * Rescales a texture
  114801. * @param source input texutre
  114802. * @param destination destination texture
  114803. * @param scene scene to use to render the resize
  114804. * @param internalFormat format to use when resizing
  114805. * @param onComplete callback to be called when resize has completed
  114806. */
  114807. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  114808. /**
  114809. * Gets the current framerate
  114810. * @returns a number representing the framerate
  114811. */
  114812. getFps(): number;
  114813. /**
  114814. * Gets the time spent between current and previous frame
  114815. * @returns a number representing the delta time in ms
  114816. */
  114817. getDeltaTime(): number;
  114818. private _measureFps;
  114819. /** @hidden */
  114820. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  114821. /**
  114822. * Update a dynamic index buffer
  114823. * @param indexBuffer defines the target index buffer
  114824. * @param indices defines the data to update
  114825. * @param offset defines the offset in the target index buffer where update should start
  114826. */
  114827. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  114828. /**
  114829. * Updates the sample count of a render target texture
  114830. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  114831. * @param texture defines the texture to update
  114832. * @param samples defines the sample count to set
  114833. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  114834. */
  114835. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  114836. /**
  114837. * Updates a depth texture Comparison Mode and Function.
  114838. * If the comparison Function is equal to 0, the mode will be set to none.
  114839. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  114840. * @param texture The texture to set the comparison function for
  114841. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  114842. */
  114843. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  114844. /**
  114845. * Creates a webGL buffer to use with instanciation
  114846. * @param capacity defines the size of the buffer
  114847. * @returns the webGL buffer
  114848. */
  114849. createInstancesBuffer(capacity: number): DataBuffer;
  114850. /**
  114851. * Delete a webGL buffer used with instanciation
  114852. * @param buffer defines the webGL buffer to delete
  114853. */
  114854. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  114855. private _clientWaitAsync;
  114856. /** @hidden */
  114857. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  114858. dispose(): void;
  114859. private _disableTouchAction;
  114860. /**
  114861. * Display the loading screen
  114862. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114863. */
  114864. displayLoadingUI(): void;
  114865. /**
  114866. * Hide the loading screen
  114867. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114868. */
  114869. hideLoadingUI(): void;
  114870. /**
  114871. * Gets the current loading screen object
  114872. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114873. */
  114874. get loadingScreen(): ILoadingScreen;
  114875. /**
  114876. * Sets the current loading screen object
  114877. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114878. */
  114879. set loadingScreen(loadingScreen: ILoadingScreen);
  114880. /**
  114881. * Sets the current loading screen text
  114882. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114883. */
  114884. set loadingUIText(text: string);
  114885. /**
  114886. * Sets the current loading screen background color
  114887. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114888. */
  114889. set loadingUIBackgroundColor(color: string);
  114890. /** Pointerlock and fullscreen */
  114891. /**
  114892. * Ask the browser to promote the current element to pointerlock mode
  114893. * @param element defines the DOM element to promote
  114894. */
  114895. static _RequestPointerlock(element: HTMLElement): void;
  114896. /**
  114897. * Asks the browser to exit pointerlock mode
  114898. */
  114899. static _ExitPointerlock(): void;
  114900. /**
  114901. * Ask the browser to promote the current element to fullscreen rendering mode
  114902. * @param element defines the DOM element to promote
  114903. */
  114904. static _RequestFullscreen(element: HTMLElement): void;
  114905. /**
  114906. * Asks the browser to exit fullscreen mode
  114907. */
  114908. static _ExitFullscreen(): void;
  114909. }
  114910. }
  114911. declare module BABYLON {
  114912. /**
  114913. * The engine store class is responsible to hold all the instances of Engine and Scene created
  114914. * during the life time of the application.
  114915. */
  114916. export class EngineStore {
  114917. /** Gets the list of created engines */
  114918. static Instances: Engine[];
  114919. /** @hidden */
  114920. static _LastCreatedScene: Nullable<Scene>;
  114921. /**
  114922. * Gets the latest created engine
  114923. */
  114924. static get LastCreatedEngine(): Nullable<Engine>;
  114925. /**
  114926. * Gets the latest created scene
  114927. */
  114928. static get LastCreatedScene(): Nullable<Scene>;
  114929. /**
  114930. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  114931. * @ignorenaming
  114932. */
  114933. static UseFallbackTexture: boolean;
  114934. /**
  114935. * Texture content used if a texture cannot loaded
  114936. * @ignorenaming
  114937. */
  114938. static FallbackTexture: string;
  114939. }
  114940. }
  114941. declare module BABYLON {
  114942. /**
  114943. * Helper class that provides a small promise polyfill
  114944. */
  114945. export class PromisePolyfill {
  114946. /**
  114947. * Static function used to check if the polyfill is required
  114948. * If this is the case then the function will inject the polyfill to window.Promise
  114949. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  114950. */
  114951. static Apply(force?: boolean): void;
  114952. }
  114953. }
  114954. declare module BABYLON {
  114955. /**
  114956. * Interface for screenshot methods with describe argument called `size` as object with options
  114957. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  114958. */
  114959. export interface IScreenshotSize {
  114960. /**
  114961. * number in pixels for canvas height
  114962. */
  114963. height?: number;
  114964. /**
  114965. * multiplier allowing render at a higher or lower resolution
  114966. * If value is defined then height and width will be ignored and taken from camera
  114967. */
  114968. precision?: number;
  114969. /**
  114970. * number in pixels for canvas width
  114971. */
  114972. width?: number;
  114973. }
  114974. }
  114975. declare module BABYLON {
  114976. interface IColor4Like {
  114977. r: float;
  114978. g: float;
  114979. b: float;
  114980. a: float;
  114981. }
  114982. /**
  114983. * Class containing a set of static utilities functions
  114984. */
  114985. export class Tools {
  114986. /**
  114987. * Gets or sets the base URL to use to load assets
  114988. */
  114989. static get BaseUrl(): string;
  114990. static set BaseUrl(value: string);
  114991. /**
  114992. * Enable/Disable Custom HTTP Request Headers globally.
  114993. * default = false
  114994. * @see CustomRequestHeaders
  114995. */
  114996. static UseCustomRequestHeaders: boolean;
  114997. /**
  114998. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  114999. * i.e. when loading files, where the server/service expects an Authorization header
  115000. */
  115001. static CustomRequestHeaders: {
  115002. [key: string]: string;
  115003. };
  115004. /**
  115005. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  115006. */
  115007. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  115008. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  115009. /**
  115010. * Default behaviour for cors in the application.
  115011. * It can be a string if the expected behavior is identical in the entire app.
  115012. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  115013. */
  115014. static get CorsBehavior(): string | ((url: string | string[]) => string);
  115015. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  115016. /**
  115017. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  115018. * @ignorenaming
  115019. */
  115020. static get UseFallbackTexture(): boolean;
  115021. static set UseFallbackTexture(value: boolean);
  115022. /**
  115023. * Use this object to register external classes like custom textures or material
  115024. * to allow the laoders to instantiate them
  115025. */
  115026. static get RegisteredExternalClasses(): {
  115027. [key: string]: Object;
  115028. };
  115029. static set RegisteredExternalClasses(classes: {
  115030. [key: string]: Object;
  115031. });
  115032. /**
  115033. * Texture content used if a texture cannot loaded
  115034. * @ignorenaming
  115035. */
  115036. static get fallbackTexture(): string;
  115037. static set fallbackTexture(value: string);
  115038. /**
  115039. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  115040. * @param u defines the coordinate on X axis
  115041. * @param v defines the coordinate on Y axis
  115042. * @param width defines the width of the source data
  115043. * @param height defines the height of the source data
  115044. * @param pixels defines the source byte array
  115045. * @param color defines the output color
  115046. */
  115047. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  115048. /**
  115049. * Interpolates between a and b via alpha
  115050. * @param a The lower value (returned when alpha = 0)
  115051. * @param b The upper value (returned when alpha = 1)
  115052. * @param alpha The interpolation-factor
  115053. * @return The mixed value
  115054. */
  115055. static Mix(a: number, b: number, alpha: number): number;
  115056. /**
  115057. * Tries to instantiate a new object from a given class name
  115058. * @param className defines the class name to instantiate
  115059. * @returns the new object or null if the system was not able to do the instantiation
  115060. */
  115061. static Instantiate(className: string): any;
  115062. /**
  115063. * Provides a slice function that will work even on IE
  115064. * @param data defines the array to slice
  115065. * @param start defines the start of the data (optional)
  115066. * @param end defines the end of the data (optional)
  115067. * @returns the new sliced array
  115068. */
  115069. static Slice<T>(data: T, start?: number, end?: number): T;
  115070. /**
  115071. * Polyfill for setImmediate
  115072. * @param action defines the action to execute after the current execution block
  115073. */
  115074. static SetImmediate(action: () => void): void;
  115075. /**
  115076. * Function indicating if a number is an exponent of 2
  115077. * @param value defines the value to test
  115078. * @returns true if the value is an exponent of 2
  115079. */
  115080. static IsExponentOfTwo(value: number): boolean;
  115081. private static _tmpFloatArray;
  115082. /**
  115083. * Returns the nearest 32-bit single precision float representation of a Number
  115084. * @param value A Number. If the parameter is of a different type, it will get converted
  115085. * to a number or to NaN if it cannot be converted
  115086. * @returns number
  115087. */
  115088. static FloatRound(value: number): number;
  115089. /**
  115090. * Extracts the filename from a path
  115091. * @param path defines the path to use
  115092. * @returns the filename
  115093. */
  115094. static GetFilename(path: string): string;
  115095. /**
  115096. * Extracts the "folder" part of a path (everything before the filename).
  115097. * @param uri The URI to extract the info from
  115098. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  115099. * @returns The "folder" part of the path
  115100. */
  115101. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  115102. /**
  115103. * Extracts text content from a DOM element hierarchy
  115104. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  115105. */
  115106. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  115107. /**
  115108. * Convert an angle in radians to degrees
  115109. * @param angle defines the angle to convert
  115110. * @returns the angle in degrees
  115111. */
  115112. static ToDegrees(angle: number): number;
  115113. /**
  115114. * Convert an angle in degrees to radians
  115115. * @param angle defines the angle to convert
  115116. * @returns the angle in radians
  115117. */
  115118. static ToRadians(angle: number): number;
  115119. /**
  115120. * Returns an array if obj is not an array
  115121. * @param obj defines the object to evaluate as an array
  115122. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  115123. * @returns either obj directly if obj is an array or a new array containing obj
  115124. */
  115125. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  115126. /**
  115127. * Gets the pointer prefix to use
  115128. * @param engine defines the engine we are finding the prefix for
  115129. * @returns "pointer" if touch is enabled. Else returns "mouse"
  115130. */
  115131. static GetPointerPrefix(engine: Engine): string;
  115132. /**
  115133. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  115134. * @param url define the url we are trying
  115135. * @param element define the dom element where to configure the cors policy
  115136. */
  115137. static SetCorsBehavior(url: string | string[], element: {
  115138. crossOrigin: string | null;
  115139. }): void;
  115140. /**
  115141. * Removes unwanted characters from an url
  115142. * @param url defines the url to clean
  115143. * @returns the cleaned url
  115144. */
  115145. static CleanUrl(url: string): string;
  115146. /**
  115147. * Gets or sets a function used to pre-process url before using them to load assets
  115148. */
  115149. static get PreprocessUrl(): (url: string) => string;
  115150. static set PreprocessUrl(processor: (url: string) => string);
  115151. /**
  115152. * Loads an image as an HTMLImageElement.
  115153. * @param input url string, ArrayBuffer, or Blob to load
  115154. * @param onLoad callback called when the image successfully loads
  115155. * @param onError callback called when the image fails to load
  115156. * @param offlineProvider offline provider for caching
  115157. * @param mimeType optional mime type
  115158. * @returns the HTMLImageElement of the loaded image
  115159. */
  115160. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  115161. /**
  115162. * Loads a file from a url
  115163. * @param url url string, ArrayBuffer, or Blob to load
  115164. * @param onSuccess callback called when the file successfully loads
  115165. * @param onProgress callback called while file is loading (if the server supports this mode)
  115166. * @param offlineProvider defines the offline provider for caching
  115167. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115168. * @param onError callback called when the file fails to load
  115169. * @returns a file request object
  115170. */
  115171. 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;
  115172. /**
  115173. * Loads a file from a url
  115174. * @param url the file url to load
  115175. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115176. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  115177. */
  115178. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  115179. /**
  115180. * Load a script (identified by an url). When the url returns, the
  115181. * content of this file is added into a new script element, attached to the DOM (body element)
  115182. * @param scriptUrl defines the url of the script to laod
  115183. * @param onSuccess defines the callback called when the script is loaded
  115184. * @param onError defines the callback to call if an error occurs
  115185. * @param scriptId defines the id of the script element
  115186. */
  115187. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  115188. /**
  115189. * Load an asynchronous script (identified by an url). When the url returns, the
  115190. * content of this file is added into a new script element, attached to the DOM (body element)
  115191. * @param scriptUrl defines the url of the script to laod
  115192. * @param scriptId defines the id of the script element
  115193. * @returns a promise request object
  115194. */
  115195. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  115196. /**
  115197. * Loads a file from a blob
  115198. * @param fileToLoad defines the blob to use
  115199. * @param callback defines the callback to call when data is loaded
  115200. * @param progressCallback defines the callback to call during loading process
  115201. * @returns a file request object
  115202. */
  115203. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  115204. /**
  115205. * Reads a file from a File object
  115206. * @param file defines the file to load
  115207. * @param onSuccess defines the callback to call when data is loaded
  115208. * @param onProgress defines the callback to call during loading process
  115209. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  115210. * @param onError defines the callback to call when an error occurs
  115211. * @returns a file request object
  115212. */
  115213. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  115214. /**
  115215. * Creates a data url from a given string content
  115216. * @param content defines the content to convert
  115217. * @returns the new data url link
  115218. */
  115219. static FileAsURL(content: string): string;
  115220. /**
  115221. * Format the given number to a specific decimal format
  115222. * @param value defines the number to format
  115223. * @param decimals defines the number of decimals to use
  115224. * @returns the formatted string
  115225. */
  115226. static Format(value: number, decimals?: number): string;
  115227. /**
  115228. * Tries to copy an object by duplicating every property
  115229. * @param source defines the source object
  115230. * @param destination defines the target object
  115231. * @param doNotCopyList defines a list of properties to avoid
  115232. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  115233. */
  115234. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  115235. /**
  115236. * Gets a boolean indicating if the given object has no own property
  115237. * @param obj defines the object to test
  115238. * @returns true if object has no own property
  115239. */
  115240. static IsEmpty(obj: any): boolean;
  115241. /**
  115242. * Function used to register events at window level
  115243. * @param windowElement defines the Window object to use
  115244. * @param events defines the events to register
  115245. */
  115246. static RegisterTopRootEvents(windowElement: Window, events: {
  115247. name: string;
  115248. handler: Nullable<(e: FocusEvent) => any>;
  115249. }[]): void;
  115250. /**
  115251. * Function used to unregister events from window level
  115252. * @param windowElement defines the Window object to use
  115253. * @param events defines the events to unregister
  115254. */
  115255. static UnregisterTopRootEvents(windowElement: Window, events: {
  115256. name: string;
  115257. handler: Nullable<(e: FocusEvent) => any>;
  115258. }[]): void;
  115259. /**
  115260. * @ignore
  115261. */
  115262. static _ScreenshotCanvas: HTMLCanvasElement;
  115263. /**
  115264. * Dumps the current bound framebuffer
  115265. * @param width defines the rendering width
  115266. * @param height defines the rendering height
  115267. * @param engine defines the hosting engine
  115268. * @param successCallback defines the callback triggered once the data are available
  115269. * @param mimeType defines the mime type of the result
  115270. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  115271. */
  115272. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  115273. /**
  115274. * Converts the canvas data to blob.
  115275. * This acts as a polyfill for browsers not supporting the to blob function.
  115276. * @param canvas Defines the canvas to extract the data from
  115277. * @param successCallback Defines the callback triggered once the data are available
  115278. * @param mimeType Defines the mime type of the result
  115279. */
  115280. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  115281. /**
  115282. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  115283. * @param successCallback defines the callback triggered once the data are available
  115284. * @param mimeType defines the mime type of the result
  115285. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  115286. */
  115287. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  115288. /**
  115289. * Downloads a blob in the browser
  115290. * @param blob defines the blob to download
  115291. * @param fileName defines the name of the downloaded file
  115292. */
  115293. static Download(blob: Blob, fileName: string): void;
  115294. /**
  115295. * Captures a screenshot of the current rendering
  115296. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115297. * @param engine defines the rendering engine
  115298. * @param camera defines the source camera
  115299. * @param size This parameter can be set to a single number or to an object with the
  115300. * following (optional) properties: precision, width, height. If a single number is passed,
  115301. * it will be used for both width and height. If an object is passed, the screenshot size
  115302. * will be derived from the parameters. The precision property is a multiplier allowing
  115303. * rendering at a higher or lower resolution
  115304. * @param successCallback defines the callback receives a single parameter which contains the
  115305. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115306. * src parameter of an <img> to display it
  115307. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115308. * Check your browser for supported MIME types
  115309. */
  115310. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  115311. /**
  115312. * Captures a screenshot of the current rendering
  115313. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115314. * @param engine defines the rendering engine
  115315. * @param camera defines the source camera
  115316. * @param size This parameter can be set to a single number or to an object with the
  115317. * following (optional) properties: precision, width, height. If a single number is passed,
  115318. * it will be used for both width and height. If an object is passed, the screenshot size
  115319. * will be derived from the parameters. The precision property is a multiplier allowing
  115320. * rendering at a higher or lower resolution
  115321. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115322. * Check your browser for supported MIME types
  115323. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  115324. * to the src parameter of an <img> to display it
  115325. */
  115326. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  115327. /**
  115328. * Generates an image screenshot from the specified camera.
  115329. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115330. * @param engine The engine to use for rendering
  115331. * @param camera The camera to use for rendering
  115332. * @param size This parameter can be set to a single number or to an object with the
  115333. * following (optional) properties: precision, width, height. If a single number is passed,
  115334. * it will be used for both width and height. If an object is passed, the screenshot size
  115335. * will be derived from the parameters. The precision property is a multiplier allowing
  115336. * rendering at a higher or lower resolution
  115337. * @param successCallback The callback receives a single parameter which contains the
  115338. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115339. * src parameter of an <img> to display it
  115340. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115341. * Check your browser for supported MIME types
  115342. * @param samples Texture samples (default: 1)
  115343. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115344. * @param fileName A name for for the downloaded file.
  115345. */
  115346. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  115347. /**
  115348. * Generates an image screenshot from the specified camera.
  115349. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115350. * @param engine The engine to use for rendering
  115351. * @param camera The camera to use for rendering
  115352. * @param size This parameter can be set to a single number or to an object with the
  115353. * following (optional) properties: precision, width, height. If a single number is passed,
  115354. * it will be used for both width and height. If an object is passed, the screenshot size
  115355. * will be derived from the parameters. The precision property is a multiplier allowing
  115356. * rendering at a higher or lower resolution
  115357. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115358. * Check your browser for supported MIME types
  115359. * @param samples Texture samples (default: 1)
  115360. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115361. * @param fileName A name for for the downloaded file.
  115362. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  115363. * to the src parameter of an <img> to display it
  115364. */
  115365. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  115366. /**
  115367. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  115368. * Be aware Math.random() could cause collisions, but:
  115369. * "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"
  115370. * @returns a pseudo random id
  115371. */
  115372. static RandomId(): string;
  115373. /**
  115374. * Test if the given uri is a base64 string
  115375. * @param uri The uri to test
  115376. * @return True if the uri is a base64 string or false otherwise
  115377. */
  115378. static IsBase64(uri: string): boolean;
  115379. /**
  115380. * Decode the given base64 uri.
  115381. * @param uri The uri to decode
  115382. * @return The decoded base64 data.
  115383. */
  115384. static DecodeBase64(uri: string): ArrayBuffer;
  115385. /**
  115386. * Gets the absolute url.
  115387. * @param url the input url
  115388. * @return the absolute url
  115389. */
  115390. static GetAbsoluteUrl(url: string): string;
  115391. /**
  115392. * No log
  115393. */
  115394. static readonly NoneLogLevel: number;
  115395. /**
  115396. * Only message logs
  115397. */
  115398. static readonly MessageLogLevel: number;
  115399. /**
  115400. * Only warning logs
  115401. */
  115402. static readonly WarningLogLevel: number;
  115403. /**
  115404. * Only error logs
  115405. */
  115406. static readonly ErrorLogLevel: number;
  115407. /**
  115408. * All logs
  115409. */
  115410. static readonly AllLogLevel: number;
  115411. /**
  115412. * Gets a value indicating the number of loading errors
  115413. * @ignorenaming
  115414. */
  115415. static get errorsCount(): number;
  115416. /**
  115417. * Callback called when a new log is added
  115418. */
  115419. static OnNewCacheEntry: (entry: string) => void;
  115420. /**
  115421. * Log a message to the console
  115422. * @param message defines the message to log
  115423. */
  115424. static Log(message: string): void;
  115425. /**
  115426. * Write a warning message to the console
  115427. * @param message defines the message to log
  115428. */
  115429. static Warn(message: string): void;
  115430. /**
  115431. * Write an error message to the console
  115432. * @param message defines the message to log
  115433. */
  115434. static Error(message: string): void;
  115435. /**
  115436. * Gets current log cache (list of logs)
  115437. */
  115438. static get LogCache(): string;
  115439. /**
  115440. * Clears the log cache
  115441. */
  115442. static ClearLogCache(): void;
  115443. /**
  115444. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  115445. */
  115446. static set LogLevels(level: number);
  115447. /**
  115448. * Checks if the window object exists
  115449. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  115450. */
  115451. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  115452. /**
  115453. * No performance log
  115454. */
  115455. static readonly PerformanceNoneLogLevel: number;
  115456. /**
  115457. * Use user marks to log performance
  115458. */
  115459. static readonly PerformanceUserMarkLogLevel: number;
  115460. /**
  115461. * Log performance to the console
  115462. */
  115463. static readonly PerformanceConsoleLogLevel: number;
  115464. private static _performance;
  115465. /**
  115466. * Sets the current performance log level
  115467. */
  115468. static set PerformanceLogLevel(level: number);
  115469. private static _StartPerformanceCounterDisabled;
  115470. private static _EndPerformanceCounterDisabled;
  115471. private static _StartUserMark;
  115472. private static _EndUserMark;
  115473. private static _StartPerformanceConsole;
  115474. private static _EndPerformanceConsole;
  115475. /**
  115476. * Starts a performance counter
  115477. */
  115478. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  115479. /**
  115480. * Ends a specific performance coutner
  115481. */
  115482. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  115483. /**
  115484. * Gets either window.performance.now() if supported or Date.now() else
  115485. */
  115486. static get Now(): number;
  115487. /**
  115488. * This method will return the name of the class used to create the instance of the given object.
  115489. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  115490. * @param object the object to get the class name from
  115491. * @param isType defines if the object is actually a type
  115492. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  115493. */
  115494. static GetClassName(object: any, isType?: boolean): string;
  115495. /**
  115496. * Gets the first element of an array satisfying a given predicate
  115497. * @param array defines the array to browse
  115498. * @param predicate defines the predicate to use
  115499. * @returns null if not found or the element
  115500. */
  115501. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  115502. /**
  115503. * This method will return the name of the full name of the class, including its owning module (if any).
  115504. * 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).
  115505. * @param object the object to get the class name from
  115506. * @param isType defines if the object is actually a type
  115507. * @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.
  115508. * @ignorenaming
  115509. */
  115510. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  115511. /**
  115512. * Returns a promise that resolves after the given amount of time.
  115513. * @param delay Number of milliseconds to delay
  115514. * @returns Promise that resolves after the given amount of time
  115515. */
  115516. static DelayAsync(delay: number): Promise<void>;
  115517. /**
  115518. * Utility function to detect if the current user agent is Safari
  115519. * @returns whether or not the current user agent is safari
  115520. */
  115521. static IsSafari(): boolean;
  115522. }
  115523. /**
  115524. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  115525. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  115526. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  115527. * @param name The name of the class, case should be preserved
  115528. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  115529. */
  115530. export function className(name: string, module?: string): (target: Object) => void;
  115531. /**
  115532. * An implementation of a loop for asynchronous functions.
  115533. */
  115534. export class AsyncLoop {
  115535. /**
  115536. * Defines the number of iterations for the loop
  115537. */
  115538. iterations: number;
  115539. /**
  115540. * Defines the current index of the loop.
  115541. */
  115542. index: number;
  115543. private _done;
  115544. private _fn;
  115545. private _successCallback;
  115546. /**
  115547. * Constructor.
  115548. * @param iterations the number of iterations.
  115549. * @param func the function to run each iteration
  115550. * @param successCallback the callback that will be called upon succesful execution
  115551. * @param offset starting offset.
  115552. */
  115553. constructor(
  115554. /**
  115555. * Defines the number of iterations for the loop
  115556. */
  115557. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  115558. /**
  115559. * Execute the next iteration. Must be called after the last iteration was finished.
  115560. */
  115561. executeNext(): void;
  115562. /**
  115563. * Break the loop and run the success callback.
  115564. */
  115565. breakLoop(): void;
  115566. /**
  115567. * Create and run an async loop.
  115568. * @param iterations the number of iterations.
  115569. * @param fn the function to run each iteration
  115570. * @param successCallback the callback that will be called upon succesful execution
  115571. * @param offset starting offset.
  115572. * @returns the created async loop object
  115573. */
  115574. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  115575. /**
  115576. * A for-loop that will run a given number of iterations synchronous and the rest async.
  115577. * @param iterations total number of iterations
  115578. * @param syncedIterations number of synchronous iterations in each async iteration.
  115579. * @param fn the function to call each iteration.
  115580. * @param callback a success call back that will be called when iterating stops.
  115581. * @param breakFunction a break condition (optional)
  115582. * @param timeout timeout settings for the setTimeout function. default - 0.
  115583. * @returns the created async loop object
  115584. */
  115585. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  115586. }
  115587. }
  115588. declare module BABYLON {
  115589. /**
  115590. * This class implement a typical dictionary using a string as key and the generic type T as value.
  115591. * The underlying implementation relies on an associative array to ensure the best performances.
  115592. * The value can be anything including 'null' but except 'undefined'
  115593. */
  115594. export class StringDictionary<T> {
  115595. /**
  115596. * This will clear this dictionary and copy the content from the 'source' one.
  115597. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  115598. * @param source the dictionary to take the content from and copy to this dictionary
  115599. */
  115600. copyFrom(source: StringDictionary<T>): void;
  115601. /**
  115602. * Get a value based from its key
  115603. * @param key the given key to get the matching value from
  115604. * @return the value if found, otherwise undefined is returned
  115605. */
  115606. get(key: string): T | undefined;
  115607. /**
  115608. * Get a value from its key or add it if it doesn't exist.
  115609. * This method will ensure you that a given key/data will be present in the dictionary.
  115610. * @param key the given key to get the matching value from
  115611. * @param factory the factory that will create the value if the key is not present in the dictionary.
  115612. * The factory will only be invoked if there's no data for the given key.
  115613. * @return the value corresponding to the key.
  115614. */
  115615. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  115616. /**
  115617. * Get a value from its key if present in the dictionary otherwise add it
  115618. * @param key the key to get the value from
  115619. * @param val if there's no such key/value pair in the dictionary add it with this value
  115620. * @return the value corresponding to the key
  115621. */
  115622. getOrAdd(key: string, val: T): T;
  115623. /**
  115624. * Check if there's a given key in the dictionary
  115625. * @param key the key to check for
  115626. * @return true if the key is present, false otherwise
  115627. */
  115628. contains(key: string): boolean;
  115629. /**
  115630. * Add a new key and its corresponding value
  115631. * @param key the key to add
  115632. * @param value the value corresponding to the key
  115633. * @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
  115634. */
  115635. add(key: string, value: T): boolean;
  115636. /**
  115637. * Update a specific value associated to a key
  115638. * @param key defines the key to use
  115639. * @param value defines the value to store
  115640. * @returns true if the value was updated (or false if the key was not found)
  115641. */
  115642. set(key: string, value: T): boolean;
  115643. /**
  115644. * Get the element of the given key and remove it from the dictionary
  115645. * @param key defines the key to search
  115646. * @returns the value associated with the key or null if not found
  115647. */
  115648. getAndRemove(key: string): Nullable<T>;
  115649. /**
  115650. * Remove a key/value from the dictionary.
  115651. * @param key the key to remove
  115652. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  115653. */
  115654. remove(key: string): boolean;
  115655. /**
  115656. * Clear the whole content of the dictionary
  115657. */
  115658. clear(): void;
  115659. /**
  115660. * Gets the current count
  115661. */
  115662. get count(): number;
  115663. /**
  115664. * Execute a callback on each key/val of the dictionary.
  115665. * Note that you can remove any element in this dictionary in the callback implementation
  115666. * @param callback the callback to execute on a given key/value pair
  115667. */
  115668. forEach(callback: (key: string, val: T) => void): void;
  115669. /**
  115670. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  115671. * If the callback returns null or undefined the method will iterate to the next key/value pair
  115672. * Note that you can remove any element in this dictionary in the callback implementation
  115673. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  115674. * @returns the first item
  115675. */
  115676. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  115677. private _count;
  115678. private _data;
  115679. }
  115680. }
  115681. declare module BABYLON {
  115682. /** @hidden */
  115683. export interface ICollisionCoordinator {
  115684. createCollider(): Collider;
  115685. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  115686. init(scene: Scene): void;
  115687. }
  115688. /** @hidden */
  115689. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  115690. private _scene;
  115691. private _scaledPosition;
  115692. private _scaledVelocity;
  115693. private _finalPosition;
  115694. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  115695. createCollider(): Collider;
  115696. init(scene: Scene): void;
  115697. private _collideWithWorld;
  115698. }
  115699. }
  115700. declare module BABYLON {
  115701. /**
  115702. * Class used to manage all inputs for the scene.
  115703. */
  115704. export class InputManager {
  115705. /** The distance in pixel that you have to move to prevent some events */
  115706. static DragMovementThreshold: number;
  115707. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  115708. static LongPressDelay: number;
  115709. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  115710. static DoubleClickDelay: number;
  115711. /** If you need to check double click without raising a single click at first click, enable this flag */
  115712. static ExclusiveDoubleClickMode: boolean;
  115713. private _wheelEventName;
  115714. private _onPointerMove;
  115715. private _onPointerDown;
  115716. private _onPointerUp;
  115717. private _initClickEvent;
  115718. private _initActionManager;
  115719. private _delayedSimpleClick;
  115720. private _delayedSimpleClickTimeout;
  115721. private _previousDelayedSimpleClickTimeout;
  115722. private _meshPickProceed;
  115723. private _previousButtonPressed;
  115724. private _currentPickResult;
  115725. private _previousPickResult;
  115726. private _totalPointersPressed;
  115727. private _doubleClickOccured;
  115728. private _pointerOverMesh;
  115729. private _pickedDownMesh;
  115730. private _pickedUpMesh;
  115731. private _pointerX;
  115732. private _pointerY;
  115733. private _unTranslatedPointerX;
  115734. private _unTranslatedPointerY;
  115735. private _startingPointerPosition;
  115736. private _previousStartingPointerPosition;
  115737. private _startingPointerTime;
  115738. private _previousStartingPointerTime;
  115739. private _pointerCaptures;
  115740. private _onKeyDown;
  115741. private _onKeyUp;
  115742. private _onCanvasFocusObserver;
  115743. private _onCanvasBlurObserver;
  115744. private _scene;
  115745. /**
  115746. * Creates a new InputManager
  115747. * @param scene defines the hosting scene
  115748. */
  115749. constructor(scene: Scene);
  115750. /**
  115751. * Gets the mesh that is currently under the pointer
  115752. */
  115753. get meshUnderPointer(): Nullable<AbstractMesh>;
  115754. /**
  115755. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  115756. */
  115757. get unTranslatedPointer(): Vector2;
  115758. /**
  115759. * Gets or sets the current on-screen X position of the pointer
  115760. */
  115761. get pointerX(): number;
  115762. set pointerX(value: number);
  115763. /**
  115764. * Gets or sets the current on-screen Y position of the pointer
  115765. */
  115766. get pointerY(): number;
  115767. set pointerY(value: number);
  115768. private _updatePointerPosition;
  115769. private _processPointerMove;
  115770. private _setRayOnPointerInfo;
  115771. private _checkPrePointerObservable;
  115772. /**
  115773. * Use this method to simulate a pointer move on a mesh
  115774. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115775. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115776. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115777. */
  115778. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  115779. /**
  115780. * Use this method to simulate a pointer down on a mesh
  115781. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115782. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115783. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115784. */
  115785. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  115786. private _processPointerDown;
  115787. /** @hidden */
  115788. _isPointerSwiping(): boolean;
  115789. /**
  115790. * Use this method to simulate a pointer up on a mesh
  115791. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115792. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115793. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115794. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  115795. */
  115796. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  115797. private _processPointerUp;
  115798. /**
  115799. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  115800. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  115801. * @returns true if the pointer was captured
  115802. */
  115803. isPointerCaptured(pointerId?: number): boolean;
  115804. /**
  115805. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  115806. * @param attachUp defines if you want to attach events to pointerup
  115807. * @param attachDown defines if you want to attach events to pointerdown
  115808. * @param attachMove defines if you want to attach events to pointermove
  115809. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  115810. */
  115811. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  115812. /**
  115813. * Detaches all event handlers
  115814. */
  115815. detachControl(): void;
  115816. /**
  115817. * Force the value of meshUnderPointer
  115818. * @param mesh defines the mesh to use
  115819. */
  115820. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  115821. /**
  115822. * Gets the mesh under the pointer
  115823. * @returns a Mesh or null if no mesh is under the pointer
  115824. */
  115825. getPointerOverMesh(): Nullable<AbstractMesh>;
  115826. }
  115827. }
  115828. declare module BABYLON {
  115829. /**
  115830. * This class defines the direct association between an animation and a target
  115831. */
  115832. export class TargetedAnimation {
  115833. /**
  115834. * Animation to perform
  115835. */
  115836. animation: Animation;
  115837. /**
  115838. * Target to animate
  115839. */
  115840. target: any;
  115841. /**
  115842. * Returns the string "TargetedAnimation"
  115843. * @returns "TargetedAnimation"
  115844. */
  115845. getClassName(): string;
  115846. /**
  115847. * Serialize the object
  115848. * @returns the JSON object representing the current entity
  115849. */
  115850. serialize(): any;
  115851. }
  115852. /**
  115853. * Use this class to create coordinated animations on multiple targets
  115854. */
  115855. export class AnimationGroup implements IDisposable {
  115856. /** The name of the animation group */
  115857. name: string;
  115858. private _scene;
  115859. private _targetedAnimations;
  115860. private _animatables;
  115861. private _from;
  115862. private _to;
  115863. private _isStarted;
  115864. private _isPaused;
  115865. private _speedRatio;
  115866. private _loopAnimation;
  115867. private _isAdditive;
  115868. /**
  115869. * Gets or sets the unique id of the node
  115870. */
  115871. uniqueId: number;
  115872. /**
  115873. * This observable will notify when one animation have ended
  115874. */
  115875. onAnimationEndObservable: Observable<TargetedAnimation>;
  115876. /**
  115877. * Observer raised when one animation loops
  115878. */
  115879. onAnimationLoopObservable: Observable<TargetedAnimation>;
  115880. /**
  115881. * Observer raised when all animations have looped
  115882. */
  115883. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  115884. /**
  115885. * This observable will notify when all animations have ended.
  115886. */
  115887. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  115888. /**
  115889. * This observable will notify when all animations have paused.
  115890. */
  115891. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  115892. /**
  115893. * This observable will notify when all animations are playing.
  115894. */
  115895. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  115896. /**
  115897. * Gets the first frame
  115898. */
  115899. get from(): number;
  115900. /**
  115901. * Gets the last frame
  115902. */
  115903. get to(): number;
  115904. /**
  115905. * Define if the animations are started
  115906. */
  115907. get isStarted(): boolean;
  115908. /**
  115909. * Gets a value indicating that the current group is playing
  115910. */
  115911. get isPlaying(): boolean;
  115912. /**
  115913. * Gets or sets the speed ratio to use for all animations
  115914. */
  115915. get speedRatio(): number;
  115916. /**
  115917. * Gets or sets the speed ratio to use for all animations
  115918. */
  115919. set speedRatio(value: number);
  115920. /**
  115921. * Gets or sets if all animations should loop or not
  115922. */
  115923. get loopAnimation(): boolean;
  115924. set loopAnimation(value: boolean);
  115925. /**
  115926. * Gets or sets if all animations should be evaluated additively
  115927. */
  115928. get isAdditive(): boolean;
  115929. set isAdditive(value: boolean);
  115930. /**
  115931. * Gets the targeted animations for this animation group
  115932. */
  115933. get targetedAnimations(): Array<TargetedAnimation>;
  115934. /**
  115935. * returning the list of animatables controlled by this animation group.
  115936. */
  115937. get animatables(): Array<Animatable>;
  115938. /**
  115939. * Gets the list of target animations
  115940. */
  115941. get children(): TargetedAnimation[];
  115942. /**
  115943. * Instantiates a new Animation Group.
  115944. * This helps managing several animations at once.
  115945. * @see http://doc.babylonjs.com/how_to/group
  115946. * @param name Defines the name of the group
  115947. * @param scene Defines the scene the group belongs to
  115948. */
  115949. constructor(
  115950. /** The name of the animation group */
  115951. name: string, scene?: Nullable<Scene>);
  115952. /**
  115953. * Add an animation (with its target) in the group
  115954. * @param animation defines the animation we want to add
  115955. * @param target defines the target of the animation
  115956. * @returns the TargetedAnimation object
  115957. */
  115958. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  115959. /**
  115960. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  115961. * It can add constant keys at begin or end
  115962. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  115963. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  115964. * @returns the animation group
  115965. */
  115966. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  115967. private _animationLoopCount;
  115968. private _animationLoopFlags;
  115969. private _processLoop;
  115970. /**
  115971. * Start all animations on given targets
  115972. * @param loop defines if animations must loop
  115973. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  115974. * @param from defines the from key (optional)
  115975. * @param to defines the to key (optional)
  115976. * @param isAdditive defines the additive state for the resulting animatables (optional)
  115977. * @returns the current animation group
  115978. */
  115979. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  115980. /**
  115981. * Pause all animations
  115982. * @returns the animation group
  115983. */
  115984. pause(): AnimationGroup;
  115985. /**
  115986. * Play all animations to initial state
  115987. * This function will start() the animations if they were not started or will restart() them if they were paused
  115988. * @param loop defines if animations must loop
  115989. * @returns the animation group
  115990. */
  115991. play(loop?: boolean): AnimationGroup;
  115992. /**
  115993. * Reset all animations to initial state
  115994. * @returns the animation group
  115995. */
  115996. reset(): AnimationGroup;
  115997. /**
  115998. * Restart animations from key 0
  115999. * @returns the animation group
  116000. */
  116001. restart(): AnimationGroup;
  116002. /**
  116003. * Stop all animations
  116004. * @returns the animation group
  116005. */
  116006. stop(): AnimationGroup;
  116007. /**
  116008. * Set animation weight for all animatables
  116009. * @param weight defines the weight to use
  116010. * @return the animationGroup
  116011. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  116012. */
  116013. setWeightForAllAnimatables(weight: number): AnimationGroup;
  116014. /**
  116015. * Synchronize and normalize all animatables with a source animatable
  116016. * @param root defines the root animatable to synchronize with
  116017. * @return the animationGroup
  116018. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  116019. */
  116020. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  116021. /**
  116022. * Goes to a specific frame in this animation group
  116023. * @param frame the frame number to go to
  116024. * @return the animationGroup
  116025. */
  116026. goToFrame(frame: number): AnimationGroup;
  116027. /**
  116028. * Dispose all associated resources
  116029. */
  116030. dispose(): void;
  116031. private _checkAnimationGroupEnded;
  116032. /**
  116033. * Clone the current animation group and returns a copy
  116034. * @param newName defines the name of the new group
  116035. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  116036. * @returns the new aniamtion group
  116037. */
  116038. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  116039. /**
  116040. * Serializes the animationGroup to an object
  116041. * @returns Serialized object
  116042. */
  116043. serialize(): any;
  116044. /**
  116045. * Returns a new AnimationGroup object parsed from the source provided.
  116046. * @param parsedAnimationGroup defines the source
  116047. * @param scene defines the scene that will receive the animationGroup
  116048. * @returns a new AnimationGroup
  116049. */
  116050. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  116051. /**
  116052. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  116053. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  116054. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  116055. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  116056. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  116057. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  116058. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  116059. */
  116060. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  116061. /**
  116062. * Returns the string "AnimationGroup"
  116063. * @returns "AnimationGroup"
  116064. */
  116065. getClassName(): string;
  116066. /**
  116067. * Creates a detailled string about the object
  116068. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  116069. * @returns a string representing the object
  116070. */
  116071. toString(fullDetails?: boolean): string;
  116072. }
  116073. }
  116074. declare module BABYLON {
  116075. /**
  116076. * Define an interface for all classes that will hold resources
  116077. */
  116078. export interface IDisposable {
  116079. /**
  116080. * Releases all held resources
  116081. */
  116082. dispose(): void;
  116083. }
  116084. /** Interface defining initialization parameters for Scene class */
  116085. export interface SceneOptions {
  116086. /**
  116087. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  116088. * It will improve performance when the number of geometries becomes important.
  116089. */
  116090. useGeometryUniqueIdsMap?: boolean;
  116091. /**
  116092. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  116093. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  116094. */
  116095. useMaterialMeshMap?: boolean;
  116096. /**
  116097. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  116098. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  116099. */
  116100. useClonedMeshMap?: boolean;
  116101. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  116102. virtual?: boolean;
  116103. }
  116104. /**
  116105. * Represents a scene to be rendered by the engine.
  116106. * @see http://doc.babylonjs.com/features/scene
  116107. */
  116108. export class Scene extends AbstractScene implements IAnimatable {
  116109. /** The fog is deactivated */
  116110. static readonly FOGMODE_NONE: number;
  116111. /** The fog density is following an exponential function */
  116112. static readonly FOGMODE_EXP: number;
  116113. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  116114. static readonly FOGMODE_EXP2: number;
  116115. /** The fog density is following a linear function. */
  116116. static readonly FOGMODE_LINEAR: number;
  116117. /**
  116118. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  116119. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116120. */
  116121. static MinDeltaTime: number;
  116122. /**
  116123. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  116124. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116125. */
  116126. static MaxDeltaTime: number;
  116127. /**
  116128. * Factory used to create the default material.
  116129. * @param name The name of the material to create
  116130. * @param scene The scene to create the material for
  116131. * @returns The default material
  116132. */
  116133. static DefaultMaterialFactory(scene: Scene): Material;
  116134. /**
  116135. * Factory used to create the a collision coordinator.
  116136. * @returns The collision coordinator
  116137. */
  116138. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  116139. /** @hidden */
  116140. _inputManager: InputManager;
  116141. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  116142. cameraToUseForPointers: Nullable<Camera>;
  116143. /** @hidden */
  116144. readonly _isScene: boolean;
  116145. /** @hidden */
  116146. _blockEntityCollection: boolean;
  116147. /**
  116148. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  116149. */
  116150. autoClear: boolean;
  116151. /**
  116152. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  116153. */
  116154. autoClearDepthAndStencil: boolean;
  116155. /**
  116156. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  116157. */
  116158. clearColor: Color4;
  116159. /**
  116160. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  116161. */
  116162. ambientColor: Color3;
  116163. /**
  116164. * This is use to store the default BRDF lookup for PBR materials in your scene.
  116165. * It should only be one of the following (if not the default embedded one):
  116166. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  116167. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  116168. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  116169. * The material properties need to be setup according to the type of texture in use.
  116170. */
  116171. environmentBRDFTexture: BaseTexture;
  116172. /** @hidden */
  116173. protected _environmentTexture: Nullable<BaseTexture>;
  116174. /**
  116175. * Texture used in all pbr material as the reflection texture.
  116176. * As in the majority of the scene they are the same (exception for multi room and so on),
  116177. * this is easier to reference from here than from all the materials.
  116178. */
  116179. get environmentTexture(): Nullable<BaseTexture>;
  116180. /**
  116181. * Texture used in all pbr material as the reflection texture.
  116182. * As in the majority of the scene they are the same (exception for multi room and so on),
  116183. * this is easier to set here than in all the materials.
  116184. */
  116185. set environmentTexture(value: Nullable<BaseTexture>);
  116186. /** @hidden */
  116187. protected _environmentIntensity: number;
  116188. /**
  116189. * Intensity of the environment in all pbr material.
  116190. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  116191. * As in the majority of the scene they are the same (exception for multi room and so on),
  116192. * this is easier to reference from here than from all the materials.
  116193. */
  116194. get environmentIntensity(): number;
  116195. /**
  116196. * Intensity of the environment in all pbr material.
  116197. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  116198. * As in the majority of the scene they are the same (exception for multi room and so on),
  116199. * this is easier to set here than in all the materials.
  116200. */
  116201. set environmentIntensity(value: number);
  116202. /** @hidden */
  116203. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116204. /**
  116205. * Default image processing configuration used either in the rendering
  116206. * Forward main pass or through the imageProcessingPostProcess if present.
  116207. * As in the majority of the scene they are the same (exception for multi camera),
  116208. * this is easier to reference from here than from all the materials and post process.
  116209. *
  116210. * No setter as we it is a shared configuration, you can set the values instead.
  116211. */
  116212. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  116213. private _forceWireframe;
  116214. /**
  116215. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  116216. */
  116217. set forceWireframe(value: boolean);
  116218. get forceWireframe(): boolean;
  116219. private _skipFrustumClipping;
  116220. /**
  116221. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  116222. */
  116223. set skipFrustumClipping(value: boolean);
  116224. get skipFrustumClipping(): boolean;
  116225. private _forcePointsCloud;
  116226. /**
  116227. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  116228. */
  116229. set forcePointsCloud(value: boolean);
  116230. get forcePointsCloud(): boolean;
  116231. /**
  116232. * Gets or sets the active clipplane 1
  116233. */
  116234. clipPlane: Nullable<Plane>;
  116235. /**
  116236. * Gets or sets the active clipplane 2
  116237. */
  116238. clipPlane2: Nullable<Plane>;
  116239. /**
  116240. * Gets or sets the active clipplane 3
  116241. */
  116242. clipPlane3: Nullable<Plane>;
  116243. /**
  116244. * Gets or sets the active clipplane 4
  116245. */
  116246. clipPlane4: Nullable<Plane>;
  116247. /**
  116248. * Gets or sets the active clipplane 5
  116249. */
  116250. clipPlane5: Nullable<Plane>;
  116251. /**
  116252. * Gets or sets the active clipplane 6
  116253. */
  116254. clipPlane6: Nullable<Plane>;
  116255. /**
  116256. * Gets or sets a boolean indicating if animations are enabled
  116257. */
  116258. animationsEnabled: boolean;
  116259. private _animationPropertiesOverride;
  116260. /**
  116261. * Gets or sets the animation properties override
  116262. */
  116263. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  116264. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  116265. /**
  116266. * Gets or sets a boolean indicating if a constant deltatime has to be used
  116267. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  116268. */
  116269. useConstantAnimationDeltaTime: boolean;
  116270. /**
  116271. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  116272. * Please note that it requires to run a ray cast through the scene on every frame
  116273. */
  116274. constantlyUpdateMeshUnderPointer: boolean;
  116275. /**
  116276. * Defines the HTML cursor to use when hovering over interactive elements
  116277. */
  116278. hoverCursor: string;
  116279. /**
  116280. * Defines the HTML default cursor to use (empty by default)
  116281. */
  116282. defaultCursor: string;
  116283. /**
  116284. * Defines whether cursors are handled by the scene.
  116285. */
  116286. doNotHandleCursors: boolean;
  116287. /**
  116288. * This is used to call preventDefault() on pointer down
  116289. * in order to block unwanted artifacts like system double clicks
  116290. */
  116291. preventDefaultOnPointerDown: boolean;
  116292. /**
  116293. * This is used to call preventDefault() on pointer up
  116294. * in order to block unwanted artifacts like system double clicks
  116295. */
  116296. preventDefaultOnPointerUp: boolean;
  116297. /**
  116298. * Gets or sets user defined metadata
  116299. */
  116300. metadata: any;
  116301. /**
  116302. * For internal use only. Please do not use.
  116303. */
  116304. reservedDataStore: any;
  116305. /**
  116306. * Gets the name of the plugin used to load this scene (null by default)
  116307. */
  116308. loadingPluginName: string;
  116309. /**
  116310. * Use this array to add regular expressions used to disable offline support for specific urls
  116311. */
  116312. disableOfflineSupportExceptionRules: RegExp[];
  116313. /**
  116314. * An event triggered when the scene is disposed.
  116315. */
  116316. onDisposeObservable: Observable<Scene>;
  116317. private _onDisposeObserver;
  116318. /** Sets a function to be executed when this scene is disposed. */
  116319. set onDispose(callback: () => void);
  116320. /**
  116321. * An event triggered before rendering the scene (right after animations and physics)
  116322. */
  116323. onBeforeRenderObservable: Observable<Scene>;
  116324. private _onBeforeRenderObserver;
  116325. /** Sets a function to be executed before rendering this scene */
  116326. set beforeRender(callback: Nullable<() => void>);
  116327. /**
  116328. * An event triggered after rendering the scene
  116329. */
  116330. onAfterRenderObservable: Observable<Scene>;
  116331. /**
  116332. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  116333. */
  116334. onAfterRenderCameraObservable: Observable<Camera>;
  116335. private _onAfterRenderObserver;
  116336. /** Sets a function to be executed after rendering this scene */
  116337. set afterRender(callback: Nullable<() => void>);
  116338. /**
  116339. * An event triggered before animating the scene
  116340. */
  116341. onBeforeAnimationsObservable: Observable<Scene>;
  116342. /**
  116343. * An event triggered after animations processing
  116344. */
  116345. onAfterAnimationsObservable: Observable<Scene>;
  116346. /**
  116347. * An event triggered before draw calls are ready to be sent
  116348. */
  116349. onBeforeDrawPhaseObservable: Observable<Scene>;
  116350. /**
  116351. * An event triggered after draw calls have been sent
  116352. */
  116353. onAfterDrawPhaseObservable: Observable<Scene>;
  116354. /**
  116355. * An event triggered when the scene is ready
  116356. */
  116357. onReadyObservable: Observable<Scene>;
  116358. /**
  116359. * An event triggered before rendering a camera
  116360. */
  116361. onBeforeCameraRenderObservable: Observable<Camera>;
  116362. private _onBeforeCameraRenderObserver;
  116363. /** Sets a function to be executed before rendering a camera*/
  116364. set beforeCameraRender(callback: () => void);
  116365. /**
  116366. * An event triggered after rendering a camera
  116367. */
  116368. onAfterCameraRenderObservable: Observable<Camera>;
  116369. private _onAfterCameraRenderObserver;
  116370. /** Sets a function to be executed after rendering a camera*/
  116371. set afterCameraRender(callback: () => void);
  116372. /**
  116373. * An event triggered when active meshes evaluation is about to start
  116374. */
  116375. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  116376. /**
  116377. * An event triggered when active meshes evaluation is done
  116378. */
  116379. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  116380. /**
  116381. * An event triggered when particles rendering is about to start
  116382. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  116383. */
  116384. onBeforeParticlesRenderingObservable: Observable<Scene>;
  116385. /**
  116386. * An event triggered when particles rendering is done
  116387. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  116388. */
  116389. onAfterParticlesRenderingObservable: Observable<Scene>;
  116390. /**
  116391. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  116392. */
  116393. onDataLoadedObservable: Observable<Scene>;
  116394. /**
  116395. * An event triggered when a camera is created
  116396. */
  116397. onNewCameraAddedObservable: Observable<Camera>;
  116398. /**
  116399. * An event triggered when a camera is removed
  116400. */
  116401. onCameraRemovedObservable: Observable<Camera>;
  116402. /**
  116403. * An event triggered when a light is created
  116404. */
  116405. onNewLightAddedObservable: Observable<Light>;
  116406. /**
  116407. * An event triggered when a light is removed
  116408. */
  116409. onLightRemovedObservable: Observable<Light>;
  116410. /**
  116411. * An event triggered when a geometry is created
  116412. */
  116413. onNewGeometryAddedObservable: Observable<Geometry>;
  116414. /**
  116415. * An event triggered when a geometry is removed
  116416. */
  116417. onGeometryRemovedObservable: Observable<Geometry>;
  116418. /**
  116419. * An event triggered when a transform node is created
  116420. */
  116421. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  116422. /**
  116423. * An event triggered when a transform node is removed
  116424. */
  116425. onTransformNodeRemovedObservable: Observable<TransformNode>;
  116426. /**
  116427. * An event triggered when a mesh is created
  116428. */
  116429. onNewMeshAddedObservable: Observable<AbstractMesh>;
  116430. /**
  116431. * An event triggered when a mesh is removed
  116432. */
  116433. onMeshRemovedObservable: Observable<AbstractMesh>;
  116434. /**
  116435. * An event triggered when a skeleton is created
  116436. */
  116437. onNewSkeletonAddedObservable: Observable<Skeleton>;
  116438. /**
  116439. * An event triggered when a skeleton is removed
  116440. */
  116441. onSkeletonRemovedObservable: Observable<Skeleton>;
  116442. /**
  116443. * An event triggered when a material is created
  116444. */
  116445. onNewMaterialAddedObservable: Observable<Material>;
  116446. /**
  116447. * An event triggered when a material is removed
  116448. */
  116449. onMaterialRemovedObservable: Observable<Material>;
  116450. /**
  116451. * An event triggered when a texture is created
  116452. */
  116453. onNewTextureAddedObservable: Observable<BaseTexture>;
  116454. /**
  116455. * An event triggered when a texture is removed
  116456. */
  116457. onTextureRemovedObservable: Observable<BaseTexture>;
  116458. /**
  116459. * An event triggered when render targets are about to be rendered
  116460. * Can happen multiple times per frame.
  116461. */
  116462. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  116463. /**
  116464. * An event triggered when render targets were rendered.
  116465. * Can happen multiple times per frame.
  116466. */
  116467. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  116468. /**
  116469. * An event triggered before calculating deterministic simulation step
  116470. */
  116471. onBeforeStepObservable: Observable<Scene>;
  116472. /**
  116473. * An event triggered after calculating deterministic simulation step
  116474. */
  116475. onAfterStepObservable: Observable<Scene>;
  116476. /**
  116477. * An event triggered when the activeCamera property is updated
  116478. */
  116479. onActiveCameraChanged: Observable<Scene>;
  116480. /**
  116481. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  116482. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  116483. * 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)
  116484. */
  116485. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  116486. /**
  116487. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  116488. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  116489. * 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)
  116490. */
  116491. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  116492. /**
  116493. * This Observable will when a mesh has been imported into the scene.
  116494. */
  116495. onMeshImportedObservable: Observable<AbstractMesh>;
  116496. /**
  116497. * This Observable will when an animation file has been imported into the scene.
  116498. */
  116499. onAnimationFileImportedObservable: Observable<Scene>;
  116500. /**
  116501. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  116502. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  116503. */
  116504. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  116505. /** @hidden */
  116506. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  116507. /**
  116508. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  116509. */
  116510. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  116511. /**
  116512. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  116513. */
  116514. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  116515. /**
  116516. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  116517. */
  116518. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  116519. /** Callback called when a pointer move is detected */
  116520. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  116521. /** Callback called when a pointer down is detected */
  116522. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  116523. /** Callback called when a pointer up is detected */
  116524. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  116525. /** Callback called when a pointer pick is detected */
  116526. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  116527. /**
  116528. * 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).
  116529. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  116530. */
  116531. onPrePointerObservable: Observable<PointerInfoPre>;
  116532. /**
  116533. * Observable event triggered each time an input event is received from the rendering canvas
  116534. */
  116535. onPointerObservable: Observable<PointerInfo>;
  116536. /**
  116537. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  116538. */
  116539. get unTranslatedPointer(): Vector2;
  116540. /**
  116541. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  116542. */
  116543. static get DragMovementThreshold(): number;
  116544. static set DragMovementThreshold(value: number);
  116545. /**
  116546. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  116547. */
  116548. static get LongPressDelay(): number;
  116549. static set LongPressDelay(value: number);
  116550. /**
  116551. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  116552. */
  116553. static get DoubleClickDelay(): number;
  116554. static set DoubleClickDelay(value: number);
  116555. /** If you need to check double click without raising a single click at first click, enable this flag */
  116556. static get ExclusiveDoubleClickMode(): boolean;
  116557. static set ExclusiveDoubleClickMode(value: boolean);
  116558. /** @hidden */
  116559. _mirroredCameraPosition: Nullable<Vector3>;
  116560. /**
  116561. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  116562. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  116563. */
  116564. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  116565. /**
  116566. * Observable event triggered each time an keyboard event is received from the hosting window
  116567. */
  116568. onKeyboardObservable: Observable<KeyboardInfo>;
  116569. private _useRightHandedSystem;
  116570. /**
  116571. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  116572. */
  116573. set useRightHandedSystem(value: boolean);
  116574. get useRightHandedSystem(): boolean;
  116575. private _timeAccumulator;
  116576. private _currentStepId;
  116577. private _currentInternalStep;
  116578. /**
  116579. * Sets the step Id used by deterministic lock step
  116580. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116581. * @param newStepId defines the step Id
  116582. */
  116583. setStepId(newStepId: number): void;
  116584. /**
  116585. * Gets the step Id used by deterministic lock step
  116586. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116587. * @returns the step Id
  116588. */
  116589. getStepId(): number;
  116590. /**
  116591. * Gets the internal step used by deterministic lock step
  116592. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116593. * @returns the internal step
  116594. */
  116595. getInternalStep(): number;
  116596. private _fogEnabled;
  116597. /**
  116598. * Gets or sets a boolean indicating if fog is enabled on this scene
  116599. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116600. * (Default is true)
  116601. */
  116602. set fogEnabled(value: boolean);
  116603. get fogEnabled(): boolean;
  116604. private _fogMode;
  116605. /**
  116606. * Gets or sets the fog mode to use
  116607. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116608. * | mode | value |
  116609. * | --- | --- |
  116610. * | FOGMODE_NONE | 0 |
  116611. * | FOGMODE_EXP | 1 |
  116612. * | FOGMODE_EXP2 | 2 |
  116613. * | FOGMODE_LINEAR | 3 |
  116614. */
  116615. set fogMode(value: number);
  116616. get fogMode(): number;
  116617. /**
  116618. * Gets or sets the fog color to use
  116619. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116620. * (Default is Color3(0.2, 0.2, 0.3))
  116621. */
  116622. fogColor: Color3;
  116623. /**
  116624. * Gets or sets the fog density to use
  116625. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116626. * (Default is 0.1)
  116627. */
  116628. fogDensity: number;
  116629. /**
  116630. * Gets or sets the fog start distance to use
  116631. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116632. * (Default is 0)
  116633. */
  116634. fogStart: number;
  116635. /**
  116636. * Gets or sets the fog end distance to use
  116637. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116638. * (Default is 1000)
  116639. */
  116640. fogEnd: number;
  116641. private _shadowsEnabled;
  116642. /**
  116643. * Gets or sets a boolean indicating if shadows are enabled on this scene
  116644. */
  116645. set shadowsEnabled(value: boolean);
  116646. get shadowsEnabled(): boolean;
  116647. private _lightsEnabled;
  116648. /**
  116649. * Gets or sets a boolean indicating if lights are enabled on this scene
  116650. */
  116651. set lightsEnabled(value: boolean);
  116652. get lightsEnabled(): boolean;
  116653. /** All of the active cameras added to this scene. */
  116654. activeCameras: Camera[];
  116655. /** @hidden */
  116656. _activeCamera: Nullable<Camera>;
  116657. /** Gets or sets the current active camera */
  116658. get activeCamera(): Nullable<Camera>;
  116659. set activeCamera(value: Nullable<Camera>);
  116660. private _defaultMaterial;
  116661. /** The default material used on meshes when no material is affected */
  116662. get defaultMaterial(): Material;
  116663. /** The default material used on meshes when no material is affected */
  116664. set defaultMaterial(value: Material);
  116665. private _texturesEnabled;
  116666. /**
  116667. * Gets or sets a boolean indicating if textures are enabled on this scene
  116668. */
  116669. set texturesEnabled(value: boolean);
  116670. get texturesEnabled(): boolean;
  116671. /**
  116672. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  116673. */
  116674. physicsEnabled: boolean;
  116675. /**
  116676. * Gets or sets a boolean indicating if particles are enabled on this scene
  116677. */
  116678. particlesEnabled: boolean;
  116679. /**
  116680. * Gets or sets a boolean indicating if sprites are enabled on this scene
  116681. */
  116682. spritesEnabled: boolean;
  116683. private _skeletonsEnabled;
  116684. /**
  116685. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  116686. */
  116687. set skeletonsEnabled(value: boolean);
  116688. get skeletonsEnabled(): boolean;
  116689. /**
  116690. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  116691. */
  116692. lensFlaresEnabled: boolean;
  116693. /**
  116694. * Gets or sets a boolean indicating if collisions are enabled on this scene
  116695. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116696. */
  116697. collisionsEnabled: boolean;
  116698. private _collisionCoordinator;
  116699. /** @hidden */
  116700. get collisionCoordinator(): ICollisionCoordinator;
  116701. /**
  116702. * Defines the gravity applied to this scene (used only for collisions)
  116703. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116704. */
  116705. gravity: Vector3;
  116706. /**
  116707. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  116708. */
  116709. postProcessesEnabled: boolean;
  116710. /**
  116711. * The list of postprocesses added to the scene
  116712. */
  116713. postProcesses: PostProcess[];
  116714. /**
  116715. * Gets the current postprocess manager
  116716. */
  116717. postProcessManager: PostProcessManager;
  116718. /**
  116719. * Gets or sets a boolean indicating if render targets are enabled on this scene
  116720. */
  116721. renderTargetsEnabled: boolean;
  116722. /**
  116723. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  116724. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  116725. */
  116726. dumpNextRenderTargets: boolean;
  116727. /**
  116728. * The list of user defined render targets added to the scene
  116729. */
  116730. customRenderTargets: RenderTargetTexture[];
  116731. /**
  116732. * Defines if texture loading must be delayed
  116733. * If true, textures will only be loaded when they need to be rendered
  116734. */
  116735. useDelayedTextureLoading: boolean;
  116736. /**
  116737. * Gets the list of meshes imported to the scene through SceneLoader
  116738. */
  116739. importedMeshesFiles: String[];
  116740. /**
  116741. * Gets or sets a boolean indicating if probes are enabled on this scene
  116742. */
  116743. probesEnabled: boolean;
  116744. /**
  116745. * Gets or sets the current offline provider to use to store scene data
  116746. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  116747. */
  116748. offlineProvider: IOfflineProvider;
  116749. /**
  116750. * Gets or sets the action manager associated with the scene
  116751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  116752. */
  116753. actionManager: AbstractActionManager;
  116754. private _meshesForIntersections;
  116755. /**
  116756. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  116757. */
  116758. proceduralTexturesEnabled: boolean;
  116759. private _engine;
  116760. private _totalVertices;
  116761. /** @hidden */
  116762. _activeIndices: PerfCounter;
  116763. /** @hidden */
  116764. _activeParticles: PerfCounter;
  116765. /** @hidden */
  116766. _activeBones: PerfCounter;
  116767. private _animationRatio;
  116768. /** @hidden */
  116769. _animationTimeLast: number;
  116770. /** @hidden */
  116771. _animationTime: number;
  116772. /**
  116773. * Gets or sets a general scale for animation speed
  116774. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  116775. */
  116776. animationTimeScale: number;
  116777. /** @hidden */
  116778. _cachedMaterial: Nullable<Material>;
  116779. /** @hidden */
  116780. _cachedEffect: Nullable<Effect>;
  116781. /** @hidden */
  116782. _cachedVisibility: Nullable<number>;
  116783. private _renderId;
  116784. private _frameId;
  116785. private _executeWhenReadyTimeoutId;
  116786. private _intermediateRendering;
  116787. private _viewUpdateFlag;
  116788. private _projectionUpdateFlag;
  116789. /** @hidden */
  116790. _toBeDisposed: Nullable<IDisposable>[];
  116791. private _activeRequests;
  116792. /** @hidden */
  116793. _pendingData: any[];
  116794. private _isDisposed;
  116795. /**
  116796. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  116797. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  116798. */
  116799. dispatchAllSubMeshesOfActiveMeshes: boolean;
  116800. private _activeMeshes;
  116801. private _processedMaterials;
  116802. private _renderTargets;
  116803. /** @hidden */
  116804. _activeParticleSystems: SmartArray<IParticleSystem>;
  116805. private _activeSkeletons;
  116806. private _softwareSkinnedMeshes;
  116807. private _renderingManager;
  116808. /** @hidden */
  116809. _activeAnimatables: Animatable[];
  116810. private _transformMatrix;
  116811. private _sceneUbo;
  116812. /** @hidden */
  116813. _viewMatrix: Matrix;
  116814. private _projectionMatrix;
  116815. /** @hidden */
  116816. _forcedViewPosition: Nullable<Vector3>;
  116817. /** @hidden */
  116818. _frustumPlanes: Plane[];
  116819. /**
  116820. * Gets the list of frustum planes (built from the active camera)
  116821. */
  116822. get frustumPlanes(): Plane[];
  116823. /**
  116824. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  116825. * This is useful if there are more lights that the maximum simulteanous authorized
  116826. */
  116827. requireLightSorting: boolean;
  116828. /** @hidden */
  116829. readonly useMaterialMeshMap: boolean;
  116830. /** @hidden */
  116831. readonly useClonedMeshMap: boolean;
  116832. private _externalData;
  116833. private _uid;
  116834. /**
  116835. * @hidden
  116836. * Backing store of defined scene components.
  116837. */
  116838. _components: ISceneComponent[];
  116839. /**
  116840. * @hidden
  116841. * Backing store of defined scene components.
  116842. */
  116843. _serializableComponents: ISceneSerializableComponent[];
  116844. /**
  116845. * List of components to register on the next registration step.
  116846. */
  116847. private _transientComponents;
  116848. /**
  116849. * Registers the transient components if needed.
  116850. */
  116851. private _registerTransientComponents;
  116852. /**
  116853. * @hidden
  116854. * Add a component to the scene.
  116855. * Note that the ccomponent could be registered on th next frame if this is called after
  116856. * the register component stage.
  116857. * @param component Defines the component to add to the scene
  116858. */
  116859. _addComponent(component: ISceneComponent): void;
  116860. /**
  116861. * @hidden
  116862. * Gets a component from the scene.
  116863. * @param name defines the name of the component to retrieve
  116864. * @returns the component or null if not present
  116865. */
  116866. _getComponent(name: string): Nullable<ISceneComponent>;
  116867. /**
  116868. * @hidden
  116869. * Defines the actions happening before camera updates.
  116870. */
  116871. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  116872. /**
  116873. * @hidden
  116874. * Defines the actions happening before clear the canvas.
  116875. */
  116876. _beforeClearStage: Stage<SimpleStageAction>;
  116877. /**
  116878. * @hidden
  116879. * Defines the actions when collecting render targets for the frame.
  116880. */
  116881. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  116882. /**
  116883. * @hidden
  116884. * Defines the actions happening for one camera in the frame.
  116885. */
  116886. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  116887. /**
  116888. * @hidden
  116889. * Defines the actions happening during the per mesh ready checks.
  116890. */
  116891. _isReadyForMeshStage: Stage<MeshStageAction>;
  116892. /**
  116893. * @hidden
  116894. * Defines the actions happening before evaluate active mesh checks.
  116895. */
  116896. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  116897. /**
  116898. * @hidden
  116899. * Defines the actions happening during the evaluate sub mesh checks.
  116900. */
  116901. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  116902. /**
  116903. * @hidden
  116904. * Defines the actions happening during the active mesh stage.
  116905. */
  116906. _activeMeshStage: Stage<ActiveMeshStageAction>;
  116907. /**
  116908. * @hidden
  116909. * Defines the actions happening during the per camera render target step.
  116910. */
  116911. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  116912. /**
  116913. * @hidden
  116914. * Defines the actions happening just before the active camera is drawing.
  116915. */
  116916. _beforeCameraDrawStage: Stage<CameraStageAction>;
  116917. /**
  116918. * @hidden
  116919. * Defines the actions happening just before a render target is drawing.
  116920. */
  116921. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  116922. /**
  116923. * @hidden
  116924. * Defines the actions happening just before a rendering group is drawing.
  116925. */
  116926. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  116927. /**
  116928. * @hidden
  116929. * Defines the actions happening just before a mesh is drawing.
  116930. */
  116931. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  116932. /**
  116933. * @hidden
  116934. * Defines the actions happening just after a mesh has been drawn.
  116935. */
  116936. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  116937. /**
  116938. * @hidden
  116939. * Defines the actions happening just after a rendering group has been drawn.
  116940. */
  116941. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  116942. /**
  116943. * @hidden
  116944. * Defines the actions happening just after the active camera has been drawn.
  116945. */
  116946. _afterCameraDrawStage: Stage<CameraStageAction>;
  116947. /**
  116948. * @hidden
  116949. * Defines the actions happening just after a render target has been drawn.
  116950. */
  116951. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  116952. /**
  116953. * @hidden
  116954. * Defines the actions happening just after rendering all cameras and computing intersections.
  116955. */
  116956. _afterRenderStage: Stage<SimpleStageAction>;
  116957. /**
  116958. * @hidden
  116959. * Defines the actions happening when a pointer move event happens.
  116960. */
  116961. _pointerMoveStage: Stage<PointerMoveStageAction>;
  116962. /**
  116963. * @hidden
  116964. * Defines the actions happening when a pointer down event happens.
  116965. */
  116966. _pointerDownStage: Stage<PointerUpDownStageAction>;
  116967. /**
  116968. * @hidden
  116969. * Defines the actions happening when a pointer up event happens.
  116970. */
  116971. _pointerUpStage: Stage<PointerUpDownStageAction>;
  116972. /**
  116973. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  116974. */
  116975. private geometriesByUniqueId;
  116976. /**
  116977. * Creates a new Scene
  116978. * @param engine defines the engine to use to render this scene
  116979. * @param options defines the scene options
  116980. */
  116981. constructor(engine: Engine, options?: SceneOptions);
  116982. /**
  116983. * Gets a string idenfifying the name of the class
  116984. * @returns "Scene" string
  116985. */
  116986. getClassName(): string;
  116987. private _defaultMeshCandidates;
  116988. /**
  116989. * @hidden
  116990. */
  116991. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  116992. private _defaultSubMeshCandidates;
  116993. /**
  116994. * @hidden
  116995. */
  116996. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  116997. /**
  116998. * Sets the default candidate providers for the scene.
  116999. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  117000. * and getCollidingSubMeshCandidates to their default function
  117001. */
  117002. setDefaultCandidateProviders(): void;
  117003. /**
  117004. * Gets the mesh that is currently under the pointer
  117005. */
  117006. get meshUnderPointer(): Nullable<AbstractMesh>;
  117007. /**
  117008. * Gets or sets the current on-screen X position of the pointer
  117009. */
  117010. get pointerX(): number;
  117011. set pointerX(value: number);
  117012. /**
  117013. * Gets or sets the current on-screen Y position of the pointer
  117014. */
  117015. get pointerY(): number;
  117016. set pointerY(value: number);
  117017. /**
  117018. * Gets the cached material (ie. the latest rendered one)
  117019. * @returns the cached material
  117020. */
  117021. getCachedMaterial(): Nullable<Material>;
  117022. /**
  117023. * Gets the cached effect (ie. the latest rendered one)
  117024. * @returns the cached effect
  117025. */
  117026. getCachedEffect(): Nullable<Effect>;
  117027. /**
  117028. * Gets the cached visibility state (ie. the latest rendered one)
  117029. * @returns the cached visibility state
  117030. */
  117031. getCachedVisibility(): Nullable<number>;
  117032. /**
  117033. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  117034. * @param material defines the current material
  117035. * @param effect defines the current effect
  117036. * @param visibility defines the current visibility state
  117037. * @returns true if one parameter is not cached
  117038. */
  117039. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  117040. /**
  117041. * Gets the engine associated with the scene
  117042. * @returns an Engine
  117043. */
  117044. getEngine(): Engine;
  117045. /**
  117046. * Gets the total number of vertices rendered per frame
  117047. * @returns the total number of vertices rendered per frame
  117048. */
  117049. getTotalVertices(): number;
  117050. /**
  117051. * Gets the performance counter for total vertices
  117052. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117053. */
  117054. get totalVerticesPerfCounter(): PerfCounter;
  117055. /**
  117056. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  117057. * @returns the total number of active indices rendered per frame
  117058. */
  117059. getActiveIndices(): number;
  117060. /**
  117061. * Gets the performance counter for active indices
  117062. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117063. */
  117064. get totalActiveIndicesPerfCounter(): PerfCounter;
  117065. /**
  117066. * Gets the total number of active particles rendered per frame
  117067. * @returns the total number of active particles rendered per frame
  117068. */
  117069. getActiveParticles(): number;
  117070. /**
  117071. * Gets the performance counter for active particles
  117072. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117073. */
  117074. get activeParticlesPerfCounter(): PerfCounter;
  117075. /**
  117076. * Gets the total number of active bones rendered per frame
  117077. * @returns the total number of active bones rendered per frame
  117078. */
  117079. getActiveBones(): number;
  117080. /**
  117081. * Gets the performance counter for active bones
  117082. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117083. */
  117084. get activeBonesPerfCounter(): PerfCounter;
  117085. /**
  117086. * Gets the array of active meshes
  117087. * @returns an array of AbstractMesh
  117088. */
  117089. getActiveMeshes(): SmartArray<AbstractMesh>;
  117090. /**
  117091. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  117092. * @returns a number
  117093. */
  117094. getAnimationRatio(): number;
  117095. /**
  117096. * Gets an unique Id for the current render phase
  117097. * @returns a number
  117098. */
  117099. getRenderId(): number;
  117100. /**
  117101. * Gets an unique Id for the current frame
  117102. * @returns a number
  117103. */
  117104. getFrameId(): number;
  117105. /** Call this function if you want to manually increment the render Id*/
  117106. incrementRenderId(): void;
  117107. private _createUbo;
  117108. /**
  117109. * Use this method to simulate a pointer move on a mesh
  117110. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117111. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117112. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117113. * @returns the current scene
  117114. */
  117115. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  117116. /**
  117117. * Use this method to simulate a pointer down on a mesh
  117118. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117119. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117120. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117121. * @returns the current scene
  117122. */
  117123. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  117124. /**
  117125. * Use this method to simulate a pointer up on a mesh
  117126. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117127. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117128. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117129. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  117130. * @returns the current scene
  117131. */
  117132. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  117133. /**
  117134. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  117135. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  117136. * @returns true if the pointer was captured
  117137. */
  117138. isPointerCaptured(pointerId?: number): boolean;
  117139. /**
  117140. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  117141. * @param attachUp defines if you want to attach events to pointerup
  117142. * @param attachDown defines if you want to attach events to pointerdown
  117143. * @param attachMove defines if you want to attach events to pointermove
  117144. */
  117145. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  117146. /** Detaches all event handlers*/
  117147. detachControl(): void;
  117148. /**
  117149. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  117150. * Delay loaded resources are not taking in account
  117151. * @return true if all required resources are ready
  117152. */
  117153. isReady(): boolean;
  117154. /** Resets all cached information relative to material (including effect and visibility) */
  117155. resetCachedMaterial(): void;
  117156. /**
  117157. * Registers a function to be called before every frame render
  117158. * @param func defines the function to register
  117159. */
  117160. registerBeforeRender(func: () => void): void;
  117161. /**
  117162. * Unregisters a function called before every frame render
  117163. * @param func defines the function to unregister
  117164. */
  117165. unregisterBeforeRender(func: () => void): void;
  117166. /**
  117167. * Registers a function to be called after every frame render
  117168. * @param func defines the function to register
  117169. */
  117170. registerAfterRender(func: () => void): void;
  117171. /**
  117172. * Unregisters a function called after every frame render
  117173. * @param func defines the function to unregister
  117174. */
  117175. unregisterAfterRender(func: () => void): void;
  117176. private _executeOnceBeforeRender;
  117177. /**
  117178. * The provided function will run before render once and will be disposed afterwards.
  117179. * A timeout delay can be provided so that the function will be executed in N ms.
  117180. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  117181. * @param func The function to be executed.
  117182. * @param timeout optional delay in ms
  117183. */
  117184. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  117185. /** @hidden */
  117186. _addPendingData(data: any): void;
  117187. /** @hidden */
  117188. _removePendingData(data: any): void;
  117189. /**
  117190. * Returns the number of items waiting to be loaded
  117191. * @returns the number of items waiting to be loaded
  117192. */
  117193. getWaitingItemsCount(): number;
  117194. /**
  117195. * Returns a boolean indicating if the scene is still loading data
  117196. */
  117197. get isLoading(): boolean;
  117198. /**
  117199. * Registers a function to be executed when the scene is ready
  117200. * @param {Function} func - the function to be executed
  117201. */
  117202. executeWhenReady(func: () => void): void;
  117203. /**
  117204. * Returns a promise that resolves when the scene is ready
  117205. * @returns A promise that resolves when the scene is ready
  117206. */
  117207. whenReadyAsync(): Promise<void>;
  117208. /** @hidden */
  117209. _checkIsReady(): void;
  117210. /**
  117211. * Gets all animatable attached to the scene
  117212. */
  117213. get animatables(): Animatable[];
  117214. /**
  117215. * Resets the last animation time frame.
  117216. * Useful to override when animations start running when loading a scene for the first time.
  117217. */
  117218. resetLastAnimationTimeFrame(): void;
  117219. /**
  117220. * Gets the current view matrix
  117221. * @returns a Matrix
  117222. */
  117223. getViewMatrix(): Matrix;
  117224. /**
  117225. * Gets the current projection matrix
  117226. * @returns a Matrix
  117227. */
  117228. getProjectionMatrix(): Matrix;
  117229. /**
  117230. * Gets the current transform matrix
  117231. * @returns a Matrix made of View * Projection
  117232. */
  117233. getTransformMatrix(): Matrix;
  117234. /**
  117235. * Sets the current transform matrix
  117236. * @param viewL defines the View matrix to use
  117237. * @param projectionL defines the Projection matrix to use
  117238. * @param viewR defines the right View matrix to use (if provided)
  117239. * @param projectionR defines the right Projection matrix to use (if provided)
  117240. */
  117241. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  117242. /**
  117243. * Gets the uniform buffer used to store scene data
  117244. * @returns a UniformBuffer
  117245. */
  117246. getSceneUniformBuffer(): UniformBuffer;
  117247. /**
  117248. * Gets an unique (relatively to the current scene) Id
  117249. * @returns an unique number for the scene
  117250. */
  117251. getUniqueId(): number;
  117252. /**
  117253. * Add a mesh to the list of scene's meshes
  117254. * @param newMesh defines the mesh to add
  117255. * @param recursive if all child meshes should also be added to the scene
  117256. */
  117257. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  117258. /**
  117259. * Remove a mesh for the list of scene's meshes
  117260. * @param toRemove defines the mesh to remove
  117261. * @param recursive if all child meshes should also be removed from the scene
  117262. * @returns the index where the mesh was in the mesh list
  117263. */
  117264. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  117265. /**
  117266. * Add a transform node to the list of scene's transform nodes
  117267. * @param newTransformNode defines the transform node to add
  117268. */
  117269. addTransformNode(newTransformNode: TransformNode): void;
  117270. /**
  117271. * Remove a transform node for the list of scene's transform nodes
  117272. * @param toRemove defines the transform node to remove
  117273. * @returns the index where the transform node was in the transform node list
  117274. */
  117275. removeTransformNode(toRemove: TransformNode): number;
  117276. /**
  117277. * Remove a skeleton for the list of scene's skeletons
  117278. * @param toRemove defines the skeleton to remove
  117279. * @returns the index where the skeleton was in the skeleton list
  117280. */
  117281. removeSkeleton(toRemove: Skeleton): number;
  117282. /**
  117283. * Remove a morph target for the list of scene's morph targets
  117284. * @param toRemove defines the morph target to remove
  117285. * @returns the index where the morph target was in the morph target list
  117286. */
  117287. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  117288. /**
  117289. * Remove a light for the list of scene's lights
  117290. * @param toRemove defines the light to remove
  117291. * @returns the index where the light was in the light list
  117292. */
  117293. removeLight(toRemove: Light): number;
  117294. /**
  117295. * Remove a camera for the list of scene's cameras
  117296. * @param toRemove defines the camera to remove
  117297. * @returns the index where the camera was in the camera list
  117298. */
  117299. removeCamera(toRemove: Camera): number;
  117300. /**
  117301. * Remove a particle system for the list of scene's particle systems
  117302. * @param toRemove defines the particle system to remove
  117303. * @returns the index where the particle system was in the particle system list
  117304. */
  117305. removeParticleSystem(toRemove: IParticleSystem): number;
  117306. /**
  117307. * Remove a animation for the list of scene's animations
  117308. * @param toRemove defines the animation to remove
  117309. * @returns the index where the animation was in the animation list
  117310. */
  117311. removeAnimation(toRemove: Animation): number;
  117312. /**
  117313. * Will stop the animation of the given target
  117314. * @param target - the target
  117315. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  117316. * @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)
  117317. */
  117318. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  117319. /**
  117320. * Removes the given animation group from this scene.
  117321. * @param toRemove The animation group to remove
  117322. * @returns The index of the removed animation group
  117323. */
  117324. removeAnimationGroup(toRemove: AnimationGroup): number;
  117325. /**
  117326. * Removes the given multi-material from this scene.
  117327. * @param toRemove The multi-material to remove
  117328. * @returns The index of the removed multi-material
  117329. */
  117330. removeMultiMaterial(toRemove: MultiMaterial): number;
  117331. /**
  117332. * Removes the given material from this scene.
  117333. * @param toRemove The material to remove
  117334. * @returns The index of the removed material
  117335. */
  117336. removeMaterial(toRemove: Material): number;
  117337. /**
  117338. * Removes the given action manager from this scene.
  117339. * @param toRemove The action manager to remove
  117340. * @returns The index of the removed action manager
  117341. */
  117342. removeActionManager(toRemove: AbstractActionManager): number;
  117343. /**
  117344. * Removes the given texture from this scene.
  117345. * @param toRemove The texture to remove
  117346. * @returns The index of the removed texture
  117347. */
  117348. removeTexture(toRemove: BaseTexture): number;
  117349. /**
  117350. * Adds the given light to this scene
  117351. * @param newLight The light to add
  117352. */
  117353. addLight(newLight: Light): void;
  117354. /**
  117355. * Sorts the list list based on light priorities
  117356. */
  117357. sortLightsByPriority(): void;
  117358. /**
  117359. * Adds the given camera to this scene
  117360. * @param newCamera The camera to add
  117361. */
  117362. addCamera(newCamera: Camera): void;
  117363. /**
  117364. * Adds the given skeleton to this scene
  117365. * @param newSkeleton The skeleton to add
  117366. */
  117367. addSkeleton(newSkeleton: Skeleton): void;
  117368. /**
  117369. * Adds the given particle system to this scene
  117370. * @param newParticleSystem The particle system to add
  117371. */
  117372. addParticleSystem(newParticleSystem: IParticleSystem): void;
  117373. /**
  117374. * Adds the given animation to this scene
  117375. * @param newAnimation The animation to add
  117376. */
  117377. addAnimation(newAnimation: Animation): void;
  117378. /**
  117379. * Adds the given animation group to this scene.
  117380. * @param newAnimationGroup The animation group to add
  117381. */
  117382. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  117383. /**
  117384. * Adds the given multi-material to this scene
  117385. * @param newMultiMaterial The multi-material to add
  117386. */
  117387. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  117388. /**
  117389. * Adds the given material to this scene
  117390. * @param newMaterial The material to add
  117391. */
  117392. addMaterial(newMaterial: Material): void;
  117393. /**
  117394. * Adds the given morph target to this scene
  117395. * @param newMorphTargetManager The morph target to add
  117396. */
  117397. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  117398. /**
  117399. * Adds the given geometry to this scene
  117400. * @param newGeometry The geometry to add
  117401. */
  117402. addGeometry(newGeometry: Geometry): void;
  117403. /**
  117404. * Adds the given action manager to this scene
  117405. * @param newActionManager The action manager to add
  117406. */
  117407. addActionManager(newActionManager: AbstractActionManager): void;
  117408. /**
  117409. * Adds the given texture to this scene.
  117410. * @param newTexture The texture to add
  117411. */
  117412. addTexture(newTexture: BaseTexture): void;
  117413. /**
  117414. * Switch active camera
  117415. * @param newCamera defines the new active camera
  117416. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  117417. */
  117418. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  117419. /**
  117420. * sets the active camera of the scene using its ID
  117421. * @param id defines the camera's ID
  117422. * @return the new active camera or null if none found.
  117423. */
  117424. setActiveCameraByID(id: string): Nullable<Camera>;
  117425. /**
  117426. * sets the active camera of the scene using its name
  117427. * @param name defines the camera's name
  117428. * @returns the new active camera or null if none found.
  117429. */
  117430. setActiveCameraByName(name: string): Nullable<Camera>;
  117431. /**
  117432. * get an animation group using its name
  117433. * @param name defines the material's name
  117434. * @return the animation group or null if none found.
  117435. */
  117436. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  117437. /**
  117438. * Get a material using its unique id
  117439. * @param uniqueId defines the material's unique id
  117440. * @return the material or null if none found.
  117441. */
  117442. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  117443. /**
  117444. * get a material using its id
  117445. * @param id defines the material's ID
  117446. * @return the material or null if none found.
  117447. */
  117448. getMaterialByID(id: string): Nullable<Material>;
  117449. /**
  117450. * Gets a the last added material using a given id
  117451. * @param id defines the material's ID
  117452. * @return the last material with the given id or null if none found.
  117453. */
  117454. getLastMaterialByID(id: string): Nullable<Material>;
  117455. /**
  117456. * Gets a material using its name
  117457. * @param name defines the material's name
  117458. * @return the material or null if none found.
  117459. */
  117460. getMaterialByName(name: string): Nullable<Material>;
  117461. /**
  117462. * Get a texture using its unique id
  117463. * @param uniqueId defines the texture's unique id
  117464. * @return the texture or null if none found.
  117465. */
  117466. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  117467. /**
  117468. * Gets a camera using its id
  117469. * @param id defines the id to look for
  117470. * @returns the camera or null if not found
  117471. */
  117472. getCameraByID(id: string): Nullable<Camera>;
  117473. /**
  117474. * Gets a camera using its unique id
  117475. * @param uniqueId defines the unique id to look for
  117476. * @returns the camera or null if not found
  117477. */
  117478. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  117479. /**
  117480. * Gets a camera using its name
  117481. * @param name defines the camera's name
  117482. * @return the camera or null if none found.
  117483. */
  117484. getCameraByName(name: string): Nullable<Camera>;
  117485. /**
  117486. * Gets a bone using its id
  117487. * @param id defines the bone's id
  117488. * @return the bone or null if not found
  117489. */
  117490. getBoneByID(id: string): Nullable<Bone>;
  117491. /**
  117492. * Gets a bone using its id
  117493. * @param name defines the bone's name
  117494. * @return the bone or null if not found
  117495. */
  117496. getBoneByName(name: string): Nullable<Bone>;
  117497. /**
  117498. * Gets a light node using its name
  117499. * @param name defines the the light's name
  117500. * @return the light or null if none found.
  117501. */
  117502. getLightByName(name: string): Nullable<Light>;
  117503. /**
  117504. * Gets a light node using its id
  117505. * @param id defines the light's id
  117506. * @return the light or null if none found.
  117507. */
  117508. getLightByID(id: string): Nullable<Light>;
  117509. /**
  117510. * Gets a light node using its scene-generated unique ID
  117511. * @param uniqueId defines the light's unique id
  117512. * @return the light or null if none found.
  117513. */
  117514. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  117515. /**
  117516. * Gets a particle system by id
  117517. * @param id defines the particle system id
  117518. * @return the corresponding system or null if none found
  117519. */
  117520. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  117521. /**
  117522. * Gets a geometry using its ID
  117523. * @param id defines the geometry's id
  117524. * @return the geometry or null if none found.
  117525. */
  117526. getGeometryByID(id: string): Nullable<Geometry>;
  117527. private _getGeometryByUniqueID;
  117528. /**
  117529. * Add a new geometry to this scene
  117530. * @param geometry defines the geometry to be added to the scene.
  117531. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  117532. * @return a boolean defining if the geometry was added or not
  117533. */
  117534. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  117535. /**
  117536. * Removes an existing geometry
  117537. * @param geometry defines the geometry to be removed from the scene
  117538. * @return a boolean defining if the geometry was removed or not
  117539. */
  117540. removeGeometry(geometry: Geometry): boolean;
  117541. /**
  117542. * Gets the list of geometries attached to the scene
  117543. * @returns an array of Geometry
  117544. */
  117545. getGeometries(): Geometry[];
  117546. /**
  117547. * Gets the first added mesh found of a given ID
  117548. * @param id defines the id to search for
  117549. * @return the mesh found or null if not found at all
  117550. */
  117551. getMeshByID(id: string): Nullable<AbstractMesh>;
  117552. /**
  117553. * Gets a list of meshes using their id
  117554. * @param id defines the id to search for
  117555. * @returns a list of meshes
  117556. */
  117557. getMeshesByID(id: string): Array<AbstractMesh>;
  117558. /**
  117559. * Gets the first added transform node found of a given ID
  117560. * @param id defines the id to search for
  117561. * @return the found transform node or null if not found at all.
  117562. */
  117563. getTransformNodeByID(id: string): Nullable<TransformNode>;
  117564. /**
  117565. * Gets a transform node with its auto-generated unique id
  117566. * @param uniqueId efines the unique id to search for
  117567. * @return the found transform node or null if not found at all.
  117568. */
  117569. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  117570. /**
  117571. * Gets a list of transform nodes using their id
  117572. * @param id defines the id to search for
  117573. * @returns a list of transform nodes
  117574. */
  117575. getTransformNodesByID(id: string): Array<TransformNode>;
  117576. /**
  117577. * Gets a mesh with its auto-generated unique id
  117578. * @param uniqueId defines the unique id to search for
  117579. * @return the found mesh or null if not found at all.
  117580. */
  117581. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  117582. /**
  117583. * Gets a the last added mesh using a given id
  117584. * @param id defines the id to search for
  117585. * @return the found mesh or null if not found at all.
  117586. */
  117587. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  117588. /**
  117589. * Gets a the last added node (Mesh, Camera, Light) using a given id
  117590. * @param id defines the id to search for
  117591. * @return the found node or null if not found at all
  117592. */
  117593. getLastEntryByID(id: string): Nullable<Node>;
  117594. /**
  117595. * Gets a node (Mesh, Camera, Light) using a given id
  117596. * @param id defines the id to search for
  117597. * @return the found node or null if not found at all
  117598. */
  117599. getNodeByID(id: string): Nullable<Node>;
  117600. /**
  117601. * Gets a node (Mesh, Camera, Light) using a given name
  117602. * @param name defines the name to search for
  117603. * @return the found node or null if not found at all.
  117604. */
  117605. getNodeByName(name: string): Nullable<Node>;
  117606. /**
  117607. * Gets a mesh using a given name
  117608. * @param name defines the name to search for
  117609. * @return the found mesh or null if not found at all.
  117610. */
  117611. getMeshByName(name: string): Nullable<AbstractMesh>;
  117612. /**
  117613. * Gets a transform node using a given name
  117614. * @param name defines the name to search for
  117615. * @return the found transform node or null if not found at all.
  117616. */
  117617. getTransformNodeByName(name: string): Nullable<TransformNode>;
  117618. /**
  117619. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  117620. * @param id defines the id to search for
  117621. * @return the found skeleton or null if not found at all.
  117622. */
  117623. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  117624. /**
  117625. * Gets a skeleton using a given auto generated unique id
  117626. * @param uniqueId defines the unique id to search for
  117627. * @return the found skeleton or null if not found at all.
  117628. */
  117629. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  117630. /**
  117631. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  117632. * @param id defines the id to search for
  117633. * @return the found skeleton or null if not found at all.
  117634. */
  117635. getSkeletonById(id: string): Nullable<Skeleton>;
  117636. /**
  117637. * Gets a skeleton using a given name
  117638. * @param name defines the name to search for
  117639. * @return the found skeleton or null if not found at all.
  117640. */
  117641. getSkeletonByName(name: string): Nullable<Skeleton>;
  117642. /**
  117643. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  117644. * @param id defines the id to search for
  117645. * @return the found morph target manager or null if not found at all.
  117646. */
  117647. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  117648. /**
  117649. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  117650. * @param id defines the id to search for
  117651. * @return the found morph target or null if not found at all.
  117652. */
  117653. getMorphTargetById(id: string): Nullable<MorphTarget>;
  117654. /**
  117655. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  117656. * @param name defines the name to search for
  117657. * @return the found morph target or null if not found at all.
  117658. */
  117659. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  117660. /**
  117661. * Gets a boolean indicating if the given mesh is active
  117662. * @param mesh defines the mesh to look for
  117663. * @returns true if the mesh is in the active list
  117664. */
  117665. isActiveMesh(mesh: AbstractMesh): boolean;
  117666. /**
  117667. * Return a unique id as a string which can serve as an identifier for the scene
  117668. */
  117669. get uid(): string;
  117670. /**
  117671. * Add an externaly attached data from its key.
  117672. * This method call will fail and return false, if such key already exists.
  117673. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  117674. * @param key the unique key that identifies the data
  117675. * @param data the data object to associate to the key for this Engine instance
  117676. * @return true if no such key were already present and the data was added successfully, false otherwise
  117677. */
  117678. addExternalData<T>(key: string, data: T): boolean;
  117679. /**
  117680. * Get an externaly attached data from its key
  117681. * @param key the unique key that identifies the data
  117682. * @return the associated data, if present (can be null), or undefined if not present
  117683. */
  117684. getExternalData<T>(key: string): Nullable<T>;
  117685. /**
  117686. * Get an externaly attached data from its key, create it using a factory if it's not already present
  117687. * @param key the unique key that identifies the data
  117688. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  117689. * @return the associated data, can be null if the factory returned null.
  117690. */
  117691. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  117692. /**
  117693. * Remove an externaly attached data from the Engine instance
  117694. * @param key the unique key that identifies the data
  117695. * @return true if the data was successfully removed, false if it doesn't exist
  117696. */
  117697. removeExternalData(key: string): boolean;
  117698. private _evaluateSubMesh;
  117699. /**
  117700. * Clear the processed materials smart array preventing retention point in material dispose.
  117701. */
  117702. freeProcessedMaterials(): void;
  117703. private _preventFreeActiveMeshesAndRenderingGroups;
  117704. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  117705. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  117706. * when disposing several meshes in a row or a hierarchy of meshes.
  117707. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  117708. */
  117709. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  117710. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  117711. /**
  117712. * Clear the active meshes smart array preventing retention point in mesh dispose.
  117713. */
  117714. freeActiveMeshes(): void;
  117715. /**
  117716. * Clear the info related to rendering groups preventing retention points during dispose.
  117717. */
  117718. freeRenderingGroups(): void;
  117719. /** @hidden */
  117720. _isInIntermediateRendering(): boolean;
  117721. /**
  117722. * Lambda returning the list of potentially active meshes.
  117723. */
  117724. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  117725. /**
  117726. * Lambda returning the list of potentially active sub meshes.
  117727. */
  117728. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  117729. /**
  117730. * Lambda returning the list of potentially intersecting sub meshes.
  117731. */
  117732. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  117733. /**
  117734. * Lambda returning the list of potentially colliding sub meshes.
  117735. */
  117736. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  117737. private _activeMeshesFrozen;
  117738. private _skipEvaluateActiveMeshesCompletely;
  117739. /**
  117740. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  117741. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  117742. * @returns the current scene
  117743. */
  117744. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  117745. /**
  117746. * Use this function to restart evaluating active meshes on every frame
  117747. * @returns the current scene
  117748. */
  117749. unfreezeActiveMeshes(): Scene;
  117750. private _evaluateActiveMeshes;
  117751. private _activeMesh;
  117752. /**
  117753. * Update the transform matrix to update from the current active camera
  117754. * @param force defines a boolean used to force the update even if cache is up to date
  117755. */
  117756. updateTransformMatrix(force?: boolean): void;
  117757. private _bindFrameBuffer;
  117758. /** @hidden */
  117759. _allowPostProcessClearColor: boolean;
  117760. /** @hidden */
  117761. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  117762. private _processSubCameras;
  117763. private _checkIntersections;
  117764. /** @hidden */
  117765. _advancePhysicsEngineStep(step: number): void;
  117766. /**
  117767. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  117768. */
  117769. getDeterministicFrameTime: () => number;
  117770. /** @hidden */
  117771. _animate(): void;
  117772. /** Execute all animations (for a frame) */
  117773. animate(): void;
  117774. /**
  117775. * Render the scene
  117776. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  117777. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  117778. */
  117779. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  117780. /**
  117781. * Freeze all materials
  117782. * A frozen material will not be updatable but should be faster to render
  117783. */
  117784. freezeMaterials(): void;
  117785. /**
  117786. * Unfreeze all materials
  117787. * A frozen material will not be updatable but should be faster to render
  117788. */
  117789. unfreezeMaterials(): void;
  117790. /**
  117791. * Releases all held ressources
  117792. */
  117793. dispose(): void;
  117794. /**
  117795. * Gets if the scene is already disposed
  117796. */
  117797. get isDisposed(): boolean;
  117798. /**
  117799. * Call this function to reduce memory footprint of the scene.
  117800. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  117801. */
  117802. clearCachedVertexData(): void;
  117803. /**
  117804. * This function will remove the local cached buffer data from texture.
  117805. * It will save memory but will prevent the texture from being rebuilt
  117806. */
  117807. cleanCachedTextureBuffer(): void;
  117808. /**
  117809. * Get the world extend vectors with an optional filter
  117810. *
  117811. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  117812. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  117813. */
  117814. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  117815. min: Vector3;
  117816. max: Vector3;
  117817. };
  117818. /**
  117819. * Creates a ray that can be used to pick in the scene
  117820. * @param x defines the x coordinate of the origin (on-screen)
  117821. * @param y defines the y coordinate of the origin (on-screen)
  117822. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  117823. * @param camera defines the camera to use for the picking
  117824. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  117825. * @returns a Ray
  117826. */
  117827. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  117828. /**
  117829. * Creates a ray that can be used to pick in the scene
  117830. * @param x defines the x coordinate of the origin (on-screen)
  117831. * @param y defines the y coordinate of the origin (on-screen)
  117832. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  117833. * @param result defines the ray where to store the picking ray
  117834. * @param camera defines the camera to use for the picking
  117835. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  117836. * @returns the current scene
  117837. */
  117838. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  117839. /**
  117840. * Creates a ray that can be used to pick in the scene
  117841. * @param x defines the x coordinate of the origin (on-screen)
  117842. * @param y defines the y coordinate of the origin (on-screen)
  117843. * @param camera defines the camera to use for the picking
  117844. * @returns a Ray
  117845. */
  117846. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  117847. /**
  117848. * Creates a ray that can be used to pick in the scene
  117849. * @param x defines the x coordinate of the origin (on-screen)
  117850. * @param y defines the y coordinate of the origin (on-screen)
  117851. * @param result defines the ray where to store the picking ray
  117852. * @param camera defines the camera to use for the picking
  117853. * @returns the current scene
  117854. */
  117855. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  117856. /** Launch a ray to try to pick a mesh in the scene
  117857. * @param x position on screen
  117858. * @param y position on screen
  117859. * @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
  117860. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117861. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117862. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117863. * @returns a PickingInfo
  117864. */
  117865. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  117866. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  117867. * @param x position on screen
  117868. * @param y position on screen
  117869. * @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
  117870. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117871. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117872. * @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)
  117873. */
  117874. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  117875. /** Use the given ray to pick a mesh in the scene
  117876. * @param ray The ray to use to pick meshes
  117877. * @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
  117878. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117879. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117880. * @returns a PickingInfo
  117881. */
  117882. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  117883. /**
  117884. * Launch a ray to try to pick a mesh in the scene
  117885. * @param x X position on screen
  117886. * @param y Y position on screen
  117887. * @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
  117888. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117889. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117890. * @returns an array of PickingInfo
  117891. */
  117892. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  117893. /**
  117894. * Launch a ray to try to pick a mesh in the scene
  117895. * @param ray Ray to use
  117896. * @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
  117897. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117898. * @returns an array of PickingInfo
  117899. */
  117900. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  117901. /**
  117902. * Force the value of meshUnderPointer
  117903. * @param mesh defines the mesh to use
  117904. */
  117905. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  117906. /**
  117907. * Gets the mesh under the pointer
  117908. * @returns a Mesh or null if no mesh is under the pointer
  117909. */
  117910. getPointerOverMesh(): Nullable<AbstractMesh>;
  117911. /** @hidden */
  117912. _rebuildGeometries(): void;
  117913. /** @hidden */
  117914. _rebuildTextures(): void;
  117915. private _getByTags;
  117916. /**
  117917. * Get a list of meshes by tags
  117918. * @param tagsQuery defines the tags query to use
  117919. * @param forEach defines a predicate used to filter results
  117920. * @returns an array of Mesh
  117921. */
  117922. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  117923. /**
  117924. * Get a list of cameras by tags
  117925. * @param tagsQuery defines the tags query to use
  117926. * @param forEach defines a predicate used to filter results
  117927. * @returns an array of Camera
  117928. */
  117929. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  117930. /**
  117931. * Get a list of lights by tags
  117932. * @param tagsQuery defines the tags query to use
  117933. * @param forEach defines a predicate used to filter results
  117934. * @returns an array of Light
  117935. */
  117936. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  117937. /**
  117938. * Get a list of materials by tags
  117939. * @param tagsQuery defines the tags query to use
  117940. * @param forEach defines a predicate used to filter results
  117941. * @returns an array of Material
  117942. */
  117943. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  117944. /**
  117945. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  117946. * This allowed control for front to back rendering or reversly depending of the special needs.
  117947. *
  117948. * @param renderingGroupId The rendering group id corresponding to its index
  117949. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  117950. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  117951. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  117952. */
  117953. 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;
  117954. /**
  117955. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  117956. *
  117957. * @param renderingGroupId The rendering group id corresponding to its index
  117958. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  117959. * @param depth Automatically clears depth between groups if true and autoClear is true.
  117960. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  117961. */
  117962. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  117963. /**
  117964. * Gets the current auto clear configuration for one rendering group of the rendering
  117965. * manager.
  117966. * @param index the rendering group index to get the information for
  117967. * @returns The auto clear setup for the requested rendering group
  117968. */
  117969. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  117970. private _blockMaterialDirtyMechanism;
  117971. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  117972. get blockMaterialDirtyMechanism(): boolean;
  117973. set blockMaterialDirtyMechanism(value: boolean);
  117974. /**
  117975. * Will flag all materials as dirty to trigger new shader compilation
  117976. * @param flag defines the flag used to specify which material part must be marked as dirty
  117977. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  117978. */
  117979. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  117980. /** @hidden */
  117981. _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;
  117982. /** @hidden */
  117983. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117984. /** @hidden */
  117985. _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;
  117986. /** @hidden */
  117987. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  117988. /** @hidden */
  117989. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  117990. /** @hidden */
  117991. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117992. }
  117993. }
  117994. declare module BABYLON {
  117995. /**
  117996. * Set of assets to keep when moving a scene into an asset container.
  117997. */
  117998. export class KeepAssets extends AbstractScene {
  117999. }
  118000. /**
  118001. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  118002. */
  118003. export class InstantiatedEntries {
  118004. /**
  118005. * List of new root nodes (eg. nodes with no parent)
  118006. */
  118007. rootNodes: TransformNode[];
  118008. /**
  118009. * List of new skeletons
  118010. */
  118011. skeletons: Skeleton[];
  118012. /**
  118013. * List of new animation groups
  118014. */
  118015. animationGroups: AnimationGroup[];
  118016. }
  118017. /**
  118018. * Container with a set of assets that can be added or removed from a scene.
  118019. */
  118020. export class AssetContainer extends AbstractScene {
  118021. private _wasAddedToScene;
  118022. /**
  118023. * The scene the AssetContainer belongs to.
  118024. */
  118025. scene: Scene;
  118026. /**
  118027. * Instantiates an AssetContainer.
  118028. * @param scene The scene the AssetContainer belongs to.
  118029. */
  118030. constructor(scene: Scene);
  118031. /**
  118032. * Instantiate or clone all meshes and add the new ones to the scene.
  118033. * Skeletons and animation groups will all be cloned
  118034. * @param nameFunction defines an optional function used to get new names for clones
  118035. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  118036. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  118037. */
  118038. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  118039. /**
  118040. * Adds all the assets from the container to the scene.
  118041. */
  118042. addAllToScene(): void;
  118043. /**
  118044. * Removes all the assets in the container from the scene
  118045. */
  118046. removeAllFromScene(): void;
  118047. /**
  118048. * Disposes all the assets in the container
  118049. */
  118050. dispose(): void;
  118051. private _moveAssets;
  118052. /**
  118053. * Removes all the assets contained in the scene and adds them to the container.
  118054. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  118055. */
  118056. moveAllFromScene(keepAssets?: KeepAssets): void;
  118057. /**
  118058. * 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.
  118059. * @returns the root mesh
  118060. */
  118061. createRootMesh(): Mesh;
  118062. /**
  118063. * Merge animations (direct and animation groups) from this asset container into a scene
  118064. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118065. * @param animatables set of animatables to retarget to a node from the scene
  118066. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  118067. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  118068. */
  118069. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  118070. }
  118071. }
  118072. declare module BABYLON {
  118073. /**
  118074. * Defines how the parser contract is defined.
  118075. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  118076. */
  118077. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  118078. /**
  118079. * Defines how the individual parser contract is defined.
  118080. * These parser can parse an individual asset
  118081. */
  118082. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  118083. /**
  118084. * Base class of the scene acting as a container for the different elements composing a scene.
  118085. * This class is dynamically extended by the different components of the scene increasing
  118086. * flexibility and reducing coupling
  118087. */
  118088. export abstract class AbstractScene {
  118089. /**
  118090. * Stores the list of available parsers in the application.
  118091. */
  118092. private static _BabylonFileParsers;
  118093. /**
  118094. * Stores the list of available individual parsers in the application.
  118095. */
  118096. private static _IndividualBabylonFileParsers;
  118097. /**
  118098. * Adds a parser in the list of available ones
  118099. * @param name Defines the name of the parser
  118100. * @param parser Defines the parser to add
  118101. */
  118102. static AddParser(name: string, parser: BabylonFileParser): void;
  118103. /**
  118104. * Gets a general parser from the list of avaialble ones
  118105. * @param name Defines the name of the parser
  118106. * @returns the requested parser or null
  118107. */
  118108. static GetParser(name: string): Nullable<BabylonFileParser>;
  118109. /**
  118110. * Adds n individual parser in the list of available ones
  118111. * @param name Defines the name of the parser
  118112. * @param parser Defines the parser to add
  118113. */
  118114. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  118115. /**
  118116. * Gets an individual parser from the list of avaialble ones
  118117. * @param name Defines the name of the parser
  118118. * @returns the requested parser or null
  118119. */
  118120. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  118121. /**
  118122. * Parser json data and populate both a scene and its associated container object
  118123. * @param jsonData Defines the data to parse
  118124. * @param scene Defines the scene to parse the data for
  118125. * @param container Defines the container attached to the parsing sequence
  118126. * @param rootUrl Defines the root url of the data
  118127. */
  118128. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  118129. /**
  118130. * Gets the list of root nodes (ie. nodes with no parent)
  118131. */
  118132. rootNodes: Node[];
  118133. /** All of the cameras added to this scene
  118134. * @see http://doc.babylonjs.com/babylon101/cameras
  118135. */
  118136. cameras: Camera[];
  118137. /**
  118138. * All of the lights added to this scene
  118139. * @see http://doc.babylonjs.com/babylon101/lights
  118140. */
  118141. lights: Light[];
  118142. /**
  118143. * All of the (abstract) meshes added to this scene
  118144. */
  118145. meshes: AbstractMesh[];
  118146. /**
  118147. * The list of skeletons added to the scene
  118148. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  118149. */
  118150. skeletons: Skeleton[];
  118151. /**
  118152. * All of the particle systems added to this scene
  118153. * @see http://doc.babylonjs.com/babylon101/particles
  118154. */
  118155. particleSystems: IParticleSystem[];
  118156. /**
  118157. * Gets a list of Animations associated with the scene
  118158. */
  118159. animations: Animation[];
  118160. /**
  118161. * All of the animation groups added to this scene
  118162. * @see http://doc.babylonjs.com/how_to/group
  118163. */
  118164. animationGroups: AnimationGroup[];
  118165. /**
  118166. * All of the multi-materials added to this scene
  118167. * @see http://doc.babylonjs.com/how_to/multi_materials
  118168. */
  118169. multiMaterials: MultiMaterial[];
  118170. /**
  118171. * All of the materials added to this scene
  118172. * In the context of a Scene, it is not supposed to be modified manually.
  118173. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  118174. * Note also that the order of the Material within the array is not significant and might change.
  118175. * @see http://doc.babylonjs.com/babylon101/materials
  118176. */
  118177. materials: Material[];
  118178. /**
  118179. * The list of morph target managers added to the scene
  118180. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  118181. */
  118182. morphTargetManagers: MorphTargetManager[];
  118183. /**
  118184. * The list of geometries used in the scene.
  118185. */
  118186. geometries: Geometry[];
  118187. /**
  118188. * All of the tranform nodes added to this scene
  118189. * In the context of a Scene, it is not supposed to be modified manually.
  118190. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  118191. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  118192. * @see http://doc.babylonjs.com/how_to/transformnode
  118193. */
  118194. transformNodes: TransformNode[];
  118195. /**
  118196. * ActionManagers available on the scene.
  118197. */
  118198. actionManagers: AbstractActionManager[];
  118199. /**
  118200. * Textures to keep.
  118201. */
  118202. textures: BaseTexture[];
  118203. /**
  118204. * Environment texture for the scene
  118205. */
  118206. environmentTexture: Nullable<BaseTexture>;
  118207. /**
  118208. * @returns all meshes, lights, cameras, transformNodes and bones
  118209. */
  118210. getNodes(): Array<Node>;
  118211. }
  118212. }
  118213. declare module BABYLON {
  118214. /**
  118215. * Interface used to define options for Sound class
  118216. */
  118217. export interface ISoundOptions {
  118218. /**
  118219. * Does the sound autoplay once loaded.
  118220. */
  118221. autoplay?: boolean;
  118222. /**
  118223. * Does the sound loop after it finishes playing once.
  118224. */
  118225. loop?: boolean;
  118226. /**
  118227. * Sound's volume
  118228. */
  118229. volume?: number;
  118230. /**
  118231. * Is it a spatial sound?
  118232. */
  118233. spatialSound?: boolean;
  118234. /**
  118235. * Maximum distance to hear that sound
  118236. */
  118237. maxDistance?: number;
  118238. /**
  118239. * Uses user defined attenuation function
  118240. */
  118241. useCustomAttenuation?: boolean;
  118242. /**
  118243. * Define the roll off factor of spatial sounds.
  118244. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118245. */
  118246. rolloffFactor?: number;
  118247. /**
  118248. * Define the reference distance the sound should be heard perfectly.
  118249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118250. */
  118251. refDistance?: number;
  118252. /**
  118253. * Define the distance attenuation model the sound will follow.
  118254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118255. */
  118256. distanceModel?: string;
  118257. /**
  118258. * Defines the playback speed (1 by default)
  118259. */
  118260. playbackRate?: number;
  118261. /**
  118262. * Defines if the sound is from a streaming source
  118263. */
  118264. streaming?: boolean;
  118265. /**
  118266. * Defines an optional length (in seconds) inside the sound file
  118267. */
  118268. length?: number;
  118269. /**
  118270. * Defines an optional offset (in seconds) inside the sound file
  118271. */
  118272. offset?: number;
  118273. /**
  118274. * If true, URLs will not be required to state the audio file codec to use.
  118275. */
  118276. skipCodecCheck?: boolean;
  118277. }
  118278. /**
  118279. * Defines a sound that can be played in the application.
  118280. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  118281. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118282. */
  118283. export class Sound {
  118284. /**
  118285. * The name of the sound in the scene.
  118286. */
  118287. name: string;
  118288. /**
  118289. * Does the sound autoplay once loaded.
  118290. */
  118291. autoplay: boolean;
  118292. /**
  118293. * Does the sound loop after it finishes playing once.
  118294. */
  118295. loop: boolean;
  118296. /**
  118297. * Does the sound use a custom attenuation curve to simulate the falloff
  118298. * happening when the source gets further away from the camera.
  118299. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  118300. */
  118301. useCustomAttenuation: boolean;
  118302. /**
  118303. * The sound track id this sound belongs to.
  118304. */
  118305. soundTrackId: number;
  118306. /**
  118307. * Is this sound currently played.
  118308. */
  118309. isPlaying: boolean;
  118310. /**
  118311. * Is this sound currently paused.
  118312. */
  118313. isPaused: boolean;
  118314. /**
  118315. * Does this sound enables spatial sound.
  118316. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118317. */
  118318. spatialSound: boolean;
  118319. /**
  118320. * Define the reference distance the sound should be heard perfectly.
  118321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118322. */
  118323. refDistance: number;
  118324. /**
  118325. * Define the roll off factor of spatial sounds.
  118326. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118327. */
  118328. rolloffFactor: number;
  118329. /**
  118330. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  118331. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118332. */
  118333. maxDistance: number;
  118334. /**
  118335. * Define the distance attenuation model the sound will follow.
  118336. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118337. */
  118338. distanceModel: string;
  118339. /**
  118340. * @hidden
  118341. * Back Compat
  118342. **/
  118343. onended: () => any;
  118344. /**
  118345. * Gets or sets an object used to store user defined information for the sound.
  118346. */
  118347. metadata: any;
  118348. /**
  118349. * Observable event when the current playing sound finishes.
  118350. */
  118351. onEndedObservable: Observable<Sound>;
  118352. private _panningModel;
  118353. private _playbackRate;
  118354. private _streaming;
  118355. private _startTime;
  118356. private _startOffset;
  118357. private _position;
  118358. /** @hidden */
  118359. _positionInEmitterSpace: boolean;
  118360. private _localDirection;
  118361. private _volume;
  118362. private _isReadyToPlay;
  118363. private _isDirectional;
  118364. private _readyToPlayCallback;
  118365. private _audioBuffer;
  118366. private _soundSource;
  118367. private _streamingSource;
  118368. private _soundPanner;
  118369. private _soundGain;
  118370. private _inputAudioNode;
  118371. private _outputAudioNode;
  118372. private _coneInnerAngle;
  118373. private _coneOuterAngle;
  118374. private _coneOuterGain;
  118375. private _scene;
  118376. private _connectedTransformNode;
  118377. private _customAttenuationFunction;
  118378. private _registerFunc;
  118379. private _isOutputConnected;
  118380. private _htmlAudioElement;
  118381. private _urlType;
  118382. private _length?;
  118383. private _offset?;
  118384. /** @hidden */
  118385. static _SceneComponentInitialization: (scene: Scene) => void;
  118386. /**
  118387. * Create a sound and attach it to a scene
  118388. * @param name Name of your sound
  118389. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  118390. * @param scene defines the scene the sound belongs to
  118391. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  118392. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  118393. */
  118394. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  118395. /**
  118396. * Release the sound and its associated resources
  118397. */
  118398. dispose(): void;
  118399. /**
  118400. * Gets if the sounds is ready to be played or not.
  118401. * @returns true if ready, otherwise false
  118402. */
  118403. isReady(): boolean;
  118404. private _soundLoaded;
  118405. /**
  118406. * Sets the data of the sound from an audiobuffer
  118407. * @param audioBuffer The audioBuffer containing the data
  118408. */
  118409. setAudioBuffer(audioBuffer: AudioBuffer): void;
  118410. /**
  118411. * Updates the current sounds options such as maxdistance, loop...
  118412. * @param options A JSON object containing values named as the object properties
  118413. */
  118414. updateOptions(options: ISoundOptions): void;
  118415. private _createSpatialParameters;
  118416. private _updateSpatialParameters;
  118417. /**
  118418. * Switch the panning model to HRTF:
  118419. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  118420. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118421. */
  118422. switchPanningModelToHRTF(): void;
  118423. /**
  118424. * Switch the panning model to Equal Power:
  118425. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  118426. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118427. */
  118428. switchPanningModelToEqualPower(): void;
  118429. private _switchPanningModel;
  118430. /**
  118431. * Connect this sound to a sound track audio node like gain...
  118432. * @param soundTrackAudioNode the sound track audio node to connect to
  118433. */
  118434. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  118435. /**
  118436. * Transform this sound into a directional source
  118437. * @param coneInnerAngle Size of the inner cone in degree
  118438. * @param coneOuterAngle Size of the outer cone in degree
  118439. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  118440. */
  118441. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  118442. /**
  118443. * Gets or sets the inner angle for the directional cone.
  118444. */
  118445. get directionalConeInnerAngle(): number;
  118446. /**
  118447. * Gets or sets the inner angle for the directional cone.
  118448. */
  118449. set directionalConeInnerAngle(value: number);
  118450. /**
  118451. * Gets or sets the outer angle for the directional cone.
  118452. */
  118453. get directionalConeOuterAngle(): number;
  118454. /**
  118455. * Gets or sets the outer angle for the directional cone.
  118456. */
  118457. set directionalConeOuterAngle(value: number);
  118458. /**
  118459. * Sets the position of the emitter if spatial sound is enabled
  118460. * @param newPosition Defines the new posisiton
  118461. */
  118462. setPosition(newPosition: Vector3): void;
  118463. /**
  118464. * Sets the local direction of the emitter if spatial sound is enabled
  118465. * @param newLocalDirection Defines the new local direction
  118466. */
  118467. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  118468. private _updateDirection;
  118469. /** @hidden */
  118470. updateDistanceFromListener(): void;
  118471. /**
  118472. * Sets a new custom attenuation function for the sound.
  118473. * @param callback Defines the function used for the attenuation
  118474. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  118475. */
  118476. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  118477. /**
  118478. * Play the sound
  118479. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  118480. * @param offset (optional) Start the sound at a specific time in seconds
  118481. * @param length (optional) Sound duration (in seconds)
  118482. */
  118483. play(time?: number, offset?: number, length?: number): void;
  118484. private _onended;
  118485. /**
  118486. * Stop the sound
  118487. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  118488. */
  118489. stop(time?: number): void;
  118490. /**
  118491. * Put the sound in pause
  118492. */
  118493. pause(): void;
  118494. /**
  118495. * Sets a dedicated volume for this sounds
  118496. * @param newVolume Define the new volume of the sound
  118497. * @param time Define time for gradual change to new volume
  118498. */
  118499. setVolume(newVolume: number, time?: number): void;
  118500. /**
  118501. * Set the sound play back rate
  118502. * @param newPlaybackRate Define the playback rate the sound should be played at
  118503. */
  118504. setPlaybackRate(newPlaybackRate: number): void;
  118505. /**
  118506. * Gets the volume of the sound.
  118507. * @returns the volume of the sound
  118508. */
  118509. getVolume(): number;
  118510. /**
  118511. * Attach the sound to a dedicated mesh
  118512. * @param transformNode The transform node to connect the sound with
  118513. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  118514. */
  118515. attachToMesh(transformNode: TransformNode): void;
  118516. /**
  118517. * Detach the sound from the previously attached mesh
  118518. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  118519. */
  118520. detachFromMesh(): void;
  118521. private _onRegisterAfterWorldMatrixUpdate;
  118522. /**
  118523. * Clone the current sound in the scene.
  118524. * @returns the new sound clone
  118525. */
  118526. clone(): Nullable<Sound>;
  118527. /**
  118528. * Gets the current underlying audio buffer containing the data
  118529. * @returns the audio buffer
  118530. */
  118531. getAudioBuffer(): Nullable<AudioBuffer>;
  118532. /**
  118533. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  118534. * @returns the source node
  118535. */
  118536. getSoundSource(): Nullable<AudioBufferSourceNode>;
  118537. /**
  118538. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  118539. * @returns the gain node
  118540. */
  118541. getSoundGain(): Nullable<GainNode>;
  118542. /**
  118543. * Serializes the Sound in a JSON representation
  118544. * @returns the JSON representation of the sound
  118545. */
  118546. serialize(): any;
  118547. /**
  118548. * Parse a JSON representation of a sound to innstantiate in a given scene
  118549. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  118550. * @param scene Define the scene the new parsed sound should be created in
  118551. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  118552. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  118553. * @returns the newly parsed sound
  118554. */
  118555. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  118556. }
  118557. }
  118558. declare module BABYLON {
  118559. /**
  118560. * This defines an action helpful to play a defined sound on a triggered action.
  118561. */
  118562. export class PlaySoundAction extends Action {
  118563. private _sound;
  118564. /**
  118565. * Instantiate the action
  118566. * @param triggerOptions defines the trigger options
  118567. * @param sound defines the sound to play
  118568. * @param condition defines the trigger related conditions
  118569. */
  118570. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  118571. /** @hidden */
  118572. _prepare(): void;
  118573. /**
  118574. * Execute the action and play the sound.
  118575. */
  118576. execute(): void;
  118577. /**
  118578. * Serializes the actions and its related information.
  118579. * @param parent defines the object to serialize in
  118580. * @returns the serialized object
  118581. */
  118582. serialize(parent: any): any;
  118583. }
  118584. /**
  118585. * This defines an action helpful to stop a defined sound on a triggered action.
  118586. */
  118587. export class StopSoundAction extends Action {
  118588. private _sound;
  118589. /**
  118590. * Instantiate the action
  118591. * @param triggerOptions defines the trigger options
  118592. * @param sound defines the sound to stop
  118593. * @param condition defines the trigger related conditions
  118594. */
  118595. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  118596. /** @hidden */
  118597. _prepare(): void;
  118598. /**
  118599. * Execute the action and stop the sound.
  118600. */
  118601. execute(): void;
  118602. /**
  118603. * Serializes the actions and its related information.
  118604. * @param parent defines the object to serialize in
  118605. * @returns the serialized object
  118606. */
  118607. serialize(parent: any): any;
  118608. }
  118609. }
  118610. declare module BABYLON {
  118611. /**
  118612. * This defines an action responsible to change the value of a property
  118613. * by interpolating between its current value and the newly set one once triggered.
  118614. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  118615. */
  118616. export class InterpolateValueAction extends Action {
  118617. /**
  118618. * Defines the path of the property where the value should be interpolated
  118619. */
  118620. propertyPath: string;
  118621. /**
  118622. * Defines the target value at the end of the interpolation.
  118623. */
  118624. value: any;
  118625. /**
  118626. * Defines the time it will take for the property to interpolate to the value.
  118627. */
  118628. duration: number;
  118629. /**
  118630. * Defines if the other scene animations should be stopped when the action has been triggered
  118631. */
  118632. stopOtherAnimations?: boolean;
  118633. /**
  118634. * Defines a callback raised once the interpolation animation has been done.
  118635. */
  118636. onInterpolationDone?: () => void;
  118637. /**
  118638. * Observable triggered once the interpolation animation has been done.
  118639. */
  118640. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  118641. private _target;
  118642. private _effectiveTarget;
  118643. private _property;
  118644. /**
  118645. * Instantiate the action
  118646. * @param triggerOptions defines the trigger options
  118647. * @param target defines the object containing the value to interpolate
  118648. * @param propertyPath defines the path to the property in the target object
  118649. * @param value defines the target value at the end of the interpolation
  118650. * @param duration deines the time it will take for the property to interpolate to the value.
  118651. * @param condition defines the trigger related conditions
  118652. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  118653. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  118654. */
  118655. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  118656. /** @hidden */
  118657. _prepare(): void;
  118658. /**
  118659. * Execute the action starts the value interpolation.
  118660. */
  118661. execute(): void;
  118662. /**
  118663. * Serializes the actions and its related information.
  118664. * @param parent defines the object to serialize in
  118665. * @returns the serialized object
  118666. */
  118667. serialize(parent: any): any;
  118668. }
  118669. }
  118670. declare module BABYLON {
  118671. /**
  118672. * Options allowed during the creation of a sound track.
  118673. */
  118674. export interface ISoundTrackOptions {
  118675. /**
  118676. * The volume the sound track should take during creation
  118677. */
  118678. volume?: number;
  118679. /**
  118680. * Define if the sound track is the main sound track of the scene
  118681. */
  118682. mainTrack?: boolean;
  118683. }
  118684. /**
  118685. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  118686. * It will be also used in a future release to apply effects on a specific track.
  118687. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  118688. */
  118689. export class SoundTrack {
  118690. /**
  118691. * The unique identifier of the sound track in the scene.
  118692. */
  118693. id: number;
  118694. /**
  118695. * The list of sounds included in the sound track.
  118696. */
  118697. soundCollection: Array<Sound>;
  118698. private _outputAudioNode;
  118699. private _scene;
  118700. private _connectedAnalyser;
  118701. private _options;
  118702. private _isInitialized;
  118703. /**
  118704. * Creates a new sound track.
  118705. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  118706. * @param scene Define the scene the sound track belongs to
  118707. * @param options
  118708. */
  118709. constructor(scene: Scene, options?: ISoundTrackOptions);
  118710. private _initializeSoundTrackAudioGraph;
  118711. /**
  118712. * Release the sound track and its associated resources
  118713. */
  118714. dispose(): void;
  118715. /**
  118716. * Adds a sound to this sound track
  118717. * @param sound define the cound to add
  118718. * @ignoreNaming
  118719. */
  118720. AddSound(sound: Sound): void;
  118721. /**
  118722. * Removes a sound to this sound track
  118723. * @param sound define the cound to remove
  118724. * @ignoreNaming
  118725. */
  118726. RemoveSound(sound: Sound): void;
  118727. /**
  118728. * Set a global volume for the full sound track.
  118729. * @param newVolume Define the new volume of the sound track
  118730. */
  118731. setVolume(newVolume: number): void;
  118732. /**
  118733. * Switch the panning model to HRTF:
  118734. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  118735. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118736. */
  118737. switchPanningModelToHRTF(): void;
  118738. /**
  118739. * Switch the panning model to Equal Power:
  118740. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  118741. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118742. */
  118743. switchPanningModelToEqualPower(): void;
  118744. /**
  118745. * Connect the sound track to an audio analyser allowing some amazing
  118746. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  118747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  118748. * @param analyser The analyser to connect to the engine
  118749. */
  118750. connectToAnalyser(analyser: Analyser): void;
  118751. }
  118752. }
  118753. declare module BABYLON {
  118754. interface AbstractScene {
  118755. /**
  118756. * The list of sounds used in the scene.
  118757. */
  118758. sounds: Nullable<Array<Sound>>;
  118759. }
  118760. interface Scene {
  118761. /**
  118762. * @hidden
  118763. * Backing field
  118764. */
  118765. _mainSoundTrack: SoundTrack;
  118766. /**
  118767. * The main sound track played by the scene.
  118768. * It cotains your primary collection of sounds.
  118769. */
  118770. mainSoundTrack: SoundTrack;
  118771. /**
  118772. * The list of sound tracks added to the scene
  118773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118774. */
  118775. soundTracks: Nullable<Array<SoundTrack>>;
  118776. /**
  118777. * Gets a sound using a given name
  118778. * @param name defines the name to search for
  118779. * @return the found sound or null if not found at all.
  118780. */
  118781. getSoundByName(name: string): Nullable<Sound>;
  118782. /**
  118783. * Gets or sets if audio support is enabled
  118784. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118785. */
  118786. audioEnabled: boolean;
  118787. /**
  118788. * Gets or sets if audio will be output to headphones
  118789. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118790. */
  118791. headphone: boolean;
  118792. /**
  118793. * Gets or sets custom audio listener position provider
  118794. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118795. */
  118796. audioListenerPositionProvider: Nullable<() => Vector3>;
  118797. /**
  118798. * Gets or sets a refresh rate when using 3D audio positioning
  118799. */
  118800. audioPositioningRefreshRate: number;
  118801. }
  118802. /**
  118803. * Defines the sound scene component responsible to manage any sounds
  118804. * in a given scene.
  118805. */
  118806. export class AudioSceneComponent implements ISceneSerializableComponent {
  118807. /**
  118808. * The component name helpfull to identify the component in the list of scene components.
  118809. */
  118810. readonly name: string;
  118811. /**
  118812. * The scene the component belongs to.
  118813. */
  118814. scene: Scene;
  118815. private _audioEnabled;
  118816. /**
  118817. * Gets whether audio is enabled or not.
  118818. * Please use related enable/disable method to switch state.
  118819. */
  118820. get audioEnabled(): boolean;
  118821. private _headphone;
  118822. /**
  118823. * Gets whether audio is outputing to headphone or not.
  118824. * Please use the according Switch methods to change output.
  118825. */
  118826. get headphone(): boolean;
  118827. /**
  118828. * Gets or sets a refresh rate when using 3D audio positioning
  118829. */
  118830. audioPositioningRefreshRate: number;
  118831. private _audioListenerPositionProvider;
  118832. /**
  118833. * Gets the current audio listener position provider
  118834. */
  118835. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  118836. /**
  118837. * Sets a custom listener position for all sounds in the scene
  118838. * By default, this is the position of the first active camera
  118839. */
  118840. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  118841. /**
  118842. * Creates a new instance of the component for the given scene
  118843. * @param scene Defines the scene to register the component in
  118844. */
  118845. constructor(scene: Scene);
  118846. /**
  118847. * Registers the component in a given scene
  118848. */
  118849. register(): void;
  118850. /**
  118851. * Rebuilds the elements related to this component in case of
  118852. * context lost for instance.
  118853. */
  118854. rebuild(): void;
  118855. /**
  118856. * Serializes the component data to the specified json object
  118857. * @param serializationObject The object to serialize to
  118858. */
  118859. serialize(serializationObject: any): void;
  118860. /**
  118861. * Adds all the elements from the container to the scene
  118862. * @param container the container holding the elements
  118863. */
  118864. addFromContainer(container: AbstractScene): void;
  118865. /**
  118866. * Removes all the elements in the container from the scene
  118867. * @param container contains the elements to remove
  118868. * @param dispose if the removed element should be disposed (default: false)
  118869. */
  118870. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118871. /**
  118872. * Disposes the component and the associated ressources.
  118873. */
  118874. dispose(): void;
  118875. /**
  118876. * Disables audio in the associated scene.
  118877. */
  118878. disableAudio(): void;
  118879. /**
  118880. * Enables audio in the associated scene.
  118881. */
  118882. enableAudio(): void;
  118883. /**
  118884. * Switch audio to headphone output.
  118885. */
  118886. switchAudioModeForHeadphones(): void;
  118887. /**
  118888. * Switch audio to normal speakers.
  118889. */
  118890. switchAudioModeForNormalSpeakers(): void;
  118891. private _cachedCameraDirection;
  118892. private _cachedCameraPosition;
  118893. private _lastCheck;
  118894. private _afterRender;
  118895. }
  118896. }
  118897. declare module BABYLON {
  118898. /**
  118899. * Wraps one or more Sound objects and selects one with random weight for playback.
  118900. */
  118901. export class WeightedSound {
  118902. /** When true a Sound will be selected and played when the current playing Sound completes. */
  118903. loop: boolean;
  118904. private _coneInnerAngle;
  118905. private _coneOuterAngle;
  118906. private _volume;
  118907. /** A Sound is currently playing. */
  118908. isPlaying: boolean;
  118909. /** A Sound is currently paused. */
  118910. isPaused: boolean;
  118911. private _sounds;
  118912. private _weights;
  118913. private _currentIndex?;
  118914. /**
  118915. * Creates a new WeightedSound from the list of sounds given.
  118916. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  118917. * @param sounds Array of Sounds that will be selected from.
  118918. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  118919. */
  118920. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  118921. /**
  118922. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  118923. */
  118924. get directionalConeInnerAngle(): number;
  118925. /**
  118926. * The size of cone in degress for a directional sound in which there will be no attenuation.
  118927. */
  118928. set directionalConeInnerAngle(value: number);
  118929. /**
  118930. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  118931. * Listener angles between innerAngle and outerAngle will falloff linearly.
  118932. */
  118933. get directionalConeOuterAngle(): number;
  118934. /**
  118935. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  118936. * Listener angles between innerAngle and outerAngle will falloff linearly.
  118937. */
  118938. set directionalConeOuterAngle(value: number);
  118939. /**
  118940. * Playback volume.
  118941. */
  118942. get volume(): number;
  118943. /**
  118944. * Playback volume.
  118945. */
  118946. set volume(value: number);
  118947. private _onended;
  118948. /**
  118949. * Suspend playback
  118950. */
  118951. pause(): void;
  118952. /**
  118953. * Stop playback
  118954. */
  118955. stop(): void;
  118956. /**
  118957. * Start playback.
  118958. * @param startOffset Position the clip head at a specific time in seconds.
  118959. */
  118960. play(startOffset?: number): void;
  118961. }
  118962. }
  118963. declare module BABYLON {
  118964. /**
  118965. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  118966. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  118967. */
  118968. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  118969. /**
  118970. * Gets the name of the behavior.
  118971. */
  118972. get name(): string;
  118973. /**
  118974. * The easing function used by animations
  118975. */
  118976. static EasingFunction: BackEase;
  118977. /**
  118978. * The easing mode used by animations
  118979. */
  118980. static EasingMode: number;
  118981. /**
  118982. * The duration of the animation, in milliseconds
  118983. */
  118984. transitionDuration: number;
  118985. /**
  118986. * Length of the distance animated by the transition when lower radius is reached
  118987. */
  118988. lowerRadiusTransitionRange: number;
  118989. /**
  118990. * Length of the distance animated by the transition when upper radius is reached
  118991. */
  118992. upperRadiusTransitionRange: number;
  118993. private _autoTransitionRange;
  118994. /**
  118995. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  118996. */
  118997. get autoTransitionRange(): boolean;
  118998. /**
  118999. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  119000. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  119001. */
  119002. set autoTransitionRange(value: boolean);
  119003. private _attachedCamera;
  119004. private _onAfterCheckInputsObserver;
  119005. private _onMeshTargetChangedObserver;
  119006. /**
  119007. * Initializes the behavior.
  119008. */
  119009. init(): void;
  119010. /**
  119011. * Attaches the behavior to its arc rotate camera.
  119012. * @param camera Defines the camera to attach the behavior to
  119013. */
  119014. attach(camera: ArcRotateCamera): void;
  119015. /**
  119016. * Detaches the behavior from its current arc rotate camera.
  119017. */
  119018. detach(): void;
  119019. private _radiusIsAnimating;
  119020. private _radiusBounceTransition;
  119021. private _animatables;
  119022. private _cachedWheelPrecision;
  119023. /**
  119024. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  119025. * @param radiusLimit The limit to check against.
  119026. * @return Bool to indicate if at limit.
  119027. */
  119028. private _isRadiusAtLimit;
  119029. /**
  119030. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  119031. * @param radiusDelta The delta by which to animate to. Can be negative.
  119032. */
  119033. private _applyBoundRadiusAnimation;
  119034. /**
  119035. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  119036. */
  119037. protected _clearAnimationLocks(): void;
  119038. /**
  119039. * Stops and removes all animations that have been applied to the camera
  119040. */
  119041. stopAllAnimations(): void;
  119042. }
  119043. }
  119044. declare module BABYLON {
  119045. /**
  119046. * 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.
  119047. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119048. */
  119049. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  119050. /**
  119051. * Gets the name of the behavior.
  119052. */
  119053. get name(): string;
  119054. private _mode;
  119055. private _radiusScale;
  119056. private _positionScale;
  119057. private _defaultElevation;
  119058. private _elevationReturnTime;
  119059. private _elevationReturnWaitTime;
  119060. private _zoomStopsAnimation;
  119061. private _framingTime;
  119062. /**
  119063. * The easing function used by animations
  119064. */
  119065. static EasingFunction: ExponentialEase;
  119066. /**
  119067. * The easing mode used by animations
  119068. */
  119069. static EasingMode: number;
  119070. /**
  119071. * Sets the current mode used by the behavior
  119072. */
  119073. set mode(mode: number);
  119074. /**
  119075. * Gets current mode used by the behavior.
  119076. */
  119077. get mode(): number;
  119078. /**
  119079. * Sets the scale applied to the radius (1 by default)
  119080. */
  119081. set radiusScale(radius: number);
  119082. /**
  119083. * Gets the scale applied to the radius
  119084. */
  119085. get radiusScale(): number;
  119086. /**
  119087. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  119088. */
  119089. set positionScale(scale: number);
  119090. /**
  119091. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  119092. */
  119093. get positionScale(): number;
  119094. /**
  119095. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  119096. * behaviour is triggered, in radians.
  119097. */
  119098. set defaultElevation(elevation: number);
  119099. /**
  119100. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  119101. * behaviour is triggered, in radians.
  119102. */
  119103. get defaultElevation(): number;
  119104. /**
  119105. * Sets the time (in milliseconds) taken to return to the default beta position.
  119106. * Negative value indicates camera should not return to default.
  119107. */
  119108. set elevationReturnTime(speed: number);
  119109. /**
  119110. * Gets the time (in milliseconds) taken to return to the default beta position.
  119111. * Negative value indicates camera should not return to default.
  119112. */
  119113. get elevationReturnTime(): number;
  119114. /**
  119115. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  119116. */
  119117. set elevationReturnWaitTime(time: number);
  119118. /**
  119119. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  119120. */
  119121. get elevationReturnWaitTime(): number;
  119122. /**
  119123. * Sets the flag that indicates if user zooming should stop animation.
  119124. */
  119125. set zoomStopsAnimation(flag: boolean);
  119126. /**
  119127. * Gets the flag that indicates if user zooming should stop animation.
  119128. */
  119129. get zoomStopsAnimation(): boolean;
  119130. /**
  119131. * Sets the transition time when framing the mesh, in milliseconds
  119132. */
  119133. set framingTime(time: number);
  119134. /**
  119135. * Gets the transition time when framing the mesh, in milliseconds
  119136. */
  119137. get framingTime(): number;
  119138. /**
  119139. * Define if the behavior should automatically change the configured
  119140. * camera limits and sensibilities.
  119141. */
  119142. autoCorrectCameraLimitsAndSensibility: boolean;
  119143. private _onPrePointerObservableObserver;
  119144. private _onAfterCheckInputsObserver;
  119145. private _onMeshTargetChangedObserver;
  119146. private _attachedCamera;
  119147. private _isPointerDown;
  119148. private _lastInteractionTime;
  119149. /**
  119150. * Initializes the behavior.
  119151. */
  119152. init(): void;
  119153. /**
  119154. * Attaches the behavior to its arc rotate camera.
  119155. * @param camera Defines the camera to attach the behavior to
  119156. */
  119157. attach(camera: ArcRotateCamera): void;
  119158. /**
  119159. * Detaches the behavior from its current arc rotate camera.
  119160. */
  119161. detach(): void;
  119162. private _animatables;
  119163. private _betaIsAnimating;
  119164. private _betaTransition;
  119165. private _radiusTransition;
  119166. private _vectorTransition;
  119167. /**
  119168. * Targets the given mesh and updates zoom level accordingly.
  119169. * @param mesh The mesh to target.
  119170. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119171. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119172. */
  119173. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119174. /**
  119175. * Targets the given mesh with its children and updates zoom level accordingly.
  119176. * @param mesh The mesh to target.
  119177. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119178. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119179. */
  119180. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119181. /**
  119182. * Targets the given meshes with their children and updates zoom level accordingly.
  119183. * @param meshes The mesh to target.
  119184. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119185. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119186. */
  119187. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119188. /**
  119189. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  119190. * @param minimumWorld Determines the smaller position of the bounding box extend
  119191. * @param maximumWorld Determines the bigger position of the bounding box extend
  119192. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119193. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119194. */
  119195. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119196. /**
  119197. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  119198. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  119199. * frustum width.
  119200. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  119201. * to fully enclose the mesh in the viewing frustum.
  119202. */
  119203. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  119204. /**
  119205. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  119206. * is automatically returned to its default position (expected to be above ground plane).
  119207. */
  119208. private _maintainCameraAboveGround;
  119209. /**
  119210. * Returns the frustum slope based on the canvas ratio and camera FOV
  119211. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  119212. */
  119213. private _getFrustumSlope;
  119214. /**
  119215. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  119216. */
  119217. private _clearAnimationLocks;
  119218. /**
  119219. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  119220. */
  119221. private _applyUserInteraction;
  119222. /**
  119223. * Stops and removes all animations that have been applied to the camera
  119224. */
  119225. stopAllAnimations(): void;
  119226. /**
  119227. * Gets a value indicating if the user is moving the camera
  119228. */
  119229. get isUserIsMoving(): boolean;
  119230. /**
  119231. * The camera can move all the way towards the mesh.
  119232. */
  119233. static IgnoreBoundsSizeMode: number;
  119234. /**
  119235. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  119236. */
  119237. static FitFrustumSidesMode: number;
  119238. }
  119239. }
  119240. declare module BABYLON {
  119241. /**
  119242. * Base class for Camera Pointer Inputs.
  119243. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  119244. * for example usage.
  119245. */
  119246. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  119247. /**
  119248. * Defines the camera the input is attached to.
  119249. */
  119250. abstract camera: Camera;
  119251. /**
  119252. * Whether keyboard modifier keys are pressed at time of last mouse event.
  119253. */
  119254. protected _altKey: boolean;
  119255. protected _ctrlKey: boolean;
  119256. protected _metaKey: boolean;
  119257. protected _shiftKey: boolean;
  119258. /**
  119259. * Which mouse buttons were pressed at time of last mouse event.
  119260. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  119261. */
  119262. protected _buttonsPressed: number;
  119263. /**
  119264. * Defines the buttons associated with the input to handle camera move.
  119265. */
  119266. buttons: number[];
  119267. /**
  119268. * Attach the input controls to a specific dom element to get the input from.
  119269. * @param element Defines the element the controls should be listened from
  119270. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119271. */
  119272. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119273. /**
  119274. * Detach the current controls from the specified dom element.
  119275. * @param element Defines the element to stop listening the inputs from
  119276. */
  119277. detachControl(element: Nullable<HTMLElement>): void;
  119278. /**
  119279. * Gets the class name of the current input.
  119280. * @returns the class name
  119281. */
  119282. getClassName(): string;
  119283. /**
  119284. * Get the friendly name associated with the input class.
  119285. * @returns the input friendly name
  119286. */
  119287. getSimpleName(): string;
  119288. /**
  119289. * Called on pointer POINTERDOUBLETAP event.
  119290. * Override this method to provide functionality on POINTERDOUBLETAP event.
  119291. */
  119292. protected onDoubleTap(type: string): void;
  119293. /**
  119294. * Called on pointer POINTERMOVE event if only a single touch is active.
  119295. * Override this method to provide functionality.
  119296. */
  119297. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  119298. /**
  119299. * Called on pointer POINTERMOVE event if multiple touches are active.
  119300. * Override this method to provide functionality.
  119301. */
  119302. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  119303. /**
  119304. * Called on JS contextmenu event.
  119305. * Override this method to provide functionality.
  119306. */
  119307. protected onContextMenu(evt: PointerEvent): void;
  119308. /**
  119309. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  119310. * press.
  119311. * Override this method to provide functionality.
  119312. */
  119313. protected onButtonDown(evt: PointerEvent): void;
  119314. /**
  119315. * Called each time a new POINTERUP event occurs. Ie, for each button
  119316. * release.
  119317. * Override this method to provide functionality.
  119318. */
  119319. protected onButtonUp(evt: PointerEvent): void;
  119320. /**
  119321. * Called when window becomes inactive.
  119322. * Override this method to provide functionality.
  119323. */
  119324. protected onLostFocus(): void;
  119325. private _pointerInput;
  119326. private _observer;
  119327. private _onLostFocus;
  119328. private pointA;
  119329. private pointB;
  119330. }
  119331. }
  119332. declare module BABYLON {
  119333. /**
  119334. * Manage the pointers inputs to control an arc rotate camera.
  119335. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119336. */
  119337. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  119338. /**
  119339. * Defines the camera the input is attached to.
  119340. */
  119341. camera: ArcRotateCamera;
  119342. /**
  119343. * Gets the class name of the current input.
  119344. * @returns the class name
  119345. */
  119346. getClassName(): string;
  119347. /**
  119348. * Defines the buttons associated with the input to handle camera move.
  119349. */
  119350. buttons: number[];
  119351. /**
  119352. * Defines the pointer angular sensibility along the X axis or how fast is
  119353. * the camera rotating.
  119354. */
  119355. angularSensibilityX: number;
  119356. /**
  119357. * Defines the pointer angular sensibility along the Y axis or how fast is
  119358. * the camera rotating.
  119359. */
  119360. angularSensibilityY: number;
  119361. /**
  119362. * Defines the pointer pinch precision or how fast is the camera zooming.
  119363. */
  119364. pinchPrecision: number;
  119365. /**
  119366. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  119367. * from 0.
  119368. * It defines the percentage of current camera.radius to use as delta when
  119369. * pinch zoom is used.
  119370. */
  119371. pinchDeltaPercentage: number;
  119372. /**
  119373. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  119374. * that any object in the plane at the camera's target point will scale
  119375. * perfectly with finger motion.
  119376. * Overrides pinchDeltaPercentage and pinchPrecision.
  119377. */
  119378. useNaturalPinchZoom: boolean;
  119379. /**
  119380. * Defines the pointer panning sensibility or how fast is the camera moving.
  119381. */
  119382. panningSensibility: number;
  119383. /**
  119384. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  119385. */
  119386. multiTouchPanning: boolean;
  119387. /**
  119388. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  119389. * zoom (pinch) through multitouch.
  119390. */
  119391. multiTouchPanAndZoom: boolean;
  119392. /**
  119393. * Revers pinch action direction.
  119394. */
  119395. pinchInwards: boolean;
  119396. private _isPanClick;
  119397. private _twoFingerActivityCount;
  119398. private _isPinching;
  119399. /**
  119400. * Called on pointer POINTERMOVE event if only a single touch is active.
  119401. */
  119402. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  119403. /**
  119404. * Called on pointer POINTERDOUBLETAP event.
  119405. */
  119406. protected onDoubleTap(type: string): void;
  119407. /**
  119408. * Called on pointer POINTERMOVE event if multiple touches are active.
  119409. */
  119410. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  119411. /**
  119412. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  119413. * press.
  119414. */
  119415. protected onButtonDown(evt: PointerEvent): void;
  119416. /**
  119417. * Called each time a new POINTERUP event occurs. Ie, for each button
  119418. * release.
  119419. */
  119420. protected onButtonUp(evt: PointerEvent): void;
  119421. /**
  119422. * Called when window becomes inactive.
  119423. */
  119424. protected onLostFocus(): void;
  119425. }
  119426. }
  119427. declare module BABYLON {
  119428. /**
  119429. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  119430. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119431. */
  119432. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  119433. /**
  119434. * Defines the camera the input is attached to.
  119435. */
  119436. camera: ArcRotateCamera;
  119437. /**
  119438. * Defines the list of key codes associated with the up action (increase alpha)
  119439. */
  119440. keysUp: number[];
  119441. /**
  119442. * Defines the list of key codes associated with the down action (decrease alpha)
  119443. */
  119444. keysDown: number[];
  119445. /**
  119446. * Defines the list of key codes associated with the left action (increase beta)
  119447. */
  119448. keysLeft: number[];
  119449. /**
  119450. * Defines the list of key codes associated with the right action (decrease beta)
  119451. */
  119452. keysRight: number[];
  119453. /**
  119454. * Defines the list of key codes associated with the reset action.
  119455. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  119456. */
  119457. keysReset: number[];
  119458. /**
  119459. * Defines the panning sensibility of the inputs.
  119460. * (How fast is the camera panning)
  119461. */
  119462. panningSensibility: number;
  119463. /**
  119464. * Defines the zooming sensibility of the inputs.
  119465. * (How fast is the camera zooming)
  119466. */
  119467. zoomingSensibility: number;
  119468. /**
  119469. * Defines whether maintaining the alt key down switch the movement mode from
  119470. * orientation to zoom.
  119471. */
  119472. useAltToZoom: boolean;
  119473. /**
  119474. * Rotation speed of the camera
  119475. */
  119476. angularSpeed: number;
  119477. private _keys;
  119478. private _ctrlPressed;
  119479. private _altPressed;
  119480. private _onCanvasBlurObserver;
  119481. private _onKeyboardObserver;
  119482. private _engine;
  119483. private _scene;
  119484. /**
  119485. * Attach the input controls to a specific dom element to get the input from.
  119486. * @param element Defines the element the controls should be listened from
  119487. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119488. */
  119489. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119490. /**
  119491. * Detach the current controls from the specified dom element.
  119492. * @param element Defines the element to stop listening the inputs from
  119493. */
  119494. detachControl(element: Nullable<HTMLElement>): void;
  119495. /**
  119496. * Update the current camera state depending on the inputs that have been used this frame.
  119497. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  119498. */
  119499. checkInputs(): void;
  119500. /**
  119501. * Gets the class name of the current intput.
  119502. * @returns the class name
  119503. */
  119504. getClassName(): string;
  119505. /**
  119506. * Get the friendly name associated with the input class.
  119507. * @returns the input friendly name
  119508. */
  119509. getSimpleName(): string;
  119510. }
  119511. }
  119512. declare module BABYLON {
  119513. /**
  119514. * Manage the mouse wheel inputs to control an arc rotate camera.
  119515. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119516. */
  119517. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  119518. /**
  119519. * Defines the camera the input is attached to.
  119520. */
  119521. camera: ArcRotateCamera;
  119522. /**
  119523. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  119524. */
  119525. wheelPrecision: number;
  119526. /**
  119527. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  119528. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  119529. */
  119530. wheelDeltaPercentage: number;
  119531. private _wheel;
  119532. private _observer;
  119533. private computeDeltaFromMouseWheelLegacyEvent;
  119534. /**
  119535. * Attach the input controls to a specific dom element to get the input from.
  119536. * @param element Defines the element the controls should be listened from
  119537. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119538. */
  119539. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119540. /**
  119541. * Detach the current controls from the specified dom element.
  119542. * @param element Defines the element to stop listening the inputs from
  119543. */
  119544. detachControl(element: Nullable<HTMLElement>): void;
  119545. /**
  119546. * Gets the class name of the current intput.
  119547. * @returns the class name
  119548. */
  119549. getClassName(): string;
  119550. /**
  119551. * Get the friendly name associated with the input class.
  119552. * @returns the input friendly name
  119553. */
  119554. getSimpleName(): string;
  119555. }
  119556. }
  119557. declare module BABYLON {
  119558. /**
  119559. * Default Inputs manager for the ArcRotateCamera.
  119560. * It groups all the default supported inputs for ease of use.
  119561. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119562. */
  119563. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  119564. /**
  119565. * Instantiates a new ArcRotateCameraInputsManager.
  119566. * @param camera Defines the camera the inputs belong to
  119567. */
  119568. constructor(camera: ArcRotateCamera);
  119569. /**
  119570. * Add mouse wheel input support to the input manager.
  119571. * @returns the current input manager
  119572. */
  119573. addMouseWheel(): ArcRotateCameraInputsManager;
  119574. /**
  119575. * Add pointers input support to the input manager.
  119576. * @returns the current input manager
  119577. */
  119578. addPointers(): ArcRotateCameraInputsManager;
  119579. /**
  119580. * Add keyboard input support to the input manager.
  119581. * @returns the current input manager
  119582. */
  119583. addKeyboard(): ArcRotateCameraInputsManager;
  119584. }
  119585. }
  119586. declare module BABYLON {
  119587. /**
  119588. * This represents an orbital type of camera.
  119589. *
  119590. * 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.
  119591. * 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.
  119592. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  119593. */
  119594. export class ArcRotateCamera extends TargetCamera {
  119595. /**
  119596. * Defines the rotation angle of the camera along the longitudinal axis.
  119597. */
  119598. alpha: number;
  119599. /**
  119600. * Defines the rotation angle of the camera along the latitudinal axis.
  119601. */
  119602. beta: number;
  119603. /**
  119604. * Defines the radius of the camera from it s target point.
  119605. */
  119606. radius: number;
  119607. protected _target: Vector3;
  119608. protected _targetHost: Nullable<AbstractMesh>;
  119609. /**
  119610. * Defines the target point of the camera.
  119611. * The camera looks towards it form the radius distance.
  119612. */
  119613. get target(): Vector3;
  119614. set target(value: Vector3);
  119615. /**
  119616. * Define the current local position of the camera in the scene
  119617. */
  119618. get position(): Vector3;
  119619. set position(newPosition: Vector3);
  119620. protected _upVector: Vector3;
  119621. protected _upToYMatrix: Matrix;
  119622. protected _YToUpMatrix: Matrix;
  119623. /**
  119624. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  119625. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  119626. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  119627. */
  119628. set upVector(vec: Vector3);
  119629. get upVector(): Vector3;
  119630. /**
  119631. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  119632. */
  119633. setMatUp(): void;
  119634. /**
  119635. * Current inertia value on the longitudinal axis.
  119636. * The bigger this number the longer it will take for the camera to stop.
  119637. */
  119638. inertialAlphaOffset: number;
  119639. /**
  119640. * Current inertia value on the latitudinal axis.
  119641. * The bigger this number the longer it will take for the camera to stop.
  119642. */
  119643. inertialBetaOffset: number;
  119644. /**
  119645. * Current inertia value on the radius axis.
  119646. * The bigger this number the longer it will take for the camera to stop.
  119647. */
  119648. inertialRadiusOffset: number;
  119649. /**
  119650. * Minimum allowed angle on the longitudinal axis.
  119651. * This can help limiting how the Camera is able to move in the scene.
  119652. */
  119653. lowerAlphaLimit: Nullable<number>;
  119654. /**
  119655. * Maximum allowed angle on the longitudinal axis.
  119656. * This can help limiting how the Camera is able to move in the scene.
  119657. */
  119658. upperAlphaLimit: Nullable<number>;
  119659. /**
  119660. * Minimum allowed angle on the latitudinal axis.
  119661. * This can help limiting how the Camera is able to move in the scene.
  119662. */
  119663. lowerBetaLimit: number;
  119664. /**
  119665. * Maximum allowed angle on the latitudinal axis.
  119666. * This can help limiting how the Camera is able to move in the scene.
  119667. */
  119668. upperBetaLimit: number;
  119669. /**
  119670. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  119671. * This can help limiting how the Camera is able to move in the scene.
  119672. */
  119673. lowerRadiusLimit: Nullable<number>;
  119674. /**
  119675. * Maximum allowed distance of the camera to the target (The camera can not get further).
  119676. * This can help limiting how the Camera is able to move in the scene.
  119677. */
  119678. upperRadiusLimit: Nullable<number>;
  119679. /**
  119680. * Defines the current inertia value used during panning of the camera along the X axis.
  119681. */
  119682. inertialPanningX: number;
  119683. /**
  119684. * Defines the current inertia value used during panning of the camera along the Y axis.
  119685. */
  119686. inertialPanningY: number;
  119687. /**
  119688. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  119689. * Basically if your fingers moves away from more than this distance you will be considered
  119690. * in pinch mode.
  119691. */
  119692. pinchToPanMaxDistance: number;
  119693. /**
  119694. * Defines the maximum distance the camera can pan.
  119695. * This could help keeping the cammera always in your scene.
  119696. */
  119697. panningDistanceLimit: Nullable<number>;
  119698. /**
  119699. * Defines the target of the camera before paning.
  119700. */
  119701. panningOriginTarget: Vector3;
  119702. /**
  119703. * Defines the value of the inertia used during panning.
  119704. * 0 would mean stop inertia and one would mean no decelleration at all.
  119705. */
  119706. panningInertia: number;
  119707. /**
  119708. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  119709. */
  119710. get angularSensibilityX(): number;
  119711. set angularSensibilityX(value: number);
  119712. /**
  119713. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  119714. */
  119715. get angularSensibilityY(): number;
  119716. set angularSensibilityY(value: number);
  119717. /**
  119718. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  119719. */
  119720. get pinchPrecision(): number;
  119721. set pinchPrecision(value: number);
  119722. /**
  119723. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  119724. * It will be used instead of pinchDeltaPrecision if different from 0.
  119725. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  119726. */
  119727. get pinchDeltaPercentage(): number;
  119728. set pinchDeltaPercentage(value: number);
  119729. /**
  119730. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  119731. * and pinch delta percentage.
  119732. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  119733. * that any object in the plane at the camera's target point will scale
  119734. * perfectly with finger motion.
  119735. */
  119736. get useNaturalPinchZoom(): boolean;
  119737. set useNaturalPinchZoom(value: boolean);
  119738. /**
  119739. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  119740. */
  119741. get panningSensibility(): number;
  119742. set panningSensibility(value: number);
  119743. /**
  119744. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  119745. */
  119746. get keysUp(): number[];
  119747. set keysUp(value: number[]);
  119748. /**
  119749. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  119750. */
  119751. get keysDown(): number[];
  119752. set keysDown(value: number[]);
  119753. /**
  119754. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  119755. */
  119756. get keysLeft(): number[];
  119757. set keysLeft(value: number[]);
  119758. /**
  119759. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  119760. */
  119761. get keysRight(): number[];
  119762. set keysRight(value: number[]);
  119763. /**
  119764. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  119765. */
  119766. get wheelPrecision(): number;
  119767. set wheelPrecision(value: number);
  119768. /**
  119769. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  119770. * It will be used instead of pinchDeltaPrecision if different from 0.
  119771. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  119772. */
  119773. get wheelDeltaPercentage(): number;
  119774. set wheelDeltaPercentage(value: number);
  119775. /**
  119776. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  119777. */
  119778. zoomOnFactor: number;
  119779. /**
  119780. * Defines a screen offset for the camera position.
  119781. */
  119782. targetScreenOffset: Vector2;
  119783. /**
  119784. * Allows the camera to be completely reversed.
  119785. * If false the camera can not arrive upside down.
  119786. */
  119787. allowUpsideDown: boolean;
  119788. /**
  119789. * Define if double tap/click is used to restore the previously saved state of the camera.
  119790. */
  119791. useInputToRestoreState: boolean;
  119792. /** @hidden */
  119793. _viewMatrix: Matrix;
  119794. /** @hidden */
  119795. _useCtrlForPanning: boolean;
  119796. /** @hidden */
  119797. _panningMouseButton: number;
  119798. /**
  119799. * Defines the input associated to the camera.
  119800. */
  119801. inputs: ArcRotateCameraInputsManager;
  119802. /** @hidden */
  119803. _reset: () => void;
  119804. /**
  119805. * Defines the allowed panning axis.
  119806. */
  119807. panningAxis: Vector3;
  119808. protected _localDirection: Vector3;
  119809. protected _transformedDirection: Vector3;
  119810. private _bouncingBehavior;
  119811. /**
  119812. * Gets the bouncing behavior of the camera if it has been enabled.
  119813. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119814. */
  119815. get bouncingBehavior(): Nullable<BouncingBehavior>;
  119816. /**
  119817. * Defines if the bouncing behavior of the camera is enabled on the camera.
  119818. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119819. */
  119820. get useBouncingBehavior(): boolean;
  119821. set useBouncingBehavior(value: boolean);
  119822. private _framingBehavior;
  119823. /**
  119824. * Gets the framing behavior of the camera if it has been enabled.
  119825. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119826. */
  119827. get framingBehavior(): Nullable<FramingBehavior>;
  119828. /**
  119829. * Defines if the framing behavior of the camera is enabled on the camera.
  119830. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119831. */
  119832. get useFramingBehavior(): boolean;
  119833. set useFramingBehavior(value: boolean);
  119834. private _autoRotationBehavior;
  119835. /**
  119836. * Gets the auto rotation behavior of the camera if it has been enabled.
  119837. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119838. */
  119839. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  119840. /**
  119841. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  119842. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119843. */
  119844. get useAutoRotationBehavior(): boolean;
  119845. set useAutoRotationBehavior(value: boolean);
  119846. /**
  119847. * Observable triggered when the mesh target has been changed on the camera.
  119848. */
  119849. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  119850. /**
  119851. * Event raised when the camera is colliding with a mesh.
  119852. */
  119853. onCollide: (collidedMesh: AbstractMesh) => void;
  119854. /**
  119855. * Defines whether the camera should check collision with the objects oh the scene.
  119856. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  119857. */
  119858. checkCollisions: boolean;
  119859. /**
  119860. * Defines the collision radius of the camera.
  119861. * This simulates a sphere around the camera.
  119862. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  119863. */
  119864. collisionRadius: Vector3;
  119865. protected _collider: Collider;
  119866. protected _previousPosition: Vector3;
  119867. protected _collisionVelocity: Vector3;
  119868. protected _newPosition: Vector3;
  119869. protected _previousAlpha: number;
  119870. protected _previousBeta: number;
  119871. protected _previousRadius: number;
  119872. protected _collisionTriggered: boolean;
  119873. protected _targetBoundingCenter: Nullable<Vector3>;
  119874. private _computationVector;
  119875. /**
  119876. * Instantiates a new ArcRotateCamera in a given scene
  119877. * @param name Defines the name of the camera
  119878. * @param alpha Defines the camera rotation along the logitudinal axis
  119879. * @param beta Defines the camera rotation along the latitudinal axis
  119880. * @param radius Defines the camera distance from its target
  119881. * @param target Defines the camera target
  119882. * @param scene Defines the scene the camera belongs to
  119883. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  119884. */
  119885. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  119886. /** @hidden */
  119887. _initCache(): void;
  119888. /** @hidden */
  119889. _updateCache(ignoreParentClass?: boolean): void;
  119890. protected _getTargetPosition(): Vector3;
  119891. private _storedAlpha;
  119892. private _storedBeta;
  119893. private _storedRadius;
  119894. private _storedTarget;
  119895. private _storedTargetScreenOffset;
  119896. /**
  119897. * Stores the current state of the camera (alpha, beta, radius and target)
  119898. * @returns the camera itself
  119899. */
  119900. storeState(): Camera;
  119901. /**
  119902. * @hidden
  119903. * Restored camera state. You must call storeState() first
  119904. */
  119905. _restoreStateValues(): boolean;
  119906. /** @hidden */
  119907. _isSynchronizedViewMatrix(): boolean;
  119908. /**
  119909. * Attached controls to the current camera.
  119910. * @param element Defines the element the controls should be listened from
  119911. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119912. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  119913. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  119914. */
  119915. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  119916. /**
  119917. * Detach the current controls from the camera.
  119918. * The camera will stop reacting to inputs.
  119919. * @param element Defines the element to stop listening the inputs from
  119920. */
  119921. detachControl(element: HTMLElement): void;
  119922. /** @hidden */
  119923. _checkInputs(): void;
  119924. protected _checkLimits(): void;
  119925. /**
  119926. * Rebuilds angles (alpha, beta) and radius from the give position and target
  119927. */
  119928. rebuildAnglesAndRadius(): void;
  119929. /**
  119930. * Use a position to define the current camera related information like alpha, beta and radius
  119931. * @param position Defines the position to set the camera at
  119932. */
  119933. setPosition(position: Vector3): void;
  119934. /**
  119935. * Defines the target the camera should look at.
  119936. * This will automatically adapt alpha beta and radius to fit within the new target.
  119937. * @param target Defines the new target as a Vector or a mesh
  119938. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  119939. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  119940. */
  119941. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  119942. /** @hidden */
  119943. _getViewMatrix(): Matrix;
  119944. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  119945. /**
  119946. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  119947. * @param meshes Defines the mesh to zoom on
  119948. * @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)
  119949. */
  119950. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  119951. /**
  119952. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  119953. * The target will be changed but the radius
  119954. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  119955. * @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)
  119956. */
  119957. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  119958. min: Vector3;
  119959. max: Vector3;
  119960. distance: number;
  119961. }, doNotUpdateMaxZ?: boolean): void;
  119962. /**
  119963. * @override
  119964. * Override Camera.createRigCamera
  119965. */
  119966. createRigCamera(name: string, cameraIndex: number): Camera;
  119967. /**
  119968. * @hidden
  119969. * @override
  119970. * Override Camera._updateRigCameras
  119971. */
  119972. _updateRigCameras(): void;
  119973. /**
  119974. * Destroy the camera and release the current resources hold by it.
  119975. */
  119976. dispose(): void;
  119977. /**
  119978. * Gets the current object class name.
  119979. * @return the class name
  119980. */
  119981. getClassName(): string;
  119982. }
  119983. }
  119984. declare module BABYLON {
  119985. /**
  119986. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  119987. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119988. */
  119989. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  119990. /**
  119991. * Gets the name of the behavior.
  119992. */
  119993. get name(): string;
  119994. private _zoomStopsAnimation;
  119995. private _idleRotationSpeed;
  119996. private _idleRotationWaitTime;
  119997. private _idleRotationSpinupTime;
  119998. /**
  119999. * Sets the flag that indicates if user zooming should stop animation.
  120000. */
  120001. set zoomStopsAnimation(flag: boolean);
  120002. /**
  120003. * Gets the flag that indicates if user zooming should stop animation.
  120004. */
  120005. get zoomStopsAnimation(): boolean;
  120006. /**
  120007. * Sets the default speed at which the camera rotates around the model.
  120008. */
  120009. set idleRotationSpeed(speed: number);
  120010. /**
  120011. * Gets the default speed at which the camera rotates around the model.
  120012. */
  120013. get idleRotationSpeed(): number;
  120014. /**
  120015. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  120016. */
  120017. set idleRotationWaitTime(time: number);
  120018. /**
  120019. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  120020. */
  120021. get idleRotationWaitTime(): number;
  120022. /**
  120023. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  120024. */
  120025. set idleRotationSpinupTime(time: number);
  120026. /**
  120027. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  120028. */
  120029. get idleRotationSpinupTime(): number;
  120030. /**
  120031. * Gets a value indicating if the camera is currently rotating because of this behavior
  120032. */
  120033. get rotationInProgress(): boolean;
  120034. private _onPrePointerObservableObserver;
  120035. private _onAfterCheckInputsObserver;
  120036. private _attachedCamera;
  120037. private _isPointerDown;
  120038. private _lastFrameTime;
  120039. private _lastInteractionTime;
  120040. private _cameraRotationSpeed;
  120041. /**
  120042. * Initializes the behavior.
  120043. */
  120044. init(): void;
  120045. /**
  120046. * Attaches the behavior to its arc rotate camera.
  120047. * @param camera Defines the camera to attach the behavior to
  120048. */
  120049. attach(camera: ArcRotateCamera): void;
  120050. /**
  120051. * Detaches the behavior from its current arc rotate camera.
  120052. */
  120053. detach(): void;
  120054. /**
  120055. * Returns true if user is scrolling.
  120056. * @return true if user is scrolling.
  120057. */
  120058. private _userIsZooming;
  120059. private _lastFrameRadius;
  120060. private _shouldAnimationStopForInteraction;
  120061. /**
  120062. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  120063. */
  120064. private _applyUserInteraction;
  120065. private _userIsMoving;
  120066. }
  120067. }
  120068. declare module BABYLON {
  120069. /**
  120070. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  120071. */
  120072. export class AttachToBoxBehavior implements Behavior<Mesh> {
  120073. private ui;
  120074. /**
  120075. * The name of the behavior
  120076. */
  120077. name: string;
  120078. /**
  120079. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  120080. */
  120081. distanceAwayFromFace: number;
  120082. /**
  120083. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  120084. */
  120085. distanceAwayFromBottomOfFace: number;
  120086. private _faceVectors;
  120087. private _target;
  120088. private _scene;
  120089. private _onRenderObserver;
  120090. private _tmpMatrix;
  120091. private _tmpVector;
  120092. /**
  120093. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  120094. * @param ui The transform node that should be attched to the mesh
  120095. */
  120096. constructor(ui: TransformNode);
  120097. /**
  120098. * Initializes the behavior
  120099. */
  120100. init(): void;
  120101. private _closestFace;
  120102. private _zeroVector;
  120103. private _lookAtTmpMatrix;
  120104. private _lookAtToRef;
  120105. /**
  120106. * Attaches the AttachToBoxBehavior to the passed in mesh
  120107. * @param target The mesh that the specified node will be attached to
  120108. */
  120109. attach(target: Mesh): void;
  120110. /**
  120111. * Detaches the behavior from the mesh
  120112. */
  120113. detach(): void;
  120114. }
  120115. }
  120116. declare module BABYLON {
  120117. /**
  120118. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  120119. */
  120120. export class FadeInOutBehavior implements Behavior<Mesh> {
  120121. /**
  120122. * Time in milliseconds to delay before fading in (Default: 0)
  120123. */
  120124. delay: number;
  120125. /**
  120126. * Time in milliseconds for the mesh to fade in (Default: 300)
  120127. */
  120128. fadeInTime: number;
  120129. private _millisecondsPerFrame;
  120130. private _hovered;
  120131. private _hoverValue;
  120132. private _ownerNode;
  120133. /**
  120134. * Instatiates the FadeInOutBehavior
  120135. */
  120136. constructor();
  120137. /**
  120138. * The name of the behavior
  120139. */
  120140. get name(): string;
  120141. /**
  120142. * Initializes the behavior
  120143. */
  120144. init(): void;
  120145. /**
  120146. * Attaches the fade behavior on the passed in mesh
  120147. * @param ownerNode The mesh that will be faded in/out once attached
  120148. */
  120149. attach(ownerNode: Mesh): void;
  120150. /**
  120151. * Detaches the behavior from the mesh
  120152. */
  120153. detach(): void;
  120154. /**
  120155. * Triggers the mesh to begin fading in or out
  120156. * @param value if the object should fade in or out (true to fade in)
  120157. */
  120158. fadeIn(value: boolean): void;
  120159. private _update;
  120160. private _setAllVisibility;
  120161. }
  120162. }
  120163. declare module BABYLON {
  120164. /**
  120165. * Class containing a set of static utilities functions for managing Pivots
  120166. * @hidden
  120167. */
  120168. export class PivotTools {
  120169. private static _PivotCached;
  120170. private static _OldPivotPoint;
  120171. private static _PivotTranslation;
  120172. private static _PivotTmpVector;
  120173. /** @hidden */
  120174. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  120175. /** @hidden */
  120176. static _RestorePivotPoint(mesh: AbstractMesh): void;
  120177. }
  120178. }
  120179. declare module BABYLON {
  120180. /**
  120181. * Class containing static functions to help procedurally build meshes
  120182. */
  120183. export class PlaneBuilder {
  120184. /**
  120185. * Creates a plane mesh
  120186. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  120187. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  120188. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  120189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120192. * @param name defines the name of the mesh
  120193. * @param options defines the options used to create the mesh
  120194. * @param scene defines the hosting scene
  120195. * @returns the plane mesh
  120196. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  120197. */
  120198. static CreatePlane(name: string, options: {
  120199. size?: number;
  120200. width?: number;
  120201. height?: number;
  120202. sideOrientation?: number;
  120203. frontUVs?: Vector4;
  120204. backUVs?: Vector4;
  120205. updatable?: boolean;
  120206. sourcePlane?: Plane;
  120207. }, scene?: Nullable<Scene>): Mesh;
  120208. }
  120209. }
  120210. declare module BABYLON {
  120211. /**
  120212. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  120213. */
  120214. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  120215. private static _AnyMouseID;
  120216. /**
  120217. * Abstract mesh the behavior is set on
  120218. */
  120219. attachedNode: AbstractMesh;
  120220. private _dragPlane;
  120221. private _scene;
  120222. private _pointerObserver;
  120223. private _beforeRenderObserver;
  120224. private static _planeScene;
  120225. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  120226. /**
  120227. * 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)
  120228. */
  120229. maxDragAngle: number;
  120230. /**
  120231. * @hidden
  120232. */
  120233. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  120234. /**
  120235. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  120236. */
  120237. currentDraggingPointerID: number;
  120238. /**
  120239. * The last position where the pointer hit the drag plane in world space
  120240. */
  120241. lastDragPosition: Vector3;
  120242. /**
  120243. * If the behavior is currently in a dragging state
  120244. */
  120245. dragging: boolean;
  120246. /**
  120247. * 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)
  120248. */
  120249. dragDeltaRatio: number;
  120250. /**
  120251. * If the drag plane orientation should be updated during the dragging (Default: true)
  120252. */
  120253. updateDragPlane: boolean;
  120254. private _debugMode;
  120255. private _moving;
  120256. /**
  120257. * Fires each time the attached mesh is dragged with the pointer
  120258. * * delta between last drag position and current drag position in world space
  120259. * * dragDistance along the drag axis
  120260. * * dragPlaneNormal normal of the current drag plane used during the drag
  120261. * * dragPlanePoint in world space where the drag intersects the drag plane
  120262. */
  120263. onDragObservable: Observable<{
  120264. delta: Vector3;
  120265. dragPlanePoint: Vector3;
  120266. dragPlaneNormal: Vector3;
  120267. dragDistance: number;
  120268. pointerId: number;
  120269. }>;
  120270. /**
  120271. * Fires each time a drag begins (eg. mouse down on mesh)
  120272. */
  120273. onDragStartObservable: Observable<{
  120274. dragPlanePoint: Vector3;
  120275. pointerId: number;
  120276. }>;
  120277. /**
  120278. * Fires each time a drag ends (eg. mouse release after drag)
  120279. */
  120280. onDragEndObservable: Observable<{
  120281. dragPlanePoint: Vector3;
  120282. pointerId: number;
  120283. }>;
  120284. /**
  120285. * If the attached mesh should be moved when dragged
  120286. */
  120287. moveAttached: boolean;
  120288. /**
  120289. * If the drag behavior will react to drag events (Default: true)
  120290. */
  120291. enabled: boolean;
  120292. /**
  120293. * If pointer events should start and release the drag (Default: true)
  120294. */
  120295. startAndReleaseDragOnPointerEvents: boolean;
  120296. /**
  120297. * If camera controls should be detached during the drag
  120298. */
  120299. detachCameraControls: boolean;
  120300. /**
  120301. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  120302. */
  120303. useObjectOrientationForDragging: boolean;
  120304. private _options;
  120305. /**
  120306. * Gets the options used by the behavior
  120307. */
  120308. get options(): {
  120309. dragAxis?: Vector3;
  120310. dragPlaneNormal?: Vector3;
  120311. };
  120312. /**
  120313. * Sets the options used by the behavior
  120314. */
  120315. set options(options: {
  120316. dragAxis?: Vector3;
  120317. dragPlaneNormal?: Vector3;
  120318. });
  120319. /**
  120320. * Creates a pointer drag behavior that can be attached to a mesh
  120321. * @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)
  120322. */
  120323. constructor(options?: {
  120324. dragAxis?: Vector3;
  120325. dragPlaneNormal?: Vector3;
  120326. });
  120327. /**
  120328. * Predicate to determine if it is valid to move the object to a new position when it is moved
  120329. */
  120330. validateDrag: (targetPosition: Vector3) => boolean;
  120331. /**
  120332. * The name of the behavior
  120333. */
  120334. get name(): string;
  120335. /**
  120336. * Initializes the behavior
  120337. */
  120338. init(): void;
  120339. private _tmpVector;
  120340. private _alternatePickedPoint;
  120341. private _worldDragAxis;
  120342. private _targetPosition;
  120343. private _attachedElement;
  120344. /**
  120345. * Attaches the drag behavior the passed in mesh
  120346. * @param ownerNode The mesh that will be dragged around once attached
  120347. * @param predicate Predicate to use for pick filtering
  120348. */
  120349. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  120350. /**
  120351. * Force relase the drag action by code.
  120352. */
  120353. releaseDrag(): void;
  120354. private _startDragRay;
  120355. private _lastPointerRay;
  120356. /**
  120357. * Simulates the start of a pointer drag event on the behavior
  120358. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  120359. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  120360. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  120361. */
  120362. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  120363. private _startDrag;
  120364. private _dragDelta;
  120365. private _moveDrag;
  120366. private _pickWithRayOnDragPlane;
  120367. private _pointA;
  120368. private _pointB;
  120369. private _pointC;
  120370. private _lineA;
  120371. private _lineB;
  120372. private _localAxis;
  120373. private _lookAt;
  120374. private _updateDragPlanePosition;
  120375. /**
  120376. * Detaches the behavior from the mesh
  120377. */
  120378. detach(): void;
  120379. }
  120380. }
  120381. declare module BABYLON {
  120382. /**
  120383. * A behavior that when attached to a mesh will allow the mesh to be scaled
  120384. */
  120385. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  120386. private _dragBehaviorA;
  120387. private _dragBehaviorB;
  120388. private _startDistance;
  120389. private _initialScale;
  120390. private _targetScale;
  120391. private _ownerNode;
  120392. private _sceneRenderObserver;
  120393. /**
  120394. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  120395. */
  120396. constructor();
  120397. /**
  120398. * The name of the behavior
  120399. */
  120400. get name(): string;
  120401. /**
  120402. * Initializes the behavior
  120403. */
  120404. init(): void;
  120405. private _getCurrentDistance;
  120406. /**
  120407. * Attaches the scale behavior the passed in mesh
  120408. * @param ownerNode The mesh that will be scaled around once attached
  120409. */
  120410. attach(ownerNode: Mesh): void;
  120411. /**
  120412. * Detaches the behavior from the mesh
  120413. */
  120414. detach(): void;
  120415. }
  120416. }
  120417. declare module BABYLON {
  120418. /**
  120419. * 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
  120420. */
  120421. export class SixDofDragBehavior implements Behavior<Mesh> {
  120422. private static _virtualScene;
  120423. private _ownerNode;
  120424. private _sceneRenderObserver;
  120425. private _scene;
  120426. private _targetPosition;
  120427. private _virtualOriginMesh;
  120428. private _virtualDragMesh;
  120429. private _pointerObserver;
  120430. private _moving;
  120431. private _startingOrientation;
  120432. private _attachedElement;
  120433. /**
  120434. * 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)
  120435. */
  120436. private zDragFactor;
  120437. /**
  120438. * If the object should rotate to face the drag origin
  120439. */
  120440. rotateDraggedObject: boolean;
  120441. /**
  120442. * If the behavior is currently in a dragging state
  120443. */
  120444. dragging: boolean;
  120445. /**
  120446. * 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)
  120447. */
  120448. dragDeltaRatio: number;
  120449. /**
  120450. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  120451. */
  120452. currentDraggingPointerID: number;
  120453. /**
  120454. * If camera controls should be detached during the drag
  120455. */
  120456. detachCameraControls: boolean;
  120457. /**
  120458. * Fires each time a drag starts
  120459. */
  120460. onDragStartObservable: Observable<{}>;
  120461. /**
  120462. * Fires each time a drag ends (eg. mouse release after drag)
  120463. */
  120464. onDragEndObservable: Observable<{}>;
  120465. /**
  120466. * 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
  120467. */
  120468. constructor();
  120469. /**
  120470. * The name of the behavior
  120471. */
  120472. get name(): string;
  120473. /**
  120474. * Initializes the behavior
  120475. */
  120476. init(): void;
  120477. /**
  120478. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  120479. */
  120480. private get _pointerCamera();
  120481. /**
  120482. * Attaches the scale behavior the passed in mesh
  120483. * @param ownerNode The mesh that will be scaled around once attached
  120484. */
  120485. attach(ownerNode: Mesh): void;
  120486. /**
  120487. * Detaches the behavior from the mesh
  120488. */
  120489. detach(): void;
  120490. }
  120491. }
  120492. declare module BABYLON {
  120493. /**
  120494. * Class used to apply inverse kinematics to bones
  120495. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  120496. */
  120497. export class BoneIKController {
  120498. private static _tmpVecs;
  120499. private static _tmpQuat;
  120500. private static _tmpMats;
  120501. /**
  120502. * Gets or sets the target mesh
  120503. */
  120504. targetMesh: AbstractMesh;
  120505. /** Gets or sets the mesh used as pole */
  120506. poleTargetMesh: AbstractMesh;
  120507. /**
  120508. * Gets or sets the bone used as pole
  120509. */
  120510. poleTargetBone: Nullable<Bone>;
  120511. /**
  120512. * Gets or sets the target position
  120513. */
  120514. targetPosition: Vector3;
  120515. /**
  120516. * Gets or sets the pole target position
  120517. */
  120518. poleTargetPosition: Vector3;
  120519. /**
  120520. * Gets or sets the pole target local offset
  120521. */
  120522. poleTargetLocalOffset: Vector3;
  120523. /**
  120524. * Gets or sets the pole angle
  120525. */
  120526. poleAngle: number;
  120527. /**
  120528. * Gets or sets the mesh associated with the controller
  120529. */
  120530. mesh: AbstractMesh;
  120531. /**
  120532. * 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)
  120533. */
  120534. slerpAmount: number;
  120535. private _bone1Quat;
  120536. private _bone1Mat;
  120537. private _bone2Ang;
  120538. private _bone1;
  120539. private _bone2;
  120540. private _bone1Length;
  120541. private _bone2Length;
  120542. private _maxAngle;
  120543. private _maxReach;
  120544. private _rightHandedSystem;
  120545. private _bendAxis;
  120546. private _slerping;
  120547. private _adjustRoll;
  120548. /**
  120549. * Gets or sets maximum allowed angle
  120550. */
  120551. get maxAngle(): number;
  120552. set maxAngle(value: number);
  120553. /**
  120554. * Creates a new BoneIKController
  120555. * @param mesh defines the mesh to control
  120556. * @param bone defines the bone to control
  120557. * @param options defines options to set up the controller
  120558. */
  120559. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  120560. targetMesh?: AbstractMesh;
  120561. poleTargetMesh?: AbstractMesh;
  120562. poleTargetBone?: Bone;
  120563. poleTargetLocalOffset?: Vector3;
  120564. poleAngle?: number;
  120565. bendAxis?: Vector3;
  120566. maxAngle?: number;
  120567. slerpAmount?: number;
  120568. });
  120569. private _setMaxAngle;
  120570. /**
  120571. * Force the controller to update the bones
  120572. */
  120573. update(): void;
  120574. }
  120575. }
  120576. declare module BABYLON {
  120577. /**
  120578. * Class used to make a bone look toward a point in space
  120579. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  120580. */
  120581. export class BoneLookController {
  120582. private static _tmpVecs;
  120583. private static _tmpQuat;
  120584. private static _tmpMats;
  120585. /**
  120586. * The target Vector3 that the bone will look at
  120587. */
  120588. target: Vector3;
  120589. /**
  120590. * The mesh that the bone is attached to
  120591. */
  120592. mesh: AbstractMesh;
  120593. /**
  120594. * The bone that will be looking to the target
  120595. */
  120596. bone: Bone;
  120597. /**
  120598. * The up axis of the coordinate system that is used when the bone is rotated
  120599. */
  120600. upAxis: Vector3;
  120601. /**
  120602. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  120603. */
  120604. upAxisSpace: Space;
  120605. /**
  120606. * Used to make an adjustment to the yaw of the bone
  120607. */
  120608. adjustYaw: number;
  120609. /**
  120610. * Used to make an adjustment to the pitch of the bone
  120611. */
  120612. adjustPitch: number;
  120613. /**
  120614. * Used to make an adjustment to the roll of the bone
  120615. */
  120616. adjustRoll: number;
  120617. /**
  120618. * 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)
  120619. */
  120620. slerpAmount: number;
  120621. private _minYaw;
  120622. private _maxYaw;
  120623. private _minPitch;
  120624. private _maxPitch;
  120625. private _minYawSin;
  120626. private _minYawCos;
  120627. private _maxYawSin;
  120628. private _maxYawCos;
  120629. private _midYawConstraint;
  120630. private _minPitchTan;
  120631. private _maxPitchTan;
  120632. private _boneQuat;
  120633. private _slerping;
  120634. private _transformYawPitch;
  120635. private _transformYawPitchInv;
  120636. private _firstFrameSkipped;
  120637. private _yawRange;
  120638. private _fowardAxis;
  120639. /**
  120640. * Gets or sets the minimum yaw angle that the bone can look to
  120641. */
  120642. get minYaw(): number;
  120643. set minYaw(value: number);
  120644. /**
  120645. * Gets or sets the maximum yaw angle that the bone can look to
  120646. */
  120647. get maxYaw(): number;
  120648. set maxYaw(value: number);
  120649. /**
  120650. * Gets or sets the minimum pitch angle that the bone can look to
  120651. */
  120652. get minPitch(): number;
  120653. set minPitch(value: number);
  120654. /**
  120655. * Gets or sets the maximum pitch angle that the bone can look to
  120656. */
  120657. get maxPitch(): number;
  120658. set maxPitch(value: number);
  120659. /**
  120660. * Create a BoneLookController
  120661. * @param mesh the mesh that the bone belongs to
  120662. * @param bone the bone that will be looking to the target
  120663. * @param target the target Vector3 to look at
  120664. * @param options optional settings:
  120665. * * maxYaw: the maximum angle the bone will yaw to
  120666. * * minYaw: the minimum angle the bone will yaw to
  120667. * * maxPitch: the maximum angle the bone will pitch to
  120668. * * minPitch: the minimum angle the bone will yaw to
  120669. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  120670. * * upAxis: the up axis of the coordinate system
  120671. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  120672. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  120673. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  120674. * * adjustYaw: used to make an adjustment to the yaw of the bone
  120675. * * adjustPitch: used to make an adjustment to the pitch of the bone
  120676. * * adjustRoll: used to make an adjustment to the roll of the bone
  120677. **/
  120678. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  120679. maxYaw?: number;
  120680. minYaw?: number;
  120681. maxPitch?: number;
  120682. minPitch?: number;
  120683. slerpAmount?: number;
  120684. upAxis?: Vector3;
  120685. upAxisSpace?: Space;
  120686. yawAxis?: Vector3;
  120687. pitchAxis?: Vector3;
  120688. adjustYaw?: number;
  120689. adjustPitch?: number;
  120690. adjustRoll?: number;
  120691. });
  120692. /**
  120693. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  120694. */
  120695. update(): void;
  120696. private _getAngleDiff;
  120697. private _getAngleBetween;
  120698. private _isAngleBetween;
  120699. }
  120700. }
  120701. declare module BABYLON {
  120702. /**
  120703. * Manage the gamepad inputs to control an arc rotate camera.
  120704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120705. */
  120706. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  120707. /**
  120708. * Defines the camera the input is attached to.
  120709. */
  120710. camera: ArcRotateCamera;
  120711. /**
  120712. * Defines the gamepad the input is gathering event from.
  120713. */
  120714. gamepad: Nullable<Gamepad>;
  120715. /**
  120716. * Defines the gamepad rotation sensiblity.
  120717. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  120718. */
  120719. gamepadRotationSensibility: number;
  120720. /**
  120721. * Defines the gamepad move sensiblity.
  120722. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  120723. */
  120724. gamepadMoveSensibility: number;
  120725. private _yAxisScale;
  120726. /**
  120727. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  120728. */
  120729. get invertYAxis(): boolean;
  120730. set invertYAxis(value: boolean);
  120731. private _onGamepadConnectedObserver;
  120732. private _onGamepadDisconnectedObserver;
  120733. /**
  120734. * Attach the input controls to a specific dom element to get the input from.
  120735. * @param element Defines the element the controls should be listened from
  120736. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120737. */
  120738. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120739. /**
  120740. * Detach the current controls from the specified dom element.
  120741. * @param element Defines the element to stop listening the inputs from
  120742. */
  120743. detachControl(element: Nullable<HTMLElement>): void;
  120744. /**
  120745. * Update the current camera state depending on the inputs that have been used this frame.
  120746. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120747. */
  120748. checkInputs(): void;
  120749. /**
  120750. * Gets the class name of the current intput.
  120751. * @returns the class name
  120752. */
  120753. getClassName(): string;
  120754. /**
  120755. * Get the friendly name associated with the input class.
  120756. * @returns the input friendly name
  120757. */
  120758. getSimpleName(): string;
  120759. }
  120760. }
  120761. declare module BABYLON {
  120762. interface ArcRotateCameraInputsManager {
  120763. /**
  120764. * Add orientation input support to the input manager.
  120765. * @returns the current input manager
  120766. */
  120767. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  120768. }
  120769. /**
  120770. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  120771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120772. */
  120773. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  120774. /**
  120775. * Defines the camera the input is attached to.
  120776. */
  120777. camera: ArcRotateCamera;
  120778. /**
  120779. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  120780. */
  120781. alphaCorrection: number;
  120782. /**
  120783. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  120784. */
  120785. gammaCorrection: number;
  120786. private _alpha;
  120787. private _gamma;
  120788. private _dirty;
  120789. private _deviceOrientationHandler;
  120790. /**
  120791. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  120792. */
  120793. constructor();
  120794. /**
  120795. * Attach the input controls to a specific dom element to get the input from.
  120796. * @param element Defines the element the controls should be listened from
  120797. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120798. */
  120799. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120800. /** @hidden */
  120801. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  120802. /**
  120803. * Update the current camera state depending on the inputs that have been used this frame.
  120804. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120805. */
  120806. checkInputs(): void;
  120807. /**
  120808. * Detach the current controls from the specified dom element.
  120809. * @param element Defines the element to stop listening the inputs from
  120810. */
  120811. detachControl(element: Nullable<HTMLElement>): void;
  120812. /**
  120813. * Gets the class name of the current intput.
  120814. * @returns the class name
  120815. */
  120816. getClassName(): string;
  120817. /**
  120818. * Get the friendly name associated with the input class.
  120819. * @returns the input friendly name
  120820. */
  120821. getSimpleName(): string;
  120822. }
  120823. }
  120824. declare module BABYLON {
  120825. /**
  120826. * Listen to mouse events to control the camera.
  120827. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120828. */
  120829. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  120830. /**
  120831. * Defines the camera the input is attached to.
  120832. */
  120833. camera: FlyCamera;
  120834. /**
  120835. * Defines if touch is enabled. (Default is true.)
  120836. */
  120837. touchEnabled: boolean;
  120838. /**
  120839. * Defines the buttons associated with the input to handle camera rotation.
  120840. */
  120841. buttons: number[];
  120842. /**
  120843. * Assign buttons for Yaw control.
  120844. */
  120845. buttonsYaw: number[];
  120846. /**
  120847. * Assign buttons for Pitch control.
  120848. */
  120849. buttonsPitch: number[];
  120850. /**
  120851. * Assign buttons for Roll control.
  120852. */
  120853. buttonsRoll: number[];
  120854. /**
  120855. * Detect if any button is being pressed while mouse is moved.
  120856. * -1 = Mouse locked.
  120857. * 0 = Left button.
  120858. * 1 = Middle Button.
  120859. * 2 = Right Button.
  120860. */
  120861. activeButton: number;
  120862. /**
  120863. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  120864. * Higher values reduce its sensitivity.
  120865. */
  120866. angularSensibility: number;
  120867. private _mousemoveCallback;
  120868. private _observer;
  120869. private _rollObserver;
  120870. private previousPosition;
  120871. private noPreventDefault;
  120872. private element;
  120873. /**
  120874. * Listen to mouse events to control the camera.
  120875. * @param touchEnabled Define if touch is enabled. (Default is true.)
  120876. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120877. */
  120878. constructor(touchEnabled?: boolean);
  120879. /**
  120880. * Attach the mouse control to the HTML DOM element.
  120881. * @param element Defines the element that listens to the input events.
  120882. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  120883. */
  120884. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120885. /**
  120886. * Detach the current controls from the specified dom element.
  120887. * @param element Defines the element to stop listening the inputs from
  120888. */
  120889. detachControl(element: Nullable<HTMLElement>): void;
  120890. /**
  120891. * Gets the class name of the current input.
  120892. * @returns the class name.
  120893. */
  120894. getClassName(): string;
  120895. /**
  120896. * Get the friendly name associated with the input class.
  120897. * @returns the input's friendly name.
  120898. */
  120899. getSimpleName(): string;
  120900. private _pointerInput;
  120901. private _onMouseMove;
  120902. /**
  120903. * Rotate camera by mouse offset.
  120904. */
  120905. private rotateCamera;
  120906. }
  120907. }
  120908. declare module BABYLON {
  120909. /**
  120910. * Default Inputs manager for the FlyCamera.
  120911. * It groups all the default supported inputs for ease of use.
  120912. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120913. */
  120914. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  120915. /**
  120916. * Instantiates a new FlyCameraInputsManager.
  120917. * @param camera Defines the camera the inputs belong to.
  120918. */
  120919. constructor(camera: FlyCamera);
  120920. /**
  120921. * Add keyboard input support to the input manager.
  120922. * @returns the new FlyCameraKeyboardMoveInput().
  120923. */
  120924. addKeyboard(): FlyCameraInputsManager;
  120925. /**
  120926. * Add mouse input support to the input manager.
  120927. * @param touchEnabled Enable touch screen support.
  120928. * @returns the new FlyCameraMouseInput().
  120929. */
  120930. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  120931. }
  120932. }
  120933. declare module BABYLON {
  120934. /**
  120935. * This is a flying camera, designed for 3D movement and rotation in all directions,
  120936. * such as in a 3D Space Shooter or a Flight Simulator.
  120937. */
  120938. export class FlyCamera extends TargetCamera {
  120939. /**
  120940. * Define the collision ellipsoid of the camera.
  120941. * This is helpful for simulating a camera body, like a player's body.
  120942. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  120943. */
  120944. ellipsoid: Vector3;
  120945. /**
  120946. * Define an offset for the position of the ellipsoid around the camera.
  120947. * This can be helpful if the camera is attached away from the player's body center,
  120948. * such as at its head.
  120949. */
  120950. ellipsoidOffset: Vector3;
  120951. /**
  120952. * Enable or disable collisions of the camera with the rest of the scene objects.
  120953. */
  120954. checkCollisions: boolean;
  120955. /**
  120956. * Enable or disable gravity on the camera.
  120957. */
  120958. applyGravity: boolean;
  120959. /**
  120960. * Define the current direction the camera is moving to.
  120961. */
  120962. cameraDirection: Vector3;
  120963. /**
  120964. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  120965. * This overrides and empties cameraRotation.
  120966. */
  120967. rotationQuaternion: Quaternion;
  120968. /**
  120969. * Track Roll to maintain the wanted Rolling when looking around.
  120970. */
  120971. _trackRoll: number;
  120972. /**
  120973. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  120974. */
  120975. rollCorrect: number;
  120976. /**
  120977. * Mimic a banked turn, Rolling the camera when Yawing.
  120978. * It's recommended to use rollCorrect = 10 for faster banking correction.
  120979. */
  120980. bankedTurn: boolean;
  120981. /**
  120982. * Limit in radians for how much Roll banking will add. (Default: 90°)
  120983. */
  120984. bankedTurnLimit: number;
  120985. /**
  120986. * Value of 0 disables the banked Roll.
  120987. * Value of 1 is equal to the Yaw angle in radians.
  120988. */
  120989. bankedTurnMultiplier: number;
  120990. /**
  120991. * The inputs manager loads all the input sources, such as keyboard and mouse.
  120992. */
  120993. inputs: FlyCameraInputsManager;
  120994. /**
  120995. * Gets the input sensibility for mouse input.
  120996. * Higher values reduce sensitivity.
  120997. */
  120998. get angularSensibility(): number;
  120999. /**
  121000. * Sets the input sensibility for a mouse input.
  121001. * Higher values reduce sensitivity.
  121002. */
  121003. set angularSensibility(value: number);
  121004. /**
  121005. * Get the keys for camera movement forward.
  121006. */
  121007. get keysForward(): number[];
  121008. /**
  121009. * Set the keys for camera movement forward.
  121010. */
  121011. set keysForward(value: number[]);
  121012. /**
  121013. * Get the keys for camera movement backward.
  121014. */
  121015. get keysBackward(): number[];
  121016. set keysBackward(value: number[]);
  121017. /**
  121018. * Get the keys for camera movement up.
  121019. */
  121020. get keysUp(): number[];
  121021. /**
  121022. * Set the keys for camera movement up.
  121023. */
  121024. set keysUp(value: number[]);
  121025. /**
  121026. * Get the keys for camera movement down.
  121027. */
  121028. get keysDown(): number[];
  121029. /**
  121030. * Set the keys for camera movement down.
  121031. */
  121032. set keysDown(value: number[]);
  121033. /**
  121034. * Get the keys for camera movement left.
  121035. */
  121036. get keysLeft(): number[];
  121037. /**
  121038. * Set the keys for camera movement left.
  121039. */
  121040. set keysLeft(value: number[]);
  121041. /**
  121042. * Set the keys for camera movement right.
  121043. */
  121044. get keysRight(): number[];
  121045. /**
  121046. * Set the keys for camera movement right.
  121047. */
  121048. set keysRight(value: number[]);
  121049. /**
  121050. * Event raised when the camera collides with a mesh in the scene.
  121051. */
  121052. onCollide: (collidedMesh: AbstractMesh) => void;
  121053. private _collider;
  121054. private _needMoveForGravity;
  121055. private _oldPosition;
  121056. private _diffPosition;
  121057. private _newPosition;
  121058. /** @hidden */
  121059. _localDirection: Vector3;
  121060. /** @hidden */
  121061. _transformedDirection: Vector3;
  121062. /**
  121063. * Instantiates a FlyCamera.
  121064. * This is a flying camera, designed for 3D movement and rotation in all directions,
  121065. * such as in a 3D Space Shooter or a Flight Simulator.
  121066. * @param name Define the name of the camera in the scene.
  121067. * @param position Define the starting position of the camera in the scene.
  121068. * @param scene Define the scene the camera belongs to.
  121069. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  121070. */
  121071. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  121072. /**
  121073. * Attach a control to the HTML DOM element.
  121074. * @param element Defines the element that listens to the input events.
  121075. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  121076. */
  121077. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121078. /**
  121079. * Detach a control from the HTML DOM element.
  121080. * The camera will stop reacting to that input.
  121081. * @param element Defines the element that listens to the input events.
  121082. */
  121083. detachControl(element: HTMLElement): void;
  121084. private _collisionMask;
  121085. /**
  121086. * Get the mask that the camera ignores in collision events.
  121087. */
  121088. get collisionMask(): number;
  121089. /**
  121090. * Set the mask that the camera ignores in collision events.
  121091. */
  121092. set collisionMask(mask: number);
  121093. /** @hidden */
  121094. _collideWithWorld(displacement: Vector3): void;
  121095. /** @hidden */
  121096. private _onCollisionPositionChange;
  121097. /** @hidden */
  121098. _checkInputs(): void;
  121099. /** @hidden */
  121100. _decideIfNeedsToMove(): boolean;
  121101. /** @hidden */
  121102. _updatePosition(): void;
  121103. /**
  121104. * Restore the Roll to its target value at the rate specified.
  121105. * @param rate - Higher means slower restoring.
  121106. * @hidden
  121107. */
  121108. restoreRoll(rate: number): void;
  121109. /**
  121110. * Destroy the camera and release the current resources held by it.
  121111. */
  121112. dispose(): void;
  121113. /**
  121114. * Get the current object class name.
  121115. * @returns the class name.
  121116. */
  121117. getClassName(): string;
  121118. }
  121119. }
  121120. declare module BABYLON {
  121121. /**
  121122. * Listen to keyboard events to control the camera.
  121123. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121124. */
  121125. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  121126. /**
  121127. * Defines the camera the input is attached to.
  121128. */
  121129. camera: FlyCamera;
  121130. /**
  121131. * The list of keyboard keys used to control the forward move of the camera.
  121132. */
  121133. keysForward: number[];
  121134. /**
  121135. * The list of keyboard keys used to control the backward move of the camera.
  121136. */
  121137. keysBackward: number[];
  121138. /**
  121139. * The list of keyboard keys used to control the forward move of the camera.
  121140. */
  121141. keysUp: number[];
  121142. /**
  121143. * The list of keyboard keys used to control the backward move of the camera.
  121144. */
  121145. keysDown: number[];
  121146. /**
  121147. * The list of keyboard keys used to control the right strafe move of the camera.
  121148. */
  121149. keysRight: number[];
  121150. /**
  121151. * The list of keyboard keys used to control the left strafe move of the camera.
  121152. */
  121153. keysLeft: number[];
  121154. private _keys;
  121155. private _onCanvasBlurObserver;
  121156. private _onKeyboardObserver;
  121157. private _engine;
  121158. private _scene;
  121159. /**
  121160. * Attach the input controls to a specific dom element to get the input from.
  121161. * @param element Defines the element the controls should be listened from
  121162. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121163. */
  121164. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121165. /**
  121166. * Detach the current controls from the specified dom element.
  121167. * @param element Defines the element to stop listening the inputs from
  121168. */
  121169. detachControl(element: Nullable<HTMLElement>): void;
  121170. /**
  121171. * Gets the class name of the current intput.
  121172. * @returns the class name
  121173. */
  121174. getClassName(): string;
  121175. /** @hidden */
  121176. _onLostFocus(e: FocusEvent): void;
  121177. /**
  121178. * Get the friendly name associated with the input class.
  121179. * @returns the input friendly name
  121180. */
  121181. getSimpleName(): string;
  121182. /**
  121183. * Update the current camera state depending on the inputs that have been used this frame.
  121184. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121185. */
  121186. checkInputs(): void;
  121187. }
  121188. }
  121189. declare module BABYLON {
  121190. /**
  121191. * Manage the mouse wheel inputs to control a follow camera.
  121192. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121193. */
  121194. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  121195. /**
  121196. * Defines the camera the input is attached to.
  121197. */
  121198. camera: FollowCamera;
  121199. /**
  121200. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  121201. */
  121202. axisControlRadius: boolean;
  121203. /**
  121204. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  121205. */
  121206. axisControlHeight: boolean;
  121207. /**
  121208. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  121209. */
  121210. axisControlRotation: boolean;
  121211. /**
  121212. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  121213. * relation to mouseWheel events.
  121214. */
  121215. wheelPrecision: number;
  121216. /**
  121217. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  121218. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  121219. */
  121220. wheelDeltaPercentage: number;
  121221. private _wheel;
  121222. private _observer;
  121223. /**
  121224. * Attach the input controls to a specific dom element to get the input from.
  121225. * @param element Defines the element the controls should be listened from
  121226. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121227. */
  121228. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121229. /**
  121230. * Detach the current controls from the specified dom element.
  121231. * @param element Defines the element to stop listening the inputs from
  121232. */
  121233. detachControl(element: Nullable<HTMLElement>): void;
  121234. /**
  121235. * Gets the class name of the current intput.
  121236. * @returns the class name
  121237. */
  121238. getClassName(): string;
  121239. /**
  121240. * Get the friendly name associated with the input class.
  121241. * @returns the input friendly name
  121242. */
  121243. getSimpleName(): string;
  121244. }
  121245. }
  121246. declare module BABYLON {
  121247. /**
  121248. * Manage the pointers inputs to control an follow camera.
  121249. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121250. */
  121251. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  121252. /**
  121253. * Defines the camera the input is attached to.
  121254. */
  121255. camera: FollowCamera;
  121256. /**
  121257. * Gets the class name of the current input.
  121258. * @returns the class name
  121259. */
  121260. getClassName(): string;
  121261. /**
  121262. * Defines the pointer angular sensibility along the X axis or how fast is
  121263. * the camera rotating.
  121264. * A negative number will reverse the axis direction.
  121265. */
  121266. angularSensibilityX: number;
  121267. /**
  121268. * Defines the pointer angular sensibility along the Y axis or how fast is
  121269. * the camera rotating.
  121270. * A negative number will reverse the axis direction.
  121271. */
  121272. angularSensibilityY: number;
  121273. /**
  121274. * Defines the pointer pinch precision or how fast is the camera zooming.
  121275. * A negative number will reverse the axis direction.
  121276. */
  121277. pinchPrecision: number;
  121278. /**
  121279. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  121280. * from 0.
  121281. * It defines the percentage of current camera.radius to use as delta when
  121282. * pinch zoom is used.
  121283. */
  121284. pinchDeltaPercentage: number;
  121285. /**
  121286. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  121287. */
  121288. axisXControlRadius: boolean;
  121289. /**
  121290. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  121291. */
  121292. axisXControlHeight: boolean;
  121293. /**
  121294. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  121295. */
  121296. axisXControlRotation: boolean;
  121297. /**
  121298. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  121299. */
  121300. axisYControlRadius: boolean;
  121301. /**
  121302. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  121303. */
  121304. axisYControlHeight: boolean;
  121305. /**
  121306. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  121307. */
  121308. axisYControlRotation: boolean;
  121309. /**
  121310. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  121311. */
  121312. axisPinchControlRadius: boolean;
  121313. /**
  121314. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  121315. */
  121316. axisPinchControlHeight: boolean;
  121317. /**
  121318. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  121319. */
  121320. axisPinchControlRotation: boolean;
  121321. /**
  121322. * Log error messages if basic misconfiguration has occurred.
  121323. */
  121324. warningEnable: boolean;
  121325. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121326. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121327. private _warningCounter;
  121328. private _warning;
  121329. }
  121330. }
  121331. declare module BABYLON {
  121332. /**
  121333. * Default Inputs manager for the FollowCamera.
  121334. * It groups all the default supported inputs for ease of use.
  121335. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121336. */
  121337. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  121338. /**
  121339. * Instantiates a new FollowCameraInputsManager.
  121340. * @param camera Defines the camera the inputs belong to
  121341. */
  121342. constructor(camera: FollowCamera);
  121343. /**
  121344. * Add keyboard input support to the input manager.
  121345. * @returns the current input manager
  121346. */
  121347. addKeyboard(): FollowCameraInputsManager;
  121348. /**
  121349. * Add mouse wheel input support to the input manager.
  121350. * @returns the current input manager
  121351. */
  121352. addMouseWheel(): FollowCameraInputsManager;
  121353. /**
  121354. * Add pointers input support to the input manager.
  121355. * @returns the current input manager
  121356. */
  121357. addPointers(): FollowCameraInputsManager;
  121358. /**
  121359. * Add orientation input support to the input manager.
  121360. * @returns the current input manager
  121361. */
  121362. addVRDeviceOrientation(): FollowCameraInputsManager;
  121363. }
  121364. }
  121365. declare module BABYLON {
  121366. /**
  121367. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  121368. * an arc rotate version arcFollowCamera are available.
  121369. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  121370. */
  121371. export class FollowCamera extends TargetCamera {
  121372. /**
  121373. * Distance the follow camera should follow an object at
  121374. */
  121375. radius: number;
  121376. /**
  121377. * Minimum allowed distance of the camera to the axis of rotation
  121378. * (The camera can not get closer).
  121379. * This can help limiting how the Camera is able to move in the scene.
  121380. */
  121381. lowerRadiusLimit: Nullable<number>;
  121382. /**
  121383. * Maximum allowed distance of the camera to the axis of rotation
  121384. * (The camera can not get further).
  121385. * This can help limiting how the Camera is able to move in the scene.
  121386. */
  121387. upperRadiusLimit: Nullable<number>;
  121388. /**
  121389. * Define a rotation offset between the camera and the object it follows
  121390. */
  121391. rotationOffset: number;
  121392. /**
  121393. * Minimum allowed angle to camera position relative to target object.
  121394. * This can help limiting how the Camera is able to move in the scene.
  121395. */
  121396. lowerRotationOffsetLimit: Nullable<number>;
  121397. /**
  121398. * Maximum allowed angle to camera position relative to target object.
  121399. * This can help limiting how the Camera is able to move in the scene.
  121400. */
  121401. upperRotationOffsetLimit: Nullable<number>;
  121402. /**
  121403. * Define a height offset between the camera and the object it follows.
  121404. * It can help following an object from the top (like a car chaing a plane)
  121405. */
  121406. heightOffset: number;
  121407. /**
  121408. * Minimum allowed height of camera position relative to target object.
  121409. * This can help limiting how the Camera is able to move in the scene.
  121410. */
  121411. lowerHeightOffsetLimit: Nullable<number>;
  121412. /**
  121413. * Maximum allowed height of camera position relative to target object.
  121414. * This can help limiting how the Camera is able to move in the scene.
  121415. */
  121416. upperHeightOffsetLimit: Nullable<number>;
  121417. /**
  121418. * Define how fast the camera can accelerate to follow it s target.
  121419. */
  121420. cameraAcceleration: number;
  121421. /**
  121422. * Define the speed limit of the camera following an object.
  121423. */
  121424. maxCameraSpeed: number;
  121425. /**
  121426. * Define the target of the camera.
  121427. */
  121428. lockedTarget: Nullable<AbstractMesh>;
  121429. /**
  121430. * Defines the input associated with the camera.
  121431. */
  121432. inputs: FollowCameraInputsManager;
  121433. /**
  121434. * Instantiates the follow camera.
  121435. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  121436. * @param name Define the name of the camera in the scene
  121437. * @param position Define the position of the camera
  121438. * @param scene Define the scene the camera belong to
  121439. * @param lockedTarget Define the target of the camera
  121440. */
  121441. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  121442. private _follow;
  121443. /**
  121444. * Attached controls to the current camera.
  121445. * @param element Defines the element the controls should be listened from
  121446. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121447. */
  121448. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121449. /**
  121450. * Detach the current controls from the camera.
  121451. * The camera will stop reacting to inputs.
  121452. * @param element Defines the element to stop listening the inputs from
  121453. */
  121454. detachControl(element: HTMLElement): void;
  121455. /** @hidden */
  121456. _checkInputs(): void;
  121457. private _checkLimits;
  121458. /**
  121459. * Gets the camera class name.
  121460. * @returns the class name
  121461. */
  121462. getClassName(): string;
  121463. }
  121464. /**
  121465. * Arc Rotate version of the follow camera.
  121466. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  121467. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  121468. */
  121469. export class ArcFollowCamera extends TargetCamera {
  121470. /** The longitudinal angle of the camera */
  121471. alpha: number;
  121472. /** The latitudinal angle of the camera */
  121473. beta: number;
  121474. /** The radius of the camera from its target */
  121475. radius: number;
  121476. /** Define the camera target (the mesh it should follow) */
  121477. target: Nullable<AbstractMesh>;
  121478. private _cartesianCoordinates;
  121479. /**
  121480. * Instantiates a new ArcFollowCamera
  121481. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  121482. * @param name Define the name of the camera
  121483. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  121484. * @param beta Define the rotation angle of the camera around the elevation axis
  121485. * @param radius Define the radius of the camera from its target point
  121486. * @param target Define the target of the camera
  121487. * @param scene Define the scene the camera belongs to
  121488. */
  121489. constructor(name: string,
  121490. /** The longitudinal angle of the camera */
  121491. alpha: number,
  121492. /** The latitudinal angle of the camera */
  121493. beta: number,
  121494. /** The radius of the camera from its target */
  121495. radius: number,
  121496. /** Define the camera target (the mesh it should follow) */
  121497. target: Nullable<AbstractMesh>, scene: Scene);
  121498. private _follow;
  121499. /** @hidden */
  121500. _checkInputs(): void;
  121501. /**
  121502. * Returns the class name of the object.
  121503. * It is mostly used internally for serialization purposes.
  121504. */
  121505. getClassName(): string;
  121506. }
  121507. }
  121508. declare module BABYLON {
  121509. /**
  121510. * Manage the keyboard inputs to control the movement of a follow camera.
  121511. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121512. */
  121513. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  121514. /**
  121515. * Defines the camera the input is attached to.
  121516. */
  121517. camera: FollowCamera;
  121518. /**
  121519. * Defines the list of key codes associated with the up action (increase heightOffset)
  121520. */
  121521. keysHeightOffsetIncr: number[];
  121522. /**
  121523. * Defines the list of key codes associated with the down action (decrease heightOffset)
  121524. */
  121525. keysHeightOffsetDecr: number[];
  121526. /**
  121527. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  121528. */
  121529. keysHeightOffsetModifierAlt: boolean;
  121530. /**
  121531. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  121532. */
  121533. keysHeightOffsetModifierCtrl: boolean;
  121534. /**
  121535. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  121536. */
  121537. keysHeightOffsetModifierShift: boolean;
  121538. /**
  121539. * Defines the list of key codes associated with the left action (increase rotationOffset)
  121540. */
  121541. keysRotationOffsetIncr: number[];
  121542. /**
  121543. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  121544. */
  121545. keysRotationOffsetDecr: number[];
  121546. /**
  121547. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  121548. */
  121549. keysRotationOffsetModifierAlt: boolean;
  121550. /**
  121551. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  121552. */
  121553. keysRotationOffsetModifierCtrl: boolean;
  121554. /**
  121555. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  121556. */
  121557. keysRotationOffsetModifierShift: boolean;
  121558. /**
  121559. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  121560. */
  121561. keysRadiusIncr: number[];
  121562. /**
  121563. * Defines the list of key codes associated with the zoom-out action (increase radius)
  121564. */
  121565. keysRadiusDecr: number[];
  121566. /**
  121567. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  121568. */
  121569. keysRadiusModifierAlt: boolean;
  121570. /**
  121571. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  121572. */
  121573. keysRadiusModifierCtrl: boolean;
  121574. /**
  121575. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  121576. */
  121577. keysRadiusModifierShift: boolean;
  121578. /**
  121579. * Defines the rate of change of heightOffset.
  121580. */
  121581. heightSensibility: number;
  121582. /**
  121583. * Defines the rate of change of rotationOffset.
  121584. */
  121585. rotationSensibility: number;
  121586. /**
  121587. * Defines the rate of change of radius.
  121588. */
  121589. radiusSensibility: number;
  121590. private _keys;
  121591. private _ctrlPressed;
  121592. private _altPressed;
  121593. private _shiftPressed;
  121594. private _onCanvasBlurObserver;
  121595. private _onKeyboardObserver;
  121596. private _engine;
  121597. private _scene;
  121598. /**
  121599. * Attach the input controls to a specific dom element to get the input from.
  121600. * @param element Defines the element the controls should be listened from
  121601. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121602. */
  121603. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121604. /**
  121605. * Detach the current controls from the specified dom element.
  121606. * @param element Defines the element to stop listening the inputs from
  121607. */
  121608. detachControl(element: Nullable<HTMLElement>): void;
  121609. /**
  121610. * Update the current camera state depending on the inputs that have been used this frame.
  121611. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121612. */
  121613. checkInputs(): void;
  121614. /**
  121615. * Gets the class name of the current input.
  121616. * @returns the class name
  121617. */
  121618. getClassName(): string;
  121619. /**
  121620. * Get the friendly name associated with the input class.
  121621. * @returns the input friendly name
  121622. */
  121623. getSimpleName(): string;
  121624. /**
  121625. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  121626. * allow modification of the heightOffset value.
  121627. */
  121628. private _modifierHeightOffset;
  121629. /**
  121630. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  121631. * allow modification of the rotationOffset value.
  121632. */
  121633. private _modifierRotationOffset;
  121634. /**
  121635. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  121636. * allow modification of the radius value.
  121637. */
  121638. private _modifierRadius;
  121639. }
  121640. }
  121641. declare module BABYLON {
  121642. interface FreeCameraInputsManager {
  121643. /**
  121644. * @hidden
  121645. */
  121646. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  121647. /**
  121648. * Add orientation input support to the input manager.
  121649. * @returns the current input manager
  121650. */
  121651. addDeviceOrientation(): FreeCameraInputsManager;
  121652. }
  121653. /**
  121654. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  121655. * Screen rotation is taken into account.
  121656. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121657. */
  121658. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  121659. private _camera;
  121660. private _screenOrientationAngle;
  121661. private _constantTranform;
  121662. private _screenQuaternion;
  121663. private _alpha;
  121664. private _beta;
  121665. private _gamma;
  121666. /**
  121667. * Can be used to detect if a device orientation sensor is available on a device
  121668. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  121669. * @returns a promise that will resolve on orientation change
  121670. */
  121671. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  121672. /**
  121673. * @hidden
  121674. */
  121675. _onDeviceOrientationChangedObservable: Observable<void>;
  121676. /**
  121677. * Instantiates a new input
  121678. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121679. */
  121680. constructor();
  121681. /**
  121682. * Define the camera controlled by the input.
  121683. */
  121684. get camera(): FreeCamera;
  121685. set camera(camera: FreeCamera);
  121686. /**
  121687. * Attach the input controls to a specific dom element to get the input from.
  121688. * @param element Defines the element the controls should be listened from
  121689. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121690. */
  121691. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121692. private _orientationChanged;
  121693. private _deviceOrientation;
  121694. /**
  121695. * Detach the current controls from the specified dom element.
  121696. * @param element Defines the element to stop listening the inputs from
  121697. */
  121698. detachControl(element: Nullable<HTMLElement>): void;
  121699. /**
  121700. * Update the current camera state depending on the inputs that have been used this frame.
  121701. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121702. */
  121703. checkInputs(): void;
  121704. /**
  121705. * Gets the class name of the current intput.
  121706. * @returns the class name
  121707. */
  121708. getClassName(): string;
  121709. /**
  121710. * Get the friendly name associated with the input class.
  121711. * @returns the input friendly name
  121712. */
  121713. getSimpleName(): string;
  121714. }
  121715. }
  121716. declare module BABYLON {
  121717. /**
  121718. * Manage the gamepad inputs to control a free camera.
  121719. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121720. */
  121721. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  121722. /**
  121723. * Define the camera the input is attached to.
  121724. */
  121725. camera: FreeCamera;
  121726. /**
  121727. * Define the Gamepad controlling the input
  121728. */
  121729. gamepad: Nullable<Gamepad>;
  121730. /**
  121731. * Defines the gamepad rotation sensiblity.
  121732. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  121733. */
  121734. gamepadAngularSensibility: number;
  121735. /**
  121736. * Defines the gamepad move sensiblity.
  121737. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  121738. */
  121739. gamepadMoveSensibility: number;
  121740. private _yAxisScale;
  121741. /**
  121742. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  121743. */
  121744. get invertYAxis(): boolean;
  121745. set invertYAxis(value: boolean);
  121746. private _onGamepadConnectedObserver;
  121747. private _onGamepadDisconnectedObserver;
  121748. private _cameraTransform;
  121749. private _deltaTransform;
  121750. private _vector3;
  121751. private _vector2;
  121752. /**
  121753. * Attach the input controls to a specific dom element to get the input from.
  121754. * @param element Defines the element the controls should be listened from
  121755. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121756. */
  121757. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121758. /**
  121759. * Detach the current controls from the specified dom element.
  121760. * @param element Defines the element to stop listening the inputs from
  121761. */
  121762. detachControl(element: Nullable<HTMLElement>): void;
  121763. /**
  121764. * Update the current camera state depending on the inputs that have been used this frame.
  121765. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121766. */
  121767. checkInputs(): void;
  121768. /**
  121769. * Gets the class name of the current intput.
  121770. * @returns the class name
  121771. */
  121772. getClassName(): string;
  121773. /**
  121774. * Get the friendly name associated with the input class.
  121775. * @returns the input friendly name
  121776. */
  121777. getSimpleName(): string;
  121778. }
  121779. }
  121780. declare module BABYLON {
  121781. /**
  121782. * Defines the potential axis of a Joystick
  121783. */
  121784. export enum JoystickAxis {
  121785. /** X axis */
  121786. X = 0,
  121787. /** Y axis */
  121788. Y = 1,
  121789. /** Z axis */
  121790. Z = 2
  121791. }
  121792. /**
  121793. * Class used to define virtual joystick (used in touch mode)
  121794. */
  121795. export class VirtualJoystick {
  121796. /**
  121797. * Gets or sets a boolean indicating that left and right values must be inverted
  121798. */
  121799. reverseLeftRight: boolean;
  121800. /**
  121801. * Gets or sets a boolean indicating that up and down values must be inverted
  121802. */
  121803. reverseUpDown: boolean;
  121804. /**
  121805. * Gets the offset value for the position (ie. the change of the position value)
  121806. */
  121807. deltaPosition: Vector3;
  121808. /**
  121809. * Gets a boolean indicating if the virtual joystick was pressed
  121810. */
  121811. pressed: boolean;
  121812. /**
  121813. * Canvas the virtual joystick will render onto, default z-index of this is 5
  121814. */
  121815. static Canvas: Nullable<HTMLCanvasElement>;
  121816. private static _globalJoystickIndex;
  121817. private static vjCanvasContext;
  121818. private static vjCanvasWidth;
  121819. private static vjCanvasHeight;
  121820. private static halfWidth;
  121821. private _action;
  121822. private _axisTargetedByLeftAndRight;
  121823. private _axisTargetedByUpAndDown;
  121824. private _joystickSensibility;
  121825. private _inversedSensibility;
  121826. private _joystickPointerID;
  121827. private _joystickColor;
  121828. private _joystickPointerPos;
  121829. private _joystickPreviousPointerPos;
  121830. private _joystickPointerStartPos;
  121831. private _deltaJoystickVector;
  121832. private _leftJoystick;
  121833. private _touches;
  121834. private _onPointerDownHandlerRef;
  121835. private _onPointerMoveHandlerRef;
  121836. private _onPointerUpHandlerRef;
  121837. private _onResize;
  121838. /**
  121839. * Creates a new virtual joystick
  121840. * @param leftJoystick defines that the joystick is for left hand (false by default)
  121841. */
  121842. constructor(leftJoystick?: boolean);
  121843. /**
  121844. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  121845. * @param newJoystickSensibility defines the new sensibility
  121846. */
  121847. setJoystickSensibility(newJoystickSensibility: number): void;
  121848. private _onPointerDown;
  121849. private _onPointerMove;
  121850. private _onPointerUp;
  121851. /**
  121852. * Change the color of the virtual joystick
  121853. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  121854. */
  121855. setJoystickColor(newColor: string): void;
  121856. /**
  121857. * Defines a callback to call when the joystick is touched
  121858. * @param action defines the callback
  121859. */
  121860. setActionOnTouch(action: () => any): void;
  121861. /**
  121862. * Defines which axis you'd like to control for left & right
  121863. * @param axis defines the axis to use
  121864. */
  121865. setAxisForLeftRight(axis: JoystickAxis): void;
  121866. /**
  121867. * Defines which axis you'd like to control for up & down
  121868. * @param axis defines the axis to use
  121869. */
  121870. setAxisForUpDown(axis: JoystickAxis): void;
  121871. private _drawVirtualJoystick;
  121872. /**
  121873. * Release internal HTML canvas
  121874. */
  121875. releaseCanvas(): void;
  121876. }
  121877. }
  121878. declare module BABYLON {
  121879. interface FreeCameraInputsManager {
  121880. /**
  121881. * Add virtual joystick input support to the input manager.
  121882. * @returns the current input manager
  121883. */
  121884. addVirtualJoystick(): FreeCameraInputsManager;
  121885. }
  121886. /**
  121887. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  121888. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121889. */
  121890. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  121891. /**
  121892. * Defines the camera the input is attached to.
  121893. */
  121894. camera: FreeCamera;
  121895. private _leftjoystick;
  121896. private _rightjoystick;
  121897. /**
  121898. * Gets the left stick of the virtual joystick.
  121899. * @returns The virtual Joystick
  121900. */
  121901. getLeftJoystick(): VirtualJoystick;
  121902. /**
  121903. * Gets the right stick of the virtual joystick.
  121904. * @returns The virtual Joystick
  121905. */
  121906. getRightJoystick(): VirtualJoystick;
  121907. /**
  121908. * Update the current camera state depending on the inputs that have been used this frame.
  121909. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121910. */
  121911. checkInputs(): void;
  121912. /**
  121913. * Attach the input controls to a specific dom element to get the input from.
  121914. * @param element Defines the element the controls should be listened from
  121915. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121916. */
  121917. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121918. /**
  121919. * Detach the current controls from the specified dom element.
  121920. * @param element Defines the element to stop listening the inputs from
  121921. */
  121922. detachControl(element: Nullable<HTMLElement>): void;
  121923. /**
  121924. * Gets the class name of the current intput.
  121925. * @returns the class name
  121926. */
  121927. getClassName(): string;
  121928. /**
  121929. * Get the friendly name associated with the input class.
  121930. * @returns the input friendly name
  121931. */
  121932. getSimpleName(): string;
  121933. }
  121934. }
  121935. declare module BABYLON {
  121936. /**
  121937. * This represents a FPS type of camera controlled by touch.
  121938. * This is like a universal camera minus the Gamepad controls.
  121939. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121940. */
  121941. export class TouchCamera extends FreeCamera {
  121942. /**
  121943. * Defines the touch sensibility for rotation.
  121944. * The higher the faster.
  121945. */
  121946. get touchAngularSensibility(): number;
  121947. set touchAngularSensibility(value: number);
  121948. /**
  121949. * Defines the touch sensibility for move.
  121950. * The higher the faster.
  121951. */
  121952. get touchMoveSensibility(): number;
  121953. set touchMoveSensibility(value: number);
  121954. /**
  121955. * Instantiates a new touch camera.
  121956. * This represents a FPS type of camera controlled by touch.
  121957. * This is like a universal camera minus the Gamepad controls.
  121958. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121959. * @param name Define the name of the camera in the scene
  121960. * @param position Define the start position of the camera in the scene
  121961. * @param scene Define the scene the camera belongs to
  121962. */
  121963. constructor(name: string, position: Vector3, scene: Scene);
  121964. /**
  121965. * Gets the current object class name.
  121966. * @return the class name
  121967. */
  121968. getClassName(): string;
  121969. /** @hidden */
  121970. _setupInputs(): void;
  121971. }
  121972. }
  121973. declare module BABYLON {
  121974. /**
  121975. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  121976. * being tilted forward or back and left or right.
  121977. */
  121978. export class DeviceOrientationCamera extends FreeCamera {
  121979. private _initialQuaternion;
  121980. private _quaternionCache;
  121981. private _tmpDragQuaternion;
  121982. private _disablePointerInputWhenUsingDeviceOrientation;
  121983. /**
  121984. * Creates a new device orientation camera
  121985. * @param name The name of the camera
  121986. * @param position The start position camera
  121987. * @param scene The scene the camera belongs to
  121988. */
  121989. constructor(name: string, position: Vector3, scene: Scene);
  121990. /**
  121991. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  121992. */
  121993. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  121994. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  121995. private _dragFactor;
  121996. /**
  121997. * Enabled turning on the y axis when the orientation sensor is active
  121998. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  121999. */
  122000. enableHorizontalDragging(dragFactor?: number): void;
  122001. /**
  122002. * Gets the current instance class name ("DeviceOrientationCamera").
  122003. * This helps avoiding instanceof at run time.
  122004. * @returns the class name
  122005. */
  122006. getClassName(): string;
  122007. /**
  122008. * @hidden
  122009. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  122010. */
  122011. _checkInputs(): void;
  122012. /**
  122013. * Reset the camera to its default orientation on the specified axis only.
  122014. * @param axis The axis to reset
  122015. */
  122016. resetToCurrentRotation(axis?: Axis): void;
  122017. }
  122018. }
  122019. declare module BABYLON {
  122020. /**
  122021. * Defines supported buttons for XBox360 compatible gamepads
  122022. */
  122023. export enum Xbox360Button {
  122024. /** A */
  122025. A = 0,
  122026. /** B */
  122027. B = 1,
  122028. /** X */
  122029. X = 2,
  122030. /** Y */
  122031. Y = 3,
  122032. /** Left button */
  122033. LB = 4,
  122034. /** Right button */
  122035. RB = 5,
  122036. /** Back */
  122037. Back = 8,
  122038. /** Start */
  122039. Start = 9,
  122040. /** Left stick */
  122041. LeftStick = 10,
  122042. /** Right stick */
  122043. RightStick = 11
  122044. }
  122045. /** Defines values for XBox360 DPad */
  122046. export enum Xbox360Dpad {
  122047. /** Up */
  122048. Up = 12,
  122049. /** Down */
  122050. Down = 13,
  122051. /** Left */
  122052. Left = 14,
  122053. /** Right */
  122054. Right = 15
  122055. }
  122056. /**
  122057. * Defines a XBox360 gamepad
  122058. */
  122059. export class Xbox360Pad extends Gamepad {
  122060. private _leftTrigger;
  122061. private _rightTrigger;
  122062. private _onlefttriggerchanged;
  122063. private _onrighttriggerchanged;
  122064. private _onbuttondown;
  122065. private _onbuttonup;
  122066. private _ondpaddown;
  122067. private _ondpadup;
  122068. /** Observable raised when a button is pressed */
  122069. onButtonDownObservable: Observable<Xbox360Button>;
  122070. /** Observable raised when a button is released */
  122071. onButtonUpObservable: Observable<Xbox360Button>;
  122072. /** Observable raised when a pad is pressed */
  122073. onPadDownObservable: Observable<Xbox360Dpad>;
  122074. /** Observable raised when a pad is released */
  122075. onPadUpObservable: Observable<Xbox360Dpad>;
  122076. private _buttonA;
  122077. private _buttonB;
  122078. private _buttonX;
  122079. private _buttonY;
  122080. private _buttonBack;
  122081. private _buttonStart;
  122082. private _buttonLB;
  122083. private _buttonRB;
  122084. private _buttonLeftStick;
  122085. private _buttonRightStick;
  122086. private _dPadUp;
  122087. private _dPadDown;
  122088. private _dPadLeft;
  122089. private _dPadRight;
  122090. private _isXboxOnePad;
  122091. /**
  122092. * Creates a new XBox360 gamepad object
  122093. * @param id defines the id of this gamepad
  122094. * @param index defines its index
  122095. * @param gamepad defines the internal HTML gamepad object
  122096. * @param xboxOne defines if it is a XBox One gamepad
  122097. */
  122098. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  122099. /**
  122100. * Defines the callback to call when left trigger is pressed
  122101. * @param callback defines the callback to use
  122102. */
  122103. onlefttriggerchanged(callback: (value: number) => void): void;
  122104. /**
  122105. * Defines the callback to call when right trigger is pressed
  122106. * @param callback defines the callback to use
  122107. */
  122108. onrighttriggerchanged(callback: (value: number) => void): void;
  122109. /**
  122110. * Gets the left trigger value
  122111. */
  122112. get leftTrigger(): number;
  122113. /**
  122114. * Sets the left trigger value
  122115. */
  122116. set leftTrigger(newValue: number);
  122117. /**
  122118. * Gets the right trigger value
  122119. */
  122120. get rightTrigger(): number;
  122121. /**
  122122. * Sets the right trigger value
  122123. */
  122124. set rightTrigger(newValue: number);
  122125. /**
  122126. * Defines the callback to call when a button is pressed
  122127. * @param callback defines the callback to use
  122128. */
  122129. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  122130. /**
  122131. * Defines the callback to call when a button is released
  122132. * @param callback defines the callback to use
  122133. */
  122134. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  122135. /**
  122136. * Defines the callback to call when a pad is pressed
  122137. * @param callback defines the callback to use
  122138. */
  122139. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  122140. /**
  122141. * Defines the callback to call when a pad is released
  122142. * @param callback defines the callback to use
  122143. */
  122144. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  122145. private _setButtonValue;
  122146. private _setDPadValue;
  122147. /**
  122148. * Gets the value of the `A` button
  122149. */
  122150. get buttonA(): number;
  122151. /**
  122152. * Sets the value of the `A` button
  122153. */
  122154. set buttonA(value: number);
  122155. /**
  122156. * Gets the value of the `B` button
  122157. */
  122158. get buttonB(): number;
  122159. /**
  122160. * Sets the value of the `B` button
  122161. */
  122162. set buttonB(value: number);
  122163. /**
  122164. * Gets the value of the `X` button
  122165. */
  122166. get buttonX(): number;
  122167. /**
  122168. * Sets the value of the `X` button
  122169. */
  122170. set buttonX(value: number);
  122171. /**
  122172. * Gets the value of the `Y` button
  122173. */
  122174. get buttonY(): number;
  122175. /**
  122176. * Sets the value of the `Y` button
  122177. */
  122178. set buttonY(value: number);
  122179. /**
  122180. * Gets the value of the `Start` button
  122181. */
  122182. get buttonStart(): number;
  122183. /**
  122184. * Sets the value of the `Start` button
  122185. */
  122186. set buttonStart(value: number);
  122187. /**
  122188. * Gets the value of the `Back` button
  122189. */
  122190. get buttonBack(): number;
  122191. /**
  122192. * Sets the value of the `Back` button
  122193. */
  122194. set buttonBack(value: number);
  122195. /**
  122196. * Gets the value of the `Left` button
  122197. */
  122198. get buttonLB(): number;
  122199. /**
  122200. * Sets the value of the `Left` button
  122201. */
  122202. set buttonLB(value: number);
  122203. /**
  122204. * Gets the value of the `Right` button
  122205. */
  122206. get buttonRB(): number;
  122207. /**
  122208. * Sets the value of the `Right` button
  122209. */
  122210. set buttonRB(value: number);
  122211. /**
  122212. * Gets the value of the Left joystick
  122213. */
  122214. get buttonLeftStick(): number;
  122215. /**
  122216. * Sets the value of the Left joystick
  122217. */
  122218. set buttonLeftStick(value: number);
  122219. /**
  122220. * Gets the value of the Right joystick
  122221. */
  122222. get buttonRightStick(): number;
  122223. /**
  122224. * Sets the value of the Right joystick
  122225. */
  122226. set buttonRightStick(value: number);
  122227. /**
  122228. * Gets the value of D-pad up
  122229. */
  122230. get dPadUp(): number;
  122231. /**
  122232. * Sets the value of D-pad up
  122233. */
  122234. set dPadUp(value: number);
  122235. /**
  122236. * Gets the value of D-pad down
  122237. */
  122238. get dPadDown(): number;
  122239. /**
  122240. * Sets the value of D-pad down
  122241. */
  122242. set dPadDown(value: number);
  122243. /**
  122244. * Gets the value of D-pad left
  122245. */
  122246. get dPadLeft(): number;
  122247. /**
  122248. * Sets the value of D-pad left
  122249. */
  122250. set dPadLeft(value: number);
  122251. /**
  122252. * Gets the value of D-pad right
  122253. */
  122254. get dPadRight(): number;
  122255. /**
  122256. * Sets the value of D-pad right
  122257. */
  122258. set dPadRight(value: number);
  122259. /**
  122260. * Force the gamepad to synchronize with device values
  122261. */
  122262. update(): void;
  122263. /**
  122264. * Disposes the gamepad
  122265. */
  122266. dispose(): void;
  122267. }
  122268. }
  122269. declare module BABYLON {
  122270. /**
  122271. * Defines supported buttons for DualShock compatible gamepads
  122272. */
  122273. export enum DualShockButton {
  122274. /** Cross */
  122275. Cross = 0,
  122276. /** Circle */
  122277. Circle = 1,
  122278. /** Square */
  122279. Square = 2,
  122280. /** Triangle */
  122281. Triangle = 3,
  122282. /** L1 */
  122283. L1 = 4,
  122284. /** R1 */
  122285. R1 = 5,
  122286. /** Share */
  122287. Share = 8,
  122288. /** Options */
  122289. Options = 9,
  122290. /** Left stick */
  122291. LeftStick = 10,
  122292. /** Right stick */
  122293. RightStick = 11
  122294. }
  122295. /** Defines values for DualShock DPad */
  122296. export enum DualShockDpad {
  122297. /** Up */
  122298. Up = 12,
  122299. /** Down */
  122300. Down = 13,
  122301. /** Left */
  122302. Left = 14,
  122303. /** Right */
  122304. Right = 15
  122305. }
  122306. /**
  122307. * Defines a DualShock gamepad
  122308. */
  122309. export class DualShockPad extends Gamepad {
  122310. private _leftTrigger;
  122311. private _rightTrigger;
  122312. private _onlefttriggerchanged;
  122313. private _onrighttriggerchanged;
  122314. private _onbuttondown;
  122315. private _onbuttonup;
  122316. private _ondpaddown;
  122317. private _ondpadup;
  122318. /** Observable raised when a button is pressed */
  122319. onButtonDownObservable: Observable<DualShockButton>;
  122320. /** Observable raised when a button is released */
  122321. onButtonUpObservable: Observable<DualShockButton>;
  122322. /** Observable raised when a pad is pressed */
  122323. onPadDownObservable: Observable<DualShockDpad>;
  122324. /** Observable raised when a pad is released */
  122325. onPadUpObservable: Observable<DualShockDpad>;
  122326. private _buttonCross;
  122327. private _buttonCircle;
  122328. private _buttonSquare;
  122329. private _buttonTriangle;
  122330. private _buttonShare;
  122331. private _buttonOptions;
  122332. private _buttonL1;
  122333. private _buttonR1;
  122334. private _buttonLeftStick;
  122335. private _buttonRightStick;
  122336. private _dPadUp;
  122337. private _dPadDown;
  122338. private _dPadLeft;
  122339. private _dPadRight;
  122340. /**
  122341. * Creates a new DualShock gamepad object
  122342. * @param id defines the id of this gamepad
  122343. * @param index defines its index
  122344. * @param gamepad defines the internal HTML gamepad object
  122345. */
  122346. constructor(id: string, index: number, gamepad: any);
  122347. /**
  122348. * Defines the callback to call when left trigger is pressed
  122349. * @param callback defines the callback to use
  122350. */
  122351. onlefttriggerchanged(callback: (value: number) => void): void;
  122352. /**
  122353. * Defines the callback to call when right trigger is pressed
  122354. * @param callback defines the callback to use
  122355. */
  122356. onrighttriggerchanged(callback: (value: number) => void): void;
  122357. /**
  122358. * Gets the left trigger value
  122359. */
  122360. get leftTrigger(): number;
  122361. /**
  122362. * Sets the left trigger value
  122363. */
  122364. set leftTrigger(newValue: number);
  122365. /**
  122366. * Gets the right trigger value
  122367. */
  122368. get rightTrigger(): number;
  122369. /**
  122370. * Sets the right trigger value
  122371. */
  122372. set rightTrigger(newValue: number);
  122373. /**
  122374. * Defines the callback to call when a button is pressed
  122375. * @param callback defines the callback to use
  122376. */
  122377. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  122378. /**
  122379. * Defines the callback to call when a button is released
  122380. * @param callback defines the callback to use
  122381. */
  122382. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  122383. /**
  122384. * Defines the callback to call when a pad is pressed
  122385. * @param callback defines the callback to use
  122386. */
  122387. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  122388. /**
  122389. * Defines the callback to call when a pad is released
  122390. * @param callback defines the callback to use
  122391. */
  122392. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  122393. private _setButtonValue;
  122394. private _setDPadValue;
  122395. /**
  122396. * Gets the value of the `Cross` button
  122397. */
  122398. get buttonCross(): number;
  122399. /**
  122400. * Sets the value of the `Cross` button
  122401. */
  122402. set buttonCross(value: number);
  122403. /**
  122404. * Gets the value of the `Circle` button
  122405. */
  122406. get buttonCircle(): number;
  122407. /**
  122408. * Sets the value of the `Circle` button
  122409. */
  122410. set buttonCircle(value: number);
  122411. /**
  122412. * Gets the value of the `Square` button
  122413. */
  122414. get buttonSquare(): number;
  122415. /**
  122416. * Sets the value of the `Square` button
  122417. */
  122418. set buttonSquare(value: number);
  122419. /**
  122420. * Gets the value of the `Triangle` button
  122421. */
  122422. get buttonTriangle(): number;
  122423. /**
  122424. * Sets the value of the `Triangle` button
  122425. */
  122426. set buttonTriangle(value: number);
  122427. /**
  122428. * Gets the value of the `Options` button
  122429. */
  122430. get buttonOptions(): number;
  122431. /**
  122432. * Sets the value of the `Options` button
  122433. */
  122434. set buttonOptions(value: number);
  122435. /**
  122436. * Gets the value of the `Share` button
  122437. */
  122438. get buttonShare(): number;
  122439. /**
  122440. * Sets the value of the `Share` button
  122441. */
  122442. set buttonShare(value: number);
  122443. /**
  122444. * Gets the value of the `L1` button
  122445. */
  122446. get buttonL1(): number;
  122447. /**
  122448. * Sets the value of the `L1` button
  122449. */
  122450. set buttonL1(value: number);
  122451. /**
  122452. * Gets the value of the `R1` button
  122453. */
  122454. get buttonR1(): number;
  122455. /**
  122456. * Sets the value of the `R1` button
  122457. */
  122458. set buttonR1(value: number);
  122459. /**
  122460. * Gets the value of the Left joystick
  122461. */
  122462. get buttonLeftStick(): number;
  122463. /**
  122464. * Sets the value of the Left joystick
  122465. */
  122466. set buttonLeftStick(value: number);
  122467. /**
  122468. * Gets the value of the Right joystick
  122469. */
  122470. get buttonRightStick(): number;
  122471. /**
  122472. * Sets the value of the Right joystick
  122473. */
  122474. set buttonRightStick(value: number);
  122475. /**
  122476. * Gets the value of D-pad up
  122477. */
  122478. get dPadUp(): number;
  122479. /**
  122480. * Sets the value of D-pad up
  122481. */
  122482. set dPadUp(value: number);
  122483. /**
  122484. * Gets the value of D-pad down
  122485. */
  122486. get dPadDown(): number;
  122487. /**
  122488. * Sets the value of D-pad down
  122489. */
  122490. set dPadDown(value: number);
  122491. /**
  122492. * Gets the value of D-pad left
  122493. */
  122494. get dPadLeft(): number;
  122495. /**
  122496. * Sets the value of D-pad left
  122497. */
  122498. set dPadLeft(value: number);
  122499. /**
  122500. * Gets the value of D-pad right
  122501. */
  122502. get dPadRight(): number;
  122503. /**
  122504. * Sets the value of D-pad right
  122505. */
  122506. set dPadRight(value: number);
  122507. /**
  122508. * Force the gamepad to synchronize with device values
  122509. */
  122510. update(): void;
  122511. /**
  122512. * Disposes the gamepad
  122513. */
  122514. dispose(): void;
  122515. }
  122516. }
  122517. declare module BABYLON {
  122518. /**
  122519. * Manager for handling gamepads
  122520. */
  122521. export class GamepadManager {
  122522. private _scene?;
  122523. private _babylonGamepads;
  122524. private _oneGamepadConnected;
  122525. /** @hidden */
  122526. _isMonitoring: boolean;
  122527. private _gamepadEventSupported;
  122528. private _gamepadSupport?;
  122529. /**
  122530. * observable to be triggered when the gamepad controller has been connected
  122531. */
  122532. onGamepadConnectedObservable: Observable<Gamepad>;
  122533. /**
  122534. * observable to be triggered when the gamepad controller has been disconnected
  122535. */
  122536. onGamepadDisconnectedObservable: Observable<Gamepad>;
  122537. private _onGamepadConnectedEvent;
  122538. private _onGamepadDisconnectedEvent;
  122539. /**
  122540. * Initializes the gamepad manager
  122541. * @param _scene BabylonJS scene
  122542. */
  122543. constructor(_scene?: Scene | undefined);
  122544. /**
  122545. * The gamepads in the game pad manager
  122546. */
  122547. get gamepads(): Gamepad[];
  122548. /**
  122549. * Get the gamepad controllers based on type
  122550. * @param type The type of gamepad controller
  122551. * @returns Nullable gamepad
  122552. */
  122553. getGamepadByType(type?: number): Nullable<Gamepad>;
  122554. /**
  122555. * Disposes the gamepad manager
  122556. */
  122557. dispose(): void;
  122558. private _addNewGamepad;
  122559. private _startMonitoringGamepads;
  122560. private _stopMonitoringGamepads;
  122561. /** @hidden */
  122562. _checkGamepadsStatus(): void;
  122563. private _updateGamepadObjects;
  122564. }
  122565. }
  122566. declare module BABYLON {
  122567. interface Scene {
  122568. /** @hidden */
  122569. _gamepadManager: Nullable<GamepadManager>;
  122570. /**
  122571. * Gets the gamepad manager associated with the scene
  122572. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  122573. */
  122574. gamepadManager: GamepadManager;
  122575. }
  122576. /**
  122577. * Interface representing a free camera inputs manager
  122578. */
  122579. interface FreeCameraInputsManager {
  122580. /**
  122581. * Adds gamepad input support to the FreeCameraInputsManager.
  122582. * @returns the FreeCameraInputsManager
  122583. */
  122584. addGamepad(): FreeCameraInputsManager;
  122585. }
  122586. /**
  122587. * Interface representing an arc rotate camera inputs manager
  122588. */
  122589. interface ArcRotateCameraInputsManager {
  122590. /**
  122591. * Adds gamepad input support to the ArcRotateCamera InputManager.
  122592. * @returns the camera inputs manager
  122593. */
  122594. addGamepad(): ArcRotateCameraInputsManager;
  122595. }
  122596. /**
  122597. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  122598. */
  122599. export class GamepadSystemSceneComponent implements ISceneComponent {
  122600. /**
  122601. * The component name helpfull to identify the component in the list of scene components.
  122602. */
  122603. readonly name: string;
  122604. /**
  122605. * The scene the component belongs to.
  122606. */
  122607. scene: Scene;
  122608. /**
  122609. * Creates a new instance of the component for the given scene
  122610. * @param scene Defines the scene to register the component in
  122611. */
  122612. constructor(scene: Scene);
  122613. /**
  122614. * Registers the component in a given scene
  122615. */
  122616. register(): void;
  122617. /**
  122618. * Rebuilds the elements related to this component in case of
  122619. * context lost for instance.
  122620. */
  122621. rebuild(): void;
  122622. /**
  122623. * Disposes the component and the associated ressources
  122624. */
  122625. dispose(): void;
  122626. private _beforeCameraUpdate;
  122627. }
  122628. }
  122629. declare module BABYLON {
  122630. /**
  122631. * 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,
  122632. * which still works and will still be found in many Playgrounds.
  122633. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122634. */
  122635. export class UniversalCamera extends TouchCamera {
  122636. /**
  122637. * Defines the gamepad rotation sensiblity.
  122638. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  122639. */
  122640. get gamepadAngularSensibility(): number;
  122641. set gamepadAngularSensibility(value: number);
  122642. /**
  122643. * Defines the gamepad move sensiblity.
  122644. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  122645. */
  122646. get gamepadMoveSensibility(): number;
  122647. set gamepadMoveSensibility(value: number);
  122648. /**
  122649. * 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,
  122650. * which still works and will still be found in many Playgrounds.
  122651. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122652. * @param name Define the name of the camera in the scene
  122653. * @param position Define the start position of the camera in the scene
  122654. * @param scene Define the scene the camera belongs to
  122655. */
  122656. constructor(name: string, position: Vector3, scene: Scene);
  122657. /**
  122658. * Gets the current object class name.
  122659. * @return the class name
  122660. */
  122661. getClassName(): string;
  122662. }
  122663. }
  122664. declare module BABYLON {
  122665. /**
  122666. * This represents a FPS type of camera. This is only here for back compat purpose.
  122667. * Please use the UniversalCamera instead as both are identical.
  122668. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122669. */
  122670. export class GamepadCamera extends UniversalCamera {
  122671. /**
  122672. * Instantiates a new Gamepad Camera
  122673. * This represents a FPS type of camera. This is only here for back compat purpose.
  122674. * Please use the UniversalCamera instead as both are identical.
  122675. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122676. * @param name Define the name of the camera in the scene
  122677. * @param position Define the start position of the camera in the scene
  122678. * @param scene Define the scene the camera belongs to
  122679. */
  122680. constructor(name: string, position: Vector3, scene: Scene);
  122681. /**
  122682. * Gets the current object class name.
  122683. * @return the class name
  122684. */
  122685. getClassName(): string;
  122686. }
  122687. }
  122688. declare module BABYLON {
  122689. /** @hidden */
  122690. export var passPixelShader: {
  122691. name: string;
  122692. shader: string;
  122693. };
  122694. }
  122695. declare module BABYLON {
  122696. /** @hidden */
  122697. export var passCubePixelShader: {
  122698. name: string;
  122699. shader: string;
  122700. };
  122701. }
  122702. declare module BABYLON {
  122703. /**
  122704. * PassPostProcess which produces an output the same as it's input
  122705. */
  122706. export class PassPostProcess extends PostProcess {
  122707. /**
  122708. * Creates the PassPostProcess
  122709. * @param name The name of the effect.
  122710. * @param options The required width/height ratio to downsize to before computing the render pass.
  122711. * @param camera The camera to apply the render pass to.
  122712. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122713. * @param engine The engine which the post process will be applied. (default: current engine)
  122714. * @param reusable If the post process can be reused on the same frame. (default: false)
  122715. * @param textureType The type of texture to be used when performing the post processing.
  122716. * @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)
  122717. */
  122718. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122719. }
  122720. /**
  122721. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  122722. */
  122723. export class PassCubePostProcess extends PostProcess {
  122724. private _face;
  122725. /**
  122726. * Gets or sets the cube face to display.
  122727. * * 0 is +X
  122728. * * 1 is -X
  122729. * * 2 is +Y
  122730. * * 3 is -Y
  122731. * * 4 is +Z
  122732. * * 5 is -Z
  122733. */
  122734. get face(): number;
  122735. set face(value: number);
  122736. /**
  122737. * Creates the PassCubePostProcess
  122738. * @param name The name of the effect.
  122739. * @param options The required width/height ratio to downsize to before computing the render pass.
  122740. * @param camera The camera to apply the render pass to.
  122741. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122742. * @param engine The engine which the post process will be applied. (default: current engine)
  122743. * @param reusable If the post process can be reused on the same frame. (default: false)
  122744. * @param textureType The type of texture to be used when performing the post processing.
  122745. * @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)
  122746. */
  122747. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122748. }
  122749. }
  122750. declare module BABYLON {
  122751. /** @hidden */
  122752. export var anaglyphPixelShader: {
  122753. name: string;
  122754. shader: string;
  122755. };
  122756. }
  122757. declare module BABYLON {
  122758. /**
  122759. * Postprocess used to generate anaglyphic rendering
  122760. */
  122761. export class AnaglyphPostProcess extends PostProcess {
  122762. private _passedProcess;
  122763. /**
  122764. * Creates a new AnaglyphPostProcess
  122765. * @param name defines postprocess name
  122766. * @param options defines creation options or target ratio scale
  122767. * @param rigCameras defines cameras using this postprocess
  122768. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  122769. * @param engine defines hosting engine
  122770. * @param reusable defines if the postprocess will be reused multiple times per frame
  122771. */
  122772. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  122773. }
  122774. }
  122775. declare module BABYLON {
  122776. /**
  122777. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  122778. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122779. */
  122780. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  122781. /**
  122782. * Creates a new AnaglyphArcRotateCamera
  122783. * @param name defines camera name
  122784. * @param alpha defines alpha angle (in radians)
  122785. * @param beta defines beta angle (in radians)
  122786. * @param radius defines radius
  122787. * @param target defines camera target
  122788. * @param interaxialDistance defines distance between each color axis
  122789. * @param scene defines the hosting scene
  122790. */
  122791. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  122792. /**
  122793. * Gets camera class name
  122794. * @returns AnaglyphArcRotateCamera
  122795. */
  122796. getClassName(): string;
  122797. }
  122798. }
  122799. declare module BABYLON {
  122800. /**
  122801. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  122802. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122803. */
  122804. export class AnaglyphFreeCamera extends FreeCamera {
  122805. /**
  122806. * Creates a new AnaglyphFreeCamera
  122807. * @param name defines camera name
  122808. * @param position defines initial position
  122809. * @param interaxialDistance defines distance between each color axis
  122810. * @param scene defines the hosting scene
  122811. */
  122812. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122813. /**
  122814. * Gets camera class name
  122815. * @returns AnaglyphFreeCamera
  122816. */
  122817. getClassName(): string;
  122818. }
  122819. }
  122820. declare module BABYLON {
  122821. /**
  122822. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  122823. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122824. */
  122825. export class AnaglyphGamepadCamera extends GamepadCamera {
  122826. /**
  122827. * Creates a new AnaglyphGamepadCamera
  122828. * @param name defines camera name
  122829. * @param position defines initial position
  122830. * @param interaxialDistance defines distance between each color axis
  122831. * @param scene defines the hosting scene
  122832. */
  122833. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122834. /**
  122835. * Gets camera class name
  122836. * @returns AnaglyphGamepadCamera
  122837. */
  122838. getClassName(): string;
  122839. }
  122840. }
  122841. declare module BABYLON {
  122842. /**
  122843. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  122844. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122845. */
  122846. export class AnaglyphUniversalCamera extends UniversalCamera {
  122847. /**
  122848. * Creates a new AnaglyphUniversalCamera
  122849. * @param name defines camera name
  122850. * @param position defines initial position
  122851. * @param interaxialDistance defines distance between each color axis
  122852. * @param scene defines the hosting scene
  122853. */
  122854. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122855. /**
  122856. * Gets camera class name
  122857. * @returns AnaglyphUniversalCamera
  122858. */
  122859. getClassName(): string;
  122860. }
  122861. }
  122862. declare module BABYLON {
  122863. /**
  122864. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  122865. * @see http://doc.babylonjs.com/features/cameras
  122866. */
  122867. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  122868. /**
  122869. * Creates a new StereoscopicArcRotateCamera
  122870. * @param name defines camera name
  122871. * @param alpha defines alpha angle (in radians)
  122872. * @param beta defines beta angle (in radians)
  122873. * @param radius defines radius
  122874. * @param target defines camera target
  122875. * @param interaxialDistance defines distance between each color axis
  122876. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122877. * @param scene defines the hosting scene
  122878. */
  122879. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122880. /**
  122881. * Gets camera class name
  122882. * @returns StereoscopicArcRotateCamera
  122883. */
  122884. getClassName(): string;
  122885. }
  122886. }
  122887. declare module BABYLON {
  122888. /**
  122889. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  122890. * @see http://doc.babylonjs.com/features/cameras
  122891. */
  122892. export class StereoscopicFreeCamera extends FreeCamera {
  122893. /**
  122894. * Creates a new StereoscopicFreeCamera
  122895. * @param name defines camera name
  122896. * @param position defines initial position
  122897. * @param interaxialDistance defines distance between each color axis
  122898. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122899. * @param scene defines the hosting scene
  122900. */
  122901. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122902. /**
  122903. * Gets camera class name
  122904. * @returns StereoscopicFreeCamera
  122905. */
  122906. getClassName(): string;
  122907. }
  122908. }
  122909. declare module BABYLON {
  122910. /**
  122911. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  122912. * @see http://doc.babylonjs.com/features/cameras
  122913. */
  122914. export class StereoscopicGamepadCamera extends GamepadCamera {
  122915. /**
  122916. * Creates a new StereoscopicGamepadCamera
  122917. * @param name defines camera name
  122918. * @param position defines initial position
  122919. * @param interaxialDistance defines distance between each color axis
  122920. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122921. * @param scene defines the hosting scene
  122922. */
  122923. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122924. /**
  122925. * Gets camera class name
  122926. * @returns StereoscopicGamepadCamera
  122927. */
  122928. getClassName(): string;
  122929. }
  122930. }
  122931. declare module BABYLON {
  122932. /**
  122933. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  122934. * @see http://doc.babylonjs.com/features/cameras
  122935. */
  122936. export class StereoscopicUniversalCamera extends UniversalCamera {
  122937. /**
  122938. * Creates a new StereoscopicUniversalCamera
  122939. * @param name defines camera name
  122940. * @param position defines initial position
  122941. * @param interaxialDistance defines distance between each color axis
  122942. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122943. * @param scene defines the hosting scene
  122944. */
  122945. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122946. /**
  122947. * Gets camera class name
  122948. * @returns StereoscopicUniversalCamera
  122949. */
  122950. getClassName(): string;
  122951. }
  122952. }
  122953. declare module BABYLON {
  122954. /**
  122955. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  122956. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  122957. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  122958. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  122959. */
  122960. export class VirtualJoysticksCamera extends FreeCamera {
  122961. /**
  122962. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  122963. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  122964. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  122965. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  122966. * @param name Define the name of the camera in the scene
  122967. * @param position Define the start position of the camera in the scene
  122968. * @param scene Define the scene the camera belongs to
  122969. */
  122970. constructor(name: string, position: Vector3, scene: Scene);
  122971. /**
  122972. * Gets the current object class name.
  122973. * @return the class name
  122974. */
  122975. getClassName(): string;
  122976. }
  122977. }
  122978. declare module BABYLON {
  122979. /**
  122980. * This represents all the required metrics to create a VR camera.
  122981. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  122982. */
  122983. export class VRCameraMetrics {
  122984. /**
  122985. * Define the horizontal resolution off the screen.
  122986. */
  122987. hResolution: number;
  122988. /**
  122989. * Define the vertical resolution off the screen.
  122990. */
  122991. vResolution: number;
  122992. /**
  122993. * Define the horizontal screen size.
  122994. */
  122995. hScreenSize: number;
  122996. /**
  122997. * Define the vertical screen size.
  122998. */
  122999. vScreenSize: number;
  123000. /**
  123001. * Define the vertical screen center position.
  123002. */
  123003. vScreenCenter: number;
  123004. /**
  123005. * Define the distance of the eyes to the screen.
  123006. */
  123007. eyeToScreenDistance: number;
  123008. /**
  123009. * Define the distance between both lenses
  123010. */
  123011. lensSeparationDistance: number;
  123012. /**
  123013. * Define the distance between both viewer's eyes.
  123014. */
  123015. interpupillaryDistance: number;
  123016. /**
  123017. * Define the distortion factor of the VR postprocess.
  123018. * Please, touch with care.
  123019. */
  123020. distortionK: number[];
  123021. /**
  123022. * Define the chromatic aberration correction factors for the VR post process.
  123023. */
  123024. chromaAbCorrection: number[];
  123025. /**
  123026. * Define the scale factor of the post process.
  123027. * The smaller the better but the slower.
  123028. */
  123029. postProcessScaleFactor: number;
  123030. /**
  123031. * Define an offset for the lens center.
  123032. */
  123033. lensCenterOffset: number;
  123034. /**
  123035. * Define if the current vr camera should compensate the distortion of the lense or not.
  123036. */
  123037. compensateDistortion: boolean;
  123038. /**
  123039. * Defines if multiview should be enabled when rendering (Default: false)
  123040. */
  123041. multiviewEnabled: boolean;
  123042. /**
  123043. * Gets the rendering aspect ratio based on the provided resolutions.
  123044. */
  123045. get aspectRatio(): number;
  123046. /**
  123047. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  123048. */
  123049. get aspectRatioFov(): number;
  123050. /**
  123051. * @hidden
  123052. */
  123053. get leftHMatrix(): Matrix;
  123054. /**
  123055. * @hidden
  123056. */
  123057. get rightHMatrix(): Matrix;
  123058. /**
  123059. * @hidden
  123060. */
  123061. get leftPreViewMatrix(): Matrix;
  123062. /**
  123063. * @hidden
  123064. */
  123065. get rightPreViewMatrix(): Matrix;
  123066. /**
  123067. * Get the default VRMetrics based on the most generic setup.
  123068. * @returns the default vr metrics
  123069. */
  123070. static GetDefault(): VRCameraMetrics;
  123071. }
  123072. }
  123073. declare module BABYLON {
  123074. /** @hidden */
  123075. export var vrDistortionCorrectionPixelShader: {
  123076. name: string;
  123077. shader: string;
  123078. };
  123079. }
  123080. declare module BABYLON {
  123081. /**
  123082. * VRDistortionCorrectionPostProcess used for mobile VR
  123083. */
  123084. export class VRDistortionCorrectionPostProcess extends PostProcess {
  123085. private _isRightEye;
  123086. private _distortionFactors;
  123087. private _postProcessScaleFactor;
  123088. private _lensCenterOffset;
  123089. private _scaleIn;
  123090. private _scaleFactor;
  123091. private _lensCenter;
  123092. /**
  123093. * Initializes the VRDistortionCorrectionPostProcess
  123094. * @param name The name of the effect.
  123095. * @param camera The camera to apply the render pass to.
  123096. * @param isRightEye If this is for the right eye distortion
  123097. * @param vrMetrics All the required metrics for the VR camera
  123098. */
  123099. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  123100. }
  123101. }
  123102. declare module BABYLON {
  123103. /**
  123104. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  123105. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123106. */
  123107. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  123108. /**
  123109. * Creates a new VRDeviceOrientationArcRotateCamera
  123110. * @param name defines camera name
  123111. * @param alpha defines the camera rotation along the logitudinal axis
  123112. * @param beta defines the camera rotation along the latitudinal axis
  123113. * @param radius defines the camera distance from its target
  123114. * @param target defines the camera target
  123115. * @param scene defines the scene the camera belongs to
  123116. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123117. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123118. */
  123119. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123120. /**
  123121. * Gets camera class name
  123122. * @returns VRDeviceOrientationArcRotateCamera
  123123. */
  123124. getClassName(): string;
  123125. }
  123126. }
  123127. declare module BABYLON {
  123128. /**
  123129. * Camera used to simulate VR rendering (based on FreeCamera)
  123130. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123131. */
  123132. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  123133. /**
  123134. * Creates a new VRDeviceOrientationFreeCamera
  123135. * @param name defines camera name
  123136. * @param position defines the start position of the camera
  123137. * @param scene defines the scene the camera belongs to
  123138. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123139. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123140. */
  123141. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123142. /**
  123143. * Gets camera class name
  123144. * @returns VRDeviceOrientationFreeCamera
  123145. */
  123146. getClassName(): string;
  123147. }
  123148. }
  123149. declare module BABYLON {
  123150. /**
  123151. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  123152. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123153. */
  123154. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  123155. /**
  123156. * Creates a new VRDeviceOrientationGamepadCamera
  123157. * @param name defines camera name
  123158. * @param position defines the start position of the camera
  123159. * @param scene defines the scene the camera belongs to
  123160. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123161. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123162. */
  123163. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123164. /**
  123165. * Gets camera class name
  123166. * @returns VRDeviceOrientationGamepadCamera
  123167. */
  123168. getClassName(): string;
  123169. }
  123170. }
  123171. declare module BABYLON {
  123172. /** @hidden */
  123173. export var imageProcessingPixelShader: {
  123174. name: string;
  123175. shader: string;
  123176. };
  123177. }
  123178. declare module BABYLON {
  123179. /**
  123180. * ImageProcessingPostProcess
  123181. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  123182. */
  123183. export class ImageProcessingPostProcess extends PostProcess {
  123184. /**
  123185. * Default configuration related to image processing available in the PBR Material.
  123186. */
  123187. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123188. /**
  123189. * Gets the image processing configuration used either in this material.
  123190. */
  123191. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  123192. /**
  123193. * Sets the Default image processing configuration used either in the this material.
  123194. *
  123195. * If sets to null, the scene one is in use.
  123196. */
  123197. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  123198. /**
  123199. * Keep track of the image processing observer to allow dispose and replace.
  123200. */
  123201. private _imageProcessingObserver;
  123202. /**
  123203. * Attaches a new image processing configuration to the PBR Material.
  123204. * @param configuration
  123205. */
  123206. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  123207. /**
  123208. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123209. */
  123210. get colorCurves(): Nullable<ColorCurves>;
  123211. /**
  123212. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123213. */
  123214. set colorCurves(value: Nullable<ColorCurves>);
  123215. /**
  123216. * Gets wether the color curves effect is enabled.
  123217. */
  123218. get colorCurvesEnabled(): boolean;
  123219. /**
  123220. * Sets wether the color curves effect is enabled.
  123221. */
  123222. set colorCurvesEnabled(value: boolean);
  123223. /**
  123224. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123225. */
  123226. get colorGradingTexture(): Nullable<BaseTexture>;
  123227. /**
  123228. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123229. */
  123230. set colorGradingTexture(value: Nullable<BaseTexture>);
  123231. /**
  123232. * Gets wether the color grading effect is enabled.
  123233. */
  123234. get colorGradingEnabled(): boolean;
  123235. /**
  123236. * Gets wether the color grading effect is enabled.
  123237. */
  123238. set colorGradingEnabled(value: boolean);
  123239. /**
  123240. * Gets exposure used in the effect.
  123241. */
  123242. get exposure(): number;
  123243. /**
  123244. * Sets exposure used in the effect.
  123245. */
  123246. set exposure(value: number);
  123247. /**
  123248. * Gets wether tonemapping is enabled or not.
  123249. */
  123250. get toneMappingEnabled(): boolean;
  123251. /**
  123252. * Sets wether tonemapping is enabled or not
  123253. */
  123254. set toneMappingEnabled(value: boolean);
  123255. /**
  123256. * Gets the type of tone mapping effect.
  123257. */
  123258. get toneMappingType(): number;
  123259. /**
  123260. * Sets the type of tone mapping effect.
  123261. */
  123262. set toneMappingType(value: number);
  123263. /**
  123264. * Gets contrast used in the effect.
  123265. */
  123266. get contrast(): number;
  123267. /**
  123268. * Sets contrast used in the effect.
  123269. */
  123270. set contrast(value: number);
  123271. /**
  123272. * Gets Vignette stretch size.
  123273. */
  123274. get vignetteStretch(): number;
  123275. /**
  123276. * Sets Vignette stretch size.
  123277. */
  123278. set vignetteStretch(value: number);
  123279. /**
  123280. * Gets Vignette centre X Offset.
  123281. */
  123282. get vignetteCentreX(): number;
  123283. /**
  123284. * Sets Vignette centre X Offset.
  123285. */
  123286. set vignetteCentreX(value: number);
  123287. /**
  123288. * Gets Vignette centre Y Offset.
  123289. */
  123290. get vignetteCentreY(): number;
  123291. /**
  123292. * Sets Vignette centre Y Offset.
  123293. */
  123294. set vignetteCentreY(value: number);
  123295. /**
  123296. * Gets Vignette weight or intensity of the vignette effect.
  123297. */
  123298. get vignetteWeight(): number;
  123299. /**
  123300. * Sets Vignette weight or intensity of the vignette effect.
  123301. */
  123302. set vignetteWeight(value: number);
  123303. /**
  123304. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  123305. * if vignetteEnabled is set to true.
  123306. */
  123307. get vignetteColor(): Color4;
  123308. /**
  123309. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  123310. * if vignetteEnabled is set to true.
  123311. */
  123312. set vignetteColor(value: Color4);
  123313. /**
  123314. * Gets Camera field of view used by the Vignette effect.
  123315. */
  123316. get vignetteCameraFov(): number;
  123317. /**
  123318. * Sets Camera field of view used by the Vignette effect.
  123319. */
  123320. set vignetteCameraFov(value: number);
  123321. /**
  123322. * Gets the vignette blend mode allowing different kind of effect.
  123323. */
  123324. get vignetteBlendMode(): number;
  123325. /**
  123326. * Sets the vignette blend mode allowing different kind of effect.
  123327. */
  123328. set vignetteBlendMode(value: number);
  123329. /**
  123330. * Gets wether the vignette effect is enabled.
  123331. */
  123332. get vignetteEnabled(): boolean;
  123333. /**
  123334. * Sets wether the vignette effect is enabled.
  123335. */
  123336. set vignetteEnabled(value: boolean);
  123337. private _fromLinearSpace;
  123338. /**
  123339. * Gets wether the input of the processing is in Gamma or Linear Space.
  123340. */
  123341. get fromLinearSpace(): boolean;
  123342. /**
  123343. * Sets wether the input of the processing is in Gamma or Linear Space.
  123344. */
  123345. set fromLinearSpace(value: boolean);
  123346. /**
  123347. * Defines cache preventing GC.
  123348. */
  123349. private _defines;
  123350. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  123351. /**
  123352. * "ImageProcessingPostProcess"
  123353. * @returns "ImageProcessingPostProcess"
  123354. */
  123355. getClassName(): string;
  123356. protected _updateParameters(): void;
  123357. dispose(camera?: Camera): void;
  123358. }
  123359. }
  123360. declare module BABYLON {
  123361. /**
  123362. * Class containing static functions to help procedurally build meshes
  123363. */
  123364. export class GroundBuilder {
  123365. /**
  123366. * Creates a ground mesh
  123367. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  123368. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  123369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123370. * @param name defines the name of the mesh
  123371. * @param options defines the options used to create the mesh
  123372. * @param scene defines the hosting scene
  123373. * @returns the ground mesh
  123374. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  123375. */
  123376. static CreateGround(name: string, options: {
  123377. width?: number;
  123378. height?: number;
  123379. subdivisions?: number;
  123380. subdivisionsX?: number;
  123381. subdivisionsY?: number;
  123382. updatable?: boolean;
  123383. }, scene: any): Mesh;
  123384. /**
  123385. * Creates a tiled ground mesh
  123386. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  123387. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  123388. * * 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
  123389. * * 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
  123390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123391. * @param name defines the name of the mesh
  123392. * @param options defines the options used to create the mesh
  123393. * @param scene defines the hosting scene
  123394. * @returns the tiled ground mesh
  123395. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  123396. */
  123397. static CreateTiledGround(name: string, options: {
  123398. xmin: number;
  123399. zmin: number;
  123400. xmax: number;
  123401. zmax: number;
  123402. subdivisions?: {
  123403. w: number;
  123404. h: number;
  123405. };
  123406. precision?: {
  123407. w: number;
  123408. h: number;
  123409. };
  123410. updatable?: boolean;
  123411. }, scene?: Nullable<Scene>): Mesh;
  123412. /**
  123413. * Creates a ground mesh from a height map
  123414. * * The parameter `url` sets the URL of the height map image resource.
  123415. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  123416. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  123417. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  123418. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  123419. * * 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.
  123420. * * 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).
  123421. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  123422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123423. * @param name defines the name of the mesh
  123424. * @param url defines the url to the height map
  123425. * @param options defines the options used to create the mesh
  123426. * @param scene defines the hosting scene
  123427. * @returns the ground mesh
  123428. * @see https://doc.babylonjs.com/babylon101/height_map
  123429. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  123430. */
  123431. static CreateGroundFromHeightMap(name: string, url: string, options: {
  123432. width?: number;
  123433. height?: number;
  123434. subdivisions?: number;
  123435. minHeight?: number;
  123436. maxHeight?: number;
  123437. colorFilter?: Color3;
  123438. alphaFilter?: number;
  123439. updatable?: boolean;
  123440. onReady?: (mesh: GroundMesh) => void;
  123441. }, scene?: Nullable<Scene>): GroundMesh;
  123442. }
  123443. }
  123444. declare module BABYLON {
  123445. /**
  123446. * Class containing static functions to help procedurally build meshes
  123447. */
  123448. export class TorusBuilder {
  123449. /**
  123450. * Creates a torus mesh
  123451. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  123452. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  123453. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  123454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123457. * @param name defines the name of the mesh
  123458. * @param options defines the options used to create the mesh
  123459. * @param scene defines the hosting scene
  123460. * @returns the torus mesh
  123461. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  123462. */
  123463. static CreateTorus(name: string, options: {
  123464. diameter?: number;
  123465. thickness?: number;
  123466. tessellation?: number;
  123467. updatable?: boolean;
  123468. sideOrientation?: number;
  123469. frontUVs?: Vector4;
  123470. backUVs?: Vector4;
  123471. }, scene: any): Mesh;
  123472. }
  123473. }
  123474. declare module BABYLON {
  123475. /**
  123476. * Class containing static functions to help procedurally build meshes
  123477. */
  123478. export class CylinderBuilder {
  123479. /**
  123480. * Creates a cylinder or a cone mesh
  123481. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  123482. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  123483. * * 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.
  123484. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  123485. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  123486. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  123487. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  123488. * * 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).
  123489. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  123490. * * 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).
  123491. * * 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
  123492. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  123493. * * 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
  123494. * * 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.
  123495. * * If `enclose` is false, a ring surface is one element.
  123496. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  123497. * * 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
  123498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123501. * @param name defines the name of the mesh
  123502. * @param options defines the options used to create the mesh
  123503. * @param scene defines the hosting scene
  123504. * @returns the cylinder mesh
  123505. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  123506. */
  123507. static CreateCylinder(name: string, options: {
  123508. height?: number;
  123509. diameterTop?: number;
  123510. diameterBottom?: number;
  123511. diameter?: number;
  123512. tessellation?: number;
  123513. subdivisions?: number;
  123514. arc?: number;
  123515. faceColors?: Color4[];
  123516. faceUV?: Vector4[];
  123517. updatable?: boolean;
  123518. hasRings?: boolean;
  123519. enclose?: boolean;
  123520. cap?: number;
  123521. sideOrientation?: number;
  123522. frontUVs?: Vector4;
  123523. backUVs?: Vector4;
  123524. }, scene: any): Mesh;
  123525. }
  123526. }
  123527. declare module BABYLON {
  123528. /**
  123529. * States of the webXR experience
  123530. */
  123531. export enum WebXRState {
  123532. /**
  123533. * Transitioning to being in XR mode
  123534. */
  123535. ENTERING_XR = 0,
  123536. /**
  123537. * Transitioning to non XR mode
  123538. */
  123539. EXITING_XR = 1,
  123540. /**
  123541. * In XR mode and presenting
  123542. */
  123543. IN_XR = 2,
  123544. /**
  123545. * Not entered XR mode
  123546. */
  123547. NOT_IN_XR = 3
  123548. }
  123549. /**
  123550. * Abstraction of the XR render target
  123551. */
  123552. export interface WebXRRenderTarget extends IDisposable {
  123553. /**
  123554. * xrpresent context of the canvas which can be used to display/mirror xr content
  123555. */
  123556. canvasContext: WebGLRenderingContext;
  123557. /**
  123558. * xr layer for the canvas
  123559. */
  123560. xrLayer: Nullable<XRWebGLLayer>;
  123561. /**
  123562. * Initializes the xr layer for the session
  123563. * @param xrSession xr session
  123564. * @returns a promise that will resolve once the XR Layer has been created
  123565. */
  123566. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  123567. }
  123568. }
  123569. declare module BABYLON {
  123570. /**
  123571. * COnfiguration object for WebXR output canvas
  123572. */
  123573. export class WebXRManagedOutputCanvasOptions {
  123574. /**
  123575. * An optional canvas in case you wish to create it yourself and provide it here.
  123576. * If not provided, a new canvas will be created
  123577. */
  123578. canvasElement?: HTMLCanvasElement;
  123579. /**
  123580. * Options for this XR Layer output
  123581. */
  123582. canvasOptions?: XRWebGLLayerOptions;
  123583. /**
  123584. * CSS styling for a newly created canvas (if not provided)
  123585. */
  123586. newCanvasCssStyle?: string;
  123587. /**
  123588. * Get the default values of the configuration object
  123589. * @returns default values of this configuration object
  123590. */
  123591. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  123592. }
  123593. /**
  123594. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  123595. */
  123596. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  123597. private _options;
  123598. private _canvas;
  123599. private _engine;
  123600. /**
  123601. * Rendering context of the canvas which can be used to display/mirror xr content
  123602. */
  123603. canvasContext: WebGLRenderingContext;
  123604. /**
  123605. * xr layer for the canvas
  123606. */
  123607. xrLayer: Nullable<XRWebGLLayer>;
  123608. /**
  123609. * Initializes the canvas to be added/removed upon entering/exiting xr
  123610. * @param _xrSessionManager The XR Session manager
  123611. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  123612. */
  123613. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  123614. /**
  123615. * Disposes of the object
  123616. */
  123617. dispose(): void;
  123618. /**
  123619. * Initializes the xr layer for the session
  123620. * @param xrSession xr session
  123621. * @returns a promise that will resolve once the XR Layer has been created
  123622. */
  123623. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  123624. private _addCanvas;
  123625. private _removeCanvas;
  123626. private _setManagedOutputCanvas;
  123627. }
  123628. }
  123629. declare module BABYLON {
  123630. /**
  123631. * Manages an XRSession to work with Babylon's engine
  123632. * @see https://doc.babylonjs.com/how_to/webxr
  123633. */
  123634. export class WebXRSessionManager implements IDisposable {
  123635. /** The scene which the session should be created for */
  123636. scene: Scene;
  123637. private _referenceSpace;
  123638. private _rttProvider;
  123639. private _sessionEnded;
  123640. private _xrNavigator;
  123641. private baseLayer;
  123642. /**
  123643. * The base reference space from which the session started. good if you want to reset your
  123644. * reference space
  123645. */
  123646. baseReferenceSpace: XRReferenceSpace;
  123647. /**
  123648. * Current XR frame
  123649. */
  123650. currentFrame: Nullable<XRFrame>;
  123651. /** WebXR timestamp updated every frame */
  123652. currentTimestamp: number;
  123653. /**
  123654. * Used just in case of a failure to initialize an immersive session.
  123655. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  123656. */
  123657. defaultHeightCompensation: number;
  123658. /**
  123659. * Fires every time a new xrFrame arrives which can be used to update the camera
  123660. */
  123661. onXRFrameObservable: Observable<XRFrame>;
  123662. /**
  123663. * Fires when the reference space changed
  123664. */
  123665. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  123666. /**
  123667. * Fires when the xr session is ended either by the device or manually done
  123668. */
  123669. onXRSessionEnded: Observable<any>;
  123670. /**
  123671. * Fires when the xr session is ended either by the device or manually done
  123672. */
  123673. onXRSessionInit: Observable<XRSession>;
  123674. /**
  123675. * Underlying xr session
  123676. */
  123677. session: XRSession;
  123678. /**
  123679. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  123680. * or get the offset the player is currently at.
  123681. */
  123682. viewerReferenceSpace: XRReferenceSpace;
  123683. /**
  123684. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  123685. * @param scene The scene which the session should be created for
  123686. */
  123687. constructor(
  123688. /** The scene which the session should be created for */
  123689. scene: Scene);
  123690. /**
  123691. * The current reference space used in this session. This reference space can constantly change!
  123692. * It is mainly used to offset the camera's position.
  123693. */
  123694. get referenceSpace(): XRReferenceSpace;
  123695. /**
  123696. * Set a new reference space and triggers the observable
  123697. */
  123698. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  123699. /**
  123700. * Disposes of the session manager
  123701. */
  123702. dispose(): void;
  123703. /**
  123704. * Stops the xrSession and restores the render loop
  123705. * @returns Promise which resolves after it exits XR
  123706. */
  123707. exitXRAsync(): Promise<void>;
  123708. /**
  123709. * Gets the correct render target texture to be rendered this frame for this eye
  123710. * @param eye the eye for which to get the render target
  123711. * @returns the render target for the specified eye
  123712. */
  123713. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  123714. /**
  123715. * Creates a WebXRRenderTarget object for the XR session
  123716. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  123717. * @param options optional options to provide when creating a new render target
  123718. * @returns a WebXR render target to which the session can render
  123719. */
  123720. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  123721. /**
  123722. * Initializes the manager
  123723. * After initialization enterXR can be called to start an XR session
  123724. * @returns Promise which resolves after it is initialized
  123725. */
  123726. initializeAsync(): Promise<void>;
  123727. /**
  123728. * Initializes an xr session
  123729. * @param xrSessionMode mode to initialize
  123730. * @param xrSessionInit defines optional and required values to pass to the session builder
  123731. * @returns a promise which will resolve once the session has been initialized
  123732. */
  123733. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  123734. /**
  123735. * Checks if a session would be supported for the creation options specified
  123736. * @param sessionMode session mode to check if supported eg. immersive-vr
  123737. * @returns A Promise that resolves to true if supported and false if not
  123738. */
  123739. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  123740. /**
  123741. * Resets the reference space to the one started the session
  123742. */
  123743. resetReferenceSpace(): void;
  123744. /**
  123745. * Starts rendering to the xr layer
  123746. */
  123747. runXRRenderLoop(): void;
  123748. /**
  123749. * Sets the reference space on the xr session
  123750. * @param referenceSpaceType space to set
  123751. * @returns a promise that will resolve once the reference space has been set
  123752. */
  123753. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  123754. /**
  123755. * Updates the render state of the session
  123756. * @param state state to set
  123757. * @returns a promise that resolves once the render state has been updated
  123758. */
  123759. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  123760. /**
  123761. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  123762. * @param sessionMode defines the session to test
  123763. * @returns a promise with boolean as final value
  123764. */
  123765. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  123766. private _createRenderTargetTexture;
  123767. }
  123768. }
  123769. declare module BABYLON {
  123770. /**
  123771. * WebXR Camera which holds the views for the xrSession
  123772. * @see https://doc.babylonjs.com/how_to/webxr_camera
  123773. */
  123774. export class WebXRCamera extends FreeCamera {
  123775. private _xrSessionManager;
  123776. private _firstFrame;
  123777. private _referenceQuaternion;
  123778. private _referencedPosition;
  123779. private _xrInvPositionCache;
  123780. private _xrInvQuaternionCache;
  123781. /**
  123782. * Should position compensation execute on first frame.
  123783. * This is used when copying the position from a native (non XR) camera
  123784. */
  123785. compensateOnFirstFrame: boolean;
  123786. /**
  123787. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  123788. * @param name the name of the camera
  123789. * @param scene the scene to add the camera to
  123790. * @param _xrSessionManager a constructed xr session manager
  123791. */
  123792. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  123793. /**
  123794. * Return the user's height, unrelated to the current ground.
  123795. * This will be the y position of this camera, when ground level is 0.
  123796. */
  123797. get realWorldHeight(): number;
  123798. /** @hidden */
  123799. _updateForDualEyeDebugging(): void;
  123800. /**
  123801. * Sets this camera's transformation based on a non-vr camera
  123802. * @param otherCamera the non-vr camera to copy the transformation from
  123803. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  123804. */
  123805. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  123806. /**
  123807. * Gets the current instance class name ("WebXRCamera").
  123808. * @returns the class name
  123809. */
  123810. getClassName(): string;
  123811. /**
  123812. * Overriding the _getViewMatrix function, as it is computed by WebXR
  123813. */
  123814. _getViewMatrix(): Matrix;
  123815. private _updateFromXRSession;
  123816. private _updateNumberOfRigCameras;
  123817. private _updateReferenceSpace;
  123818. private _updateReferenceSpaceOffset;
  123819. }
  123820. }
  123821. declare module BABYLON {
  123822. /**
  123823. * Defining the interface required for a (webxr) feature
  123824. */
  123825. export interface IWebXRFeature extends IDisposable {
  123826. /**
  123827. * Is this feature attached
  123828. */
  123829. attached: boolean;
  123830. /**
  123831. * Should auto-attach be disabled?
  123832. */
  123833. disableAutoAttach: boolean;
  123834. /**
  123835. * Attach the feature to the session
  123836. * Will usually be called by the features manager
  123837. *
  123838. * @param force should attachment be forced (even when already attached)
  123839. * @returns true if successful.
  123840. */
  123841. attach(force?: boolean): boolean;
  123842. /**
  123843. * Detach the feature from the session
  123844. * Will usually be called by the features manager
  123845. *
  123846. * @returns true if successful.
  123847. */
  123848. detach(): boolean;
  123849. }
  123850. /**
  123851. * A list of the currently available features without referencing them
  123852. */
  123853. export class WebXRFeatureName {
  123854. /**
  123855. * The name of the anchor system feature
  123856. */
  123857. static ANCHOR_SYSTEM: string;
  123858. /**
  123859. * The name of the background remover feature
  123860. */
  123861. static BACKGROUND_REMOVER: string;
  123862. /**
  123863. * The name of the hit test feature
  123864. */
  123865. static HIT_TEST: string;
  123866. /**
  123867. * physics impostors for xr controllers feature
  123868. */
  123869. static PHYSICS_CONTROLLERS: string;
  123870. /**
  123871. * The name of the plane detection feature
  123872. */
  123873. static PLANE_DETECTION: string;
  123874. /**
  123875. * The name of the pointer selection feature
  123876. */
  123877. static POINTER_SELECTION: string;
  123878. /**
  123879. * The name of the teleportation feature
  123880. */
  123881. static TELEPORTATION: string;
  123882. }
  123883. /**
  123884. * Defining the constructor of a feature. Used to register the modules.
  123885. */
  123886. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  123887. /**
  123888. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  123889. * It is mainly used in AR sessions.
  123890. *
  123891. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  123892. */
  123893. export class WebXRFeaturesManager implements IDisposable {
  123894. private _xrSessionManager;
  123895. private static readonly _AvailableFeatures;
  123896. private _features;
  123897. /**
  123898. * constructs a new features manages.
  123899. *
  123900. * @param _xrSessionManager an instance of WebXRSessionManager
  123901. */
  123902. constructor(_xrSessionManager: WebXRSessionManager);
  123903. /**
  123904. * Used to register a module. After calling this function a developer can use this feature in the scene.
  123905. * Mainly used internally.
  123906. *
  123907. * @param featureName the name of the feature to register
  123908. * @param constructorFunction the function used to construct the module
  123909. * @param version the (babylon) version of the module
  123910. * @param stable is that a stable version of this module
  123911. */
  123912. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  123913. /**
  123914. * Returns a constructor of a specific feature.
  123915. *
  123916. * @param featureName the name of the feature to construct
  123917. * @param version the version of the feature to load
  123918. * @param xrSessionManager the xrSessionManager. Used to construct the module
  123919. * @param options optional options provided to the module.
  123920. * @returns a function that, when called, will return a new instance of this feature
  123921. */
  123922. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  123923. /**
  123924. * Can be used to return the list of features currently registered
  123925. *
  123926. * @returns an Array of available features
  123927. */
  123928. static GetAvailableFeatures(): string[];
  123929. /**
  123930. * Gets the versions available for a specific feature
  123931. * @param featureName the name of the feature
  123932. * @returns an array with the available versions
  123933. */
  123934. static GetAvailableVersions(featureName: string): string[];
  123935. /**
  123936. * Return the latest unstable version of this feature
  123937. * @param featureName the name of the feature to search
  123938. * @returns the version number. if not found will return -1
  123939. */
  123940. static GetLatestVersionOfFeature(featureName: string): number;
  123941. /**
  123942. * Return the latest stable version of this feature
  123943. * @param featureName the name of the feature to search
  123944. * @returns the version number. if not found will return -1
  123945. */
  123946. static GetStableVersionOfFeature(featureName: string): number;
  123947. /**
  123948. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  123949. * Can be used during a session to start a feature
  123950. * @param featureName the name of feature to attach
  123951. */
  123952. attachFeature(featureName: string): void;
  123953. /**
  123954. * Can be used inside a session or when the session ends to detach a specific feature
  123955. * @param featureName the name of the feature to detach
  123956. */
  123957. detachFeature(featureName: string): void;
  123958. /**
  123959. * Used to disable an already-enabled feature
  123960. * The feature will be disposed and will be recreated once enabled.
  123961. * @param featureName the feature to disable
  123962. * @returns true if disable was successful
  123963. */
  123964. disableFeature(featureName: string | {
  123965. Name: string;
  123966. }): boolean;
  123967. /**
  123968. * dispose this features manager
  123969. */
  123970. dispose(): void;
  123971. /**
  123972. * 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.
  123973. * 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.
  123974. *
  123975. * @param featureName the name of the feature to load or the class of the feature
  123976. * @param version optional version to load. if not provided the latest version will be enabled
  123977. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  123978. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  123979. * @returns a new constructed feature or throws an error if feature not found.
  123980. */
  123981. enableFeature(featureName: string | {
  123982. Name: string;
  123983. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  123984. /**
  123985. * get the implementation of an enabled feature.
  123986. * @param featureName the name of the feature to load
  123987. * @returns the feature class, if found
  123988. */
  123989. getEnabledFeature(featureName: string): IWebXRFeature;
  123990. /**
  123991. * Get the list of enabled features
  123992. * @returns an array of enabled features
  123993. */
  123994. getEnabledFeatures(): string[];
  123995. }
  123996. }
  123997. declare module BABYLON {
  123998. /**
  123999. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  124000. * @see https://doc.babylonjs.com/how_to/webxr
  124001. */
  124002. export class WebXRExperienceHelper implements IDisposable {
  124003. private scene;
  124004. private _nonVRCamera;
  124005. private _originalSceneAutoClear;
  124006. private _supported;
  124007. /**
  124008. * Camera used to render xr content
  124009. */
  124010. camera: WebXRCamera;
  124011. /** A features manager for this xr session */
  124012. featuresManager: WebXRFeaturesManager;
  124013. /**
  124014. * Observers registered here will be triggered after the camera's initial transformation is set
  124015. * This can be used to set a different ground level or an extra rotation.
  124016. *
  124017. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  124018. * to the position set after this observable is done executing.
  124019. */
  124020. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  124021. /**
  124022. * Fires when the state of the experience helper has changed
  124023. */
  124024. onStateChangedObservable: Observable<WebXRState>;
  124025. /** Session manager used to keep track of xr session */
  124026. sessionManager: WebXRSessionManager;
  124027. /**
  124028. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  124029. */
  124030. state: WebXRState;
  124031. /**
  124032. * Creates a WebXRExperienceHelper
  124033. * @param scene The scene the helper should be created in
  124034. */
  124035. private constructor();
  124036. /**
  124037. * Creates the experience helper
  124038. * @param scene the scene to attach the experience helper to
  124039. * @returns a promise for the experience helper
  124040. */
  124041. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  124042. /**
  124043. * Disposes of the experience helper
  124044. */
  124045. dispose(): void;
  124046. /**
  124047. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  124048. * @param sessionMode options for the XR session
  124049. * @param referenceSpaceType frame of reference of the XR session
  124050. * @param renderTarget the output canvas that will be used to enter XR mode
  124051. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  124052. * @returns promise that resolves after xr mode has entered
  124053. */
  124054. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  124055. /**
  124056. * Exits XR mode and returns the scene to its original state
  124057. * @returns promise that resolves after xr mode has exited
  124058. */
  124059. exitXRAsync(): Promise<void>;
  124060. private _nonXRToXRCamera;
  124061. private _setState;
  124062. }
  124063. }
  124064. declare module BABYLON {
  124065. /**
  124066. * X-Y values for axes in WebXR
  124067. */
  124068. export interface IWebXRMotionControllerAxesValue {
  124069. /**
  124070. * The value of the x axis
  124071. */
  124072. x: number;
  124073. /**
  124074. * The value of the y-axis
  124075. */
  124076. y: number;
  124077. }
  124078. /**
  124079. * changed / previous values for the values of this component
  124080. */
  124081. export interface IWebXRMotionControllerComponentChangesValues<T> {
  124082. /**
  124083. * current (this frame) value
  124084. */
  124085. current: T;
  124086. /**
  124087. * previous (last change) value
  124088. */
  124089. previous: T;
  124090. }
  124091. /**
  124092. * Represents changes in the component between current frame and last values recorded
  124093. */
  124094. export interface IWebXRMotionControllerComponentChanges {
  124095. /**
  124096. * will be populated with previous and current values if axes changed
  124097. */
  124098. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  124099. /**
  124100. * will be populated with previous and current values if pressed changed
  124101. */
  124102. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  124103. /**
  124104. * will be populated with previous and current values if touched changed
  124105. */
  124106. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  124107. /**
  124108. * will be populated with previous and current values if value changed
  124109. */
  124110. value?: IWebXRMotionControllerComponentChangesValues<number>;
  124111. }
  124112. /**
  124113. * This class represents a single component (for example button or thumbstick) of a motion controller
  124114. */
  124115. export class WebXRControllerComponent implements IDisposable {
  124116. /**
  124117. * the id of this component
  124118. */
  124119. id: string;
  124120. /**
  124121. * the type of the component
  124122. */
  124123. type: MotionControllerComponentType;
  124124. private _buttonIndex;
  124125. private _axesIndices;
  124126. private _axes;
  124127. private _changes;
  124128. private _currentValue;
  124129. private _hasChanges;
  124130. private _pressed;
  124131. private _touched;
  124132. /**
  124133. * button component type
  124134. */
  124135. static BUTTON_TYPE: MotionControllerComponentType;
  124136. /**
  124137. * squeeze component type
  124138. */
  124139. static SQUEEZE_TYPE: MotionControllerComponentType;
  124140. /**
  124141. * Thumbstick component type
  124142. */
  124143. static THUMBSTICK_TYPE: MotionControllerComponentType;
  124144. /**
  124145. * Touchpad component type
  124146. */
  124147. static TOUCHPAD_TYPE: MotionControllerComponentType;
  124148. /**
  124149. * trigger component type
  124150. */
  124151. static TRIGGER_TYPE: MotionControllerComponentType;
  124152. /**
  124153. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  124154. * the axes data changes
  124155. */
  124156. onAxisValueChangedObservable: Observable<{
  124157. x: number;
  124158. y: number;
  124159. }>;
  124160. /**
  124161. * Observers registered here will be triggered when the state of a button changes
  124162. * State change is either pressed / touched / value
  124163. */
  124164. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  124165. /**
  124166. * Creates a new component for a motion controller.
  124167. * It is created by the motion controller itself
  124168. *
  124169. * @param id the id of this component
  124170. * @param type the type of the component
  124171. * @param _buttonIndex index in the buttons array of the gamepad
  124172. * @param _axesIndices indices of the values in the axes array of the gamepad
  124173. */
  124174. constructor(
  124175. /**
  124176. * the id of this component
  124177. */
  124178. id: string,
  124179. /**
  124180. * the type of the component
  124181. */
  124182. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  124183. /**
  124184. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  124185. */
  124186. get axes(): IWebXRMotionControllerAxesValue;
  124187. /**
  124188. * Get the changes. Elements will be populated only if they changed with their previous and current value
  124189. */
  124190. get changes(): IWebXRMotionControllerComponentChanges;
  124191. /**
  124192. * Return whether or not the component changed the last frame
  124193. */
  124194. get hasChanges(): boolean;
  124195. /**
  124196. * is the button currently pressed
  124197. */
  124198. get pressed(): boolean;
  124199. /**
  124200. * is the button currently touched
  124201. */
  124202. get touched(): boolean;
  124203. /**
  124204. * Get the current value of this component
  124205. */
  124206. get value(): number;
  124207. /**
  124208. * Dispose this component
  124209. */
  124210. dispose(): void;
  124211. /**
  124212. * Are there axes correlating to this component
  124213. * @return true is axes data is available
  124214. */
  124215. isAxes(): boolean;
  124216. /**
  124217. * Is this component a button (hence - pressable)
  124218. * @returns true if can be pressed
  124219. */
  124220. isButton(): boolean;
  124221. /**
  124222. * update this component using the gamepad object it is in. Called on every frame
  124223. * @param nativeController the native gamepad controller object
  124224. */
  124225. update(nativeController: IMinimalMotionControllerObject): void;
  124226. }
  124227. }
  124228. declare module BABYLON {
  124229. /**
  124230. * Class used to represent data loading progression
  124231. */
  124232. export class SceneLoaderProgressEvent {
  124233. /** defines if data length to load can be evaluated */
  124234. readonly lengthComputable: boolean;
  124235. /** defines the loaded data length */
  124236. readonly loaded: number;
  124237. /** defines the data length to load */
  124238. readonly total: number;
  124239. /**
  124240. * Create a new progress event
  124241. * @param lengthComputable defines if data length to load can be evaluated
  124242. * @param loaded defines the loaded data length
  124243. * @param total defines the data length to load
  124244. */
  124245. constructor(
  124246. /** defines if data length to load can be evaluated */
  124247. lengthComputable: boolean,
  124248. /** defines the loaded data length */
  124249. loaded: number,
  124250. /** defines the data length to load */
  124251. total: number);
  124252. /**
  124253. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  124254. * @param event defines the source event
  124255. * @returns a new SceneLoaderProgressEvent
  124256. */
  124257. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  124258. }
  124259. /**
  124260. * Interface used by SceneLoader plugins to define supported file extensions
  124261. */
  124262. export interface ISceneLoaderPluginExtensions {
  124263. /**
  124264. * Defines the list of supported extensions
  124265. */
  124266. [extension: string]: {
  124267. isBinary: boolean;
  124268. };
  124269. }
  124270. /**
  124271. * Interface used by SceneLoader plugin factory
  124272. */
  124273. export interface ISceneLoaderPluginFactory {
  124274. /**
  124275. * Defines the name of the factory
  124276. */
  124277. name: string;
  124278. /**
  124279. * Function called to create a new plugin
  124280. * @return the new plugin
  124281. */
  124282. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  124283. /**
  124284. * The callback that returns true if the data can be directly loaded.
  124285. * @param data string containing the file data
  124286. * @returns if the data can be loaded directly
  124287. */
  124288. canDirectLoad?(data: string): boolean;
  124289. }
  124290. /**
  124291. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  124292. */
  124293. export interface ISceneLoaderPluginBase {
  124294. /**
  124295. * The friendly name of this plugin.
  124296. */
  124297. name: string;
  124298. /**
  124299. * The file extensions supported by this plugin.
  124300. */
  124301. extensions: string | ISceneLoaderPluginExtensions;
  124302. /**
  124303. * The callback called when loading from a url.
  124304. * @param scene scene loading this url
  124305. * @param url url to load
  124306. * @param onSuccess callback called when the file successfully loads
  124307. * @param onProgress callback called while file is loading (if the server supports this mode)
  124308. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  124309. * @param onError callback called when the file fails to load
  124310. * @returns a file request object
  124311. */
  124312. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  124313. /**
  124314. * The callback called when loading from a file object.
  124315. * @param scene scene loading this file
  124316. * @param file defines the file to load
  124317. * @param onSuccess defines the callback to call when data is loaded
  124318. * @param onProgress defines the callback to call during loading process
  124319. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  124320. * @param onError defines the callback to call when an error occurs
  124321. * @returns a file request object
  124322. */
  124323. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  124324. /**
  124325. * The callback that returns true if the data can be directly loaded.
  124326. * @param data string containing the file data
  124327. * @returns if the data can be loaded directly
  124328. */
  124329. canDirectLoad?(data: string): boolean;
  124330. /**
  124331. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  124332. * @param scene scene loading this data
  124333. * @param data string containing the data
  124334. * @returns data to pass to the plugin
  124335. */
  124336. directLoad?(scene: Scene, data: string): any;
  124337. /**
  124338. * The callback that allows custom handling of the root url based on the response url.
  124339. * @param rootUrl the original root url
  124340. * @param responseURL the response url if available
  124341. * @returns the new root url
  124342. */
  124343. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  124344. }
  124345. /**
  124346. * Interface used to define a SceneLoader plugin
  124347. */
  124348. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  124349. /**
  124350. * Import meshes into a scene.
  124351. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  124352. * @param scene The scene to import into
  124353. * @param data The data to import
  124354. * @param rootUrl The root url for scene and resources
  124355. * @param meshes The meshes array to import into
  124356. * @param particleSystems The particle systems array to import into
  124357. * @param skeletons The skeletons array to import into
  124358. * @param onError The callback when import fails
  124359. * @returns True if successful or false otherwise
  124360. */
  124361. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  124362. /**
  124363. * Load into a scene.
  124364. * @param scene The scene to load into
  124365. * @param data The data to import
  124366. * @param rootUrl The root url for scene and resources
  124367. * @param onError The callback when import fails
  124368. * @returns True if successful or false otherwise
  124369. */
  124370. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  124371. /**
  124372. * Load into an asset container.
  124373. * @param scene The scene to load into
  124374. * @param data The data to import
  124375. * @param rootUrl The root url for scene and resources
  124376. * @param onError The callback when import fails
  124377. * @returns The loaded asset container
  124378. */
  124379. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  124380. }
  124381. /**
  124382. * Interface used to define an async SceneLoader plugin
  124383. */
  124384. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  124385. /**
  124386. * Import meshes into a scene.
  124387. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  124388. * @param scene The scene to import into
  124389. * @param data The data to import
  124390. * @param rootUrl The root url for scene and resources
  124391. * @param onProgress The callback when the load progresses
  124392. * @param fileName Defines the name of the file to load
  124393. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  124394. */
  124395. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  124396. meshes: AbstractMesh[];
  124397. particleSystems: IParticleSystem[];
  124398. skeletons: Skeleton[];
  124399. animationGroups: AnimationGroup[];
  124400. }>;
  124401. /**
  124402. * Load into a scene.
  124403. * @param scene The scene to load into
  124404. * @param data The data to import
  124405. * @param rootUrl The root url for scene and resources
  124406. * @param onProgress The callback when the load progresses
  124407. * @param fileName Defines the name of the file to load
  124408. * @returns Nothing
  124409. */
  124410. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  124411. /**
  124412. * Load into an asset container.
  124413. * @param scene The scene to load into
  124414. * @param data The data to import
  124415. * @param rootUrl The root url for scene and resources
  124416. * @param onProgress The callback when the load progresses
  124417. * @param fileName Defines the name of the file to load
  124418. * @returns The loaded asset container
  124419. */
  124420. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  124421. }
  124422. /**
  124423. * Mode that determines how to handle old animation groups before loading new ones.
  124424. */
  124425. export enum SceneLoaderAnimationGroupLoadingMode {
  124426. /**
  124427. * Reset all old animations to initial state then dispose them.
  124428. */
  124429. Clean = 0,
  124430. /**
  124431. * Stop all old animations.
  124432. */
  124433. Stop = 1,
  124434. /**
  124435. * Restart old animations from first frame.
  124436. */
  124437. Sync = 2,
  124438. /**
  124439. * Old animations remains untouched.
  124440. */
  124441. NoSync = 3
  124442. }
  124443. /**
  124444. * Class used to load scene from various file formats using registered plugins
  124445. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  124446. */
  124447. export class SceneLoader {
  124448. /**
  124449. * No logging while loading
  124450. */
  124451. static readonly NO_LOGGING: number;
  124452. /**
  124453. * Minimal logging while loading
  124454. */
  124455. static readonly MINIMAL_LOGGING: number;
  124456. /**
  124457. * Summary logging while loading
  124458. */
  124459. static readonly SUMMARY_LOGGING: number;
  124460. /**
  124461. * Detailled logging while loading
  124462. */
  124463. static readonly DETAILED_LOGGING: number;
  124464. /**
  124465. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  124466. */
  124467. static get ForceFullSceneLoadingForIncremental(): boolean;
  124468. static set ForceFullSceneLoadingForIncremental(value: boolean);
  124469. /**
  124470. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  124471. */
  124472. static get ShowLoadingScreen(): boolean;
  124473. static set ShowLoadingScreen(value: boolean);
  124474. /**
  124475. * Defines the current logging level (while loading the scene)
  124476. * @ignorenaming
  124477. */
  124478. static get loggingLevel(): number;
  124479. static set loggingLevel(value: number);
  124480. /**
  124481. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  124482. */
  124483. static get CleanBoneMatrixWeights(): boolean;
  124484. static set CleanBoneMatrixWeights(value: boolean);
  124485. /**
  124486. * Event raised when a plugin is used to load a scene
  124487. */
  124488. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  124489. private static _registeredPlugins;
  124490. private static _getDefaultPlugin;
  124491. private static _getPluginForExtension;
  124492. private static _getPluginForDirectLoad;
  124493. private static _getPluginForFilename;
  124494. private static _getDirectLoad;
  124495. private static _loadData;
  124496. private static _getFileInfo;
  124497. /**
  124498. * Gets a plugin that can load the given extension
  124499. * @param extension defines the extension to load
  124500. * @returns a plugin or null if none works
  124501. */
  124502. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  124503. /**
  124504. * Gets a boolean indicating that the given extension can be loaded
  124505. * @param extension defines the extension to load
  124506. * @returns true if the extension is supported
  124507. */
  124508. static IsPluginForExtensionAvailable(extension: string): boolean;
  124509. /**
  124510. * Adds a new plugin to the list of registered plugins
  124511. * @param plugin defines the plugin to add
  124512. */
  124513. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  124514. /**
  124515. * Import meshes into a scene
  124516. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  124517. * @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)
  124518. * @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)
  124519. * @param scene the instance of BABYLON.Scene to append to
  124520. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  124521. * @param onProgress a callback with a progress event for each file being loaded
  124522. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124523. * @param pluginExtension the extension used to determine the plugin
  124524. * @returns The loaded plugin
  124525. */
  124526. 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>;
  124527. /**
  124528. * Import meshes into a scene
  124529. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  124530. * @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)
  124531. * @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)
  124532. * @param scene the instance of BABYLON.Scene to append to
  124533. * @param onProgress a callback with a progress event for each file being loaded
  124534. * @param pluginExtension the extension used to determine the plugin
  124535. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  124536. */
  124537. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  124538. meshes: AbstractMesh[];
  124539. particleSystems: IParticleSystem[];
  124540. skeletons: Skeleton[];
  124541. animationGroups: AnimationGroup[];
  124542. }>;
  124543. /**
  124544. * Load a scene
  124545. * @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)
  124546. * @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)
  124547. * @param engine is the instance of BABYLON.Engine to use to create the scene
  124548. * @param onSuccess a callback with the scene when import succeeds
  124549. * @param onProgress a callback with a progress event for each file being loaded
  124550. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124551. * @param pluginExtension the extension used to determine the plugin
  124552. * @returns The loaded plugin
  124553. */
  124554. 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>;
  124555. /**
  124556. * Load a scene
  124557. * @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)
  124558. * @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)
  124559. * @param engine is the instance of BABYLON.Engine to use to create the scene
  124560. * @param onProgress a callback with a progress event for each file being loaded
  124561. * @param pluginExtension the extension used to determine the plugin
  124562. * @returns The loaded scene
  124563. */
  124564. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  124565. /**
  124566. * Append a scene
  124567. * @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)
  124568. * @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)
  124569. * @param scene is the instance of BABYLON.Scene to append to
  124570. * @param onSuccess a callback with the scene when import succeeds
  124571. * @param onProgress a callback with a progress event for each file being loaded
  124572. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124573. * @param pluginExtension the extension used to determine the plugin
  124574. * @returns The loaded plugin
  124575. */
  124576. 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>;
  124577. /**
  124578. * Append a scene
  124579. * @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)
  124580. * @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)
  124581. * @param scene is the instance of BABYLON.Scene to append to
  124582. * @param onProgress a callback with a progress event for each file being loaded
  124583. * @param pluginExtension the extension used to determine the plugin
  124584. * @returns The given scene
  124585. */
  124586. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  124587. /**
  124588. * Load a scene into an asset container
  124589. * @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)
  124590. * @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)
  124591. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  124592. * @param onSuccess a callback with the scene when import succeeds
  124593. * @param onProgress a callback with a progress event for each file being loaded
  124594. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124595. * @param pluginExtension the extension used to determine the plugin
  124596. * @returns The loaded plugin
  124597. */
  124598. 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>;
  124599. /**
  124600. * Load a scene into an asset container
  124601. * @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)
  124602. * @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)
  124603. * @param scene is the instance of Scene to append to
  124604. * @param onProgress a callback with a progress event for each file being loaded
  124605. * @param pluginExtension the extension used to determine the plugin
  124606. * @returns The loaded asset container
  124607. */
  124608. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  124609. /**
  124610. * Import animations from a file into a scene
  124611. * @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)
  124612. * @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)
  124613. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  124614. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  124615. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  124616. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  124617. * @param onSuccess a callback with the scene when import succeeds
  124618. * @param onProgress a callback with a progress event for each file being loaded
  124619. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124620. */
  124621. 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;
  124622. /**
  124623. * Import animations from a file into a scene
  124624. * @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)
  124625. * @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)
  124626. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  124627. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  124628. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  124629. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  124630. * @param onSuccess a callback with the scene when import succeeds
  124631. * @param onProgress a callback with a progress event for each file being loaded
  124632. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124633. * @returns the updated scene with imported animations
  124634. */
  124635. 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>;
  124636. }
  124637. }
  124638. declare module BABYLON {
  124639. /**
  124640. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  124641. */
  124642. export type MotionControllerHandedness = "none" | "left" | "right";
  124643. /**
  124644. * The type of components available in motion controllers.
  124645. * This is not the name of the component.
  124646. */
  124647. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  124648. /**
  124649. * The state of a controller component
  124650. */
  124651. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  124652. /**
  124653. * The schema of motion controller layout.
  124654. * No object will be initialized using this interface
  124655. * This is used just to define the profile.
  124656. */
  124657. export interface IMotionControllerLayout {
  124658. /**
  124659. * Path to load the assets. Usually relative to the base path
  124660. */
  124661. assetPath: string;
  124662. /**
  124663. * Available components (unsorted)
  124664. */
  124665. components: {
  124666. /**
  124667. * A map of component Ids
  124668. */
  124669. [componentId: string]: {
  124670. /**
  124671. * The type of input the component outputs
  124672. */
  124673. type: MotionControllerComponentType;
  124674. /**
  124675. * The indices of this component in the gamepad object
  124676. */
  124677. gamepadIndices: {
  124678. /**
  124679. * Index of button
  124680. */
  124681. button?: number;
  124682. /**
  124683. * If available, index of x-axis
  124684. */
  124685. xAxis?: number;
  124686. /**
  124687. * If available, index of y-axis
  124688. */
  124689. yAxis?: number;
  124690. };
  124691. /**
  124692. * The mesh's root node name
  124693. */
  124694. rootNodeName: string;
  124695. /**
  124696. * Animation definitions for this model
  124697. */
  124698. visualResponses: {
  124699. [stateKey: string]: {
  124700. /**
  124701. * What property will be animated
  124702. */
  124703. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  124704. /**
  124705. * What states influence this visual response
  124706. */
  124707. states: MotionControllerComponentStateType[];
  124708. /**
  124709. * Type of animation - movement or visibility
  124710. */
  124711. valueNodeProperty: "transform" | "visibility";
  124712. /**
  124713. * Base node name to move. Its position will be calculated according to the min and max nodes
  124714. */
  124715. valueNodeName?: string;
  124716. /**
  124717. * Minimum movement node
  124718. */
  124719. minNodeName?: string;
  124720. /**
  124721. * Max movement node
  124722. */
  124723. maxNodeName?: string;
  124724. };
  124725. };
  124726. /**
  124727. * If touch enabled, what is the name of node to display user feedback
  124728. */
  124729. touchPointNodeName?: string;
  124730. };
  124731. };
  124732. /**
  124733. * Is it xr standard mapping or not
  124734. */
  124735. gamepadMapping: "" | "xr-standard";
  124736. /**
  124737. * Base root node of this entire model
  124738. */
  124739. rootNodeName: string;
  124740. /**
  124741. * Defines the main button component id
  124742. */
  124743. selectComponentId: string;
  124744. }
  124745. /**
  124746. * A definition for the layout map in the input profile
  124747. */
  124748. export interface IMotionControllerLayoutMap {
  124749. /**
  124750. * Layouts with handedness type as a key
  124751. */
  124752. [handedness: string]: IMotionControllerLayout;
  124753. }
  124754. /**
  124755. * The XR Input profile schema
  124756. * Profiles can be found here:
  124757. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  124758. */
  124759. export interface IMotionControllerProfile {
  124760. /**
  124761. * fallback profiles for this profileId
  124762. */
  124763. fallbackProfileIds: string[];
  124764. /**
  124765. * The layout map, with handedness as key
  124766. */
  124767. layouts: IMotionControllerLayoutMap;
  124768. /**
  124769. * The id of this profile
  124770. * correlates to the profile(s) in the xrInput.profiles array
  124771. */
  124772. profileId: string;
  124773. }
  124774. /**
  124775. * A helper-interface for the 3 meshes needed for controller button animation
  124776. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  124777. */
  124778. export interface IMotionControllerButtonMeshMap {
  124779. /**
  124780. * the mesh that defines the pressed value mesh position.
  124781. * This is used to find the max-position of this button
  124782. */
  124783. pressedMesh: AbstractMesh;
  124784. /**
  124785. * the mesh that defines the unpressed value mesh position.
  124786. * This is used to find the min (or initial) position of this button
  124787. */
  124788. unpressedMesh: AbstractMesh;
  124789. /**
  124790. * The mesh that will be changed when value changes
  124791. */
  124792. valueMesh: AbstractMesh;
  124793. }
  124794. /**
  124795. * A helper-interface for the 3 meshes needed for controller axis animation.
  124796. * This will be expanded when touchpad animations are fully supported
  124797. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  124798. */
  124799. export interface IMotionControllerMeshMap {
  124800. /**
  124801. * the mesh that defines the maximum value mesh position.
  124802. */
  124803. maxMesh?: AbstractMesh;
  124804. /**
  124805. * the mesh that defines the minimum value mesh position.
  124806. */
  124807. minMesh?: AbstractMesh;
  124808. /**
  124809. * The mesh that will be changed when axis value changes
  124810. */
  124811. valueMesh: AbstractMesh;
  124812. }
  124813. /**
  124814. * The elements needed for change-detection of the gamepad objects in motion controllers
  124815. */
  124816. export interface IMinimalMotionControllerObject {
  124817. /**
  124818. * Available axes of this controller
  124819. */
  124820. axes: number[];
  124821. /**
  124822. * An array of available buttons
  124823. */
  124824. buttons: Array<{
  124825. /**
  124826. * Value of the button/trigger
  124827. */
  124828. value: number;
  124829. /**
  124830. * If the button/trigger is currently touched
  124831. */
  124832. touched: boolean;
  124833. /**
  124834. * If the button/trigger is currently pressed
  124835. */
  124836. pressed: boolean;
  124837. }>;
  124838. /**
  124839. * EXPERIMENTAL haptic support.
  124840. */
  124841. hapticActuators?: Array<{
  124842. pulse: (value: number, duration: number) => Promise<boolean>;
  124843. }>;
  124844. }
  124845. /**
  124846. * An Abstract Motion controller
  124847. * This class receives an xrInput and a profile layout and uses those to initialize the components
  124848. * Each component has an observable to check for changes in value and state
  124849. */
  124850. export abstract class WebXRAbstractMotionController implements IDisposable {
  124851. protected scene: Scene;
  124852. protected layout: IMotionControllerLayout;
  124853. /**
  124854. * The gamepad object correlating to this controller
  124855. */
  124856. gamepadObject: IMinimalMotionControllerObject;
  124857. /**
  124858. * handedness (left/right/none) of this controller
  124859. */
  124860. handedness: MotionControllerHandedness;
  124861. private _initComponent;
  124862. private _modelReady;
  124863. /**
  124864. * A map of components (WebXRControllerComponent) in this motion controller
  124865. * Components have a ComponentType and can also have both button and axis definitions
  124866. */
  124867. readonly components: {
  124868. [id: string]: WebXRControllerComponent;
  124869. };
  124870. /**
  124871. * Disable the model's animation. Can be set at any time.
  124872. */
  124873. disableAnimation: boolean;
  124874. /**
  124875. * Observers registered here will be triggered when the model of this controller is done loading
  124876. */
  124877. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  124878. /**
  124879. * The profile id of this motion controller
  124880. */
  124881. abstract profileId: string;
  124882. /**
  124883. * The root mesh of the model. It is null if the model was not yet initialized
  124884. */
  124885. rootMesh: Nullable<AbstractMesh>;
  124886. /**
  124887. * constructs a new abstract motion controller
  124888. * @param scene the scene to which the model of the controller will be added
  124889. * @param layout The profile layout to load
  124890. * @param gamepadObject The gamepad object correlating to this controller
  124891. * @param handedness handedness (left/right/none) of this controller
  124892. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  124893. */
  124894. constructor(scene: Scene, layout: IMotionControllerLayout,
  124895. /**
  124896. * The gamepad object correlating to this controller
  124897. */
  124898. gamepadObject: IMinimalMotionControllerObject,
  124899. /**
  124900. * handedness (left/right/none) of this controller
  124901. */
  124902. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  124903. /**
  124904. * Dispose this controller, the model mesh and all its components
  124905. */
  124906. dispose(): void;
  124907. /**
  124908. * Returns all components of specific type
  124909. * @param type the type to search for
  124910. * @return an array of components with this type
  124911. */
  124912. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  124913. /**
  124914. * get a component based an its component id as defined in layout.components
  124915. * @param id the id of the component
  124916. * @returns the component correlates to the id or undefined if not found
  124917. */
  124918. getComponent(id: string): WebXRControllerComponent;
  124919. /**
  124920. * Get the list of components available in this motion controller
  124921. * @returns an array of strings correlating to available components
  124922. */
  124923. getComponentIds(): string[];
  124924. /**
  124925. * Get the first component of specific type
  124926. * @param type type of component to find
  124927. * @return a controller component or null if not found
  124928. */
  124929. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  124930. /**
  124931. * Get the main (Select) component of this controller as defined in the layout
  124932. * @returns the main component of this controller
  124933. */
  124934. getMainComponent(): WebXRControllerComponent;
  124935. /**
  124936. * Loads the model correlating to this controller
  124937. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  124938. * @returns A promise fulfilled with the result of the model loading
  124939. */
  124940. loadModel(): Promise<boolean>;
  124941. /**
  124942. * Update this model using the current XRFrame
  124943. * @param xrFrame the current xr frame to use and update the model
  124944. */
  124945. updateFromXRFrame(xrFrame: XRFrame): void;
  124946. /**
  124947. * Backwards compatibility due to a deeply-integrated typo
  124948. */
  124949. get handness(): XREye;
  124950. /**
  124951. * Pulse (vibrate) this controller
  124952. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  124953. * Consecutive calls to this function will cancel the last pulse call
  124954. *
  124955. * @param value the strength of the pulse in 0.0...1.0 range
  124956. * @param duration Duration of the pulse in milliseconds
  124957. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  124958. * @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
  124959. */
  124960. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  124961. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  124962. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  124963. /**
  124964. * Moves the axis on the controller mesh based on its current state
  124965. * @param axis the index of the axis
  124966. * @param axisValue the value of the axis which determines the meshes new position
  124967. * @hidden
  124968. */
  124969. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  124970. /**
  124971. * Update the model itself with the current frame data
  124972. * @param xrFrame the frame to use for updating the model mesh
  124973. */
  124974. protected updateModel(xrFrame: XRFrame): void;
  124975. /**
  124976. * Get the filename and path for this controller's model
  124977. * @returns a map of filename and path
  124978. */
  124979. protected abstract _getFilenameAndPath(): {
  124980. filename: string;
  124981. path: string;
  124982. };
  124983. /**
  124984. * This function is called before the mesh is loaded. It checks for loading constraints.
  124985. * For example, this function can check if the GLB loader is available
  124986. * If this function returns false, the generic controller will be loaded instead
  124987. * @returns Is the client ready to load the mesh
  124988. */
  124989. protected abstract _getModelLoadingConstraints(): boolean;
  124990. /**
  124991. * This function will be called after the model was successfully loaded and can be used
  124992. * for mesh transformations before it is available for the user
  124993. * @param meshes the loaded meshes
  124994. */
  124995. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  124996. /**
  124997. * Set the root mesh for this controller. Important for the WebXR controller class
  124998. * @param meshes the loaded meshes
  124999. */
  125000. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  125001. /**
  125002. * A function executed each frame that updates the mesh (if needed)
  125003. * @param xrFrame the current xrFrame
  125004. */
  125005. protected abstract _updateModel(xrFrame: XRFrame): void;
  125006. private _getGenericFilenameAndPath;
  125007. private _getGenericParentMesh;
  125008. }
  125009. }
  125010. declare module BABYLON {
  125011. /**
  125012. * A generic trigger-only motion controller for WebXR
  125013. */
  125014. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  125015. /**
  125016. * Static version of the profile id of this controller
  125017. */
  125018. static ProfileId: string;
  125019. profileId: string;
  125020. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  125021. protected _getFilenameAndPath(): {
  125022. filename: string;
  125023. path: string;
  125024. };
  125025. protected _getModelLoadingConstraints(): boolean;
  125026. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  125027. protected _setRootMesh(meshes: AbstractMesh[]): void;
  125028. protected _updateModel(): void;
  125029. }
  125030. }
  125031. declare module BABYLON {
  125032. /**
  125033. * Class containing static functions to help procedurally build meshes
  125034. */
  125035. export class SphereBuilder {
  125036. /**
  125037. * Creates a sphere mesh
  125038. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  125039. * * 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`)
  125040. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  125041. * * 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
  125042. * * 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)
  125043. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125044. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125046. * @param name defines the name of the mesh
  125047. * @param options defines the options used to create the mesh
  125048. * @param scene defines the hosting scene
  125049. * @returns the sphere mesh
  125050. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  125051. */
  125052. static CreateSphere(name: string, options: {
  125053. segments?: number;
  125054. diameter?: number;
  125055. diameterX?: number;
  125056. diameterY?: number;
  125057. diameterZ?: number;
  125058. arc?: number;
  125059. slice?: number;
  125060. sideOrientation?: number;
  125061. frontUVs?: Vector4;
  125062. backUVs?: Vector4;
  125063. updatable?: boolean;
  125064. }, scene?: Nullable<Scene>): Mesh;
  125065. }
  125066. }
  125067. declare module BABYLON {
  125068. /**
  125069. * A profiled motion controller has its profile loaded from an online repository.
  125070. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  125071. */
  125072. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  125073. private _repositoryUrl;
  125074. private _buttonMeshMapping;
  125075. private _touchDots;
  125076. /**
  125077. * The profile ID of this controller. Will be populated when the controller initializes.
  125078. */
  125079. profileId: string;
  125080. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  125081. dispose(): void;
  125082. protected _getFilenameAndPath(): {
  125083. filename: string;
  125084. path: string;
  125085. };
  125086. protected _getModelLoadingConstraints(): boolean;
  125087. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  125088. protected _setRootMesh(meshes: AbstractMesh[]): void;
  125089. protected _updateModel(_xrFrame: XRFrame): void;
  125090. }
  125091. }
  125092. declare module BABYLON {
  125093. /**
  125094. * A construction function type to create a new controller based on an xrInput object
  125095. */
  125096. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  125097. /**
  125098. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  125099. *
  125100. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  125101. * it should be replaced with auto-loaded controllers.
  125102. *
  125103. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  125104. */
  125105. export class WebXRMotionControllerManager {
  125106. private static _AvailableControllers;
  125107. private static _Fallbacks;
  125108. private static _ProfileLoadingPromises;
  125109. private static _ProfilesList;
  125110. /**
  125111. * The base URL of the online controller repository. Can be changed at any time.
  125112. */
  125113. static BaseRepositoryUrl: string;
  125114. /**
  125115. * Which repository gets priority - local or online
  125116. */
  125117. static PrioritizeOnlineRepository: boolean;
  125118. /**
  125119. * Use the online repository, or use only locally-defined controllers
  125120. */
  125121. static UseOnlineRepository: boolean;
  125122. /**
  125123. * Clear the cache used for profile loading and reload when requested again
  125124. */
  125125. static ClearProfilesCache(): void;
  125126. /**
  125127. * Register the default fallbacks.
  125128. * This function is called automatically when this file is imported.
  125129. */
  125130. static DefaultFallbacks(): void;
  125131. /**
  125132. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  125133. * @param profileId the profile to which a fallback needs to be found
  125134. * @return an array with corresponding fallback profiles
  125135. */
  125136. static FindFallbackWithProfileId(profileId: string): string[];
  125137. /**
  125138. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  125139. * The order of search:
  125140. *
  125141. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  125142. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  125143. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  125144. * 4) return the generic trigger controller if none were found
  125145. *
  125146. * @param xrInput the xrInput to which a new controller is initialized
  125147. * @param scene the scene to which the model will be added
  125148. * @param forceProfile force a certain profile for this controller
  125149. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  125150. */
  125151. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  125152. /**
  125153. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  125154. *
  125155. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  125156. *
  125157. * @param type the profile type to register
  125158. * @param constructFunction the function to be called when loading this profile
  125159. */
  125160. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  125161. /**
  125162. * Register a fallback to a specific profile.
  125163. * @param profileId the profileId that will receive the fallbacks
  125164. * @param fallbacks A list of fallback profiles
  125165. */
  125166. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  125167. /**
  125168. * Will update the list of profiles available in the repository
  125169. * @return a promise that resolves to a map of profiles available online
  125170. */
  125171. static UpdateProfilesList(): Promise<{
  125172. [profile: string]: string;
  125173. }>;
  125174. private static _LoadProfileFromRepository;
  125175. private static _LoadProfilesFromAvailableControllers;
  125176. }
  125177. }
  125178. declare module BABYLON {
  125179. /**
  125180. * Configuration options for the WebXR controller creation
  125181. */
  125182. export interface IWebXRControllerOptions {
  125183. /**
  125184. * Should the controller mesh be animated when a user interacts with it
  125185. * The pressed buttons / thumbstick and touchpad animations will be disabled
  125186. */
  125187. disableMotionControllerAnimation?: boolean;
  125188. /**
  125189. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  125190. */
  125191. doNotLoadControllerMesh?: boolean;
  125192. /**
  125193. * Force a specific controller type for this controller.
  125194. * This can be used when creating your own profile or when testing different controllers
  125195. */
  125196. forceControllerProfile?: string;
  125197. /**
  125198. * Defines a rendering group ID for meshes that will be loaded.
  125199. * This is for the default controllers only.
  125200. */
  125201. renderingGroupId?: number;
  125202. }
  125203. /**
  125204. * Represents an XR controller
  125205. */
  125206. export class WebXRInputSource {
  125207. private _scene;
  125208. /** The underlying input source for the controller */
  125209. inputSource: XRInputSource;
  125210. private _options;
  125211. private _tmpVector;
  125212. private _uniqueId;
  125213. /**
  125214. * 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
  125215. */
  125216. grip?: AbstractMesh;
  125217. /**
  125218. * If available, this is the gamepad object related to this controller.
  125219. * Using this object it is possible to get click events and trackpad changes of the
  125220. * webxr controller that is currently being used.
  125221. */
  125222. motionController?: WebXRAbstractMotionController;
  125223. /**
  125224. * Event that fires when the controller is removed/disposed.
  125225. * The object provided as event data is this controller, after associated assets were disposed.
  125226. * uniqueId is still available.
  125227. */
  125228. onDisposeObservable: Observable<WebXRInputSource>;
  125229. /**
  125230. * Will be triggered when the mesh associated with the motion controller is done loading.
  125231. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  125232. * A shortened version of controller -> motion controller -> on mesh loaded.
  125233. */
  125234. onMeshLoadedObservable: Observable<AbstractMesh>;
  125235. /**
  125236. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  125237. */
  125238. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  125239. /**
  125240. * Pointer which can be used to select objects or attach a visible laser to
  125241. */
  125242. pointer: AbstractMesh;
  125243. /**
  125244. * Creates the controller
  125245. * @see https://doc.babylonjs.com/how_to/webxr
  125246. * @param _scene the scene which the controller should be associated to
  125247. * @param inputSource the underlying input source for the controller
  125248. * @param _options options for this controller creation
  125249. */
  125250. constructor(_scene: Scene,
  125251. /** The underlying input source for the controller */
  125252. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  125253. /**
  125254. * Get this controllers unique id
  125255. */
  125256. get uniqueId(): string;
  125257. /**
  125258. * Disposes of the object
  125259. */
  125260. dispose(): void;
  125261. /**
  125262. * Gets a world space ray coming from the pointer or grip
  125263. * @param result the resulting ray
  125264. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  125265. */
  125266. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  125267. /**
  125268. * Updates the controller pose based on the given XRFrame
  125269. * @param xrFrame xr frame to update the pose with
  125270. * @param referenceSpace reference space to use
  125271. */
  125272. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  125273. }
  125274. }
  125275. declare module BABYLON {
  125276. /**
  125277. * The schema for initialization options of the XR Input class
  125278. */
  125279. export interface IWebXRInputOptions {
  125280. /**
  125281. * If set to true no model will be automatically loaded
  125282. */
  125283. doNotLoadControllerMeshes?: boolean;
  125284. /**
  125285. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  125286. * If not found, the xr input profile data will be used.
  125287. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  125288. */
  125289. forceInputProfile?: string;
  125290. /**
  125291. * Do not send a request to the controller repository to load the profile.
  125292. *
  125293. * Instead, use the controllers available in babylon itself.
  125294. */
  125295. disableOnlineControllerRepository?: boolean;
  125296. /**
  125297. * A custom URL for the controllers repository
  125298. */
  125299. customControllersRepositoryURL?: string;
  125300. /**
  125301. * Should the controller model's components not move according to the user input
  125302. */
  125303. disableControllerAnimation?: boolean;
  125304. /**
  125305. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  125306. */
  125307. controllerOptions?: IWebXRControllerOptions;
  125308. }
  125309. /**
  125310. * XR input used to track XR inputs such as controllers/rays
  125311. */
  125312. export class WebXRInput implements IDisposable {
  125313. /**
  125314. * the xr session manager for this session
  125315. */
  125316. xrSessionManager: WebXRSessionManager;
  125317. /**
  125318. * the WebXR camera for this session. Mainly used for teleportation
  125319. */
  125320. xrCamera: WebXRCamera;
  125321. private readonly options;
  125322. /**
  125323. * XR controllers being tracked
  125324. */
  125325. controllers: Array<WebXRInputSource>;
  125326. private _frameObserver;
  125327. private _sessionEndedObserver;
  125328. private _sessionInitObserver;
  125329. /**
  125330. * Event when a controller has been connected/added
  125331. */
  125332. onControllerAddedObservable: Observable<WebXRInputSource>;
  125333. /**
  125334. * Event when a controller has been removed/disconnected
  125335. */
  125336. onControllerRemovedObservable: Observable<WebXRInputSource>;
  125337. /**
  125338. * Initializes the WebXRInput
  125339. * @param xrSessionManager the xr session manager for this session
  125340. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  125341. * @param options = initialization options for this xr input
  125342. */
  125343. constructor(
  125344. /**
  125345. * the xr session manager for this session
  125346. */
  125347. xrSessionManager: WebXRSessionManager,
  125348. /**
  125349. * the WebXR camera for this session. Mainly used for teleportation
  125350. */
  125351. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  125352. private _onInputSourcesChange;
  125353. private _addAndRemoveControllers;
  125354. /**
  125355. * Disposes of the object
  125356. */
  125357. dispose(): void;
  125358. }
  125359. }
  125360. declare module BABYLON {
  125361. /**
  125362. * This is the base class for all WebXR features.
  125363. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  125364. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  125365. */
  125366. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  125367. protected _xrSessionManager: WebXRSessionManager;
  125368. private _attached;
  125369. private _removeOnDetach;
  125370. /**
  125371. * Should auto-attach be disabled?
  125372. */
  125373. disableAutoAttach: boolean;
  125374. /**
  125375. * Construct a new (abstract) WebXR feature
  125376. * @param _xrSessionManager the xr session manager for this feature
  125377. */
  125378. constructor(_xrSessionManager: WebXRSessionManager);
  125379. /**
  125380. * Is this feature attached
  125381. */
  125382. get attached(): boolean;
  125383. /**
  125384. * attach this feature
  125385. *
  125386. * @param force should attachment be forced (even when already attached)
  125387. * @returns true if successful, false is failed or already attached
  125388. */
  125389. attach(force?: boolean): boolean;
  125390. /**
  125391. * detach this feature.
  125392. *
  125393. * @returns true if successful, false if failed or already detached
  125394. */
  125395. detach(): boolean;
  125396. /**
  125397. * Dispose this feature and all of the resources attached
  125398. */
  125399. dispose(): void;
  125400. /**
  125401. * This is used to register callbacks that will automatically be removed when detach is called.
  125402. * @param observable the observable to which the observer will be attached
  125403. * @param callback the callback to register
  125404. */
  125405. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  125406. /**
  125407. * Code in this function will be executed on each xrFrame received from the browser.
  125408. * This function will not execute after the feature is detached.
  125409. * @param _xrFrame the current frame
  125410. */
  125411. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  125412. }
  125413. }
  125414. declare module BABYLON {
  125415. /**
  125416. * Renders a layer on top of an existing scene
  125417. */
  125418. export class UtilityLayerRenderer implements IDisposable {
  125419. /** the original scene that will be rendered on top of */
  125420. originalScene: Scene;
  125421. private _pointerCaptures;
  125422. private _lastPointerEvents;
  125423. private static _DefaultUtilityLayer;
  125424. private static _DefaultKeepDepthUtilityLayer;
  125425. private _sharedGizmoLight;
  125426. private _renderCamera;
  125427. /**
  125428. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  125429. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  125430. * @returns the camera that is used when rendering the utility layer
  125431. */
  125432. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  125433. /**
  125434. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  125435. * @param cam the camera that should be used when rendering the utility layer
  125436. */
  125437. setRenderCamera(cam: Nullable<Camera>): void;
  125438. /**
  125439. * @hidden
  125440. * Light which used by gizmos to get light shading
  125441. */
  125442. _getSharedGizmoLight(): HemisphericLight;
  125443. /**
  125444. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  125445. */
  125446. pickUtilitySceneFirst: boolean;
  125447. /**
  125448. * 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)
  125449. */
  125450. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  125451. /**
  125452. * 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)
  125453. */
  125454. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  125455. /**
  125456. * The scene that is rendered on top of the original scene
  125457. */
  125458. utilityLayerScene: Scene;
  125459. /**
  125460. * If the utility layer should automatically be rendered on top of existing scene
  125461. */
  125462. shouldRender: boolean;
  125463. /**
  125464. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  125465. */
  125466. onlyCheckPointerDownEvents: boolean;
  125467. /**
  125468. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  125469. */
  125470. processAllEvents: boolean;
  125471. /**
  125472. * Observable raised when the pointer move from the utility layer scene to the main scene
  125473. */
  125474. onPointerOutObservable: Observable<number>;
  125475. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  125476. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  125477. private _afterRenderObserver;
  125478. private _sceneDisposeObserver;
  125479. private _originalPointerObserver;
  125480. /**
  125481. * Instantiates a UtilityLayerRenderer
  125482. * @param originalScene the original scene that will be rendered on top of
  125483. * @param handleEvents boolean indicating if the utility layer should handle events
  125484. */
  125485. constructor(
  125486. /** the original scene that will be rendered on top of */
  125487. originalScene: Scene, handleEvents?: boolean);
  125488. private _notifyObservers;
  125489. /**
  125490. * Renders the utility layers scene on top of the original scene
  125491. */
  125492. render(): void;
  125493. /**
  125494. * Disposes of the renderer
  125495. */
  125496. dispose(): void;
  125497. private _updateCamera;
  125498. }
  125499. }
  125500. declare module BABYLON {
  125501. /**
  125502. * Options interface for the pointer selection module
  125503. */
  125504. export interface IWebXRControllerPointerSelectionOptions {
  125505. /**
  125506. * if provided, this scene will be used to render meshes.
  125507. */
  125508. customUtilityLayerScene?: Scene;
  125509. /**
  125510. * 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)
  125511. * If not disabled, the last picked point will be used to execute a pointer up event
  125512. * If disabled, pointer up event will be triggered right after the pointer down event.
  125513. * Used in screen and gaze target ray mode only
  125514. */
  125515. disablePointerUpOnTouchOut: boolean;
  125516. /**
  125517. * For gaze mode (time to select instead of press)
  125518. */
  125519. forceGazeMode: boolean;
  125520. /**
  125521. * 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
  125522. * to start a new countdown to the pointer down event.
  125523. * Defaults to 1.
  125524. */
  125525. gazeModePointerMovedFactor?: number;
  125526. /**
  125527. * Different button type to use instead of the main component
  125528. */
  125529. overrideButtonId?: string;
  125530. /**
  125531. * use this rendering group id for the meshes (optional)
  125532. */
  125533. renderingGroupId?: number;
  125534. /**
  125535. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  125536. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  125537. * 3000 means 3 seconds between pointing at something and selecting it
  125538. */
  125539. timeToSelect?: number;
  125540. /**
  125541. * Should meshes created here be added to a utility layer or the main scene
  125542. */
  125543. useUtilityLayer?: boolean;
  125544. /**
  125545. * the xr input to use with this pointer selection
  125546. */
  125547. xrInput: WebXRInput;
  125548. }
  125549. /**
  125550. * A module that will enable pointer selection for motion controllers of XR Input Sources
  125551. */
  125552. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  125553. private readonly _options;
  125554. private static _idCounter;
  125555. private _attachController;
  125556. private _controllers;
  125557. private _scene;
  125558. private _tmpVectorForPickCompare;
  125559. /**
  125560. * The module's name
  125561. */
  125562. static readonly Name: string;
  125563. /**
  125564. * The (Babylon) version of this module.
  125565. * This is an integer representing the implementation version.
  125566. * This number does not correspond to the WebXR specs version
  125567. */
  125568. static readonly Version: number;
  125569. /**
  125570. * Disable lighting on the laser pointer (so it will always be visible)
  125571. */
  125572. disablePointerLighting: boolean;
  125573. /**
  125574. * Disable lighting on the selection mesh (so it will always be visible)
  125575. */
  125576. disableSelectionMeshLighting: boolean;
  125577. /**
  125578. * Should the laser pointer be displayed
  125579. */
  125580. displayLaserPointer: boolean;
  125581. /**
  125582. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  125583. */
  125584. displaySelectionMesh: boolean;
  125585. /**
  125586. * This color will be set to the laser pointer when selection is triggered
  125587. */
  125588. laserPointerPickedColor: Color3;
  125589. /**
  125590. * Default color of the laser pointer
  125591. */
  125592. laserPointerDefaultColor: Color3;
  125593. /**
  125594. * default color of the selection ring
  125595. */
  125596. selectionMeshDefaultColor: Color3;
  125597. /**
  125598. * This color will be applied to the selection ring when selection is triggered
  125599. */
  125600. selectionMeshPickedColor: Color3;
  125601. /**
  125602. * Optional filter to be used for ray selection. This predicate shares behavior with
  125603. * scene.pointerMovePredicate which takes priority if it is also assigned.
  125604. */
  125605. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  125606. /**
  125607. * constructs a new background remover module
  125608. * @param _xrSessionManager the session manager for this module
  125609. * @param _options read-only options to be used in this module
  125610. */
  125611. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  125612. /**
  125613. * attach this feature
  125614. * Will usually be called by the features manager
  125615. *
  125616. * @returns true if successful.
  125617. */
  125618. attach(): boolean;
  125619. /**
  125620. * detach this feature.
  125621. * Will usually be called by the features manager
  125622. *
  125623. * @returns true if successful.
  125624. */
  125625. detach(): boolean;
  125626. /**
  125627. * Will get the mesh under a specific pointer.
  125628. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  125629. * @param controllerId the controllerId to check
  125630. * @returns The mesh under pointer or null if no mesh is under the pointer
  125631. */
  125632. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  125633. /**
  125634. * Get the xr controller that correlates to the pointer id in the pointer event
  125635. *
  125636. * @param id the pointer id to search for
  125637. * @returns the controller that correlates to this id or null if not found
  125638. */
  125639. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  125640. protected _onXRFrame(_xrFrame: XRFrame): void;
  125641. private _attachGazeMode;
  125642. private _attachScreenRayMode;
  125643. private _attachTrackedPointerRayMode;
  125644. private _convertNormalToDirectionOfRay;
  125645. private _detachController;
  125646. private _generateNewMeshPair;
  125647. private _pickingMoved;
  125648. private _updatePointerDistance;
  125649. /** @hidden */
  125650. get lasterPointerDefaultColor(): Color3;
  125651. }
  125652. }
  125653. declare module BABYLON {
  125654. /**
  125655. * Button which can be used to enter a different mode of XR
  125656. */
  125657. export class WebXREnterExitUIButton {
  125658. /** button element */
  125659. element: HTMLElement;
  125660. /** XR initialization options for the button */
  125661. sessionMode: XRSessionMode;
  125662. /** Reference space type */
  125663. referenceSpaceType: XRReferenceSpaceType;
  125664. /**
  125665. * Creates a WebXREnterExitUIButton
  125666. * @param element button element
  125667. * @param sessionMode XR initialization session mode
  125668. * @param referenceSpaceType the type of reference space to be used
  125669. */
  125670. constructor(
  125671. /** button element */
  125672. element: HTMLElement,
  125673. /** XR initialization options for the button */
  125674. sessionMode: XRSessionMode,
  125675. /** Reference space type */
  125676. referenceSpaceType: XRReferenceSpaceType);
  125677. /**
  125678. * Extendable function which can be used to update the button's visuals when the state changes
  125679. * @param activeButton the current active button in the UI
  125680. */
  125681. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  125682. }
  125683. /**
  125684. * Options to create the webXR UI
  125685. */
  125686. export class WebXREnterExitUIOptions {
  125687. /**
  125688. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  125689. */
  125690. customButtons?: Array<WebXREnterExitUIButton>;
  125691. /**
  125692. * A reference space type to use when creating the default button.
  125693. * Default is local-floor
  125694. */
  125695. referenceSpaceType?: XRReferenceSpaceType;
  125696. /**
  125697. * Context to enter xr with
  125698. */
  125699. renderTarget?: Nullable<WebXRRenderTarget>;
  125700. /**
  125701. * A session mode to use when creating the default button.
  125702. * Default is immersive-vr
  125703. */
  125704. sessionMode?: XRSessionMode;
  125705. /**
  125706. * A list of optional features to init the session with
  125707. */
  125708. optionalFeatures?: string[];
  125709. }
  125710. /**
  125711. * UI to allow the user to enter/exit XR mode
  125712. */
  125713. export class WebXREnterExitUI implements IDisposable {
  125714. private scene;
  125715. /** version of the options passed to this UI */
  125716. options: WebXREnterExitUIOptions;
  125717. private _activeButton;
  125718. private _buttons;
  125719. private _overlay;
  125720. /**
  125721. * Fired every time the active button is changed.
  125722. *
  125723. * When xr is entered via a button that launches xr that button will be the callback parameter
  125724. *
  125725. * When exiting xr the callback parameter will be null)
  125726. */
  125727. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  125728. /**
  125729. *
  125730. * @param scene babylon scene object to use
  125731. * @param options (read-only) version of the options passed to this UI
  125732. */
  125733. private constructor();
  125734. /**
  125735. * Creates UI to allow the user to enter/exit XR mode
  125736. * @param scene the scene to add the ui to
  125737. * @param helper the xr experience helper to enter/exit xr with
  125738. * @param options options to configure the UI
  125739. * @returns the created ui
  125740. */
  125741. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  125742. /**
  125743. * Disposes of the XR UI component
  125744. */
  125745. dispose(): void;
  125746. private _updateButtons;
  125747. }
  125748. }
  125749. declare module BABYLON {
  125750. /**
  125751. * Class containing static functions to help procedurally build meshes
  125752. */
  125753. export class LinesBuilder {
  125754. /**
  125755. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  125756. * * 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
  125757. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  125758. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  125759. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  125760. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  125761. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125762. * * 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
  125763. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  125764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125765. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  125766. * @param name defines the name of the new line system
  125767. * @param options defines the options used to create the line system
  125768. * @param scene defines the hosting scene
  125769. * @returns a new line system mesh
  125770. */
  125771. static CreateLineSystem(name: string, options: {
  125772. lines: Vector3[][];
  125773. updatable?: boolean;
  125774. instance?: Nullable<LinesMesh>;
  125775. colors?: Nullable<Color4[][]>;
  125776. useVertexAlpha?: boolean;
  125777. }, scene: Nullable<Scene>): LinesMesh;
  125778. /**
  125779. * Creates a line mesh
  125780. * 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
  125781. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125782. * * The parameter `points` is an array successive Vector3
  125783. * * 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
  125784. * * The optional parameter `colors` is an array of successive Color4, one per line point
  125785. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  125786. * * When updating an instance, remember that only point positions can change, not the number of points
  125787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125788. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  125789. * @param name defines the name of the new line system
  125790. * @param options defines the options used to create the line system
  125791. * @param scene defines the hosting scene
  125792. * @returns a new line mesh
  125793. */
  125794. static CreateLines(name: string, options: {
  125795. points: Vector3[];
  125796. updatable?: boolean;
  125797. instance?: Nullable<LinesMesh>;
  125798. colors?: Color4[];
  125799. useVertexAlpha?: boolean;
  125800. }, scene?: Nullable<Scene>): LinesMesh;
  125801. /**
  125802. * Creates a dashed line mesh
  125803. * * 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
  125804. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125805. * * The parameter `points` is an array successive Vector3
  125806. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  125807. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  125808. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  125809. * * 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
  125810. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125811. * * When updating an instance, remember that only point positions can change, not the number of points
  125812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125813. * @param name defines the name of the mesh
  125814. * @param options defines the options used to create the mesh
  125815. * @param scene defines the hosting scene
  125816. * @returns the dashed line mesh
  125817. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  125818. */
  125819. static CreateDashedLines(name: string, options: {
  125820. points: Vector3[];
  125821. dashSize?: number;
  125822. gapSize?: number;
  125823. dashNb?: number;
  125824. updatable?: boolean;
  125825. instance?: LinesMesh;
  125826. useVertexAlpha?: boolean;
  125827. }, scene?: Nullable<Scene>): LinesMesh;
  125828. }
  125829. }
  125830. declare module BABYLON {
  125831. /**
  125832. * Construction options for a timer
  125833. */
  125834. export interface ITimerOptions<T> {
  125835. /**
  125836. * Time-to-end
  125837. */
  125838. timeout: number;
  125839. /**
  125840. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  125841. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  125842. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  125843. */
  125844. contextObservable: Observable<T>;
  125845. /**
  125846. * Optional parameters when adding an observer to the observable
  125847. */
  125848. observableParameters?: {
  125849. mask?: number;
  125850. insertFirst?: boolean;
  125851. scope?: any;
  125852. };
  125853. /**
  125854. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  125855. */
  125856. breakCondition?: (data?: ITimerData<T>) => boolean;
  125857. /**
  125858. * Will be triggered when the time condition has met
  125859. */
  125860. onEnded?: (data: ITimerData<any>) => void;
  125861. /**
  125862. * Will be triggered when the break condition has met (prematurely ended)
  125863. */
  125864. onAborted?: (data: ITimerData<any>) => void;
  125865. /**
  125866. * Optional function to execute on each tick (or count)
  125867. */
  125868. onTick?: (data: ITimerData<any>) => void;
  125869. }
  125870. /**
  125871. * An interface defining the data sent by the timer
  125872. */
  125873. export interface ITimerData<T> {
  125874. /**
  125875. * When did it start
  125876. */
  125877. startTime: number;
  125878. /**
  125879. * Time now
  125880. */
  125881. currentTime: number;
  125882. /**
  125883. * Time passed since started
  125884. */
  125885. deltaTime: number;
  125886. /**
  125887. * How much is completed, in [0.0...1.0].
  125888. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  125889. */
  125890. completeRate: number;
  125891. /**
  125892. * What the registered observable sent in the last count
  125893. */
  125894. payload: T;
  125895. }
  125896. /**
  125897. * The current state of the timer
  125898. */
  125899. export enum TimerState {
  125900. /**
  125901. * Timer initialized, not yet started
  125902. */
  125903. INIT = 0,
  125904. /**
  125905. * Timer started and counting
  125906. */
  125907. STARTED = 1,
  125908. /**
  125909. * Timer ended (whether aborted or time reached)
  125910. */
  125911. ENDED = 2
  125912. }
  125913. /**
  125914. * A simple version of the timer. Will take options and start the timer immediately after calling it
  125915. *
  125916. * @param options options with which to initialize this timer
  125917. */
  125918. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  125919. /**
  125920. * An advanced implementation of a timer class
  125921. */
  125922. export class AdvancedTimer<T = any> implements IDisposable {
  125923. /**
  125924. * Will notify each time the timer calculates the remaining time
  125925. */
  125926. onEachCountObservable: Observable<ITimerData<T>>;
  125927. /**
  125928. * Will trigger when the timer was aborted due to the break condition
  125929. */
  125930. onTimerAbortedObservable: Observable<ITimerData<T>>;
  125931. /**
  125932. * Will trigger when the timer ended successfully
  125933. */
  125934. onTimerEndedObservable: Observable<ITimerData<T>>;
  125935. /**
  125936. * Will trigger when the timer state has changed
  125937. */
  125938. onStateChangedObservable: Observable<TimerState>;
  125939. private _observer;
  125940. private _contextObservable;
  125941. private _observableParameters;
  125942. private _startTime;
  125943. private _timer;
  125944. private _state;
  125945. private _breakCondition;
  125946. private _timeToEnd;
  125947. private _breakOnNextTick;
  125948. /**
  125949. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  125950. * @param options construction options for this advanced timer
  125951. */
  125952. constructor(options: ITimerOptions<T>);
  125953. /**
  125954. * set a breaking condition for this timer. Default is to never break during count
  125955. * @param predicate the new break condition. Returns true to break, false otherwise
  125956. */
  125957. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  125958. /**
  125959. * Reset ALL associated observables in this advanced timer
  125960. */
  125961. clearObservables(): void;
  125962. /**
  125963. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  125964. *
  125965. * @param timeToEnd how much time to measure until timer ended
  125966. */
  125967. start(timeToEnd?: number): void;
  125968. /**
  125969. * Will force a stop on the next tick.
  125970. */
  125971. stop(): void;
  125972. /**
  125973. * Dispose this timer, clearing all resources
  125974. */
  125975. dispose(): void;
  125976. private _setState;
  125977. private _tick;
  125978. private _stop;
  125979. }
  125980. }
  125981. declare module BABYLON {
  125982. /**
  125983. * The options container for the teleportation module
  125984. */
  125985. export interface IWebXRTeleportationOptions {
  125986. /**
  125987. * if provided, this scene will be used to render meshes.
  125988. */
  125989. customUtilityLayerScene?: Scene;
  125990. /**
  125991. * Values to configure the default target mesh
  125992. */
  125993. defaultTargetMeshOptions?: {
  125994. /**
  125995. * Fill color of the teleportation area
  125996. */
  125997. teleportationFillColor?: string;
  125998. /**
  125999. * Border color for the teleportation area
  126000. */
  126001. teleportationBorderColor?: string;
  126002. /**
  126003. * Disable the mesh's animation sequence
  126004. */
  126005. disableAnimation?: boolean;
  126006. /**
  126007. * Disable lighting on the material or the ring and arrow
  126008. */
  126009. disableLighting?: boolean;
  126010. /**
  126011. * Override the default material of the torus and arrow
  126012. */
  126013. torusArrowMaterial?: Material;
  126014. };
  126015. /**
  126016. * A list of meshes to use as floor meshes.
  126017. * Meshes can be added and removed after initializing the feature using the
  126018. * addFloorMesh and removeFloorMesh functions
  126019. * If empty, rotation will still work
  126020. */
  126021. floorMeshes?: AbstractMesh[];
  126022. /**
  126023. * use this rendering group id for the meshes (optional)
  126024. */
  126025. renderingGroupId?: number;
  126026. /**
  126027. * Should teleportation move only to snap points
  126028. */
  126029. snapPointsOnly?: boolean;
  126030. /**
  126031. * An array of points to which the teleportation will snap to.
  126032. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  126033. */
  126034. snapPositions?: Vector3[];
  126035. /**
  126036. * How close should the teleportation ray be in order to snap to position.
  126037. * Default to 0.8 units (meters)
  126038. */
  126039. snapToPositionRadius?: number;
  126040. /**
  126041. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  126042. * If you want to support rotation, make sure your mesh has a direction indicator.
  126043. *
  126044. * When left untouched, the default mesh will be initialized.
  126045. */
  126046. teleportationTargetMesh?: AbstractMesh;
  126047. /**
  126048. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  126049. */
  126050. timeToTeleport?: number;
  126051. /**
  126052. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  126053. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  126054. */
  126055. useMainComponentOnly?: boolean;
  126056. /**
  126057. * Should meshes created here be added to a utility layer or the main scene
  126058. */
  126059. useUtilityLayer?: boolean;
  126060. /**
  126061. * Babylon XR Input class for controller
  126062. */
  126063. xrInput: WebXRInput;
  126064. }
  126065. /**
  126066. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  126067. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  126068. * the input of the attached controllers.
  126069. */
  126070. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  126071. private _options;
  126072. private _controllers;
  126073. private _currentTeleportationControllerId;
  126074. private _floorMeshes;
  126075. private _quadraticBezierCurve;
  126076. private _selectionFeature;
  126077. private _snapToPositions;
  126078. private _snappedToPoint;
  126079. private _teleportationRingMaterial?;
  126080. private _tmpRay;
  126081. private _tmpVector;
  126082. /**
  126083. * The module's name
  126084. */
  126085. static readonly Name: string;
  126086. /**
  126087. * The (Babylon) version of this module.
  126088. * This is an integer representing the implementation version.
  126089. * This number does not correspond to the webxr specs version
  126090. */
  126091. static readonly Version: number;
  126092. /**
  126093. * Is movement backwards enabled
  126094. */
  126095. backwardsMovementEnabled: boolean;
  126096. /**
  126097. * Distance to travel when moving backwards
  126098. */
  126099. backwardsTeleportationDistance: number;
  126100. /**
  126101. * The distance from the user to the inspection point in the direction of the controller
  126102. * A higher number will allow the user to move further
  126103. * defaults to 5 (meters, in xr units)
  126104. */
  126105. parabolicCheckRadius: number;
  126106. /**
  126107. * Should the module support parabolic ray on top of direct ray
  126108. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  126109. * Very helpful when moving between floors / different heights
  126110. */
  126111. parabolicRayEnabled: boolean;
  126112. /**
  126113. * How much rotation should be applied when rotating right and left
  126114. */
  126115. rotationAngle: number;
  126116. /**
  126117. * Is rotation enabled when moving forward?
  126118. * Disabling this feature will prevent the user from deciding the direction when teleporting
  126119. */
  126120. rotationEnabled: boolean;
  126121. /**
  126122. * constructs a new anchor system
  126123. * @param _xrSessionManager an instance of WebXRSessionManager
  126124. * @param _options configuration object for this feature
  126125. */
  126126. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  126127. /**
  126128. * Get the snapPointsOnly flag
  126129. */
  126130. get snapPointsOnly(): boolean;
  126131. /**
  126132. * Sets the snapPointsOnly flag
  126133. * @param snapToPoints should teleportation be exclusively to snap points
  126134. */
  126135. set snapPointsOnly(snapToPoints: boolean);
  126136. /**
  126137. * Add a new mesh to the floor meshes array
  126138. * @param mesh the mesh to use as floor mesh
  126139. */
  126140. addFloorMesh(mesh: AbstractMesh): void;
  126141. /**
  126142. * Add a new snap-to point to fix teleportation to this position
  126143. * @param newSnapPoint The new Snap-To point
  126144. */
  126145. addSnapPoint(newSnapPoint: Vector3): void;
  126146. attach(): boolean;
  126147. detach(): boolean;
  126148. dispose(): void;
  126149. /**
  126150. * Remove a mesh from the floor meshes array
  126151. * @param mesh the mesh to remove
  126152. */
  126153. removeFloorMesh(mesh: AbstractMesh): void;
  126154. /**
  126155. * Remove a mesh from the floor meshes array using its name
  126156. * @param name the mesh name to remove
  126157. */
  126158. removeFloorMeshByName(name: string): void;
  126159. /**
  126160. * 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
  126161. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  126162. * @returns was the point found and removed or not
  126163. */
  126164. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  126165. /**
  126166. * This function sets a selection feature that will be disabled when
  126167. * the forward ray is shown and will be reattached when hidden.
  126168. * This is used to remove the selection rays when moving.
  126169. * @param selectionFeature the feature to disable when forward movement is enabled
  126170. */
  126171. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  126172. protected _onXRFrame(_xrFrame: XRFrame): void;
  126173. private _attachController;
  126174. private _createDefaultTargetMesh;
  126175. private _detachController;
  126176. private _findClosestSnapPointWithRadius;
  126177. private _setTargetMeshPosition;
  126178. private _setTargetMeshVisibility;
  126179. private _showParabolicPath;
  126180. private _teleportForward;
  126181. }
  126182. }
  126183. declare module BABYLON {
  126184. /**
  126185. * Options for the default xr helper
  126186. */
  126187. export class WebXRDefaultExperienceOptions {
  126188. /**
  126189. * Enable or disable default UI to enter XR
  126190. */
  126191. disableDefaultUI?: boolean;
  126192. /**
  126193. * Should teleportation not initialize. defaults to false.
  126194. */
  126195. disableTeleportation?: boolean;
  126196. /**
  126197. * Floor meshes that will be used for teleport
  126198. */
  126199. floorMeshes?: Array<AbstractMesh>;
  126200. /**
  126201. * If set to true, the first frame will not be used to reset position
  126202. * The first frame is mainly used when copying transformation from the old camera
  126203. * Mainly used in AR
  126204. */
  126205. ignoreNativeCameraTransformation?: boolean;
  126206. /**
  126207. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  126208. */
  126209. inputOptions?: IWebXRInputOptions;
  126210. /**
  126211. * optional configuration for the output canvas
  126212. */
  126213. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  126214. /**
  126215. * optional UI options. This can be used among other to change session mode and reference space type
  126216. */
  126217. uiOptions?: WebXREnterExitUIOptions;
  126218. /**
  126219. * When loading teleportation and pointer select, use stable versions instead of latest.
  126220. */
  126221. useStablePlugins?: boolean;
  126222. /**
  126223. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  126224. */
  126225. renderingGroupId?: number;
  126226. /**
  126227. * A list of optional features to init the session with
  126228. * If set to true, all features we support will be added
  126229. */
  126230. optionalFeatures?: boolean | string[];
  126231. }
  126232. /**
  126233. * Default experience which provides a similar setup to the previous webVRExperience
  126234. */
  126235. export class WebXRDefaultExperience {
  126236. /**
  126237. * Base experience
  126238. */
  126239. baseExperience: WebXRExperienceHelper;
  126240. /**
  126241. * Enables ui for entering/exiting xr
  126242. */
  126243. enterExitUI: WebXREnterExitUI;
  126244. /**
  126245. * Input experience extension
  126246. */
  126247. input: WebXRInput;
  126248. /**
  126249. * Enables laser pointer and selection
  126250. */
  126251. pointerSelection: WebXRControllerPointerSelection;
  126252. /**
  126253. * Default target xr should render to
  126254. */
  126255. renderTarget: WebXRRenderTarget;
  126256. /**
  126257. * Enables teleportation
  126258. */
  126259. teleportation: WebXRMotionControllerTeleportation;
  126260. private constructor();
  126261. /**
  126262. * Creates the default xr experience
  126263. * @param scene scene
  126264. * @param options options for basic configuration
  126265. * @returns resulting WebXRDefaultExperience
  126266. */
  126267. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  126268. /**
  126269. * DIsposes of the experience helper
  126270. */
  126271. dispose(): void;
  126272. }
  126273. }
  126274. declare module BABYLON {
  126275. /**
  126276. * Options to modify the vr teleportation behavior.
  126277. */
  126278. export interface VRTeleportationOptions {
  126279. /**
  126280. * The name of the mesh which should be used as the teleportation floor. (default: null)
  126281. */
  126282. floorMeshName?: string;
  126283. /**
  126284. * A list of meshes to be used as the teleportation floor. (default: empty)
  126285. */
  126286. floorMeshes?: Mesh[];
  126287. /**
  126288. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  126289. */
  126290. teleportationMode?: number;
  126291. /**
  126292. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  126293. */
  126294. teleportationTime?: number;
  126295. /**
  126296. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  126297. */
  126298. teleportationSpeed?: number;
  126299. /**
  126300. * The easing function used in the animation or null for Linear. (default CircleEase)
  126301. */
  126302. easingFunction?: EasingFunction;
  126303. }
  126304. /**
  126305. * Options to modify the vr experience helper's behavior.
  126306. */
  126307. export interface VRExperienceHelperOptions extends WebVROptions {
  126308. /**
  126309. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  126310. */
  126311. createDeviceOrientationCamera?: boolean;
  126312. /**
  126313. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  126314. */
  126315. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  126316. /**
  126317. * Uses the main button on the controller to toggle the laser casted. (default: true)
  126318. */
  126319. laserToggle?: boolean;
  126320. /**
  126321. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  126322. */
  126323. floorMeshes?: Mesh[];
  126324. /**
  126325. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  126326. */
  126327. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  126328. /**
  126329. * Defines if WebXR should be used instead of WebVR (if available)
  126330. */
  126331. useXR?: boolean;
  126332. }
  126333. /**
  126334. * Event containing information after VR has been entered
  126335. */
  126336. export class OnAfterEnteringVRObservableEvent {
  126337. /**
  126338. * If entering vr was successful
  126339. */
  126340. success: boolean;
  126341. }
  126342. /**
  126343. * Helps to quickly add VR support to an existing scene.
  126344. * See http://doc.babylonjs.com/how_to/webvr_helper
  126345. */
  126346. export class VRExperienceHelper {
  126347. /** Options to modify the vr experience helper's behavior. */
  126348. webVROptions: VRExperienceHelperOptions;
  126349. private _scene;
  126350. private _position;
  126351. private _btnVR;
  126352. private _btnVRDisplayed;
  126353. private _webVRsupported;
  126354. private _webVRready;
  126355. private _webVRrequesting;
  126356. private _webVRpresenting;
  126357. private _hasEnteredVR;
  126358. private _fullscreenVRpresenting;
  126359. private _inputElement;
  126360. private _webVRCamera;
  126361. private _vrDeviceOrientationCamera;
  126362. private _deviceOrientationCamera;
  126363. private _existingCamera;
  126364. private _onKeyDown;
  126365. private _onVrDisplayPresentChange;
  126366. private _onVRDisplayChanged;
  126367. private _onVRRequestPresentStart;
  126368. private _onVRRequestPresentComplete;
  126369. /**
  126370. * 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)
  126371. */
  126372. enableGazeEvenWhenNoPointerLock: boolean;
  126373. /**
  126374. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  126375. */
  126376. exitVROnDoubleTap: boolean;
  126377. /**
  126378. * Observable raised right before entering VR.
  126379. */
  126380. onEnteringVRObservable: Observable<VRExperienceHelper>;
  126381. /**
  126382. * Observable raised when entering VR has completed.
  126383. */
  126384. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  126385. /**
  126386. * Observable raised when exiting VR.
  126387. */
  126388. onExitingVRObservable: Observable<VRExperienceHelper>;
  126389. /**
  126390. * Observable raised when controller mesh is loaded.
  126391. */
  126392. onControllerMeshLoadedObservable: Observable<WebVRController>;
  126393. /** Return this.onEnteringVRObservable
  126394. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  126395. */
  126396. get onEnteringVR(): Observable<VRExperienceHelper>;
  126397. /** Return this.onExitingVRObservable
  126398. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  126399. */
  126400. get onExitingVR(): Observable<VRExperienceHelper>;
  126401. /** Return this.onControllerMeshLoadedObservable
  126402. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  126403. */
  126404. get onControllerMeshLoaded(): Observable<WebVRController>;
  126405. private _rayLength;
  126406. private _useCustomVRButton;
  126407. private _teleportationRequested;
  126408. private _teleportActive;
  126409. private _floorMeshName;
  126410. private _floorMeshesCollection;
  126411. private _teleportationMode;
  126412. private _teleportationTime;
  126413. private _teleportationSpeed;
  126414. private _teleportationEasing;
  126415. private _rotationAllowed;
  126416. private _teleportBackwardsVector;
  126417. private _teleportationTarget;
  126418. private _isDefaultTeleportationTarget;
  126419. private _postProcessMove;
  126420. private _teleportationFillColor;
  126421. private _teleportationBorderColor;
  126422. private _rotationAngle;
  126423. private _haloCenter;
  126424. private _cameraGazer;
  126425. private _padSensibilityUp;
  126426. private _padSensibilityDown;
  126427. private _leftController;
  126428. private _rightController;
  126429. private _gazeColor;
  126430. private _laserColor;
  126431. private _pickedLaserColor;
  126432. private _pickedGazeColor;
  126433. /**
  126434. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  126435. */
  126436. onNewMeshSelected: Observable<AbstractMesh>;
  126437. /**
  126438. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  126439. * This observable will provide the mesh and the controller used to select the mesh
  126440. */
  126441. onMeshSelectedWithController: Observable<{
  126442. mesh: AbstractMesh;
  126443. controller: WebVRController;
  126444. }>;
  126445. /**
  126446. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  126447. */
  126448. onNewMeshPicked: Observable<PickingInfo>;
  126449. private _circleEase;
  126450. /**
  126451. * Observable raised before camera teleportation
  126452. */
  126453. onBeforeCameraTeleport: Observable<Vector3>;
  126454. /**
  126455. * Observable raised after camera teleportation
  126456. */
  126457. onAfterCameraTeleport: Observable<Vector3>;
  126458. /**
  126459. * Observable raised when current selected mesh gets unselected
  126460. */
  126461. onSelectedMeshUnselected: Observable<AbstractMesh>;
  126462. private _raySelectionPredicate;
  126463. /**
  126464. * To be optionaly changed by user to define custom ray selection
  126465. */
  126466. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  126467. /**
  126468. * To be optionaly changed by user to define custom selection logic (after ray selection)
  126469. */
  126470. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  126471. /**
  126472. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  126473. */
  126474. teleportationEnabled: boolean;
  126475. private _defaultHeight;
  126476. private _teleportationInitialized;
  126477. private _interactionsEnabled;
  126478. private _interactionsRequested;
  126479. private _displayGaze;
  126480. private _displayLaserPointer;
  126481. /**
  126482. * The mesh used to display where the user is going to teleport.
  126483. */
  126484. get teleportationTarget(): Mesh;
  126485. /**
  126486. * Sets the mesh to be used to display where the user is going to teleport.
  126487. */
  126488. set teleportationTarget(value: Mesh);
  126489. /**
  126490. * 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
  126491. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  126492. * See http://doc.babylonjs.com/resources/baking_transformations
  126493. */
  126494. get gazeTrackerMesh(): Mesh;
  126495. set gazeTrackerMesh(value: Mesh);
  126496. /**
  126497. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  126498. */
  126499. updateGazeTrackerScale: boolean;
  126500. /**
  126501. * If the gaze trackers color should be updated when selecting meshes
  126502. */
  126503. updateGazeTrackerColor: boolean;
  126504. /**
  126505. * If the controller laser color should be updated when selecting meshes
  126506. */
  126507. updateControllerLaserColor: boolean;
  126508. /**
  126509. * The gaze tracking mesh corresponding to the left controller
  126510. */
  126511. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  126512. /**
  126513. * The gaze tracking mesh corresponding to the right controller
  126514. */
  126515. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  126516. /**
  126517. * If the ray of the gaze should be displayed.
  126518. */
  126519. get displayGaze(): boolean;
  126520. /**
  126521. * Sets if the ray of the gaze should be displayed.
  126522. */
  126523. set displayGaze(value: boolean);
  126524. /**
  126525. * If the ray of the LaserPointer should be displayed.
  126526. */
  126527. get displayLaserPointer(): boolean;
  126528. /**
  126529. * Sets if the ray of the LaserPointer should be displayed.
  126530. */
  126531. set displayLaserPointer(value: boolean);
  126532. /**
  126533. * The deviceOrientationCamera used as the camera when not in VR.
  126534. */
  126535. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  126536. /**
  126537. * Based on the current WebVR support, returns the current VR camera used.
  126538. */
  126539. get currentVRCamera(): Nullable<Camera>;
  126540. /**
  126541. * The webVRCamera which is used when in VR.
  126542. */
  126543. get webVRCamera(): WebVRFreeCamera;
  126544. /**
  126545. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  126546. */
  126547. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  126548. /**
  126549. * The html button that is used to trigger entering into VR.
  126550. */
  126551. get vrButton(): Nullable<HTMLButtonElement>;
  126552. private get _teleportationRequestInitiated();
  126553. /**
  126554. * Defines whether or not Pointer lock should be requested when switching to
  126555. * full screen.
  126556. */
  126557. requestPointerLockOnFullScreen: boolean;
  126558. /**
  126559. * If asking to force XR, this will be populated with the default xr experience
  126560. */
  126561. xr: WebXRDefaultExperience;
  126562. /**
  126563. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  126564. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  126565. */
  126566. xrTestDone: boolean;
  126567. /**
  126568. * Instantiates a VRExperienceHelper.
  126569. * Helps to quickly add VR support to an existing scene.
  126570. * @param scene The scene the VRExperienceHelper belongs to.
  126571. * @param webVROptions Options to modify the vr experience helper's behavior.
  126572. */
  126573. constructor(scene: Scene,
  126574. /** Options to modify the vr experience helper's behavior. */
  126575. webVROptions?: VRExperienceHelperOptions);
  126576. private completeVRInit;
  126577. private _onDefaultMeshLoaded;
  126578. private _onResize;
  126579. private _onFullscreenChange;
  126580. /**
  126581. * Gets a value indicating if we are currently in VR mode.
  126582. */
  126583. get isInVRMode(): boolean;
  126584. private onVrDisplayPresentChange;
  126585. private onVRDisplayChanged;
  126586. private moveButtonToBottomRight;
  126587. private displayVRButton;
  126588. private updateButtonVisibility;
  126589. private _cachedAngularSensibility;
  126590. /**
  126591. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  126592. * Otherwise, will use the fullscreen API.
  126593. */
  126594. enterVR(): void;
  126595. /**
  126596. * Attempt to exit VR, or fullscreen.
  126597. */
  126598. exitVR(): void;
  126599. /**
  126600. * The position of the vr experience helper.
  126601. */
  126602. get position(): Vector3;
  126603. /**
  126604. * Sets the position of the vr experience helper.
  126605. */
  126606. set position(value: Vector3);
  126607. /**
  126608. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  126609. */
  126610. enableInteractions(): void;
  126611. private get _noControllerIsActive();
  126612. private beforeRender;
  126613. private _isTeleportationFloor;
  126614. /**
  126615. * Adds a floor mesh to be used for teleportation.
  126616. * @param floorMesh the mesh to be used for teleportation.
  126617. */
  126618. addFloorMesh(floorMesh: Mesh): void;
  126619. /**
  126620. * Removes a floor mesh from being used for teleportation.
  126621. * @param floorMesh the mesh to be removed.
  126622. */
  126623. removeFloorMesh(floorMesh: Mesh): void;
  126624. /**
  126625. * Enables interactions and teleportation using the VR controllers and gaze.
  126626. * @param vrTeleportationOptions options to modify teleportation behavior.
  126627. */
  126628. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  126629. private _onNewGamepadConnected;
  126630. private _tryEnableInteractionOnController;
  126631. private _onNewGamepadDisconnected;
  126632. private _enableInteractionOnController;
  126633. private _checkTeleportWithRay;
  126634. private _checkRotate;
  126635. private _checkTeleportBackwards;
  126636. private _enableTeleportationOnController;
  126637. private _createTeleportationCircles;
  126638. private _displayTeleportationTarget;
  126639. private _hideTeleportationTarget;
  126640. private _rotateCamera;
  126641. private _moveTeleportationSelectorTo;
  126642. private _workingVector;
  126643. private _workingQuaternion;
  126644. private _workingMatrix;
  126645. /**
  126646. * Time Constant Teleportation Mode
  126647. */
  126648. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  126649. /**
  126650. * Speed Constant Teleportation Mode
  126651. */
  126652. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  126653. /**
  126654. * Teleports the users feet to the desired location
  126655. * @param location The location where the user's feet should be placed
  126656. */
  126657. teleportCamera(location: Vector3): void;
  126658. private _convertNormalToDirectionOfRay;
  126659. private _castRayAndSelectObject;
  126660. private _notifySelectedMeshUnselected;
  126661. /**
  126662. * Permanently set new colors for the laser pointer
  126663. * @param color the new laser color
  126664. * @param pickedColor the new laser color when picked mesh detected
  126665. */
  126666. setLaserColor(color: Color3, pickedColor?: Color3): void;
  126667. /**
  126668. * Set lighting enabled / disabled on the laser pointer of both controllers
  126669. * @param enabled should the lighting be enabled on the laser pointer
  126670. */
  126671. setLaserLightingState(enabled?: boolean): void;
  126672. /**
  126673. * Permanently set new colors for the gaze pointer
  126674. * @param color the new gaze color
  126675. * @param pickedColor the new gaze color when picked mesh detected
  126676. */
  126677. setGazeColor(color: Color3, pickedColor?: Color3): void;
  126678. /**
  126679. * Sets the color of the laser ray from the vr controllers.
  126680. * @param color new color for the ray.
  126681. */
  126682. changeLaserColor(color: Color3): void;
  126683. /**
  126684. * Sets the color of the ray from the vr headsets gaze.
  126685. * @param color new color for the ray.
  126686. */
  126687. changeGazeColor(color: Color3): void;
  126688. /**
  126689. * Exits VR and disposes of the vr experience helper
  126690. */
  126691. dispose(): void;
  126692. /**
  126693. * Gets the name of the VRExperienceHelper class
  126694. * @returns "VRExperienceHelper"
  126695. */
  126696. getClassName(): string;
  126697. }
  126698. }
  126699. declare module BABYLON {
  126700. /**
  126701. * Contains an array of blocks representing the octree
  126702. */
  126703. export interface IOctreeContainer<T> {
  126704. /**
  126705. * Blocks within the octree
  126706. */
  126707. blocks: Array<OctreeBlock<T>>;
  126708. }
  126709. /**
  126710. * Class used to store a cell in an octree
  126711. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126712. */
  126713. export class OctreeBlock<T> {
  126714. /**
  126715. * Gets the content of the current block
  126716. */
  126717. entries: T[];
  126718. /**
  126719. * Gets the list of block children
  126720. */
  126721. blocks: Array<OctreeBlock<T>>;
  126722. private _depth;
  126723. private _maxDepth;
  126724. private _capacity;
  126725. private _minPoint;
  126726. private _maxPoint;
  126727. private _boundingVectors;
  126728. private _creationFunc;
  126729. /**
  126730. * Creates a new block
  126731. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  126732. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  126733. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  126734. * @param depth defines the current depth of this block in the octree
  126735. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  126736. * @param creationFunc defines a callback to call when an element is added to the block
  126737. */
  126738. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  126739. /**
  126740. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  126741. */
  126742. get capacity(): number;
  126743. /**
  126744. * Gets the minimum vector (in world space) of the block's bounding box
  126745. */
  126746. get minPoint(): Vector3;
  126747. /**
  126748. * Gets the maximum vector (in world space) of the block's bounding box
  126749. */
  126750. get maxPoint(): Vector3;
  126751. /**
  126752. * Add a new element to this block
  126753. * @param entry defines the element to add
  126754. */
  126755. addEntry(entry: T): void;
  126756. /**
  126757. * Remove an element from this block
  126758. * @param entry defines the element to remove
  126759. */
  126760. removeEntry(entry: T): void;
  126761. /**
  126762. * Add an array of elements to this block
  126763. * @param entries defines the array of elements to add
  126764. */
  126765. addEntries(entries: T[]): void;
  126766. /**
  126767. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  126768. * @param frustumPlanes defines the frustum planes to test
  126769. * @param selection defines the array to store current content if selection is positive
  126770. * @param allowDuplicate defines if the selection array can contains duplicated entries
  126771. */
  126772. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  126773. /**
  126774. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  126775. * @param sphereCenter defines the bounding sphere center
  126776. * @param sphereRadius defines the bounding sphere radius
  126777. * @param selection defines the array to store current content if selection is positive
  126778. * @param allowDuplicate defines if the selection array can contains duplicated entries
  126779. */
  126780. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  126781. /**
  126782. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  126783. * @param ray defines the ray to test with
  126784. * @param selection defines the array to store current content if selection is positive
  126785. */
  126786. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  126787. /**
  126788. * Subdivide the content into child blocks (this block will then be empty)
  126789. */
  126790. createInnerBlocks(): void;
  126791. /**
  126792. * @hidden
  126793. */
  126794. 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;
  126795. }
  126796. }
  126797. declare module BABYLON {
  126798. /**
  126799. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  126800. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126801. */
  126802. export class Octree<T> {
  126803. /** 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.) */
  126804. maxDepth: number;
  126805. /**
  126806. * Blocks within the octree containing objects
  126807. */
  126808. blocks: Array<OctreeBlock<T>>;
  126809. /**
  126810. * Content stored in the octree
  126811. */
  126812. dynamicContent: T[];
  126813. private _maxBlockCapacity;
  126814. private _selectionContent;
  126815. private _creationFunc;
  126816. /**
  126817. * Creates a octree
  126818. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126819. * @param creationFunc function to be used to instatiate the octree
  126820. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  126821. * @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.)
  126822. */
  126823. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  126824. /** 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.) */
  126825. maxDepth?: number);
  126826. /**
  126827. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  126828. * @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);
  126829. * @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);
  126830. * @param entries meshes to be added to the octree blocks
  126831. */
  126832. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  126833. /**
  126834. * Adds a mesh to the octree
  126835. * @param entry Mesh to add to the octree
  126836. */
  126837. addMesh(entry: T): void;
  126838. /**
  126839. * Remove an element from the octree
  126840. * @param entry defines the element to remove
  126841. */
  126842. removeMesh(entry: T): void;
  126843. /**
  126844. * Selects an array of meshes within the frustum
  126845. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  126846. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  126847. * @returns array of meshes within the frustum
  126848. */
  126849. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  126850. /**
  126851. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  126852. * @param sphereCenter defines the bounding sphere center
  126853. * @param sphereRadius defines the bounding sphere radius
  126854. * @param allowDuplicate defines if the selection array can contains duplicated entries
  126855. * @returns an array of objects that intersect the sphere
  126856. */
  126857. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  126858. /**
  126859. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  126860. * @param ray defines the ray to test with
  126861. * @returns array of intersected objects
  126862. */
  126863. intersectsRay(ray: Ray): SmartArray<T>;
  126864. /**
  126865. * Adds a mesh into the octree block if it intersects the block
  126866. */
  126867. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  126868. /**
  126869. * Adds a submesh into the octree block if it intersects the block
  126870. */
  126871. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  126872. }
  126873. }
  126874. declare module BABYLON {
  126875. interface Scene {
  126876. /**
  126877. * @hidden
  126878. * Backing Filed
  126879. */
  126880. _selectionOctree: Octree<AbstractMesh>;
  126881. /**
  126882. * Gets the octree used to boost mesh selection (picking)
  126883. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126884. */
  126885. selectionOctree: Octree<AbstractMesh>;
  126886. /**
  126887. * Creates or updates the octree used to boost selection (picking)
  126888. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126889. * @param maxCapacity defines the maximum capacity per leaf
  126890. * @param maxDepth defines the maximum depth of the octree
  126891. * @returns an octree of AbstractMesh
  126892. */
  126893. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  126894. }
  126895. interface AbstractMesh {
  126896. /**
  126897. * @hidden
  126898. * Backing Field
  126899. */
  126900. _submeshesOctree: Octree<SubMesh>;
  126901. /**
  126902. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  126903. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  126904. * @param maxCapacity defines the maximum size of each block (64 by default)
  126905. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  126906. * @returns the new octree
  126907. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  126908. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126909. */
  126910. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  126911. }
  126912. /**
  126913. * Defines the octree scene component responsible to manage any octrees
  126914. * in a given scene.
  126915. */
  126916. export class OctreeSceneComponent {
  126917. /**
  126918. * The component name help to identify the component in the list of scene components.
  126919. */
  126920. readonly name: string;
  126921. /**
  126922. * The scene the component belongs to.
  126923. */
  126924. scene: Scene;
  126925. /**
  126926. * Indicates if the meshes have been checked to make sure they are isEnabled()
  126927. */
  126928. readonly checksIsEnabled: boolean;
  126929. /**
  126930. * Creates a new instance of the component for the given scene
  126931. * @param scene Defines the scene to register the component in
  126932. */
  126933. constructor(scene: Scene);
  126934. /**
  126935. * Registers the component in a given scene
  126936. */
  126937. register(): void;
  126938. /**
  126939. * Return the list of active meshes
  126940. * @returns the list of active meshes
  126941. */
  126942. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  126943. /**
  126944. * Return the list of active sub meshes
  126945. * @param mesh The mesh to get the candidates sub meshes from
  126946. * @returns the list of active sub meshes
  126947. */
  126948. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  126949. private _tempRay;
  126950. /**
  126951. * Return the list of sub meshes intersecting with a given local ray
  126952. * @param mesh defines the mesh to find the submesh for
  126953. * @param localRay defines the ray in local space
  126954. * @returns the list of intersecting sub meshes
  126955. */
  126956. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  126957. /**
  126958. * Return the list of sub meshes colliding with a collider
  126959. * @param mesh defines the mesh to find the submesh for
  126960. * @param collider defines the collider to evaluate the collision against
  126961. * @returns the list of colliding sub meshes
  126962. */
  126963. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  126964. /**
  126965. * Rebuilds the elements related to this component in case of
  126966. * context lost for instance.
  126967. */
  126968. rebuild(): void;
  126969. /**
  126970. * Disposes the component and the associated ressources.
  126971. */
  126972. dispose(): void;
  126973. }
  126974. }
  126975. declare module BABYLON {
  126976. /**
  126977. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  126978. */
  126979. export class Gizmo implements IDisposable {
  126980. /** The utility layer the gizmo will be added to */
  126981. gizmoLayer: UtilityLayerRenderer;
  126982. /**
  126983. * The root mesh of the gizmo
  126984. */
  126985. _rootMesh: Mesh;
  126986. private _attachedMesh;
  126987. /**
  126988. * Ratio for the scale of the gizmo (Default: 1)
  126989. */
  126990. scaleRatio: number;
  126991. /**
  126992. * If a custom mesh has been set (Default: false)
  126993. */
  126994. protected _customMeshSet: boolean;
  126995. /**
  126996. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  126997. * * When set, interactions will be enabled
  126998. */
  126999. get attachedMesh(): Nullable<AbstractMesh>;
  127000. set attachedMesh(value: Nullable<AbstractMesh>);
  127001. /**
  127002. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  127003. * @param mesh The mesh to replace the default mesh of the gizmo
  127004. */
  127005. setCustomMesh(mesh: Mesh): void;
  127006. /**
  127007. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  127008. */
  127009. updateGizmoRotationToMatchAttachedMesh: boolean;
  127010. /**
  127011. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  127012. */
  127013. updateGizmoPositionToMatchAttachedMesh: boolean;
  127014. /**
  127015. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  127016. */
  127017. updateScale: boolean;
  127018. protected _interactionsEnabled: boolean;
  127019. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127020. private _beforeRenderObserver;
  127021. private _tempVector;
  127022. /**
  127023. * Creates a gizmo
  127024. * @param gizmoLayer The utility layer the gizmo will be added to
  127025. */
  127026. constructor(
  127027. /** The utility layer the gizmo will be added to */
  127028. gizmoLayer?: UtilityLayerRenderer);
  127029. /**
  127030. * Updates the gizmo to match the attached mesh's position/rotation
  127031. */
  127032. protected _update(): void;
  127033. /**
  127034. * Disposes of the gizmo
  127035. */
  127036. dispose(): void;
  127037. }
  127038. }
  127039. declare module BABYLON {
  127040. /**
  127041. * Single plane drag gizmo
  127042. */
  127043. export class PlaneDragGizmo extends Gizmo {
  127044. /**
  127045. * Drag behavior responsible for the gizmos dragging interactions
  127046. */
  127047. dragBehavior: PointerDragBehavior;
  127048. private _pointerObserver;
  127049. /**
  127050. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127051. */
  127052. snapDistance: number;
  127053. /**
  127054. * Event that fires each time the gizmo snaps to a new location.
  127055. * * snapDistance is the the change in distance
  127056. */
  127057. onSnapObservable: Observable<{
  127058. snapDistance: number;
  127059. }>;
  127060. private _plane;
  127061. private _coloredMaterial;
  127062. private _hoverMaterial;
  127063. private _isEnabled;
  127064. private _parent;
  127065. /** @hidden */
  127066. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  127067. /** @hidden */
  127068. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  127069. /**
  127070. * Creates a PlaneDragGizmo
  127071. * @param gizmoLayer The utility layer the gizmo will be added to
  127072. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  127073. * @param color The color of the gizmo
  127074. */
  127075. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  127076. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127077. /**
  127078. * If the gizmo is enabled
  127079. */
  127080. set isEnabled(value: boolean);
  127081. get isEnabled(): boolean;
  127082. /**
  127083. * Disposes of the gizmo
  127084. */
  127085. dispose(): void;
  127086. }
  127087. }
  127088. declare module BABYLON {
  127089. /**
  127090. * Gizmo that enables dragging a mesh along 3 axis
  127091. */
  127092. export class PositionGizmo extends Gizmo {
  127093. /**
  127094. * Internal gizmo used for interactions on the x axis
  127095. */
  127096. xGizmo: AxisDragGizmo;
  127097. /**
  127098. * Internal gizmo used for interactions on the y axis
  127099. */
  127100. yGizmo: AxisDragGizmo;
  127101. /**
  127102. * Internal gizmo used for interactions on the z axis
  127103. */
  127104. zGizmo: AxisDragGizmo;
  127105. /**
  127106. * Internal gizmo used for interactions on the yz plane
  127107. */
  127108. xPlaneGizmo: PlaneDragGizmo;
  127109. /**
  127110. * Internal gizmo used for interactions on the xz plane
  127111. */
  127112. yPlaneGizmo: PlaneDragGizmo;
  127113. /**
  127114. * Internal gizmo used for interactions on the xy plane
  127115. */
  127116. zPlaneGizmo: PlaneDragGizmo;
  127117. /**
  127118. * private variables
  127119. */
  127120. private _meshAttached;
  127121. private _updateGizmoRotationToMatchAttachedMesh;
  127122. private _snapDistance;
  127123. private _scaleRatio;
  127124. /** Fires an event when any of it's sub gizmos are dragged */
  127125. onDragStartObservable: Observable<unknown>;
  127126. /** Fires an event when any of it's sub gizmos are released from dragging */
  127127. onDragEndObservable: Observable<unknown>;
  127128. /**
  127129. * If set to true, planar drag is enabled
  127130. */
  127131. private _planarGizmoEnabled;
  127132. get attachedMesh(): Nullable<AbstractMesh>;
  127133. set attachedMesh(mesh: Nullable<AbstractMesh>);
  127134. /**
  127135. * Creates a PositionGizmo
  127136. * @param gizmoLayer The utility layer the gizmo will be added to
  127137. */
  127138. constructor(gizmoLayer?: UtilityLayerRenderer);
  127139. /**
  127140. * If the planar drag gizmo is enabled
  127141. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  127142. */
  127143. set planarGizmoEnabled(value: boolean);
  127144. get planarGizmoEnabled(): boolean;
  127145. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  127146. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  127147. /**
  127148. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127149. */
  127150. set snapDistance(value: number);
  127151. get snapDistance(): number;
  127152. /**
  127153. * Ratio for the scale of the gizmo (Default: 1)
  127154. */
  127155. set scaleRatio(value: number);
  127156. get scaleRatio(): number;
  127157. /**
  127158. * Disposes of the gizmo
  127159. */
  127160. dispose(): void;
  127161. /**
  127162. * CustomMeshes are not supported by this gizmo
  127163. * @param mesh The mesh to replace the default mesh of the gizmo
  127164. */
  127165. setCustomMesh(mesh: Mesh): void;
  127166. }
  127167. }
  127168. declare module BABYLON {
  127169. /**
  127170. * Single axis drag gizmo
  127171. */
  127172. export class AxisDragGizmo extends Gizmo {
  127173. /**
  127174. * Drag behavior responsible for the gizmos dragging interactions
  127175. */
  127176. dragBehavior: PointerDragBehavior;
  127177. private _pointerObserver;
  127178. /**
  127179. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127180. */
  127181. snapDistance: number;
  127182. /**
  127183. * Event that fires each time the gizmo snaps to a new location.
  127184. * * snapDistance is the the change in distance
  127185. */
  127186. onSnapObservable: Observable<{
  127187. snapDistance: number;
  127188. }>;
  127189. private _isEnabled;
  127190. private _parent;
  127191. private _arrow;
  127192. private _coloredMaterial;
  127193. private _hoverMaterial;
  127194. /** @hidden */
  127195. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  127196. /** @hidden */
  127197. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  127198. /**
  127199. * Creates an AxisDragGizmo
  127200. * @param gizmoLayer The utility layer the gizmo will be added to
  127201. * @param dragAxis The axis which the gizmo will be able to drag on
  127202. * @param color The color of the gizmo
  127203. */
  127204. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  127205. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127206. /**
  127207. * If the gizmo is enabled
  127208. */
  127209. set isEnabled(value: boolean);
  127210. get isEnabled(): boolean;
  127211. /**
  127212. * Disposes of the gizmo
  127213. */
  127214. dispose(): void;
  127215. }
  127216. }
  127217. declare module BABYLON.Debug {
  127218. /**
  127219. * The Axes viewer will show 3 axes in a specific point in space
  127220. */
  127221. export class AxesViewer {
  127222. private _xAxis;
  127223. private _yAxis;
  127224. private _zAxis;
  127225. private _scaleLinesFactor;
  127226. private _instanced;
  127227. /**
  127228. * Gets the hosting scene
  127229. */
  127230. scene: Scene;
  127231. /**
  127232. * Gets or sets a number used to scale line length
  127233. */
  127234. scaleLines: number;
  127235. /** Gets the node hierarchy used to render x-axis */
  127236. get xAxis(): TransformNode;
  127237. /** Gets the node hierarchy used to render y-axis */
  127238. get yAxis(): TransformNode;
  127239. /** Gets the node hierarchy used to render z-axis */
  127240. get zAxis(): TransformNode;
  127241. /**
  127242. * Creates a new AxesViewer
  127243. * @param scene defines the hosting scene
  127244. * @param scaleLines defines a number used to scale line length (1 by default)
  127245. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  127246. * @param xAxis defines the node hierarchy used to render the x-axis
  127247. * @param yAxis defines the node hierarchy used to render the y-axis
  127248. * @param zAxis defines the node hierarchy used to render the z-axis
  127249. */
  127250. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  127251. /**
  127252. * Force the viewer to update
  127253. * @param position defines the position of the viewer
  127254. * @param xaxis defines the x axis of the viewer
  127255. * @param yaxis defines the y axis of the viewer
  127256. * @param zaxis defines the z axis of the viewer
  127257. */
  127258. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  127259. /**
  127260. * Creates an instance of this axes viewer.
  127261. * @returns a new axes viewer with instanced meshes
  127262. */
  127263. createInstance(): AxesViewer;
  127264. /** Releases resources */
  127265. dispose(): void;
  127266. private static _SetRenderingGroupId;
  127267. }
  127268. }
  127269. declare module BABYLON.Debug {
  127270. /**
  127271. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  127272. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  127273. */
  127274. export class BoneAxesViewer extends AxesViewer {
  127275. /**
  127276. * Gets or sets the target mesh where to display the axes viewer
  127277. */
  127278. mesh: Nullable<Mesh>;
  127279. /**
  127280. * Gets or sets the target bone where to display the axes viewer
  127281. */
  127282. bone: Nullable<Bone>;
  127283. /** Gets current position */
  127284. pos: Vector3;
  127285. /** Gets direction of X axis */
  127286. xaxis: Vector3;
  127287. /** Gets direction of Y axis */
  127288. yaxis: Vector3;
  127289. /** Gets direction of Z axis */
  127290. zaxis: Vector3;
  127291. /**
  127292. * Creates a new BoneAxesViewer
  127293. * @param scene defines the hosting scene
  127294. * @param bone defines the target bone
  127295. * @param mesh defines the target mesh
  127296. * @param scaleLines defines a scaling factor for line length (1 by default)
  127297. */
  127298. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  127299. /**
  127300. * Force the viewer to update
  127301. */
  127302. update(): void;
  127303. /** Releases resources */
  127304. dispose(): void;
  127305. }
  127306. }
  127307. declare module BABYLON {
  127308. /**
  127309. * Interface used to define scene explorer extensibility option
  127310. */
  127311. export interface IExplorerExtensibilityOption {
  127312. /**
  127313. * Define the option label
  127314. */
  127315. label: string;
  127316. /**
  127317. * Defines the action to execute on click
  127318. */
  127319. action: (entity: any) => void;
  127320. }
  127321. /**
  127322. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  127323. */
  127324. export interface IExplorerExtensibilityGroup {
  127325. /**
  127326. * Defines a predicate to test if a given type mut be extended
  127327. */
  127328. predicate: (entity: any) => boolean;
  127329. /**
  127330. * Gets the list of options added to a type
  127331. */
  127332. entries: IExplorerExtensibilityOption[];
  127333. }
  127334. /**
  127335. * Interface used to define the options to use to create the Inspector
  127336. */
  127337. export interface IInspectorOptions {
  127338. /**
  127339. * Display in overlay mode (default: false)
  127340. */
  127341. overlay?: boolean;
  127342. /**
  127343. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  127344. */
  127345. globalRoot?: HTMLElement;
  127346. /**
  127347. * Display the Scene explorer
  127348. */
  127349. showExplorer?: boolean;
  127350. /**
  127351. * Display the property inspector
  127352. */
  127353. showInspector?: boolean;
  127354. /**
  127355. * Display in embed mode (both panes on the right)
  127356. */
  127357. embedMode?: boolean;
  127358. /**
  127359. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  127360. */
  127361. handleResize?: boolean;
  127362. /**
  127363. * Allow the panes to popup (default: true)
  127364. */
  127365. enablePopup?: boolean;
  127366. /**
  127367. * Allow the panes to be closed by users (default: true)
  127368. */
  127369. enableClose?: boolean;
  127370. /**
  127371. * Optional list of extensibility entries
  127372. */
  127373. explorerExtensibility?: IExplorerExtensibilityGroup[];
  127374. /**
  127375. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  127376. */
  127377. inspectorURL?: string;
  127378. /**
  127379. * Optional initial tab (default to DebugLayerTab.Properties)
  127380. */
  127381. initialTab?: DebugLayerTab;
  127382. }
  127383. interface Scene {
  127384. /**
  127385. * @hidden
  127386. * Backing field
  127387. */
  127388. _debugLayer: DebugLayer;
  127389. /**
  127390. * Gets the debug layer (aka Inspector) associated with the scene
  127391. * @see http://doc.babylonjs.com/features/playground_debuglayer
  127392. */
  127393. debugLayer: DebugLayer;
  127394. }
  127395. /**
  127396. * Enum of inspector action tab
  127397. */
  127398. export enum DebugLayerTab {
  127399. /**
  127400. * Properties tag (default)
  127401. */
  127402. Properties = 0,
  127403. /**
  127404. * Debug tab
  127405. */
  127406. Debug = 1,
  127407. /**
  127408. * Statistics tab
  127409. */
  127410. Statistics = 2,
  127411. /**
  127412. * Tools tab
  127413. */
  127414. Tools = 3,
  127415. /**
  127416. * Settings tab
  127417. */
  127418. Settings = 4
  127419. }
  127420. /**
  127421. * The debug layer (aka Inspector) is the go to tool in order to better understand
  127422. * what is happening in your scene
  127423. * @see http://doc.babylonjs.com/features/playground_debuglayer
  127424. */
  127425. export class DebugLayer {
  127426. /**
  127427. * Define the url to get the inspector script from.
  127428. * By default it uses the babylonjs CDN.
  127429. * @ignoreNaming
  127430. */
  127431. static InspectorURL: string;
  127432. private _scene;
  127433. private BJSINSPECTOR;
  127434. private _onPropertyChangedObservable?;
  127435. /**
  127436. * Observable triggered when a property is changed through the inspector.
  127437. */
  127438. get onPropertyChangedObservable(): any;
  127439. /**
  127440. * Instantiates a new debug layer.
  127441. * The debug layer (aka Inspector) is the go to tool in order to better understand
  127442. * what is happening in your scene
  127443. * @see http://doc.babylonjs.com/features/playground_debuglayer
  127444. * @param scene Defines the scene to inspect
  127445. */
  127446. constructor(scene: Scene);
  127447. /** Creates the inspector window. */
  127448. private _createInspector;
  127449. /**
  127450. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  127451. * @param entity defines the entity to select
  127452. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  127453. */
  127454. select(entity: any, lineContainerTitles?: string | string[]): void;
  127455. /** Get the inspector from bundle or global */
  127456. private _getGlobalInspector;
  127457. /**
  127458. * Get if the inspector is visible or not.
  127459. * @returns true if visible otherwise, false
  127460. */
  127461. isVisible(): boolean;
  127462. /**
  127463. * Hide the inspector and close its window.
  127464. */
  127465. hide(): void;
  127466. /**
  127467. * Update the scene in the inspector
  127468. */
  127469. setAsActiveScene(): void;
  127470. /**
  127471. * Launch the debugLayer.
  127472. * @param config Define the configuration of the inspector
  127473. * @return a promise fulfilled when the debug layer is visible
  127474. */
  127475. show(config?: IInspectorOptions): Promise<DebugLayer>;
  127476. }
  127477. }
  127478. declare module BABYLON {
  127479. /**
  127480. * Class containing static functions to help procedurally build meshes
  127481. */
  127482. export class BoxBuilder {
  127483. /**
  127484. * Creates a box mesh
  127485. * * The parameter `size` sets the size (float) of each box side (default 1)
  127486. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  127487. * * 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)
  127488. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  127489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127490. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127492. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  127493. * @param name defines the name of the mesh
  127494. * @param options defines the options used to create the mesh
  127495. * @param scene defines the hosting scene
  127496. * @returns the box mesh
  127497. */
  127498. static CreateBox(name: string, options: {
  127499. size?: number;
  127500. width?: number;
  127501. height?: number;
  127502. depth?: number;
  127503. faceUV?: Vector4[];
  127504. faceColors?: Color4[];
  127505. sideOrientation?: number;
  127506. frontUVs?: Vector4;
  127507. backUVs?: Vector4;
  127508. wrap?: boolean;
  127509. topBaseAt?: number;
  127510. bottomBaseAt?: number;
  127511. updatable?: boolean;
  127512. }, scene?: Nullable<Scene>): Mesh;
  127513. }
  127514. }
  127515. declare module BABYLON.Debug {
  127516. /**
  127517. * Used to show the physics impostor around the specific mesh
  127518. */
  127519. export class PhysicsViewer {
  127520. /** @hidden */
  127521. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  127522. /** @hidden */
  127523. protected _meshes: Array<Nullable<AbstractMesh>>;
  127524. /** @hidden */
  127525. protected _scene: Nullable<Scene>;
  127526. /** @hidden */
  127527. protected _numMeshes: number;
  127528. /** @hidden */
  127529. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  127530. private _renderFunction;
  127531. private _utilityLayer;
  127532. private _debugBoxMesh;
  127533. private _debugSphereMesh;
  127534. private _debugCylinderMesh;
  127535. private _debugMaterial;
  127536. private _debugMeshMeshes;
  127537. /**
  127538. * Creates a new PhysicsViewer
  127539. * @param scene defines the hosting scene
  127540. */
  127541. constructor(scene: Scene);
  127542. /** @hidden */
  127543. protected _updateDebugMeshes(): void;
  127544. /**
  127545. * Renders a specified physic impostor
  127546. * @param impostor defines the impostor to render
  127547. * @param targetMesh defines the mesh represented by the impostor
  127548. * @returns the new debug mesh used to render the impostor
  127549. */
  127550. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  127551. /**
  127552. * Hides a specified physic impostor
  127553. * @param impostor defines the impostor to hide
  127554. */
  127555. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  127556. private _getDebugMaterial;
  127557. private _getDebugBoxMesh;
  127558. private _getDebugSphereMesh;
  127559. private _getDebugCylinderMesh;
  127560. private _getDebugMeshMesh;
  127561. private _getDebugMesh;
  127562. /** Releases all resources */
  127563. dispose(): void;
  127564. }
  127565. }
  127566. declare module BABYLON {
  127567. /**
  127568. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  127569. * in order to better appreciate the issue one might have.
  127570. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  127571. */
  127572. export class RayHelper {
  127573. /**
  127574. * Defines the ray we are currently tryin to visualize.
  127575. */
  127576. ray: Nullable<Ray>;
  127577. private _renderPoints;
  127578. private _renderLine;
  127579. private _renderFunction;
  127580. private _scene;
  127581. private _updateToMeshFunction;
  127582. private _attachedToMesh;
  127583. private _meshSpaceDirection;
  127584. private _meshSpaceOrigin;
  127585. /**
  127586. * Helper function to create a colored helper in a scene in one line.
  127587. * @param ray Defines the ray we are currently tryin to visualize
  127588. * @param scene Defines the scene the ray is used in
  127589. * @param color Defines the color we want to see the ray in
  127590. * @returns The newly created ray helper.
  127591. */
  127592. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  127593. /**
  127594. * Instantiate a new ray helper.
  127595. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  127596. * in order to better appreciate the issue one might have.
  127597. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  127598. * @param ray Defines the ray we are currently tryin to visualize
  127599. */
  127600. constructor(ray: Ray);
  127601. /**
  127602. * Shows the ray we are willing to debug.
  127603. * @param scene Defines the scene the ray needs to be rendered in
  127604. * @param color Defines the color the ray needs to be rendered in
  127605. */
  127606. show(scene: Scene, color?: Color3): void;
  127607. /**
  127608. * Hides the ray we are debugging.
  127609. */
  127610. hide(): void;
  127611. private _render;
  127612. /**
  127613. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  127614. * @param mesh Defines the mesh we want the helper attached to
  127615. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  127616. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  127617. * @param length Defines the length of the ray
  127618. */
  127619. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  127620. /**
  127621. * Detach the ray helper from the mesh it has previously been attached to.
  127622. */
  127623. detachFromMesh(): void;
  127624. private _updateToMesh;
  127625. /**
  127626. * Dispose the helper and release its associated resources.
  127627. */
  127628. dispose(): void;
  127629. }
  127630. }
  127631. declare module BABYLON.Debug {
  127632. /**
  127633. * Class used to render a debug view of a given skeleton
  127634. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  127635. */
  127636. export class SkeletonViewer {
  127637. /** defines the skeleton to render */
  127638. skeleton: Skeleton;
  127639. /** defines the mesh attached to the skeleton */
  127640. mesh: AbstractMesh;
  127641. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  127642. autoUpdateBonesMatrices: boolean;
  127643. /** defines the rendering group id to use with the viewer */
  127644. renderingGroupId: number;
  127645. /** Gets or sets the color used to render the skeleton */
  127646. color: Color3;
  127647. private _scene;
  127648. private _debugLines;
  127649. private _debugMesh;
  127650. private _isEnabled;
  127651. private _renderFunction;
  127652. private _utilityLayer;
  127653. /**
  127654. * Returns the mesh used to render the bones
  127655. */
  127656. get debugMesh(): Nullable<LinesMesh>;
  127657. /**
  127658. * Creates a new SkeletonViewer
  127659. * @param skeleton defines the skeleton to render
  127660. * @param mesh defines the mesh attached to the skeleton
  127661. * @param scene defines the hosting scene
  127662. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  127663. * @param renderingGroupId defines the rendering group id to use with the viewer
  127664. */
  127665. constructor(
  127666. /** defines the skeleton to render */
  127667. skeleton: Skeleton,
  127668. /** defines the mesh attached to the skeleton */
  127669. mesh: AbstractMesh, scene: Scene,
  127670. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  127671. autoUpdateBonesMatrices?: boolean,
  127672. /** defines the rendering group id to use with the viewer */
  127673. renderingGroupId?: number);
  127674. /** Gets or sets a boolean indicating if the viewer is enabled */
  127675. set isEnabled(value: boolean);
  127676. get isEnabled(): boolean;
  127677. private _getBonePosition;
  127678. private _getLinesForBonesWithLength;
  127679. private _getLinesForBonesNoLength;
  127680. /** Update the viewer to sync with current skeleton state */
  127681. update(): void;
  127682. /** Release associated resources */
  127683. dispose(): void;
  127684. }
  127685. }
  127686. declare module BABYLON {
  127687. /**
  127688. * Enum for Device Types
  127689. */
  127690. export enum DeviceType {
  127691. /** Generic */
  127692. Generic = 0,
  127693. /** Keyboard */
  127694. Keyboard = 1,
  127695. /** Mouse */
  127696. Mouse = 2,
  127697. /** Touch Pointers */
  127698. Touch = 3,
  127699. /** PS4 Dual Shock */
  127700. DualShock = 4,
  127701. /** Xbox */
  127702. Xbox = 5,
  127703. /** Switch Controller */
  127704. Switch = 6
  127705. }
  127706. /**
  127707. * Enum for All Pointers (Touch/Mouse)
  127708. */
  127709. export enum PointerInput {
  127710. /** Horizontal Axis */
  127711. Horizontal = 0,
  127712. /** Vertical Axis */
  127713. Vertical = 1,
  127714. /** Left Click or Touch */
  127715. LeftClick = 2,
  127716. /** Middle Click */
  127717. MiddleClick = 3,
  127718. /** Right Click */
  127719. RightClick = 4,
  127720. /** Browser Back */
  127721. BrowserBack = 5,
  127722. /** Browser Forward */
  127723. BrowserForward = 6
  127724. }
  127725. /**
  127726. * Enum for Dual Shock Gamepad
  127727. */
  127728. export enum DualShockInput {
  127729. /** Cross */
  127730. Cross = 0,
  127731. /** Circle */
  127732. Circle = 1,
  127733. /** Square */
  127734. Square = 2,
  127735. /** Triangle */
  127736. Triangle = 3,
  127737. /** L1 */
  127738. L1 = 4,
  127739. /** R1 */
  127740. R1 = 5,
  127741. /** L2 */
  127742. L2 = 6,
  127743. /** R2 */
  127744. R2 = 7,
  127745. /** Share */
  127746. Share = 8,
  127747. /** Options */
  127748. Options = 9,
  127749. /** L3 */
  127750. L3 = 10,
  127751. /** R3 */
  127752. R3 = 11,
  127753. /** DPadUp */
  127754. DPadUp = 12,
  127755. /** DPadDown */
  127756. DPadDown = 13,
  127757. /** DPadLeft */
  127758. DPadLeft = 14,
  127759. /** DRight */
  127760. DPadRight = 15,
  127761. /** Home */
  127762. Home = 16,
  127763. /** TouchPad */
  127764. TouchPad = 17,
  127765. /** LStickXAxis */
  127766. LStickXAxis = 18,
  127767. /** LStickYAxis */
  127768. LStickYAxis = 19,
  127769. /** RStickXAxis */
  127770. RStickXAxis = 20,
  127771. /** RStickYAxis */
  127772. RStickYAxis = 21
  127773. }
  127774. /**
  127775. * Enum for Xbox Gamepad
  127776. */
  127777. export enum XboxInput {
  127778. /** A */
  127779. A = 0,
  127780. /** B */
  127781. B = 1,
  127782. /** X */
  127783. X = 2,
  127784. /** Y */
  127785. Y = 3,
  127786. /** LB */
  127787. LB = 4,
  127788. /** RB */
  127789. RB = 5,
  127790. /** LT */
  127791. LT = 6,
  127792. /** RT */
  127793. RT = 7,
  127794. /** Back */
  127795. Back = 8,
  127796. /** Start */
  127797. Start = 9,
  127798. /** LS */
  127799. LS = 10,
  127800. /** RS */
  127801. RS = 11,
  127802. /** DPadUp */
  127803. DPadUp = 12,
  127804. /** DPadDown */
  127805. DPadDown = 13,
  127806. /** DPadLeft */
  127807. DPadLeft = 14,
  127808. /** DRight */
  127809. DPadRight = 15,
  127810. /** Home */
  127811. Home = 16,
  127812. /** LStickXAxis */
  127813. LStickXAxis = 17,
  127814. /** LStickYAxis */
  127815. LStickYAxis = 18,
  127816. /** RStickXAxis */
  127817. RStickXAxis = 19,
  127818. /** RStickYAxis */
  127819. RStickYAxis = 20
  127820. }
  127821. /**
  127822. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  127823. */
  127824. export enum SwitchInput {
  127825. /** B */
  127826. B = 0,
  127827. /** A */
  127828. A = 1,
  127829. /** Y */
  127830. Y = 2,
  127831. /** X */
  127832. X = 3,
  127833. /** L */
  127834. L = 4,
  127835. /** R */
  127836. R = 5,
  127837. /** ZL */
  127838. ZL = 6,
  127839. /** ZR */
  127840. ZR = 7,
  127841. /** Minus */
  127842. Minus = 8,
  127843. /** Plus */
  127844. Plus = 9,
  127845. /** LS */
  127846. LS = 10,
  127847. /** RS */
  127848. RS = 11,
  127849. /** DPadUp */
  127850. DPadUp = 12,
  127851. /** DPadDown */
  127852. DPadDown = 13,
  127853. /** DPadLeft */
  127854. DPadLeft = 14,
  127855. /** DRight */
  127856. DPadRight = 15,
  127857. /** Home */
  127858. Home = 16,
  127859. /** Capture */
  127860. Capture = 17,
  127861. /** LStickXAxis */
  127862. LStickXAxis = 18,
  127863. /** LStickYAxis */
  127864. LStickYAxis = 19,
  127865. /** RStickXAxis */
  127866. RStickXAxis = 20,
  127867. /** RStickYAxis */
  127868. RStickYAxis = 21
  127869. }
  127870. }
  127871. declare module BABYLON {
  127872. /**
  127873. * This class will take all inputs from Keyboard, Pointer, and
  127874. * any Gamepads and provide a polling system that all devices
  127875. * will use. This class assumes that there will only be one
  127876. * pointer device and one keyboard.
  127877. */
  127878. export class DeviceInputSystem implements IDisposable {
  127879. /**
  127880. * Callback to be triggered when a device is connected
  127881. */
  127882. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  127883. /**
  127884. * Callback to be triggered when a device is disconnected
  127885. */
  127886. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  127887. /**
  127888. * Callback to be triggered when event driven input is updated
  127889. */
  127890. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  127891. private _inputs;
  127892. private _gamepads;
  127893. private _keyboardActive;
  127894. private _pointerActive;
  127895. private _elementToAttachTo;
  127896. private _keyboardDownEvent;
  127897. private _keyboardUpEvent;
  127898. private _pointerMoveEvent;
  127899. private _pointerDownEvent;
  127900. private _pointerUpEvent;
  127901. private _gamepadConnectedEvent;
  127902. private _gamepadDisconnectedEvent;
  127903. private static _MAX_KEYCODES;
  127904. private static _MAX_POINTER_INPUTS;
  127905. private constructor();
  127906. /**
  127907. * Creates a new DeviceInputSystem instance
  127908. * @param engine Engine to pull input element from
  127909. * @returns The new instance
  127910. */
  127911. static Create(engine: Engine): DeviceInputSystem;
  127912. /**
  127913. * Checks for current device input value, given an id and input index
  127914. * @param deviceName Id of connected device
  127915. * @param inputIndex Index of device input
  127916. * @returns Current value of input
  127917. */
  127918. /**
  127919. * Checks for current device input value, given an id and input index
  127920. * @param deviceType Enum specifiying device type
  127921. * @param deviceSlot "Slot" or index that device is referenced in
  127922. * @param inputIndex Id of input to be checked
  127923. * @returns Current value of input
  127924. */
  127925. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  127926. /**
  127927. * Dispose of all the eventlisteners
  127928. */
  127929. dispose(): void;
  127930. /**
  127931. * Add device and inputs to device array
  127932. * @param deviceType Enum specifiying device type
  127933. * @param deviceSlot "Slot" or index that device is referenced in
  127934. * @param numberOfInputs Number of input entries to create for given device
  127935. */
  127936. private _registerDevice;
  127937. /**
  127938. * Given a specific device name, remove that device from the device map
  127939. * @param deviceType Enum specifiying device type
  127940. * @param deviceSlot "Slot" or index that device is referenced in
  127941. */
  127942. private _unregisterDevice;
  127943. /**
  127944. * Handle all actions that come from keyboard interaction
  127945. */
  127946. private _handleKeyActions;
  127947. /**
  127948. * Handle all actions that come from pointer interaction
  127949. */
  127950. private _handlePointerActions;
  127951. /**
  127952. * Handle all actions that come from gamepad interaction
  127953. */
  127954. private _handleGamepadActions;
  127955. /**
  127956. * Update all non-event based devices with each frame
  127957. * @param deviceType Enum specifiying device type
  127958. * @param deviceSlot "Slot" or index that device is referenced in
  127959. * @param inputIndex Id of input to be checked
  127960. */
  127961. private _updateDevice;
  127962. /**
  127963. * Gets DeviceType from the device name
  127964. * @param deviceName Name of Device from DeviceInputSystem
  127965. * @returns DeviceType enum value
  127966. */
  127967. private _getGamepadDeviceType;
  127968. }
  127969. }
  127970. declare module BABYLON {
  127971. /**
  127972. * Type to handle enforcement of inputs
  127973. */
  127974. 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;
  127975. }
  127976. declare module BABYLON {
  127977. /**
  127978. * Class that handles all input for a specific device
  127979. */
  127980. export class DeviceSource<T extends DeviceType> {
  127981. /** Type of device */
  127982. readonly deviceType: DeviceType;
  127983. /** "Slot" or index that device is referenced in */
  127984. readonly deviceSlot: number;
  127985. /**
  127986. * Observable to handle device input changes per device
  127987. */
  127988. readonly onInputChangedObservable: Observable<{
  127989. inputIndex: DeviceInput<T>;
  127990. previousState: Nullable<number>;
  127991. currentState: Nullable<number>;
  127992. }>;
  127993. private readonly _deviceInputSystem;
  127994. /**
  127995. * Default Constructor
  127996. * @param deviceInputSystem Reference to DeviceInputSystem
  127997. * @param deviceType Type of device
  127998. * @param deviceSlot "Slot" or index that device is referenced in
  127999. */
  128000. constructor(deviceInputSystem: DeviceInputSystem,
  128001. /** Type of device */
  128002. deviceType: DeviceType,
  128003. /** "Slot" or index that device is referenced in */
  128004. deviceSlot?: number);
  128005. /**
  128006. * Get input for specific input
  128007. * @param inputIndex index of specific input on device
  128008. * @returns Input value from DeviceInputSystem
  128009. */
  128010. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  128011. }
  128012. /**
  128013. * Class to keep track of devices
  128014. */
  128015. export class DeviceSourceManager implements IDisposable {
  128016. /**
  128017. * Observable to be triggered when before a device is connected
  128018. */
  128019. readonly onBeforeDeviceConnectedObservable: Observable<{
  128020. deviceType: DeviceType;
  128021. deviceSlot: number;
  128022. }>;
  128023. /**
  128024. * Observable to be triggered when before a device is disconnected
  128025. */
  128026. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  128027. deviceType: DeviceType;
  128028. deviceSlot: number;
  128029. }>;
  128030. /**
  128031. * Observable to be triggered when after a device is connected
  128032. */
  128033. readonly onAfterDeviceConnectedObservable: Observable<{
  128034. deviceType: DeviceType;
  128035. deviceSlot: number;
  128036. }>;
  128037. /**
  128038. * Observable to be triggered when after a device is disconnected
  128039. */
  128040. readonly onAfterDeviceDisconnectedObservable: Observable<{
  128041. deviceType: DeviceType;
  128042. deviceSlot: number;
  128043. }>;
  128044. private readonly _devices;
  128045. private readonly _firstDevice;
  128046. private readonly _deviceInputSystem;
  128047. /**
  128048. * Default Constructor
  128049. * @param engine engine to pull input element from
  128050. */
  128051. constructor(engine: Engine);
  128052. /**
  128053. * Gets a DeviceSource, given a type and slot
  128054. * @param deviceType Enum specifying device type
  128055. * @param deviceSlot "Slot" or index that device is referenced in
  128056. * @returns DeviceSource object
  128057. */
  128058. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  128059. /**
  128060. * Gets an array of DeviceSource objects for a given device type
  128061. * @param deviceType Enum specifying device type
  128062. * @returns Array of DeviceSource objects
  128063. */
  128064. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  128065. /**
  128066. * Dispose of DeviceInputSystem and other parts
  128067. */
  128068. dispose(): void;
  128069. /**
  128070. * Function to add device name to device list
  128071. * @param deviceType Enum specifying device type
  128072. * @param deviceSlot "Slot" or index that device is referenced in
  128073. */
  128074. private _addDevice;
  128075. /**
  128076. * Function to remove device name to device list
  128077. * @param deviceType Enum specifying device type
  128078. * @param deviceSlot "Slot" or index that device is referenced in
  128079. */
  128080. private _removeDevice;
  128081. /**
  128082. * Updates array storing first connected device of each type
  128083. * @param type Type of Device
  128084. */
  128085. private _updateFirstDevices;
  128086. }
  128087. }
  128088. declare module BABYLON {
  128089. /**
  128090. * Options to create the null engine
  128091. */
  128092. export class NullEngineOptions {
  128093. /**
  128094. * Render width (Default: 512)
  128095. */
  128096. renderWidth: number;
  128097. /**
  128098. * Render height (Default: 256)
  128099. */
  128100. renderHeight: number;
  128101. /**
  128102. * Texture size (Default: 512)
  128103. */
  128104. textureSize: number;
  128105. /**
  128106. * If delta time between frames should be constant
  128107. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128108. */
  128109. deterministicLockstep: boolean;
  128110. /**
  128111. * Maximum about of steps between frames (Default: 4)
  128112. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128113. */
  128114. lockstepMaxSteps: number;
  128115. }
  128116. /**
  128117. * The null engine class provides support for headless version of babylon.js.
  128118. * This can be used in server side scenario or for testing purposes
  128119. */
  128120. export class NullEngine extends Engine {
  128121. private _options;
  128122. /**
  128123. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  128124. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128125. * @returns true if engine is in deterministic lock step mode
  128126. */
  128127. isDeterministicLockStep(): boolean;
  128128. /**
  128129. * Gets the max steps when engine is running in deterministic lock step
  128130. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128131. * @returns the max steps
  128132. */
  128133. getLockstepMaxSteps(): number;
  128134. /**
  128135. * Gets the current hardware scaling level.
  128136. * By default the hardware scaling level is computed from the window device ratio.
  128137. * 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.
  128138. * @returns a number indicating the current hardware scaling level
  128139. */
  128140. getHardwareScalingLevel(): number;
  128141. constructor(options?: NullEngineOptions);
  128142. /**
  128143. * Creates a vertex buffer
  128144. * @param vertices the data for the vertex buffer
  128145. * @returns the new WebGL static buffer
  128146. */
  128147. createVertexBuffer(vertices: FloatArray): DataBuffer;
  128148. /**
  128149. * Creates a new index buffer
  128150. * @param indices defines the content of the index buffer
  128151. * @param updatable defines if the index buffer must be updatable
  128152. * @returns a new webGL buffer
  128153. */
  128154. createIndexBuffer(indices: IndicesArray): DataBuffer;
  128155. /**
  128156. * Clear the current render buffer or the current render target (if any is set up)
  128157. * @param color defines the color to use
  128158. * @param backBuffer defines if the back buffer must be cleared
  128159. * @param depth defines if the depth buffer must be cleared
  128160. * @param stencil defines if the stencil buffer must be cleared
  128161. */
  128162. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  128163. /**
  128164. * Gets the current render width
  128165. * @param useScreen defines if screen size must be used (or the current render target if any)
  128166. * @returns a number defining the current render width
  128167. */
  128168. getRenderWidth(useScreen?: boolean): number;
  128169. /**
  128170. * Gets the current render height
  128171. * @param useScreen defines if screen size must be used (or the current render target if any)
  128172. * @returns a number defining the current render height
  128173. */
  128174. getRenderHeight(useScreen?: boolean): number;
  128175. /**
  128176. * Set the WebGL's viewport
  128177. * @param viewport defines the viewport element to be used
  128178. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  128179. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  128180. */
  128181. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  128182. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  128183. /**
  128184. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  128185. * @param pipelineContext defines the pipeline context to use
  128186. * @param uniformsNames defines the list of uniform names
  128187. * @returns an array of webGL uniform locations
  128188. */
  128189. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  128190. /**
  128191. * Gets the lsit of active attributes for a given webGL program
  128192. * @param pipelineContext defines the pipeline context to use
  128193. * @param attributesNames defines the list of attribute names to get
  128194. * @returns an array of indices indicating the offset of each attribute
  128195. */
  128196. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  128197. /**
  128198. * Binds an effect to the webGL context
  128199. * @param effect defines the effect to bind
  128200. */
  128201. bindSamplers(effect: Effect): void;
  128202. /**
  128203. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  128204. * @param effect defines the effect to activate
  128205. */
  128206. enableEffect(effect: Effect): void;
  128207. /**
  128208. * Set various states to the webGL context
  128209. * @param culling defines backface culling state
  128210. * @param zOffset defines the value to apply to zOffset (0 by default)
  128211. * @param force defines if states must be applied even if cache is up to date
  128212. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  128213. */
  128214. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  128215. /**
  128216. * Set the value of an uniform to an array of int32
  128217. * @param uniform defines the webGL uniform location where to store the value
  128218. * @param array defines the array of int32 to store
  128219. */
  128220. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  128221. /**
  128222. * Set the value of an uniform to an array of int32 (stored as vec2)
  128223. * @param uniform defines the webGL uniform location where to store the value
  128224. * @param array defines the array of int32 to store
  128225. */
  128226. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  128227. /**
  128228. * Set the value of an uniform to an array of int32 (stored as vec3)
  128229. * @param uniform defines the webGL uniform location where to store the value
  128230. * @param array defines the array of int32 to store
  128231. */
  128232. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  128233. /**
  128234. * Set the value of an uniform to an array of int32 (stored as vec4)
  128235. * @param uniform defines the webGL uniform location where to store the value
  128236. * @param array defines the array of int32 to store
  128237. */
  128238. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  128239. /**
  128240. * Set the value of an uniform to an array of float32
  128241. * @param uniform defines the webGL uniform location where to store the value
  128242. * @param array defines the array of float32 to store
  128243. */
  128244. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  128245. /**
  128246. * Set the value of an uniform to an array of float32 (stored as vec2)
  128247. * @param uniform defines the webGL uniform location where to store the value
  128248. * @param array defines the array of float32 to store
  128249. */
  128250. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  128251. /**
  128252. * Set the value of an uniform to an array of float32 (stored as vec3)
  128253. * @param uniform defines the webGL uniform location where to store the value
  128254. * @param array defines the array of float32 to store
  128255. */
  128256. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  128257. /**
  128258. * Set the value of an uniform to an array of float32 (stored as vec4)
  128259. * @param uniform defines the webGL uniform location where to store the value
  128260. * @param array defines the array of float32 to store
  128261. */
  128262. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  128263. /**
  128264. * Set the value of an uniform to an array of number
  128265. * @param uniform defines the webGL uniform location where to store the value
  128266. * @param array defines the array of number to store
  128267. */
  128268. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  128269. /**
  128270. * Set the value of an uniform to an array of number (stored as vec2)
  128271. * @param uniform defines the webGL uniform location where to store the value
  128272. * @param array defines the array of number to store
  128273. */
  128274. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  128275. /**
  128276. * Set the value of an uniform to an array of number (stored as vec3)
  128277. * @param uniform defines the webGL uniform location where to store the value
  128278. * @param array defines the array of number to store
  128279. */
  128280. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  128281. /**
  128282. * Set the value of an uniform to an array of number (stored as vec4)
  128283. * @param uniform defines the webGL uniform location where to store the value
  128284. * @param array defines the array of number to store
  128285. */
  128286. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  128287. /**
  128288. * Set the value of an uniform to an array of float32 (stored as matrices)
  128289. * @param uniform defines the webGL uniform location where to store the value
  128290. * @param matrices defines the array of float32 to store
  128291. */
  128292. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  128293. /**
  128294. * Set the value of an uniform to a matrix (3x3)
  128295. * @param uniform defines the webGL uniform location where to store the value
  128296. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  128297. */
  128298. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128299. /**
  128300. * Set the value of an uniform to a matrix (2x2)
  128301. * @param uniform defines the webGL uniform location where to store the value
  128302. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  128303. */
  128304. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128305. /**
  128306. * Set the value of an uniform to a number (float)
  128307. * @param uniform defines the webGL uniform location where to store the value
  128308. * @param value defines the float number to store
  128309. */
  128310. setFloat(uniform: WebGLUniformLocation, value: number): void;
  128311. /**
  128312. * Set the value of an uniform to a vec2
  128313. * @param uniform defines the webGL uniform location where to store the value
  128314. * @param x defines the 1st component of the value
  128315. * @param y defines the 2nd component of the value
  128316. */
  128317. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  128318. /**
  128319. * Set the value of an uniform to a vec3
  128320. * @param uniform defines the webGL uniform location where to store the value
  128321. * @param x defines the 1st component of the value
  128322. * @param y defines the 2nd component of the value
  128323. * @param z defines the 3rd component of the value
  128324. */
  128325. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  128326. /**
  128327. * Set the value of an uniform to a boolean
  128328. * @param uniform defines the webGL uniform location where to store the value
  128329. * @param bool defines the boolean to store
  128330. */
  128331. setBool(uniform: WebGLUniformLocation, bool: number): void;
  128332. /**
  128333. * Set the value of an uniform to a vec4
  128334. * @param uniform defines the webGL uniform location where to store the value
  128335. * @param x defines the 1st component of the value
  128336. * @param y defines the 2nd component of the value
  128337. * @param z defines the 3rd component of the value
  128338. * @param w defines the 4th component of the value
  128339. */
  128340. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  128341. /**
  128342. * Sets the current alpha mode
  128343. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  128344. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  128345. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  128346. */
  128347. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  128348. /**
  128349. * Bind webGl buffers directly to the webGL context
  128350. * @param vertexBuffers defines the vertex buffer to bind
  128351. * @param indexBuffer defines the index buffer to bind
  128352. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  128353. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  128354. * @param effect defines the effect associated with the vertex buffer
  128355. */
  128356. bindBuffers(vertexBuffers: {
  128357. [key: string]: VertexBuffer;
  128358. }, indexBuffer: DataBuffer, effect: Effect): void;
  128359. /**
  128360. * Force the entire cache to be cleared
  128361. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  128362. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  128363. */
  128364. wipeCaches(bruteForce?: boolean): void;
  128365. /**
  128366. * Send a draw order
  128367. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  128368. * @param indexStart defines the starting index
  128369. * @param indexCount defines the number of index to draw
  128370. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128371. */
  128372. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  128373. /**
  128374. * Draw a list of indexed primitives
  128375. * @param fillMode defines the primitive to use
  128376. * @param indexStart defines the starting index
  128377. * @param indexCount defines the number of index to draw
  128378. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128379. */
  128380. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  128381. /**
  128382. * Draw a list of unindexed primitives
  128383. * @param fillMode defines the primitive to use
  128384. * @param verticesStart defines the index of first vertex to draw
  128385. * @param verticesCount defines the count of vertices to draw
  128386. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128387. */
  128388. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  128389. /** @hidden */
  128390. _createTexture(): WebGLTexture;
  128391. /** @hidden */
  128392. _releaseTexture(texture: InternalTexture): void;
  128393. /**
  128394. * Usually called from Texture.ts.
  128395. * Passed information to create a WebGLTexture
  128396. * @param urlArg defines a value which contains one of the following:
  128397. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  128398. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  128399. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  128400. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  128401. * @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)
  128402. * @param scene needed for loading to the correct scene
  128403. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  128404. * @param onLoad optional callback to be called upon successful completion
  128405. * @param onError optional callback to be called upon failure
  128406. * @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
  128407. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  128408. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  128409. * @param forcedExtension defines the extension to use to pick the right loader
  128410. * @param mimeType defines an optional mime type
  128411. * @returns a InternalTexture for assignment back into BABYLON.Texture
  128412. */
  128413. 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;
  128414. /**
  128415. * Creates a new render target texture
  128416. * @param size defines the size of the texture
  128417. * @param options defines the options used to create the texture
  128418. * @returns a new render target texture stored in an InternalTexture
  128419. */
  128420. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  128421. /**
  128422. * Update the sampling mode of a given texture
  128423. * @param samplingMode defines the required sampling mode
  128424. * @param texture defines the texture to update
  128425. */
  128426. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  128427. /**
  128428. * Binds the frame buffer to the specified texture.
  128429. * @param texture The texture to render to or null for the default canvas
  128430. * @param faceIndex The face of the texture to render to in case of cube texture
  128431. * @param requiredWidth The width of the target to render to
  128432. * @param requiredHeight The height of the target to render to
  128433. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  128434. * @param lodLevel defines le lod level to bind to the frame buffer
  128435. */
  128436. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  128437. /**
  128438. * Unbind the current render target texture from the webGL context
  128439. * @param texture defines the render target texture to unbind
  128440. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  128441. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  128442. */
  128443. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  128444. /**
  128445. * Creates a dynamic vertex buffer
  128446. * @param vertices the data for the dynamic vertex buffer
  128447. * @returns the new WebGL dynamic buffer
  128448. */
  128449. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  128450. /**
  128451. * Update the content of a dynamic texture
  128452. * @param texture defines the texture to update
  128453. * @param canvas defines the canvas containing the source
  128454. * @param invertY defines if data must be stored with Y axis inverted
  128455. * @param premulAlpha defines if alpha is stored as premultiplied
  128456. * @param format defines the format of the data
  128457. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  128458. */
  128459. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  128460. /**
  128461. * Gets a boolean indicating if all created effects are ready
  128462. * @returns true if all effects are ready
  128463. */
  128464. areAllEffectsReady(): boolean;
  128465. /**
  128466. * @hidden
  128467. * Get the current error code of the webGL context
  128468. * @returns the error code
  128469. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  128470. */
  128471. getError(): number;
  128472. /** @hidden */
  128473. _getUnpackAlignement(): number;
  128474. /** @hidden */
  128475. _unpackFlipY(value: boolean): void;
  128476. /**
  128477. * Update a dynamic index buffer
  128478. * @param indexBuffer defines the target index buffer
  128479. * @param indices defines the data to update
  128480. * @param offset defines the offset in the target index buffer where update should start
  128481. */
  128482. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  128483. /**
  128484. * Updates a dynamic vertex buffer.
  128485. * @param vertexBuffer the vertex buffer to update
  128486. * @param vertices the data used to update the vertex buffer
  128487. * @param byteOffset the byte offset of the data (optional)
  128488. * @param byteLength the byte length of the data (optional)
  128489. */
  128490. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  128491. /** @hidden */
  128492. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  128493. /** @hidden */
  128494. _bindTexture(channel: number, texture: InternalTexture): void;
  128495. protected _deleteBuffer(buffer: WebGLBuffer): void;
  128496. /**
  128497. * 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
  128498. */
  128499. releaseEffects(): void;
  128500. displayLoadingUI(): void;
  128501. hideLoadingUI(): void;
  128502. /** @hidden */
  128503. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128504. /** @hidden */
  128505. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128506. /** @hidden */
  128507. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128508. /** @hidden */
  128509. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  128510. }
  128511. }
  128512. declare module BABYLON {
  128513. /**
  128514. * @hidden
  128515. **/
  128516. export class _TimeToken {
  128517. _startTimeQuery: Nullable<WebGLQuery>;
  128518. _endTimeQuery: Nullable<WebGLQuery>;
  128519. _timeElapsedQuery: Nullable<WebGLQuery>;
  128520. _timeElapsedQueryEnded: boolean;
  128521. }
  128522. }
  128523. declare module BABYLON {
  128524. /** @hidden */
  128525. export class _OcclusionDataStorage {
  128526. /** @hidden */
  128527. occlusionInternalRetryCounter: number;
  128528. /** @hidden */
  128529. isOcclusionQueryInProgress: boolean;
  128530. /** @hidden */
  128531. isOccluded: boolean;
  128532. /** @hidden */
  128533. occlusionRetryCount: number;
  128534. /** @hidden */
  128535. occlusionType: number;
  128536. /** @hidden */
  128537. occlusionQueryAlgorithmType: number;
  128538. }
  128539. interface Engine {
  128540. /**
  128541. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  128542. * @return the new query
  128543. */
  128544. createQuery(): WebGLQuery;
  128545. /**
  128546. * Delete and release a webGL query
  128547. * @param query defines the query to delete
  128548. * @return the current engine
  128549. */
  128550. deleteQuery(query: WebGLQuery): Engine;
  128551. /**
  128552. * Check if a given query has resolved and got its value
  128553. * @param query defines the query to check
  128554. * @returns true if the query got its value
  128555. */
  128556. isQueryResultAvailable(query: WebGLQuery): boolean;
  128557. /**
  128558. * Gets the value of a given query
  128559. * @param query defines the query to check
  128560. * @returns the value of the query
  128561. */
  128562. getQueryResult(query: WebGLQuery): number;
  128563. /**
  128564. * Initiates an occlusion query
  128565. * @param algorithmType defines the algorithm to use
  128566. * @param query defines the query to use
  128567. * @returns the current engine
  128568. * @see http://doc.babylonjs.com/features/occlusionquery
  128569. */
  128570. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  128571. /**
  128572. * Ends an occlusion query
  128573. * @see http://doc.babylonjs.com/features/occlusionquery
  128574. * @param algorithmType defines the algorithm to use
  128575. * @returns the current engine
  128576. */
  128577. endOcclusionQuery(algorithmType: number): Engine;
  128578. /**
  128579. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  128580. * Please note that only one query can be issued at a time
  128581. * @returns a time token used to track the time span
  128582. */
  128583. startTimeQuery(): Nullable<_TimeToken>;
  128584. /**
  128585. * Ends a time query
  128586. * @param token defines the token used to measure the time span
  128587. * @returns the time spent (in ns)
  128588. */
  128589. endTimeQuery(token: _TimeToken): int;
  128590. /** @hidden */
  128591. _currentNonTimestampToken: Nullable<_TimeToken>;
  128592. /** @hidden */
  128593. _createTimeQuery(): WebGLQuery;
  128594. /** @hidden */
  128595. _deleteTimeQuery(query: WebGLQuery): void;
  128596. /** @hidden */
  128597. _getGlAlgorithmType(algorithmType: number): number;
  128598. /** @hidden */
  128599. _getTimeQueryResult(query: WebGLQuery): any;
  128600. /** @hidden */
  128601. _getTimeQueryAvailability(query: WebGLQuery): any;
  128602. }
  128603. interface AbstractMesh {
  128604. /**
  128605. * Backing filed
  128606. * @hidden
  128607. */
  128608. __occlusionDataStorage: _OcclusionDataStorage;
  128609. /**
  128610. * Access property
  128611. * @hidden
  128612. */
  128613. _occlusionDataStorage: _OcclusionDataStorage;
  128614. /**
  128615. * 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.
  128616. * The default value is -1 which means don't break the query and wait till the result
  128617. * @see http://doc.babylonjs.com/features/occlusionquery
  128618. */
  128619. occlusionRetryCount: number;
  128620. /**
  128621. * 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:
  128622. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  128623. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  128624. * * 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.
  128625. * @see http://doc.babylonjs.com/features/occlusionquery
  128626. */
  128627. occlusionType: number;
  128628. /**
  128629. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  128630. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  128631. * * 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.
  128632. * @see http://doc.babylonjs.com/features/occlusionquery
  128633. */
  128634. occlusionQueryAlgorithmType: number;
  128635. /**
  128636. * 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
  128637. * @see http://doc.babylonjs.com/features/occlusionquery
  128638. */
  128639. isOccluded: boolean;
  128640. /**
  128641. * Flag to check the progress status of the query
  128642. * @see http://doc.babylonjs.com/features/occlusionquery
  128643. */
  128644. isOcclusionQueryInProgress: boolean;
  128645. }
  128646. }
  128647. declare module BABYLON {
  128648. /** @hidden */
  128649. export var _forceTransformFeedbackToBundle: boolean;
  128650. interface Engine {
  128651. /**
  128652. * Creates a webGL transform feedback object
  128653. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  128654. * @returns the webGL transform feedback object
  128655. */
  128656. createTransformFeedback(): WebGLTransformFeedback;
  128657. /**
  128658. * Delete a webGL transform feedback object
  128659. * @param value defines the webGL transform feedback object to delete
  128660. */
  128661. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  128662. /**
  128663. * Bind a webGL transform feedback object to the webgl context
  128664. * @param value defines the webGL transform feedback object to bind
  128665. */
  128666. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  128667. /**
  128668. * Begins a transform feedback operation
  128669. * @param usePoints defines if points or triangles must be used
  128670. */
  128671. beginTransformFeedback(usePoints: boolean): void;
  128672. /**
  128673. * Ends a transform feedback operation
  128674. */
  128675. endTransformFeedback(): void;
  128676. /**
  128677. * Specify the varyings to use with transform feedback
  128678. * @param program defines the associated webGL program
  128679. * @param value defines the list of strings representing the varying names
  128680. */
  128681. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  128682. /**
  128683. * Bind a webGL buffer for a transform feedback operation
  128684. * @param value defines the webGL buffer to bind
  128685. */
  128686. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  128687. }
  128688. }
  128689. declare module BABYLON {
  128690. /**
  128691. * Creation options of the multi render target texture.
  128692. */
  128693. export interface IMultiRenderTargetOptions {
  128694. /**
  128695. * Define if the texture needs to create mip maps after render.
  128696. */
  128697. generateMipMaps?: boolean;
  128698. /**
  128699. * Define the types of all the draw buffers we want to create
  128700. */
  128701. types?: number[];
  128702. /**
  128703. * Define the sampling modes of all the draw buffers we want to create
  128704. */
  128705. samplingModes?: number[];
  128706. /**
  128707. * Define if a depth buffer is required
  128708. */
  128709. generateDepthBuffer?: boolean;
  128710. /**
  128711. * Define if a stencil buffer is required
  128712. */
  128713. generateStencilBuffer?: boolean;
  128714. /**
  128715. * Define if a depth texture is required instead of a depth buffer
  128716. */
  128717. generateDepthTexture?: boolean;
  128718. /**
  128719. * Define the number of desired draw buffers
  128720. */
  128721. textureCount?: number;
  128722. /**
  128723. * Define if aspect ratio should be adapted to the texture or stay the scene one
  128724. */
  128725. doNotChangeAspectRatio?: boolean;
  128726. /**
  128727. * Define the default type of the buffers we are creating
  128728. */
  128729. defaultType?: number;
  128730. }
  128731. /**
  128732. * A multi render target, like a render target provides the ability to render to a texture.
  128733. * Unlike the render target, it can render to several draw buffers in one draw.
  128734. * This is specially interesting in deferred rendering or for any effects requiring more than
  128735. * just one color from a single pass.
  128736. */
  128737. export class MultiRenderTarget extends RenderTargetTexture {
  128738. private _internalTextures;
  128739. private _textures;
  128740. private _multiRenderTargetOptions;
  128741. /**
  128742. * Get if draw buffers are currently supported by the used hardware and browser.
  128743. */
  128744. get isSupported(): boolean;
  128745. /**
  128746. * Get the list of textures generated by the multi render target.
  128747. */
  128748. get textures(): Texture[];
  128749. /**
  128750. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  128751. */
  128752. get depthTexture(): Texture;
  128753. /**
  128754. * Set the wrapping mode on U of all the textures we are rendering to.
  128755. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  128756. */
  128757. set wrapU(wrap: number);
  128758. /**
  128759. * Set the wrapping mode on V of all the textures we are rendering to.
  128760. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  128761. */
  128762. set wrapV(wrap: number);
  128763. /**
  128764. * Instantiate a new multi render target texture.
  128765. * A multi render target, like a render target provides the ability to render to a texture.
  128766. * Unlike the render target, it can render to several draw buffers in one draw.
  128767. * This is specially interesting in deferred rendering or for any effects requiring more than
  128768. * just one color from a single pass.
  128769. * @param name Define the name of the texture
  128770. * @param size Define the size of the buffers to render to
  128771. * @param count Define the number of target we are rendering into
  128772. * @param scene Define the scene the texture belongs to
  128773. * @param options Define the options used to create the multi render target
  128774. */
  128775. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  128776. /** @hidden */
  128777. _rebuild(): void;
  128778. private _createInternalTextures;
  128779. private _createTextures;
  128780. /**
  128781. * Define the number of samples used if MSAA is enabled.
  128782. */
  128783. get samples(): number;
  128784. set samples(value: number);
  128785. /**
  128786. * Resize all the textures in the multi render target.
  128787. * Be carrefull as it will recreate all the data in the new texture.
  128788. * @param size Define the new size
  128789. */
  128790. resize(size: any): void;
  128791. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  128792. /**
  128793. * Dispose the render targets and their associated resources
  128794. */
  128795. dispose(): void;
  128796. /**
  128797. * Release all the underlying texture used as draw buffers.
  128798. */
  128799. releaseInternalTextures(): void;
  128800. }
  128801. }
  128802. declare module BABYLON {
  128803. interface ThinEngine {
  128804. /**
  128805. * Unbind a list of render target textures from the webGL context
  128806. * This is used only when drawBuffer extension or webGL2 are active
  128807. * @param textures defines the render target textures to unbind
  128808. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  128809. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  128810. */
  128811. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  128812. /**
  128813. * Create a multi render target texture
  128814. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  128815. * @param size defines the size of the texture
  128816. * @param options defines the creation options
  128817. * @returns the cube texture as an InternalTexture
  128818. */
  128819. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  128820. /**
  128821. * Update the sample count for a given multiple render target texture
  128822. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  128823. * @param textures defines the textures to update
  128824. * @param samples defines the sample count to set
  128825. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  128826. */
  128827. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  128828. }
  128829. }
  128830. declare module BABYLON {
  128831. /**
  128832. * Class used to define an additional view for the engine
  128833. * @see https://doc.babylonjs.com/how_to/multi_canvases
  128834. */
  128835. export class EngineView {
  128836. /** Defines the canvas where to render the view */
  128837. target: HTMLCanvasElement;
  128838. /** Defines an optional camera used to render the view (will use active camera else) */
  128839. camera?: Camera;
  128840. }
  128841. interface Engine {
  128842. /**
  128843. * Gets or sets the HTML element to use for attaching events
  128844. */
  128845. inputElement: Nullable<HTMLElement>;
  128846. /**
  128847. * Gets the current engine view
  128848. * @see https://doc.babylonjs.com/how_to/multi_canvases
  128849. */
  128850. activeView: Nullable<EngineView>;
  128851. /** Gets or sets the list of views */
  128852. views: EngineView[];
  128853. /**
  128854. * Register a new child canvas
  128855. * @param canvas defines the canvas to register
  128856. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  128857. * @returns the associated view
  128858. */
  128859. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  128860. /**
  128861. * Remove a registered child canvas
  128862. * @param canvas defines the canvas to remove
  128863. * @returns the current engine
  128864. */
  128865. unRegisterView(canvas: HTMLCanvasElement): Engine;
  128866. }
  128867. }
  128868. declare module BABYLON {
  128869. interface Engine {
  128870. /** @hidden */
  128871. _excludedCompressedTextures: string[];
  128872. /** @hidden */
  128873. _textureFormatInUse: string;
  128874. /**
  128875. * Gets the list of texture formats supported
  128876. */
  128877. readonly texturesSupported: Array<string>;
  128878. /**
  128879. * Gets the texture format in use
  128880. */
  128881. readonly textureFormatInUse: Nullable<string>;
  128882. /**
  128883. * Set the compressed texture extensions or file names to skip.
  128884. *
  128885. * @param skippedFiles defines the list of those texture files you want to skip
  128886. * Example: [".dds", ".env", "myfile.png"]
  128887. */
  128888. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  128889. /**
  128890. * Set the compressed texture format to use, based on the formats you have, and the formats
  128891. * supported by the hardware / browser.
  128892. *
  128893. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  128894. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  128895. * to API arguments needed to compressed textures. This puts the burden on the container
  128896. * generator to house the arcane code for determining these for current & future formats.
  128897. *
  128898. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  128899. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  128900. *
  128901. * Note: The result of this call is not taken into account when a texture is base64.
  128902. *
  128903. * @param formatsAvailable defines the list of those format families you have created
  128904. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  128905. *
  128906. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  128907. * @returns The extension selected.
  128908. */
  128909. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  128910. }
  128911. }
  128912. declare module BABYLON {
  128913. /**
  128914. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  128915. */
  128916. export interface CubeMapInfo {
  128917. /**
  128918. * The pixel array for the front face.
  128919. * This is stored in format, left to right, up to down format.
  128920. */
  128921. front: Nullable<ArrayBufferView>;
  128922. /**
  128923. * The pixel array for the back face.
  128924. * This is stored in format, left to right, up to down format.
  128925. */
  128926. back: Nullable<ArrayBufferView>;
  128927. /**
  128928. * The pixel array for the left face.
  128929. * This is stored in format, left to right, up to down format.
  128930. */
  128931. left: Nullable<ArrayBufferView>;
  128932. /**
  128933. * The pixel array for the right face.
  128934. * This is stored in format, left to right, up to down format.
  128935. */
  128936. right: Nullable<ArrayBufferView>;
  128937. /**
  128938. * The pixel array for the up face.
  128939. * This is stored in format, left to right, up to down format.
  128940. */
  128941. up: Nullable<ArrayBufferView>;
  128942. /**
  128943. * The pixel array for the down face.
  128944. * This is stored in format, left to right, up to down format.
  128945. */
  128946. down: Nullable<ArrayBufferView>;
  128947. /**
  128948. * The size of the cubemap stored.
  128949. *
  128950. * Each faces will be size * size pixels.
  128951. */
  128952. size: number;
  128953. /**
  128954. * The format of the texture.
  128955. *
  128956. * RGBA, RGB.
  128957. */
  128958. format: number;
  128959. /**
  128960. * The type of the texture data.
  128961. *
  128962. * UNSIGNED_INT, FLOAT.
  128963. */
  128964. type: number;
  128965. /**
  128966. * Specifies whether the texture is in gamma space.
  128967. */
  128968. gammaSpace: boolean;
  128969. }
  128970. /**
  128971. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  128972. */
  128973. export class PanoramaToCubeMapTools {
  128974. private static FACE_LEFT;
  128975. private static FACE_RIGHT;
  128976. private static FACE_FRONT;
  128977. private static FACE_BACK;
  128978. private static FACE_DOWN;
  128979. private static FACE_UP;
  128980. /**
  128981. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  128982. *
  128983. * @param float32Array The source data.
  128984. * @param inputWidth The width of the input panorama.
  128985. * @param inputHeight The height of the input panorama.
  128986. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  128987. * @return The cubemap data
  128988. */
  128989. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  128990. private static CreateCubemapTexture;
  128991. private static CalcProjectionSpherical;
  128992. }
  128993. }
  128994. declare module BABYLON {
  128995. /**
  128996. * Helper class dealing with the extraction of spherical polynomial dataArray
  128997. * from a cube map.
  128998. */
  128999. export class CubeMapToSphericalPolynomialTools {
  129000. private static FileFaces;
  129001. /**
  129002. * Converts a texture to the according Spherical Polynomial data.
  129003. * This extracts the first 3 orders only as they are the only one used in the lighting.
  129004. *
  129005. * @param texture The texture to extract the information from.
  129006. * @return The Spherical Polynomial data.
  129007. */
  129008. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  129009. /**
  129010. * Converts a cubemap to the according Spherical Polynomial data.
  129011. * This extracts the first 3 orders only as they are the only one used in the lighting.
  129012. *
  129013. * @param cubeInfo The Cube map to extract the information from.
  129014. * @return The Spherical Polynomial data.
  129015. */
  129016. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  129017. }
  129018. }
  129019. declare module BABYLON {
  129020. interface BaseTexture {
  129021. /**
  129022. * Get the polynomial representation of the texture data.
  129023. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  129024. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  129025. */
  129026. sphericalPolynomial: Nullable<SphericalPolynomial>;
  129027. }
  129028. }
  129029. declare module BABYLON {
  129030. /** @hidden */
  129031. export var rgbdEncodePixelShader: {
  129032. name: string;
  129033. shader: string;
  129034. };
  129035. }
  129036. declare module BABYLON {
  129037. /** @hidden */
  129038. export var rgbdDecodePixelShader: {
  129039. name: string;
  129040. shader: string;
  129041. };
  129042. }
  129043. declare module BABYLON {
  129044. /**
  129045. * Raw texture data and descriptor sufficient for WebGL texture upload
  129046. */
  129047. export interface EnvironmentTextureInfo {
  129048. /**
  129049. * Version of the environment map
  129050. */
  129051. version: number;
  129052. /**
  129053. * Width of image
  129054. */
  129055. width: number;
  129056. /**
  129057. * Irradiance information stored in the file.
  129058. */
  129059. irradiance: any;
  129060. /**
  129061. * Specular information stored in the file.
  129062. */
  129063. specular: any;
  129064. }
  129065. /**
  129066. * Defines One Image in the file. It requires only the position in the file
  129067. * as well as the length.
  129068. */
  129069. interface BufferImageData {
  129070. /**
  129071. * Length of the image data.
  129072. */
  129073. length: number;
  129074. /**
  129075. * Position of the data from the null terminator delimiting the end of the JSON.
  129076. */
  129077. position: number;
  129078. }
  129079. /**
  129080. * Defines the specular data enclosed in the file.
  129081. * This corresponds to the version 1 of the data.
  129082. */
  129083. export interface EnvironmentTextureSpecularInfoV1 {
  129084. /**
  129085. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  129086. */
  129087. specularDataPosition?: number;
  129088. /**
  129089. * This contains all the images data needed to reconstruct the cubemap.
  129090. */
  129091. mipmaps: Array<BufferImageData>;
  129092. /**
  129093. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  129094. */
  129095. lodGenerationScale: number;
  129096. }
  129097. /**
  129098. * Sets of helpers addressing the serialization and deserialization of environment texture
  129099. * stored in a BabylonJS env file.
  129100. * Those files are usually stored as .env files.
  129101. */
  129102. export class EnvironmentTextureTools {
  129103. /**
  129104. * Magic number identifying the env file.
  129105. */
  129106. private static _MagicBytes;
  129107. /**
  129108. * Gets the environment info from an env file.
  129109. * @param data The array buffer containing the .env bytes.
  129110. * @returns the environment file info (the json header) if successfully parsed.
  129111. */
  129112. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  129113. /**
  129114. * Creates an environment texture from a loaded cube texture.
  129115. * @param texture defines the cube texture to convert in env file
  129116. * @return a promise containing the environment data if succesfull.
  129117. */
  129118. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  129119. /**
  129120. * Creates a JSON representation of the spherical data.
  129121. * @param texture defines the texture containing the polynomials
  129122. * @return the JSON representation of the spherical info
  129123. */
  129124. private static _CreateEnvTextureIrradiance;
  129125. /**
  129126. * Creates the ArrayBufferViews used for initializing environment texture image data.
  129127. * @param data the image data
  129128. * @param info parameters that determine what views will be created for accessing the underlying buffer
  129129. * @return the views described by info providing access to the underlying buffer
  129130. */
  129131. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  129132. /**
  129133. * Uploads the texture info contained in the env file to the GPU.
  129134. * @param texture defines the internal texture to upload to
  129135. * @param data defines the data to load
  129136. * @param info defines the texture info retrieved through the GetEnvInfo method
  129137. * @returns a promise
  129138. */
  129139. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  129140. private static _OnImageReadyAsync;
  129141. /**
  129142. * Uploads the levels of image data to the GPU.
  129143. * @param texture defines the internal texture to upload to
  129144. * @param imageData defines the array buffer views of image data [mipmap][face]
  129145. * @returns a promise
  129146. */
  129147. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  129148. /**
  129149. * Uploads spherical polynomials information to the texture.
  129150. * @param texture defines the texture we are trying to upload the information to
  129151. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  129152. */
  129153. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  129154. /** @hidden */
  129155. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129156. }
  129157. }
  129158. declare module BABYLON {
  129159. /** @hidden */
  129160. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  129161. private _genericAttributeLocation;
  129162. private _varyingLocationCount;
  129163. private _varyingLocationMap;
  129164. private _replacements;
  129165. private _textureCount;
  129166. private _uniforms;
  129167. lineProcessor(line: string): string;
  129168. attributeProcessor(attribute: string): string;
  129169. varyingProcessor(varying: string, isFragment: boolean): string;
  129170. uniformProcessor(uniform: string): string;
  129171. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  129172. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  129173. }
  129174. }
  129175. declare module BABYLON {
  129176. /**
  129177. * Class used to inline functions in shader code
  129178. */
  129179. export class ShaderCodeInliner {
  129180. private static readonly _RegexpFindFunctionNameAndType;
  129181. private _sourceCode;
  129182. private _functionDescr;
  129183. private _numMaxIterations;
  129184. /** Gets or sets the token used to mark the functions to inline */
  129185. inlineToken: string;
  129186. /** Gets or sets the debug mode */
  129187. debug: boolean;
  129188. /** Gets the code after the inlining process */
  129189. get code(): string;
  129190. /**
  129191. * Initializes the inliner
  129192. * @param sourceCode shader code source to inline
  129193. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  129194. */
  129195. constructor(sourceCode: string, numMaxIterations?: number);
  129196. /**
  129197. * Start the processing of the shader code
  129198. */
  129199. processCode(): void;
  129200. private _collectFunctions;
  129201. private _processInlining;
  129202. private _extractBetweenMarkers;
  129203. private _skipWhitespaces;
  129204. private _removeComments;
  129205. private _replaceFunctionCallsByCode;
  129206. private _findBackward;
  129207. private _escapeRegExp;
  129208. private _replaceNames;
  129209. }
  129210. }
  129211. declare module BABYLON {
  129212. /**
  129213. * Container for accessors for natively-stored mesh data buffers.
  129214. */
  129215. class NativeDataBuffer extends DataBuffer {
  129216. /**
  129217. * Accessor value used to identify/retrieve a natively-stored index buffer.
  129218. */
  129219. nativeIndexBuffer?: any;
  129220. /**
  129221. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  129222. */
  129223. nativeVertexBuffer?: any;
  129224. }
  129225. /** @hidden */
  129226. class NativeTexture extends InternalTexture {
  129227. getInternalTexture(): InternalTexture;
  129228. getViewCount(): number;
  129229. }
  129230. /** @hidden */
  129231. export class NativeEngine extends Engine {
  129232. private readonly _native;
  129233. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  129234. private readonly INVALID_HANDLE;
  129235. getHardwareScalingLevel(): number;
  129236. constructor();
  129237. dispose(): void;
  129238. /**
  129239. * Can be used to override the current requestAnimationFrame requester.
  129240. * @hidden
  129241. */
  129242. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  129243. /**
  129244. * Override default engine behavior.
  129245. * @param color
  129246. * @param backBuffer
  129247. * @param depth
  129248. * @param stencil
  129249. */
  129250. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  129251. /**
  129252. * Gets host document
  129253. * @returns the host document object
  129254. */
  129255. getHostDocument(): Nullable<Document>;
  129256. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  129257. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  129258. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  129259. recordVertexArrayObject(vertexBuffers: {
  129260. [key: string]: VertexBuffer;
  129261. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  129262. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  129263. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  129264. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  129265. /**
  129266. * Draw a list of indexed primitives
  129267. * @param fillMode defines the primitive to use
  129268. * @param indexStart defines the starting index
  129269. * @param indexCount defines the number of index to draw
  129270. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129271. */
  129272. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  129273. /**
  129274. * Draw a list of unindexed primitives
  129275. * @param fillMode defines the primitive to use
  129276. * @param verticesStart defines the index of first vertex to draw
  129277. * @param verticesCount defines the count of vertices to draw
  129278. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129279. */
  129280. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  129281. createPipelineContext(): IPipelineContext;
  129282. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  129283. /** @hidden */
  129284. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  129285. /** @hidden */
  129286. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  129287. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  129288. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  129289. protected _setProgram(program: WebGLProgram): void;
  129290. _releaseEffect(effect: Effect): void;
  129291. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  129292. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  129293. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  129294. bindSamplers(effect: Effect): void;
  129295. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  129296. getRenderWidth(useScreen?: boolean): number;
  129297. getRenderHeight(useScreen?: boolean): number;
  129298. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  129299. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  129300. /**
  129301. * Set the z offset to apply to current rendering
  129302. * @param value defines the offset to apply
  129303. */
  129304. setZOffset(value: number): void;
  129305. /**
  129306. * Gets the current value of the zOffset
  129307. * @returns the current zOffset state
  129308. */
  129309. getZOffset(): number;
  129310. /**
  129311. * Enable or disable depth buffering
  129312. * @param enable defines the state to set
  129313. */
  129314. setDepthBuffer(enable: boolean): void;
  129315. /**
  129316. * Gets a boolean indicating if depth writing is enabled
  129317. * @returns the current depth writing state
  129318. */
  129319. getDepthWrite(): boolean;
  129320. /**
  129321. * Enable or disable depth writing
  129322. * @param enable defines the state to set
  129323. */
  129324. setDepthWrite(enable: boolean): void;
  129325. /**
  129326. * Enable or disable color writing
  129327. * @param enable defines the state to set
  129328. */
  129329. setColorWrite(enable: boolean): void;
  129330. /**
  129331. * Gets a boolean indicating if color writing is enabled
  129332. * @returns the current color writing state
  129333. */
  129334. getColorWrite(): boolean;
  129335. /**
  129336. * Sets alpha constants used by some alpha blending modes
  129337. * @param r defines the red component
  129338. * @param g defines the green component
  129339. * @param b defines the blue component
  129340. * @param a defines the alpha component
  129341. */
  129342. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  129343. /**
  129344. * Sets the current alpha mode
  129345. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  129346. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  129347. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  129348. */
  129349. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  129350. /**
  129351. * Gets the current alpha mode
  129352. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  129353. * @returns the current alpha mode
  129354. */
  129355. getAlphaMode(): number;
  129356. setInt(uniform: WebGLUniformLocation, int: number): void;
  129357. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  129358. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  129359. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  129360. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  129361. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  129362. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  129363. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  129364. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  129365. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  129366. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  129367. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  129368. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  129369. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  129370. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  129371. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  129372. setFloat(uniform: WebGLUniformLocation, value: number): void;
  129373. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  129374. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  129375. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  129376. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  129377. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  129378. wipeCaches(bruteForce?: boolean): void;
  129379. _createTexture(): WebGLTexture;
  129380. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  129381. /**
  129382. * Usually called from Texture.ts.
  129383. * Passed information to create a WebGLTexture
  129384. * @param url defines a value which contains one of the following:
  129385. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  129386. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  129387. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  129388. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  129389. * @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)
  129390. * @param scene needed for loading to the correct scene
  129391. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  129392. * @param onLoad optional callback to be called upon successful completion
  129393. * @param onError optional callback to be called upon failure
  129394. * @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
  129395. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  129396. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  129397. * @param forcedExtension defines the extension to use to pick the right loader
  129398. * @param mimeType defines an optional mime type
  129399. * @returns a InternalTexture for assignment back into BABYLON.Texture
  129400. */
  129401. 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;
  129402. /**
  129403. * Creates a cube texture
  129404. * @param rootUrl defines the url where the files to load is located
  129405. * @param scene defines the current scene
  129406. * @param files defines the list of files to load (1 per face)
  129407. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  129408. * @param onLoad defines an optional callback raised when the texture is loaded
  129409. * @param onError defines an optional callback raised if there is an issue to load the texture
  129410. * @param format defines the format of the data
  129411. * @param forcedExtension defines the extension to use to pick the right loader
  129412. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  129413. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129414. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129415. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  129416. * @returns the cube texture as an InternalTexture
  129417. */
  129418. 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;
  129419. private _getSamplingFilter;
  129420. private static _GetNativeTextureFormat;
  129421. createRenderTargetTexture(size: number | {
  129422. width: number;
  129423. height: number;
  129424. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  129425. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  129426. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  129427. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  129428. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  129429. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  129430. /**
  129431. * Updates a dynamic vertex buffer.
  129432. * @param vertexBuffer the vertex buffer to update
  129433. * @param data the data used to update the vertex buffer
  129434. * @param byteOffset the byte offset of the data (optional)
  129435. * @param byteLength the byte length of the data (optional)
  129436. */
  129437. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  129438. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  129439. private _updateAnisotropicLevel;
  129440. private _getAddressMode;
  129441. /** @hidden */
  129442. _bindTexture(channel: number, texture: InternalTexture): void;
  129443. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  129444. releaseEffects(): void;
  129445. /** @hidden */
  129446. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129447. /** @hidden */
  129448. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129449. /** @hidden */
  129450. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129451. /** @hidden */
  129452. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  129453. }
  129454. }
  129455. declare module BABYLON {
  129456. /**
  129457. * Gather the list of clipboard event types as constants.
  129458. */
  129459. export class ClipboardEventTypes {
  129460. /**
  129461. * The clipboard event is fired when a copy command is active (pressed).
  129462. */
  129463. static readonly COPY: number;
  129464. /**
  129465. * The clipboard event is fired when a cut command is active (pressed).
  129466. */
  129467. static readonly CUT: number;
  129468. /**
  129469. * The clipboard event is fired when a paste command is active (pressed).
  129470. */
  129471. static readonly PASTE: number;
  129472. }
  129473. /**
  129474. * This class is used to store clipboard related info for the onClipboardObservable event.
  129475. */
  129476. export class ClipboardInfo {
  129477. /**
  129478. * Defines the type of event (BABYLON.ClipboardEventTypes)
  129479. */
  129480. type: number;
  129481. /**
  129482. * Defines the related dom event
  129483. */
  129484. event: ClipboardEvent;
  129485. /**
  129486. *Creates an instance of ClipboardInfo.
  129487. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  129488. * @param event Defines the related dom event
  129489. */
  129490. constructor(
  129491. /**
  129492. * Defines the type of event (BABYLON.ClipboardEventTypes)
  129493. */
  129494. type: number,
  129495. /**
  129496. * Defines the related dom event
  129497. */
  129498. event: ClipboardEvent);
  129499. /**
  129500. * Get the clipboard event's type from the keycode.
  129501. * @param keyCode Defines the keyCode for the current keyboard event.
  129502. * @return {number}
  129503. */
  129504. static GetTypeFromCharacter(keyCode: number): number;
  129505. }
  129506. }
  129507. declare module BABYLON {
  129508. /**
  129509. * Google Daydream controller
  129510. */
  129511. export class DaydreamController extends WebVRController {
  129512. /**
  129513. * Base Url for the controller model.
  129514. */
  129515. static MODEL_BASE_URL: string;
  129516. /**
  129517. * File name for the controller model.
  129518. */
  129519. static MODEL_FILENAME: string;
  129520. /**
  129521. * Gamepad Id prefix used to identify Daydream Controller.
  129522. */
  129523. static readonly GAMEPAD_ID_PREFIX: string;
  129524. /**
  129525. * Creates a new DaydreamController from a gamepad
  129526. * @param vrGamepad the gamepad that the controller should be created from
  129527. */
  129528. constructor(vrGamepad: any);
  129529. /**
  129530. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129531. * @param scene scene in which to add meshes
  129532. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129533. */
  129534. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129535. /**
  129536. * Called once for each button that changed state since the last frame
  129537. * @param buttonIdx Which button index changed
  129538. * @param state New state of the button
  129539. * @param changes Which properties on the state changed since last frame
  129540. */
  129541. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129542. }
  129543. }
  129544. declare module BABYLON {
  129545. /**
  129546. * Gear VR Controller
  129547. */
  129548. export class GearVRController extends WebVRController {
  129549. /**
  129550. * Base Url for the controller model.
  129551. */
  129552. static MODEL_BASE_URL: string;
  129553. /**
  129554. * File name for the controller model.
  129555. */
  129556. static MODEL_FILENAME: string;
  129557. /**
  129558. * Gamepad Id prefix used to identify this controller.
  129559. */
  129560. static readonly GAMEPAD_ID_PREFIX: string;
  129561. private readonly _buttonIndexToObservableNameMap;
  129562. /**
  129563. * Creates a new GearVRController from a gamepad
  129564. * @param vrGamepad the gamepad that the controller should be created from
  129565. */
  129566. constructor(vrGamepad: any);
  129567. /**
  129568. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129569. * @param scene scene in which to add meshes
  129570. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129571. */
  129572. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129573. /**
  129574. * Called once for each button that changed state since the last frame
  129575. * @param buttonIdx Which button index changed
  129576. * @param state New state of the button
  129577. * @param changes Which properties on the state changed since last frame
  129578. */
  129579. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129580. }
  129581. }
  129582. declare module BABYLON {
  129583. /**
  129584. * Generic Controller
  129585. */
  129586. export class GenericController extends WebVRController {
  129587. /**
  129588. * Base Url for the controller model.
  129589. */
  129590. static readonly MODEL_BASE_URL: string;
  129591. /**
  129592. * File name for the controller model.
  129593. */
  129594. static readonly MODEL_FILENAME: string;
  129595. /**
  129596. * Creates a new GenericController from a gamepad
  129597. * @param vrGamepad the gamepad that the controller should be created from
  129598. */
  129599. constructor(vrGamepad: any);
  129600. /**
  129601. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129602. * @param scene scene in which to add meshes
  129603. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129604. */
  129605. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129606. /**
  129607. * Called once for each button that changed state since the last frame
  129608. * @param buttonIdx Which button index changed
  129609. * @param state New state of the button
  129610. * @param changes Which properties on the state changed since last frame
  129611. */
  129612. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129613. }
  129614. }
  129615. declare module BABYLON {
  129616. /**
  129617. * Oculus Touch Controller
  129618. */
  129619. export class OculusTouchController extends WebVRController {
  129620. /**
  129621. * Base Url for the controller model.
  129622. */
  129623. static MODEL_BASE_URL: string;
  129624. /**
  129625. * File name for the left controller model.
  129626. */
  129627. static MODEL_LEFT_FILENAME: string;
  129628. /**
  129629. * File name for the right controller model.
  129630. */
  129631. static MODEL_RIGHT_FILENAME: string;
  129632. /**
  129633. * Base Url for the Quest controller model.
  129634. */
  129635. static QUEST_MODEL_BASE_URL: string;
  129636. /**
  129637. * @hidden
  129638. * If the controllers are running on a device that needs the updated Quest controller models
  129639. */
  129640. static _IsQuest: boolean;
  129641. /**
  129642. * Fired when the secondary trigger on this controller is modified
  129643. */
  129644. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  129645. /**
  129646. * Fired when the thumb rest on this controller is modified
  129647. */
  129648. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  129649. /**
  129650. * Creates a new OculusTouchController from a gamepad
  129651. * @param vrGamepad the gamepad that the controller should be created from
  129652. */
  129653. constructor(vrGamepad: any);
  129654. /**
  129655. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129656. * @param scene scene in which to add meshes
  129657. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129658. */
  129659. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129660. /**
  129661. * Fired when the A button on this controller is modified
  129662. */
  129663. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129664. /**
  129665. * Fired when the B button on this controller is modified
  129666. */
  129667. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129668. /**
  129669. * Fired when the X button on this controller is modified
  129670. */
  129671. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129672. /**
  129673. * Fired when the Y button on this controller is modified
  129674. */
  129675. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129676. /**
  129677. * Called once for each button that changed state since the last frame
  129678. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  129679. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  129680. * 2) secondary trigger (same)
  129681. * 3) A (right) X (left), touch, pressed = value
  129682. * 4) B / Y
  129683. * 5) thumb rest
  129684. * @param buttonIdx Which button index changed
  129685. * @param state New state of the button
  129686. * @param changes Which properties on the state changed since last frame
  129687. */
  129688. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129689. }
  129690. }
  129691. declare module BABYLON {
  129692. /**
  129693. * Vive Controller
  129694. */
  129695. export class ViveController extends WebVRController {
  129696. /**
  129697. * Base Url for the controller model.
  129698. */
  129699. static MODEL_BASE_URL: string;
  129700. /**
  129701. * File name for the controller model.
  129702. */
  129703. static MODEL_FILENAME: string;
  129704. /**
  129705. * Creates a new ViveController from a gamepad
  129706. * @param vrGamepad the gamepad that the controller should be created from
  129707. */
  129708. constructor(vrGamepad: any);
  129709. /**
  129710. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129711. * @param scene scene in which to add meshes
  129712. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129713. */
  129714. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129715. /**
  129716. * Fired when the left button on this controller is modified
  129717. */
  129718. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129719. /**
  129720. * Fired when the right button on this controller is modified
  129721. */
  129722. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129723. /**
  129724. * Fired when the menu button on this controller is modified
  129725. */
  129726. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129727. /**
  129728. * Called once for each button that changed state since the last frame
  129729. * Vive mapping:
  129730. * 0: touchpad
  129731. * 1: trigger
  129732. * 2: left AND right buttons
  129733. * 3: menu button
  129734. * @param buttonIdx Which button index changed
  129735. * @param state New state of the button
  129736. * @param changes Which properties on the state changed since last frame
  129737. */
  129738. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129739. }
  129740. }
  129741. declare module BABYLON {
  129742. /**
  129743. * Defines the WindowsMotionController object that the state of the windows motion controller
  129744. */
  129745. export class WindowsMotionController extends WebVRController {
  129746. /**
  129747. * The base url used to load the left and right controller models
  129748. */
  129749. static MODEL_BASE_URL: string;
  129750. /**
  129751. * The name of the left controller model file
  129752. */
  129753. static MODEL_LEFT_FILENAME: string;
  129754. /**
  129755. * The name of the right controller model file
  129756. */
  129757. static MODEL_RIGHT_FILENAME: string;
  129758. /**
  129759. * The controller name prefix for this controller type
  129760. */
  129761. static readonly GAMEPAD_ID_PREFIX: string;
  129762. /**
  129763. * The controller id pattern for this controller type
  129764. */
  129765. private static readonly GAMEPAD_ID_PATTERN;
  129766. private _loadedMeshInfo;
  129767. protected readonly _mapping: {
  129768. buttons: string[];
  129769. buttonMeshNames: {
  129770. trigger: string;
  129771. menu: string;
  129772. grip: string;
  129773. thumbstick: string;
  129774. trackpad: string;
  129775. };
  129776. buttonObservableNames: {
  129777. trigger: string;
  129778. menu: string;
  129779. grip: string;
  129780. thumbstick: string;
  129781. trackpad: string;
  129782. };
  129783. axisMeshNames: string[];
  129784. pointingPoseMeshName: string;
  129785. };
  129786. /**
  129787. * Fired when the trackpad on this controller is clicked
  129788. */
  129789. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  129790. /**
  129791. * Fired when the trackpad on this controller is modified
  129792. */
  129793. onTrackpadValuesChangedObservable: Observable<StickValues>;
  129794. /**
  129795. * The current x and y values of this controller's trackpad
  129796. */
  129797. trackpad: StickValues;
  129798. /**
  129799. * Creates a new WindowsMotionController from a gamepad
  129800. * @param vrGamepad the gamepad that the controller should be created from
  129801. */
  129802. constructor(vrGamepad: any);
  129803. /**
  129804. * Fired when the trigger on this controller is modified
  129805. */
  129806. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129807. /**
  129808. * Fired when the menu button on this controller is modified
  129809. */
  129810. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129811. /**
  129812. * Fired when the grip button on this controller is modified
  129813. */
  129814. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129815. /**
  129816. * Fired when the thumbstick button on this controller is modified
  129817. */
  129818. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129819. /**
  129820. * Fired when the touchpad button on this controller is modified
  129821. */
  129822. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129823. /**
  129824. * Fired when the touchpad values on this controller are modified
  129825. */
  129826. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  129827. protected _updateTrackpad(): void;
  129828. /**
  129829. * Called once per frame by the engine.
  129830. */
  129831. update(): void;
  129832. /**
  129833. * Called once for each button that changed state since the last frame
  129834. * @param buttonIdx Which button index changed
  129835. * @param state New state of the button
  129836. * @param changes Which properties on the state changed since last frame
  129837. */
  129838. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129839. /**
  129840. * Moves the buttons on the controller mesh based on their current state
  129841. * @param buttonName the name of the button to move
  129842. * @param buttonValue the value of the button which determines the buttons new position
  129843. */
  129844. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  129845. /**
  129846. * Moves the axis on the controller mesh based on its current state
  129847. * @param axis the index of the axis
  129848. * @param axisValue the value of the axis which determines the meshes new position
  129849. * @hidden
  129850. */
  129851. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  129852. /**
  129853. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129854. * @param scene scene in which to add meshes
  129855. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129856. */
  129857. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  129858. /**
  129859. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  129860. * can be transformed by button presses and axes values, based on this._mapping.
  129861. *
  129862. * @param scene scene in which the meshes exist
  129863. * @param meshes list of meshes that make up the controller model to process
  129864. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  129865. */
  129866. private processModel;
  129867. private createMeshInfo;
  129868. /**
  129869. * Gets the ray of the controller in the direction the controller is pointing
  129870. * @param length the length the resulting ray should be
  129871. * @returns a ray in the direction the controller is pointing
  129872. */
  129873. getForwardRay(length?: number): Ray;
  129874. /**
  129875. * Disposes of the controller
  129876. */
  129877. dispose(): void;
  129878. }
  129879. /**
  129880. * This class represents a new windows motion controller in XR.
  129881. */
  129882. export class XRWindowsMotionController extends WindowsMotionController {
  129883. /**
  129884. * Changing the original WIndowsMotionController mapping to fir the new mapping
  129885. */
  129886. protected readonly _mapping: {
  129887. buttons: string[];
  129888. buttonMeshNames: {
  129889. trigger: string;
  129890. menu: string;
  129891. grip: string;
  129892. thumbstick: string;
  129893. trackpad: string;
  129894. };
  129895. buttonObservableNames: {
  129896. trigger: string;
  129897. menu: string;
  129898. grip: string;
  129899. thumbstick: string;
  129900. trackpad: string;
  129901. };
  129902. axisMeshNames: string[];
  129903. pointingPoseMeshName: string;
  129904. };
  129905. /**
  129906. * Construct a new XR-Based windows motion controller
  129907. *
  129908. * @param gamepadInfo the gamepad object from the browser
  129909. */
  129910. constructor(gamepadInfo: any);
  129911. /**
  129912. * holds the thumbstick values (X,Y)
  129913. */
  129914. thumbstickValues: StickValues;
  129915. /**
  129916. * Fired when the thumbstick on this controller is clicked
  129917. */
  129918. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  129919. /**
  129920. * Fired when the thumbstick on this controller is modified
  129921. */
  129922. onThumbstickValuesChangedObservable: Observable<StickValues>;
  129923. /**
  129924. * Fired when the touchpad button on this controller is modified
  129925. */
  129926. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  129927. /**
  129928. * Fired when the touchpad values on this controller are modified
  129929. */
  129930. onTrackpadValuesChangedObservable: Observable<StickValues>;
  129931. /**
  129932. * Fired when the thumbstick button on this controller is modified
  129933. * here to prevent breaking changes
  129934. */
  129935. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129936. /**
  129937. * updating the thumbstick(!) and not the trackpad.
  129938. * This is named this way due to the difference between WebVR and XR and to avoid
  129939. * changing the parent class.
  129940. */
  129941. protected _updateTrackpad(): void;
  129942. /**
  129943. * Disposes the class with joy
  129944. */
  129945. dispose(): void;
  129946. }
  129947. }
  129948. declare module BABYLON {
  129949. /**
  129950. * Class containing static functions to help procedurally build meshes
  129951. */
  129952. export class PolyhedronBuilder {
  129953. /**
  129954. * Creates a polyhedron mesh
  129955. * * 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
  129956. * * The parameter `size` (positive float, default 1) sets the polygon size
  129957. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  129958. * * 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`
  129959. * * 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
  129960. * * 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)`)
  129961. * * 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
  129962. * * 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
  129963. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129964. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129966. * @param name defines the name of the mesh
  129967. * @param options defines the options used to create the mesh
  129968. * @param scene defines the hosting scene
  129969. * @returns the polyhedron mesh
  129970. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  129971. */
  129972. static CreatePolyhedron(name: string, options: {
  129973. type?: number;
  129974. size?: number;
  129975. sizeX?: number;
  129976. sizeY?: number;
  129977. sizeZ?: number;
  129978. custom?: any;
  129979. faceUV?: Vector4[];
  129980. faceColors?: Color4[];
  129981. flat?: boolean;
  129982. updatable?: boolean;
  129983. sideOrientation?: number;
  129984. frontUVs?: Vector4;
  129985. backUVs?: Vector4;
  129986. }, scene?: Nullable<Scene>): Mesh;
  129987. }
  129988. }
  129989. declare module BABYLON {
  129990. /**
  129991. * Gizmo that enables scaling a mesh along 3 axis
  129992. */
  129993. export class ScaleGizmo extends Gizmo {
  129994. /**
  129995. * Internal gizmo used for interactions on the x axis
  129996. */
  129997. xGizmo: AxisScaleGizmo;
  129998. /**
  129999. * Internal gizmo used for interactions on the y axis
  130000. */
  130001. yGizmo: AxisScaleGizmo;
  130002. /**
  130003. * Internal gizmo used for interactions on the z axis
  130004. */
  130005. zGizmo: AxisScaleGizmo;
  130006. /**
  130007. * Internal gizmo used to scale all axis equally
  130008. */
  130009. uniformScaleGizmo: AxisScaleGizmo;
  130010. private _meshAttached;
  130011. private _updateGizmoRotationToMatchAttachedMesh;
  130012. private _snapDistance;
  130013. private _scaleRatio;
  130014. private _uniformScalingMesh;
  130015. private _octahedron;
  130016. private _sensitivity;
  130017. /** Fires an event when any of it's sub gizmos are dragged */
  130018. onDragStartObservable: Observable<unknown>;
  130019. /** Fires an event when any of it's sub gizmos are released from dragging */
  130020. onDragEndObservable: Observable<unknown>;
  130021. get attachedMesh(): Nullable<AbstractMesh>;
  130022. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130023. /**
  130024. * Creates a ScaleGizmo
  130025. * @param gizmoLayer The utility layer the gizmo will be added to
  130026. */
  130027. constructor(gizmoLayer?: UtilityLayerRenderer);
  130028. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130029. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130030. /**
  130031. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130032. */
  130033. set snapDistance(value: number);
  130034. get snapDistance(): number;
  130035. /**
  130036. * Ratio for the scale of the gizmo (Default: 1)
  130037. */
  130038. set scaleRatio(value: number);
  130039. get scaleRatio(): number;
  130040. /**
  130041. * Sensitivity factor for dragging (Default: 1)
  130042. */
  130043. set sensitivity(value: number);
  130044. get sensitivity(): number;
  130045. /**
  130046. * Disposes of the gizmo
  130047. */
  130048. dispose(): void;
  130049. }
  130050. }
  130051. declare module BABYLON {
  130052. /**
  130053. * Single axis scale gizmo
  130054. */
  130055. export class AxisScaleGizmo extends Gizmo {
  130056. /**
  130057. * Drag behavior responsible for the gizmos dragging interactions
  130058. */
  130059. dragBehavior: PointerDragBehavior;
  130060. private _pointerObserver;
  130061. /**
  130062. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130063. */
  130064. snapDistance: number;
  130065. /**
  130066. * Event that fires each time the gizmo snaps to a new location.
  130067. * * snapDistance is the the change in distance
  130068. */
  130069. onSnapObservable: Observable<{
  130070. snapDistance: number;
  130071. }>;
  130072. /**
  130073. * If the scaling operation should be done on all axis (default: false)
  130074. */
  130075. uniformScaling: boolean;
  130076. /**
  130077. * Custom sensitivity value for the drag strength
  130078. */
  130079. sensitivity: number;
  130080. private _isEnabled;
  130081. private _parent;
  130082. private _arrow;
  130083. private _coloredMaterial;
  130084. private _hoverMaterial;
  130085. /**
  130086. * Creates an AxisScaleGizmo
  130087. * @param gizmoLayer The utility layer the gizmo will be added to
  130088. * @param dragAxis The axis which the gizmo will be able to scale on
  130089. * @param color The color of the gizmo
  130090. */
  130091. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  130092. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130093. /**
  130094. * If the gizmo is enabled
  130095. */
  130096. set isEnabled(value: boolean);
  130097. get isEnabled(): boolean;
  130098. /**
  130099. * Disposes of the gizmo
  130100. */
  130101. dispose(): void;
  130102. /**
  130103. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  130104. * @param mesh The mesh to replace the default mesh of the gizmo
  130105. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  130106. */
  130107. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  130108. }
  130109. }
  130110. declare module BABYLON {
  130111. /**
  130112. * Bounding box gizmo
  130113. */
  130114. export class BoundingBoxGizmo extends Gizmo {
  130115. private _lineBoundingBox;
  130116. private _rotateSpheresParent;
  130117. private _scaleBoxesParent;
  130118. private _boundingDimensions;
  130119. private _renderObserver;
  130120. private _pointerObserver;
  130121. private _scaleDragSpeed;
  130122. private _tmpQuaternion;
  130123. private _tmpVector;
  130124. private _tmpRotationMatrix;
  130125. /**
  130126. * 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)
  130127. */
  130128. ignoreChildren: boolean;
  130129. /**
  130130. * 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)
  130131. */
  130132. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  130133. /**
  130134. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  130135. */
  130136. rotationSphereSize: number;
  130137. /**
  130138. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  130139. */
  130140. scaleBoxSize: number;
  130141. /**
  130142. * 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)
  130143. */
  130144. fixedDragMeshScreenSize: boolean;
  130145. /**
  130146. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  130147. */
  130148. fixedDragMeshScreenSizeDistanceFactor: number;
  130149. /**
  130150. * Fired when a rotation sphere or scale box is dragged
  130151. */
  130152. onDragStartObservable: Observable<{}>;
  130153. /**
  130154. * Fired when a scale box is dragged
  130155. */
  130156. onScaleBoxDragObservable: Observable<{}>;
  130157. /**
  130158. * Fired when a scale box drag is ended
  130159. */
  130160. onScaleBoxDragEndObservable: Observable<{}>;
  130161. /**
  130162. * Fired when a rotation sphere is dragged
  130163. */
  130164. onRotationSphereDragObservable: Observable<{}>;
  130165. /**
  130166. * Fired when a rotation sphere drag is ended
  130167. */
  130168. onRotationSphereDragEndObservable: Observable<{}>;
  130169. /**
  130170. * 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)
  130171. */
  130172. scalePivot: Nullable<Vector3>;
  130173. /**
  130174. * Mesh used as a pivot to rotate the attached mesh
  130175. */
  130176. private _anchorMesh;
  130177. private _existingMeshScale;
  130178. private _dragMesh;
  130179. private pointerDragBehavior;
  130180. private coloredMaterial;
  130181. private hoverColoredMaterial;
  130182. /**
  130183. * Sets the color of the bounding box gizmo
  130184. * @param color the color to set
  130185. */
  130186. setColor(color: Color3): void;
  130187. /**
  130188. * Creates an BoundingBoxGizmo
  130189. * @param gizmoLayer The utility layer the gizmo will be added to
  130190. * @param color The color of the gizmo
  130191. */
  130192. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  130193. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130194. private _selectNode;
  130195. /**
  130196. * Updates the bounding box information for the Gizmo
  130197. */
  130198. updateBoundingBox(): void;
  130199. private _updateRotationSpheres;
  130200. private _updateScaleBoxes;
  130201. /**
  130202. * Enables rotation on the specified axis and disables rotation on the others
  130203. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  130204. */
  130205. setEnabledRotationAxis(axis: string): void;
  130206. /**
  130207. * Enables/disables scaling
  130208. * @param enable if scaling should be enabled
  130209. * @param homogeneousScaling defines if scaling should only be homogeneous
  130210. */
  130211. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  130212. private _updateDummy;
  130213. /**
  130214. * Enables a pointer drag behavior on the bounding box of the gizmo
  130215. */
  130216. enableDragBehavior(): void;
  130217. /**
  130218. * Disposes of the gizmo
  130219. */
  130220. dispose(): void;
  130221. /**
  130222. * 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)
  130223. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  130224. * @returns the bounding box mesh with the passed in mesh as a child
  130225. */
  130226. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  130227. /**
  130228. * CustomMeshes are not supported by this gizmo
  130229. * @param mesh The mesh to replace the default mesh of the gizmo
  130230. */
  130231. setCustomMesh(mesh: Mesh): void;
  130232. }
  130233. }
  130234. declare module BABYLON {
  130235. /**
  130236. * Single plane rotation gizmo
  130237. */
  130238. export class PlaneRotationGizmo extends Gizmo {
  130239. /**
  130240. * Drag behavior responsible for the gizmos dragging interactions
  130241. */
  130242. dragBehavior: PointerDragBehavior;
  130243. private _pointerObserver;
  130244. /**
  130245. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  130246. */
  130247. snapDistance: number;
  130248. /**
  130249. * Event that fires each time the gizmo snaps to a new location.
  130250. * * snapDistance is the the change in distance
  130251. */
  130252. onSnapObservable: Observable<{
  130253. snapDistance: number;
  130254. }>;
  130255. private _isEnabled;
  130256. private _parent;
  130257. /**
  130258. * Creates a PlaneRotationGizmo
  130259. * @param gizmoLayer The utility layer the gizmo will be added to
  130260. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  130261. * @param color The color of the gizmo
  130262. * @param tessellation Amount of tessellation to be used when creating rotation circles
  130263. * @param useEulerRotation Use and update Euler angle instead of quaternion
  130264. */
  130265. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  130266. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130267. /**
  130268. * If the gizmo is enabled
  130269. */
  130270. set isEnabled(value: boolean);
  130271. get isEnabled(): boolean;
  130272. /**
  130273. * Disposes of the gizmo
  130274. */
  130275. dispose(): void;
  130276. }
  130277. }
  130278. declare module BABYLON {
  130279. /**
  130280. * Gizmo that enables rotating a mesh along 3 axis
  130281. */
  130282. export class RotationGizmo extends Gizmo {
  130283. /**
  130284. * Internal gizmo used for interactions on the x axis
  130285. */
  130286. xGizmo: PlaneRotationGizmo;
  130287. /**
  130288. * Internal gizmo used for interactions on the y axis
  130289. */
  130290. yGizmo: PlaneRotationGizmo;
  130291. /**
  130292. * Internal gizmo used for interactions on the z axis
  130293. */
  130294. zGizmo: PlaneRotationGizmo;
  130295. /** Fires an event when any of it's sub gizmos are dragged */
  130296. onDragStartObservable: Observable<unknown>;
  130297. /** Fires an event when any of it's sub gizmos are released from dragging */
  130298. onDragEndObservable: Observable<unknown>;
  130299. private _meshAttached;
  130300. get attachedMesh(): Nullable<AbstractMesh>;
  130301. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130302. /**
  130303. * Creates a RotationGizmo
  130304. * @param gizmoLayer The utility layer the gizmo will be added to
  130305. * @param tessellation Amount of tessellation to be used when creating rotation circles
  130306. * @param useEulerRotation Use and update Euler angle instead of quaternion
  130307. */
  130308. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  130309. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130310. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130311. /**
  130312. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130313. */
  130314. set snapDistance(value: number);
  130315. get snapDistance(): number;
  130316. /**
  130317. * Ratio for the scale of the gizmo (Default: 1)
  130318. */
  130319. set scaleRatio(value: number);
  130320. get scaleRatio(): number;
  130321. /**
  130322. * Disposes of the gizmo
  130323. */
  130324. dispose(): void;
  130325. /**
  130326. * CustomMeshes are not supported by this gizmo
  130327. * @param mesh The mesh to replace the default mesh of the gizmo
  130328. */
  130329. setCustomMesh(mesh: Mesh): void;
  130330. }
  130331. }
  130332. declare module BABYLON {
  130333. /**
  130334. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  130335. */
  130336. export class GizmoManager implements IDisposable {
  130337. private scene;
  130338. /**
  130339. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  130340. */
  130341. gizmos: {
  130342. positionGizmo: Nullable<PositionGizmo>;
  130343. rotationGizmo: Nullable<RotationGizmo>;
  130344. scaleGizmo: Nullable<ScaleGizmo>;
  130345. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  130346. };
  130347. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  130348. clearGizmoOnEmptyPointerEvent: boolean;
  130349. /** Fires an event when the manager is attached to a mesh */
  130350. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  130351. private _gizmosEnabled;
  130352. private _pointerObserver;
  130353. private _attachedMesh;
  130354. private _boundingBoxColor;
  130355. private _defaultUtilityLayer;
  130356. private _defaultKeepDepthUtilityLayer;
  130357. /**
  130358. * When bounding box gizmo is enabled, this can be used to track drag/end events
  130359. */
  130360. boundingBoxDragBehavior: SixDofDragBehavior;
  130361. /**
  130362. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  130363. */
  130364. attachableMeshes: Nullable<Array<AbstractMesh>>;
  130365. /**
  130366. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  130367. */
  130368. usePointerToAttachGizmos: boolean;
  130369. /**
  130370. * Utility layer that the bounding box gizmo belongs to
  130371. */
  130372. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  130373. /**
  130374. * Utility layer that all gizmos besides bounding box belong to
  130375. */
  130376. get utilityLayer(): UtilityLayerRenderer;
  130377. /**
  130378. * Instatiates a gizmo manager
  130379. * @param scene the scene to overlay the gizmos on top of
  130380. */
  130381. constructor(scene: Scene);
  130382. /**
  130383. * Attaches a set of gizmos to the specified mesh
  130384. * @param mesh The mesh the gizmo's should be attached to
  130385. */
  130386. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  130387. /**
  130388. * If the position gizmo is enabled
  130389. */
  130390. set positionGizmoEnabled(value: boolean);
  130391. get positionGizmoEnabled(): boolean;
  130392. /**
  130393. * If the rotation gizmo is enabled
  130394. */
  130395. set rotationGizmoEnabled(value: boolean);
  130396. get rotationGizmoEnabled(): boolean;
  130397. /**
  130398. * If the scale gizmo is enabled
  130399. */
  130400. set scaleGizmoEnabled(value: boolean);
  130401. get scaleGizmoEnabled(): boolean;
  130402. /**
  130403. * If the boundingBox gizmo is enabled
  130404. */
  130405. set boundingBoxGizmoEnabled(value: boolean);
  130406. get boundingBoxGizmoEnabled(): boolean;
  130407. /**
  130408. * Disposes of the gizmo manager
  130409. */
  130410. dispose(): void;
  130411. }
  130412. }
  130413. declare module BABYLON {
  130414. /**
  130415. * A directional light is defined by a direction (what a surprise!).
  130416. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  130417. * 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.
  130418. * Documentation: https://doc.babylonjs.com/babylon101/lights
  130419. */
  130420. export class DirectionalLight extends ShadowLight {
  130421. private _shadowFrustumSize;
  130422. /**
  130423. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  130424. */
  130425. get shadowFrustumSize(): number;
  130426. /**
  130427. * Specifies a fix frustum size for the shadow generation.
  130428. */
  130429. set shadowFrustumSize(value: number);
  130430. private _shadowOrthoScale;
  130431. /**
  130432. * Gets the shadow projection scale against the optimal computed one.
  130433. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  130434. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  130435. */
  130436. get shadowOrthoScale(): number;
  130437. /**
  130438. * Sets the shadow projection scale against the optimal computed one.
  130439. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  130440. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  130441. */
  130442. set shadowOrthoScale(value: number);
  130443. /**
  130444. * Automatically compute the projection matrix to best fit (including all the casters)
  130445. * on each frame.
  130446. */
  130447. autoUpdateExtends: boolean;
  130448. /**
  130449. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  130450. * on each frame. autoUpdateExtends must be set to true for this to work
  130451. */
  130452. autoCalcShadowZBounds: boolean;
  130453. private _orthoLeft;
  130454. private _orthoRight;
  130455. private _orthoTop;
  130456. private _orthoBottom;
  130457. /**
  130458. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  130459. * The directional light is emitted from everywhere in the given direction.
  130460. * It can cast shadows.
  130461. * Documentation : https://doc.babylonjs.com/babylon101/lights
  130462. * @param name The friendly name of the light
  130463. * @param direction The direction of the light
  130464. * @param scene The scene the light belongs to
  130465. */
  130466. constructor(name: string, direction: Vector3, scene: Scene);
  130467. /**
  130468. * Returns the string "DirectionalLight".
  130469. * @return The class name
  130470. */
  130471. getClassName(): string;
  130472. /**
  130473. * Returns the integer 1.
  130474. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  130475. */
  130476. getTypeID(): number;
  130477. /**
  130478. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  130479. * Returns the DirectionalLight Shadow projection matrix.
  130480. */
  130481. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  130482. /**
  130483. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  130484. * Returns the DirectionalLight Shadow projection matrix.
  130485. */
  130486. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  130487. /**
  130488. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  130489. * Returns the DirectionalLight Shadow projection matrix.
  130490. */
  130491. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  130492. protected _buildUniformLayout(): void;
  130493. /**
  130494. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  130495. * @param effect The effect to update
  130496. * @param lightIndex The index of the light in the effect to update
  130497. * @returns The directional light
  130498. */
  130499. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  130500. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  130501. /**
  130502. * Gets the minZ used for shadow according to both the scene and the light.
  130503. *
  130504. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  130505. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  130506. * @param activeCamera The camera we are returning the min for
  130507. * @returns the depth min z
  130508. */
  130509. getDepthMinZ(activeCamera: Camera): number;
  130510. /**
  130511. * Gets the maxZ used for shadow according to both the scene and the light.
  130512. *
  130513. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  130514. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  130515. * @param activeCamera The camera we are returning the max for
  130516. * @returns the depth max z
  130517. */
  130518. getDepthMaxZ(activeCamera: Camera): number;
  130519. /**
  130520. * Prepares the list of defines specific to the light type.
  130521. * @param defines the list of defines
  130522. * @param lightIndex defines the index of the light for the effect
  130523. */
  130524. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  130525. }
  130526. }
  130527. declare module BABYLON {
  130528. /**
  130529. * Class containing static functions to help procedurally build meshes
  130530. */
  130531. export class HemisphereBuilder {
  130532. /**
  130533. * Creates a hemisphere mesh
  130534. * @param name defines the name of the mesh
  130535. * @param options defines the options used to create the mesh
  130536. * @param scene defines the hosting scene
  130537. * @returns the hemisphere mesh
  130538. */
  130539. static CreateHemisphere(name: string, options: {
  130540. segments?: number;
  130541. diameter?: number;
  130542. sideOrientation?: number;
  130543. }, scene: any): Mesh;
  130544. }
  130545. }
  130546. declare module BABYLON {
  130547. /**
  130548. * A spot light is defined by a position, a direction, an angle, and an exponent.
  130549. * These values define a cone of light starting from the position, emitting toward the direction.
  130550. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  130551. * and the exponent defines the speed of the decay of the light with distance (reach).
  130552. * Documentation: https://doc.babylonjs.com/babylon101/lights
  130553. */
  130554. export class SpotLight extends ShadowLight {
  130555. private _angle;
  130556. private _innerAngle;
  130557. private _cosHalfAngle;
  130558. private _lightAngleScale;
  130559. private _lightAngleOffset;
  130560. /**
  130561. * Gets the cone angle of the spot light in Radians.
  130562. */
  130563. get angle(): number;
  130564. /**
  130565. * Sets the cone angle of the spot light in Radians.
  130566. */
  130567. set angle(value: number);
  130568. /**
  130569. * Only used in gltf falloff mode, this defines the angle where
  130570. * the directional falloff will start before cutting at angle which could be seen
  130571. * as outer angle.
  130572. */
  130573. get innerAngle(): number;
  130574. /**
  130575. * Only used in gltf falloff mode, this defines the angle where
  130576. * the directional falloff will start before cutting at angle which could be seen
  130577. * as outer angle.
  130578. */
  130579. set innerAngle(value: number);
  130580. private _shadowAngleScale;
  130581. /**
  130582. * Allows scaling the angle of the light for shadow generation only.
  130583. */
  130584. get shadowAngleScale(): number;
  130585. /**
  130586. * Allows scaling the angle of the light for shadow generation only.
  130587. */
  130588. set shadowAngleScale(value: number);
  130589. /**
  130590. * The light decay speed with the distance from the emission spot.
  130591. */
  130592. exponent: number;
  130593. private _projectionTextureMatrix;
  130594. /**
  130595. * Allows reading the projecton texture
  130596. */
  130597. get projectionTextureMatrix(): Matrix;
  130598. protected _projectionTextureLightNear: number;
  130599. /**
  130600. * Gets the near clip of the Spotlight for texture projection.
  130601. */
  130602. get projectionTextureLightNear(): number;
  130603. /**
  130604. * Sets the near clip of the Spotlight for texture projection.
  130605. */
  130606. set projectionTextureLightNear(value: number);
  130607. protected _projectionTextureLightFar: number;
  130608. /**
  130609. * Gets the far clip of the Spotlight for texture projection.
  130610. */
  130611. get projectionTextureLightFar(): number;
  130612. /**
  130613. * Sets the far clip of the Spotlight for texture projection.
  130614. */
  130615. set projectionTextureLightFar(value: number);
  130616. protected _projectionTextureUpDirection: Vector3;
  130617. /**
  130618. * Gets the Up vector of the Spotlight for texture projection.
  130619. */
  130620. get projectionTextureUpDirection(): Vector3;
  130621. /**
  130622. * Sets the Up vector of the Spotlight for texture projection.
  130623. */
  130624. set projectionTextureUpDirection(value: Vector3);
  130625. private _projectionTexture;
  130626. /**
  130627. * Gets the projection texture of the light.
  130628. */
  130629. get projectionTexture(): Nullable<BaseTexture>;
  130630. /**
  130631. * Sets the projection texture of the light.
  130632. */
  130633. set projectionTexture(value: Nullable<BaseTexture>);
  130634. private _projectionTextureViewLightDirty;
  130635. private _projectionTextureProjectionLightDirty;
  130636. private _projectionTextureDirty;
  130637. private _projectionTextureViewTargetVector;
  130638. private _projectionTextureViewLightMatrix;
  130639. private _projectionTextureProjectionLightMatrix;
  130640. private _projectionTextureScalingMatrix;
  130641. /**
  130642. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  130643. * It can cast shadows.
  130644. * Documentation : https://doc.babylonjs.com/babylon101/lights
  130645. * @param name The light friendly name
  130646. * @param position The position of the spot light in the scene
  130647. * @param direction The direction of the light in the scene
  130648. * @param angle The cone angle of the light in Radians
  130649. * @param exponent The light decay speed with the distance from the emission spot
  130650. * @param scene The scene the lights belongs to
  130651. */
  130652. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  130653. /**
  130654. * Returns the string "SpotLight".
  130655. * @returns the class name
  130656. */
  130657. getClassName(): string;
  130658. /**
  130659. * Returns the integer 2.
  130660. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  130661. */
  130662. getTypeID(): number;
  130663. /**
  130664. * Overrides the direction setter to recompute the projection texture view light Matrix.
  130665. */
  130666. protected _setDirection(value: Vector3): void;
  130667. /**
  130668. * Overrides the position setter to recompute the projection texture view light Matrix.
  130669. */
  130670. protected _setPosition(value: Vector3): void;
  130671. /**
  130672. * 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.
  130673. * Returns the SpotLight.
  130674. */
  130675. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  130676. protected _computeProjectionTextureViewLightMatrix(): void;
  130677. protected _computeProjectionTextureProjectionLightMatrix(): void;
  130678. /**
  130679. * Main function for light texture projection matrix computing.
  130680. */
  130681. protected _computeProjectionTextureMatrix(): void;
  130682. protected _buildUniformLayout(): void;
  130683. private _computeAngleValues;
  130684. /**
  130685. * Sets the passed Effect "effect" with the Light textures.
  130686. * @param effect The effect to update
  130687. * @param lightIndex The index of the light in the effect to update
  130688. * @returns The light
  130689. */
  130690. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  130691. /**
  130692. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  130693. * @param effect The effect to update
  130694. * @param lightIndex The index of the light in the effect to update
  130695. * @returns The spot light
  130696. */
  130697. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  130698. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  130699. /**
  130700. * Disposes the light and the associated resources.
  130701. */
  130702. dispose(): void;
  130703. /**
  130704. * Prepares the list of defines specific to the light type.
  130705. * @param defines the list of defines
  130706. * @param lightIndex defines the index of the light for the effect
  130707. */
  130708. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  130709. }
  130710. }
  130711. declare module BABYLON {
  130712. /**
  130713. * Gizmo that enables viewing a light
  130714. */
  130715. export class LightGizmo extends Gizmo {
  130716. private _lightMesh;
  130717. private _material;
  130718. private _cachedPosition;
  130719. private _cachedForward;
  130720. private _attachedMeshParent;
  130721. /**
  130722. * Creates a LightGizmo
  130723. * @param gizmoLayer The utility layer the gizmo will be added to
  130724. */
  130725. constructor(gizmoLayer?: UtilityLayerRenderer);
  130726. private _light;
  130727. /**
  130728. * The light that the gizmo is attached to
  130729. */
  130730. set light(light: Nullable<Light>);
  130731. get light(): Nullable<Light>;
  130732. /**
  130733. * Gets the material used to render the light gizmo
  130734. */
  130735. get material(): StandardMaterial;
  130736. /**
  130737. * @hidden
  130738. * Updates the gizmo to match the attached mesh's position/rotation
  130739. */
  130740. protected _update(): void;
  130741. private static _Scale;
  130742. /**
  130743. * Creates the lines for a light mesh
  130744. */
  130745. private static _CreateLightLines;
  130746. /**
  130747. * Disposes of the light gizmo
  130748. */
  130749. dispose(): void;
  130750. private static _CreateHemisphericLightMesh;
  130751. private static _CreatePointLightMesh;
  130752. private static _CreateSpotLightMesh;
  130753. private static _CreateDirectionalLightMesh;
  130754. }
  130755. }
  130756. declare module BABYLON {
  130757. /** @hidden */
  130758. export var backgroundFragmentDeclaration: {
  130759. name: string;
  130760. shader: string;
  130761. };
  130762. }
  130763. declare module BABYLON {
  130764. /** @hidden */
  130765. export var backgroundUboDeclaration: {
  130766. name: string;
  130767. shader: string;
  130768. };
  130769. }
  130770. declare module BABYLON {
  130771. /** @hidden */
  130772. export var backgroundPixelShader: {
  130773. name: string;
  130774. shader: string;
  130775. };
  130776. }
  130777. declare module BABYLON {
  130778. /** @hidden */
  130779. export var backgroundVertexDeclaration: {
  130780. name: string;
  130781. shader: string;
  130782. };
  130783. }
  130784. declare module BABYLON {
  130785. /** @hidden */
  130786. export var backgroundVertexShader: {
  130787. name: string;
  130788. shader: string;
  130789. };
  130790. }
  130791. declare module BABYLON {
  130792. /**
  130793. * Background material used to create an efficient environement around your scene.
  130794. */
  130795. export class BackgroundMaterial extends PushMaterial {
  130796. /**
  130797. * Standard reflectance value at parallel view angle.
  130798. */
  130799. static StandardReflectance0: number;
  130800. /**
  130801. * Standard reflectance value at grazing angle.
  130802. */
  130803. static StandardReflectance90: number;
  130804. protected _primaryColor: Color3;
  130805. /**
  130806. * Key light Color (multiply against the environement texture)
  130807. */
  130808. primaryColor: Color3;
  130809. protected __perceptualColor: Nullable<Color3>;
  130810. /**
  130811. * Experimental Internal Use Only.
  130812. *
  130813. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  130814. * This acts as a helper to set the primary color to a more "human friendly" value.
  130815. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  130816. * output color as close as possible from the chosen value.
  130817. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  130818. * part of lighting setup.)
  130819. */
  130820. get _perceptualColor(): Nullable<Color3>;
  130821. set _perceptualColor(value: Nullable<Color3>);
  130822. protected _primaryColorShadowLevel: float;
  130823. /**
  130824. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  130825. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  130826. */
  130827. get primaryColorShadowLevel(): float;
  130828. set primaryColorShadowLevel(value: float);
  130829. protected _primaryColorHighlightLevel: float;
  130830. /**
  130831. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  130832. * The primary color is used at the level chosen to define what the white area would look.
  130833. */
  130834. get primaryColorHighlightLevel(): float;
  130835. set primaryColorHighlightLevel(value: float);
  130836. protected _reflectionTexture: Nullable<BaseTexture>;
  130837. /**
  130838. * Reflection Texture used in the material.
  130839. * Should be author in a specific way for the best result (refer to the documentation).
  130840. */
  130841. reflectionTexture: Nullable<BaseTexture>;
  130842. protected _reflectionBlur: float;
  130843. /**
  130844. * Reflection Texture level of blur.
  130845. *
  130846. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  130847. * texture twice.
  130848. */
  130849. reflectionBlur: float;
  130850. protected _diffuseTexture: Nullable<BaseTexture>;
  130851. /**
  130852. * Diffuse Texture used in the material.
  130853. * Should be author in a specific way for the best result (refer to the documentation).
  130854. */
  130855. diffuseTexture: Nullable<BaseTexture>;
  130856. protected _shadowLights: Nullable<IShadowLight[]>;
  130857. /**
  130858. * Specify the list of lights casting shadow on the material.
  130859. * All scene shadow lights will be included if null.
  130860. */
  130861. shadowLights: Nullable<IShadowLight[]>;
  130862. protected _shadowLevel: float;
  130863. /**
  130864. * Helps adjusting the shadow to a softer level if required.
  130865. * 0 means black shadows and 1 means no shadows.
  130866. */
  130867. shadowLevel: float;
  130868. protected _sceneCenter: Vector3;
  130869. /**
  130870. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  130871. * It is usually zero but might be interesting to modify according to your setup.
  130872. */
  130873. sceneCenter: Vector3;
  130874. protected _opacityFresnel: boolean;
  130875. /**
  130876. * This helps specifying that the material is falling off to the sky box at grazing angle.
  130877. * This helps ensuring a nice transition when the camera goes under the ground.
  130878. */
  130879. opacityFresnel: boolean;
  130880. protected _reflectionFresnel: boolean;
  130881. /**
  130882. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  130883. * This helps adding a mirror texture on the ground.
  130884. */
  130885. reflectionFresnel: boolean;
  130886. protected _reflectionFalloffDistance: number;
  130887. /**
  130888. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  130889. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  130890. */
  130891. reflectionFalloffDistance: number;
  130892. protected _reflectionAmount: number;
  130893. /**
  130894. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  130895. */
  130896. reflectionAmount: number;
  130897. protected _reflectionReflectance0: number;
  130898. /**
  130899. * This specifies the weight of the reflection at grazing angle.
  130900. */
  130901. reflectionReflectance0: number;
  130902. protected _reflectionReflectance90: number;
  130903. /**
  130904. * This specifies the weight of the reflection at a perpendicular point of view.
  130905. */
  130906. reflectionReflectance90: number;
  130907. /**
  130908. * Sets the reflection reflectance fresnel values according to the default standard
  130909. * empirically know to work well :-)
  130910. */
  130911. set reflectionStandardFresnelWeight(value: number);
  130912. protected _useRGBColor: boolean;
  130913. /**
  130914. * Helps to directly use the maps channels instead of their level.
  130915. */
  130916. useRGBColor: boolean;
  130917. protected _enableNoise: boolean;
  130918. /**
  130919. * This helps reducing the banding effect that could occur on the background.
  130920. */
  130921. enableNoise: boolean;
  130922. /**
  130923. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  130924. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  130925. * Recommended to be keep at 1.0 except for special cases.
  130926. */
  130927. get fovMultiplier(): number;
  130928. set fovMultiplier(value: number);
  130929. private _fovMultiplier;
  130930. /**
  130931. * Enable the FOV adjustment feature controlled by fovMultiplier.
  130932. */
  130933. useEquirectangularFOV: boolean;
  130934. private _maxSimultaneousLights;
  130935. /**
  130936. * Number of Simultaneous lights allowed on the material.
  130937. */
  130938. maxSimultaneousLights: int;
  130939. /**
  130940. * Default configuration related to image processing available in the Background Material.
  130941. */
  130942. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130943. /**
  130944. * Keep track of the image processing observer to allow dispose and replace.
  130945. */
  130946. private _imageProcessingObserver;
  130947. /**
  130948. * Attaches a new image processing configuration to the PBR Material.
  130949. * @param configuration (if null the scene configuration will be use)
  130950. */
  130951. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130952. /**
  130953. * Gets the image processing configuration used either in this material.
  130954. */
  130955. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  130956. /**
  130957. * Sets the Default image processing configuration used either in the this material.
  130958. *
  130959. * If sets to null, the scene one is in use.
  130960. */
  130961. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  130962. /**
  130963. * Gets wether the color curves effect is enabled.
  130964. */
  130965. get cameraColorCurvesEnabled(): boolean;
  130966. /**
  130967. * Sets wether the color curves effect is enabled.
  130968. */
  130969. set cameraColorCurvesEnabled(value: boolean);
  130970. /**
  130971. * Gets wether the color grading effect is enabled.
  130972. */
  130973. get cameraColorGradingEnabled(): boolean;
  130974. /**
  130975. * Gets wether the color grading effect is enabled.
  130976. */
  130977. set cameraColorGradingEnabled(value: boolean);
  130978. /**
  130979. * Gets wether tonemapping is enabled or not.
  130980. */
  130981. get cameraToneMappingEnabled(): boolean;
  130982. /**
  130983. * Sets wether tonemapping is enabled or not
  130984. */
  130985. set cameraToneMappingEnabled(value: boolean);
  130986. /**
  130987. * The camera exposure used on this material.
  130988. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  130989. * This corresponds to a photographic exposure.
  130990. */
  130991. get cameraExposure(): float;
  130992. /**
  130993. * The camera exposure used on this material.
  130994. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  130995. * This corresponds to a photographic exposure.
  130996. */
  130997. set cameraExposure(value: float);
  130998. /**
  130999. * Gets The camera contrast used on this material.
  131000. */
  131001. get cameraContrast(): float;
  131002. /**
  131003. * Sets The camera contrast used on this material.
  131004. */
  131005. set cameraContrast(value: float);
  131006. /**
  131007. * Gets the Color Grading 2D Lookup Texture.
  131008. */
  131009. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  131010. /**
  131011. * Sets the Color Grading 2D Lookup Texture.
  131012. */
  131013. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  131014. /**
  131015. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  131016. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  131017. * 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;
  131018. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  131019. */
  131020. get cameraColorCurves(): Nullable<ColorCurves>;
  131021. /**
  131022. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  131023. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  131024. * 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;
  131025. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  131026. */
  131027. set cameraColorCurves(value: Nullable<ColorCurves>);
  131028. /**
  131029. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  131030. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  131031. */
  131032. switchToBGR: boolean;
  131033. private _renderTargets;
  131034. private _reflectionControls;
  131035. private _white;
  131036. private _primaryShadowColor;
  131037. private _primaryHighlightColor;
  131038. /**
  131039. * Instantiates a Background Material in the given scene
  131040. * @param name The friendly name of the material
  131041. * @param scene The scene to add the material to
  131042. */
  131043. constructor(name: string, scene: Scene);
  131044. /**
  131045. * Gets a boolean indicating that current material needs to register RTT
  131046. */
  131047. get hasRenderTargetTextures(): boolean;
  131048. /**
  131049. * The entire material has been created in order to prevent overdraw.
  131050. * @returns false
  131051. */
  131052. needAlphaTesting(): boolean;
  131053. /**
  131054. * The entire material has been created in order to prevent overdraw.
  131055. * @returns true if blending is enable
  131056. */
  131057. needAlphaBlending(): boolean;
  131058. /**
  131059. * Checks wether the material is ready to be rendered for a given mesh.
  131060. * @param mesh The mesh to render
  131061. * @param subMesh The submesh to check against
  131062. * @param useInstances Specify wether or not the material is used with instances
  131063. * @returns true if all the dependencies are ready (Textures, Effects...)
  131064. */
  131065. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  131066. /**
  131067. * Compute the primary color according to the chosen perceptual color.
  131068. */
  131069. private _computePrimaryColorFromPerceptualColor;
  131070. /**
  131071. * Compute the highlights and shadow colors according to their chosen levels.
  131072. */
  131073. private _computePrimaryColors;
  131074. /**
  131075. * Build the uniform buffer used in the material.
  131076. */
  131077. buildUniformLayout(): void;
  131078. /**
  131079. * Unbind the material.
  131080. */
  131081. unbind(): void;
  131082. /**
  131083. * Bind only the world matrix to the material.
  131084. * @param world The world matrix to bind.
  131085. */
  131086. bindOnlyWorldMatrix(world: Matrix): void;
  131087. /**
  131088. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  131089. * @param world The world matrix to bind.
  131090. * @param subMesh The submesh to bind for.
  131091. */
  131092. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  131093. /**
  131094. * Checks to see if a texture is used in the material.
  131095. * @param texture - Base texture to use.
  131096. * @returns - Boolean specifying if a texture is used in the material.
  131097. */
  131098. hasTexture(texture: BaseTexture): boolean;
  131099. /**
  131100. * Dispose the material.
  131101. * @param forceDisposeEffect Force disposal of the associated effect.
  131102. * @param forceDisposeTextures Force disposal of the associated textures.
  131103. */
  131104. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  131105. /**
  131106. * Clones the material.
  131107. * @param name The cloned name.
  131108. * @returns The cloned material.
  131109. */
  131110. clone(name: string): BackgroundMaterial;
  131111. /**
  131112. * Serializes the current material to its JSON representation.
  131113. * @returns The JSON representation.
  131114. */
  131115. serialize(): any;
  131116. /**
  131117. * Gets the class name of the material
  131118. * @returns "BackgroundMaterial"
  131119. */
  131120. getClassName(): string;
  131121. /**
  131122. * Parse a JSON input to create back a background material.
  131123. * @param source The JSON data to parse
  131124. * @param scene The scene to create the parsed material in
  131125. * @param rootUrl The root url of the assets the material depends upon
  131126. * @returns the instantiated BackgroundMaterial.
  131127. */
  131128. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  131129. }
  131130. }
  131131. declare module BABYLON {
  131132. /**
  131133. * Represents the different options available during the creation of
  131134. * a Environment helper.
  131135. *
  131136. * This can control the default ground, skybox and image processing setup of your scene.
  131137. */
  131138. export interface IEnvironmentHelperOptions {
  131139. /**
  131140. * Specifies whether or not to create a ground.
  131141. * True by default.
  131142. */
  131143. createGround: boolean;
  131144. /**
  131145. * Specifies the ground size.
  131146. * 15 by default.
  131147. */
  131148. groundSize: number;
  131149. /**
  131150. * The texture used on the ground for the main color.
  131151. * Comes from the BabylonJS CDN by default.
  131152. *
  131153. * Remarks: Can be either a texture or a url.
  131154. */
  131155. groundTexture: string | BaseTexture;
  131156. /**
  131157. * The color mixed in the ground texture by default.
  131158. * BabylonJS clearColor by default.
  131159. */
  131160. groundColor: Color3;
  131161. /**
  131162. * Specifies the ground opacity.
  131163. * 1 by default.
  131164. */
  131165. groundOpacity: number;
  131166. /**
  131167. * Enables the ground to receive shadows.
  131168. * True by default.
  131169. */
  131170. enableGroundShadow: boolean;
  131171. /**
  131172. * Helps preventing the shadow to be fully black on the ground.
  131173. * 0.5 by default.
  131174. */
  131175. groundShadowLevel: number;
  131176. /**
  131177. * Creates a mirror texture attach to the ground.
  131178. * false by default.
  131179. */
  131180. enableGroundMirror: boolean;
  131181. /**
  131182. * Specifies the ground mirror size ratio.
  131183. * 0.3 by default as the default kernel is 64.
  131184. */
  131185. groundMirrorSizeRatio: number;
  131186. /**
  131187. * Specifies the ground mirror blur kernel size.
  131188. * 64 by default.
  131189. */
  131190. groundMirrorBlurKernel: number;
  131191. /**
  131192. * Specifies the ground mirror visibility amount.
  131193. * 1 by default
  131194. */
  131195. groundMirrorAmount: number;
  131196. /**
  131197. * Specifies the ground mirror reflectance weight.
  131198. * This uses the standard weight of the background material to setup the fresnel effect
  131199. * of the mirror.
  131200. * 1 by default.
  131201. */
  131202. groundMirrorFresnelWeight: number;
  131203. /**
  131204. * Specifies the ground mirror Falloff distance.
  131205. * This can helps reducing the size of the reflection.
  131206. * 0 by Default.
  131207. */
  131208. groundMirrorFallOffDistance: number;
  131209. /**
  131210. * Specifies the ground mirror texture type.
  131211. * Unsigned Int by Default.
  131212. */
  131213. groundMirrorTextureType: number;
  131214. /**
  131215. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  131216. * the shown objects.
  131217. */
  131218. groundYBias: number;
  131219. /**
  131220. * Specifies whether or not to create a skybox.
  131221. * True by default.
  131222. */
  131223. createSkybox: boolean;
  131224. /**
  131225. * Specifies the skybox size.
  131226. * 20 by default.
  131227. */
  131228. skyboxSize: number;
  131229. /**
  131230. * The texture used on the skybox for the main color.
  131231. * Comes from the BabylonJS CDN by default.
  131232. *
  131233. * Remarks: Can be either a texture or a url.
  131234. */
  131235. skyboxTexture: string | BaseTexture;
  131236. /**
  131237. * The color mixed in the skybox texture by default.
  131238. * BabylonJS clearColor by default.
  131239. */
  131240. skyboxColor: Color3;
  131241. /**
  131242. * The background rotation around the Y axis of the scene.
  131243. * This helps aligning the key lights of your scene with the background.
  131244. * 0 by default.
  131245. */
  131246. backgroundYRotation: number;
  131247. /**
  131248. * Compute automatically the size of the elements to best fit with the scene.
  131249. */
  131250. sizeAuto: boolean;
  131251. /**
  131252. * Default position of the rootMesh if autoSize is not true.
  131253. */
  131254. rootPosition: Vector3;
  131255. /**
  131256. * Sets up the image processing in the scene.
  131257. * true by default.
  131258. */
  131259. setupImageProcessing: boolean;
  131260. /**
  131261. * The texture used as your environment texture in the scene.
  131262. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  131263. *
  131264. * Remarks: Can be either a texture or a url.
  131265. */
  131266. environmentTexture: string | BaseTexture;
  131267. /**
  131268. * The value of the exposure to apply to the scene.
  131269. * 0.6 by default if setupImageProcessing is true.
  131270. */
  131271. cameraExposure: number;
  131272. /**
  131273. * The value of the contrast to apply to the scene.
  131274. * 1.6 by default if setupImageProcessing is true.
  131275. */
  131276. cameraContrast: number;
  131277. /**
  131278. * Specifies whether or not tonemapping should be enabled in the scene.
  131279. * true by default if setupImageProcessing is true.
  131280. */
  131281. toneMappingEnabled: boolean;
  131282. }
  131283. /**
  131284. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  131285. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  131286. * It also helps with the default setup of your imageProcessing configuration.
  131287. */
  131288. export class EnvironmentHelper {
  131289. /**
  131290. * Default ground texture URL.
  131291. */
  131292. private static _groundTextureCDNUrl;
  131293. /**
  131294. * Default skybox texture URL.
  131295. */
  131296. private static _skyboxTextureCDNUrl;
  131297. /**
  131298. * Default environment texture URL.
  131299. */
  131300. private static _environmentTextureCDNUrl;
  131301. /**
  131302. * Creates the default options for the helper.
  131303. */
  131304. private static _getDefaultOptions;
  131305. private _rootMesh;
  131306. /**
  131307. * Gets the root mesh created by the helper.
  131308. */
  131309. get rootMesh(): Mesh;
  131310. private _skybox;
  131311. /**
  131312. * Gets the skybox created by the helper.
  131313. */
  131314. get skybox(): Nullable<Mesh>;
  131315. private _skyboxTexture;
  131316. /**
  131317. * Gets the skybox texture created by the helper.
  131318. */
  131319. get skyboxTexture(): Nullable<BaseTexture>;
  131320. private _skyboxMaterial;
  131321. /**
  131322. * Gets the skybox material created by the helper.
  131323. */
  131324. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  131325. private _ground;
  131326. /**
  131327. * Gets the ground mesh created by the helper.
  131328. */
  131329. get ground(): Nullable<Mesh>;
  131330. private _groundTexture;
  131331. /**
  131332. * Gets the ground texture created by the helper.
  131333. */
  131334. get groundTexture(): Nullable<BaseTexture>;
  131335. private _groundMirror;
  131336. /**
  131337. * Gets the ground mirror created by the helper.
  131338. */
  131339. get groundMirror(): Nullable<MirrorTexture>;
  131340. /**
  131341. * Gets the ground mirror render list to helps pushing the meshes
  131342. * you wish in the ground reflection.
  131343. */
  131344. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  131345. private _groundMaterial;
  131346. /**
  131347. * Gets the ground material created by the helper.
  131348. */
  131349. get groundMaterial(): Nullable<BackgroundMaterial>;
  131350. /**
  131351. * Stores the creation options.
  131352. */
  131353. private readonly _scene;
  131354. private _options;
  131355. /**
  131356. * This observable will be notified with any error during the creation of the environment,
  131357. * mainly texture creation errors.
  131358. */
  131359. onErrorObservable: Observable<{
  131360. message?: string;
  131361. exception?: any;
  131362. }>;
  131363. /**
  131364. * constructor
  131365. * @param options Defines the options we want to customize the helper
  131366. * @param scene The scene to add the material to
  131367. */
  131368. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  131369. /**
  131370. * Updates the background according to the new options
  131371. * @param options
  131372. */
  131373. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  131374. /**
  131375. * Sets the primary color of all the available elements.
  131376. * @param color the main color to affect to the ground and the background
  131377. */
  131378. setMainColor(color: Color3): void;
  131379. /**
  131380. * Setup the image processing according to the specified options.
  131381. */
  131382. private _setupImageProcessing;
  131383. /**
  131384. * Setup the environment texture according to the specified options.
  131385. */
  131386. private _setupEnvironmentTexture;
  131387. /**
  131388. * Setup the background according to the specified options.
  131389. */
  131390. private _setupBackground;
  131391. /**
  131392. * Get the scene sizes according to the setup.
  131393. */
  131394. private _getSceneSize;
  131395. /**
  131396. * Setup the ground according to the specified options.
  131397. */
  131398. private _setupGround;
  131399. /**
  131400. * Setup the ground material according to the specified options.
  131401. */
  131402. private _setupGroundMaterial;
  131403. /**
  131404. * Setup the ground diffuse texture according to the specified options.
  131405. */
  131406. private _setupGroundDiffuseTexture;
  131407. /**
  131408. * Setup the ground mirror texture according to the specified options.
  131409. */
  131410. private _setupGroundMirrorTexture;
  131411. /**
  131412. * Setup the ground to receive the mirror texture.
  131413. */
  131414. private _setupMirrorInGroundMaterial;
  131415. /**
  131416. * Setup the skybox according to the specified options.
  131417. */
  131418. private _setupSkybox;
  131419. /**
  131420. * Setup the skybox material according to the specified options.
  131421. */
  131422. private _setupSkyboxMaterial;
  131423. /**
  131424. * Setup the skybox reflection texture according to the specified options.
  131425. */
  131426. private _setupSkyboxReflectionTexture;
  131427. private _errorHandler;
  131428. /**
  131429. * Dispose all the elements created by the Helper.
  131430. */
  131431. dispose(): void;
  131432. }
  131433. }
  131434. declare module BABYLON {
  131435. /**
  131436. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  131437. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  131438. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  131439. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  131440. */
  131441. export class PhotoDome extends TransformNode {
  131442. /**
  131443. * Define the image as a Monoscopic panoramic 360 image.
  131444. */
  131445. static readonly MODE_MONOSCOPIC: number;
  131446. /**
  131447. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  131448. */
  131449. static readonly MODE_TOPBOTTOM: number;
  131450. /**
  131451. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  131452. */
  131453. static readonly MODE_SIDEBYSIDE: number;
  131454. private _useDirectMapping;
  131455. /**
  131456. * The texture being displayed on the sphere
  131457. */
  131458. protected _photoTexture: Texture;
  131459. /**
  131460. * Gets or sets the texture being displayed on the sphere
  131461. */
  131462. get photoTexture(): Texture;
  131463. set photoTexture(value: Texture);
  131464. /**
  131465. * Observable raised when an error occured while loading the 360 image
  131466. */
  131467. onLoadErrorObservable: Observable<string>;
  131468. /**
  131469. * The skybox material
  131470. */
  131471. protected _material: BackgroundMaterial;
  131472. /**
  131473. * The surface used for the skybox
  131474. */
  131475. protected _mesh: Mesh;
  131476. /**
  131477. * Gets the mesh used for the skybox.
  131478. */
  131479. get mesh(): Mesh;
  131480. /**
  131481. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  131482. * Also see the options.resolution property.
  131483. */
  131484. get fovMultiplier(): number;
  131485. set fovMultiplier(value: number);
  131486. private _imageMode;
  131487. /**
  131488. * Gets or set the current video mode for the video. It can be:
  131489. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  131490. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  131491. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  131492. */
  131493. get imageMode(): number;
  131494. set imageMode(value: number);
  131495. /**
  131496. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  131497. * @param name Element's name, child elements will append suffixes for their own names.
  131498. * @param urlsOfPhoto defines the url of the photo to display
  131499. * @param options defines an object containing optional or exposed sub element properties
  131500. * @param onError defines a callback called when an error occured while loading the texture
  131501. */
  131502. constructor(name: string, urlOfPhoto: string, options: {
  131503. resolution?: number;
  131504. size?: number;
  131505. useDirectMapping?: boolean;
  131506. faceForward?: boolean;
  131507. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  131508. private _onBeforeCameraRenderObserver;
  131509. private _changeImageMode;
  131510. /**
  131511. * Releases resources associated with this node.
  131512. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  131513. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  131514. */
  131515. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  131516. }
  131517. }
  131518. declare module BABYLON {
  131519. /**
  131520. * Class used to host RGBD texture specific utilities
  131521. */
  131522. export class RGBDTextureTools {
  131523. /**
  131524. * Expand the RGBD Texture from RGBD to Half Float if possible.
  131525. * @param texture the texture to expand.
  131526. */
  131527. static ExpandRGBDTexture(texture: Texture): void;
  131528. }
  131529. }
  131530. declare module BABYLON {
  131531. /**
  131532. * Class used to host texture specific utilities
  131533. */
  131534. export class BRDFTextureTools {
  131535. /**
  131536. * Prevents texture cache collision
  131537. */
  131538. private static _instanceNumber;
  131539. /**
  131540. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  131541. * @param scene defines the hosting scene
  131542. * @returns the environment BRDF texture
  131543. */
  131544. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  131545. private static _environmentBRDFBase64Texture;
  131546. }
  131547. }
  131548. declare module BABYLON {
  131549. /**
  131550. * @hidden
  131551. */
  131552. export interface IMaterialClearCoatDefines {
  131553. CLEARCOAT: boolean;
  131554. CLEARCOAT_DEFAULTIOR: boolean;
  131555. CLEARCOAT_TEXTURE: boolean;
  131556. CLEARCOAT_TEXTUREDIRECTUV: number;
  131557. CLEARCOAT_BUMP: boolean;
  131558. CLEARCOAT_BUMPDIRECTUV: number;
  131559. CLEARCOAT_TINT: boolean;
  131560. CLEARCOAT_TINT_TEXTURE: boolean;
  131561. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  131562. /** @hidden */
  131563. _areTexturesDirty: boolean;
  131564. }
  131565. /**
  131566. * Define the code related to the clear coat parameters of the pbr material.
  131567. */
  131568. export class PBRClearCoatConfiguration {
  131569. /**
  131570. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  131571. * The default fits with a polyurethane material.
  131572. */
  131573. private static readonly _DefaultIndexOfRefraction;
  131574. private _isEnabled;
  131575. /**
  131576. * Defines if the clear coat is enabled in the material.
  131577. */
  131578. isEnabled: boolean;
  131579. /**
  131580. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  131581. */
  131582. intensity: number;
  131583. /**
  131584. * Defines the clear coat layer roughness.
  131585. */
  131586. roughness: number;
  131587. private _indexOfRefraction;
  131588. /**
  131589. * Defines the index of refraction of the clear coat.
  131590. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  131591. * The default fits with a polyurethane material.
  131592. * Changing the default value is more performance intensive.
  131593. */
  131594. indexOfRefraction: number;
  131595. private _texture;
  131596. /**
  131597. * Stores the clear coat values in a texture.
  131598. */
  131599. texture: Nullable<BaseTexture>;
  131600. private _bumpTexture;
  131601. /**
  131602. * Define the clear coat specific bump texture.
  131603. */
  131604. bumpTexture: Nullable<BaseTexture>;
  131605. private _isTintEnabled;
  131606. /**
  131607. * Defines if the clear coat tint is enabled in the material.
  131608. */
  131609. isTintEnabled: boolean;
  131610. /**
  131611. * Defines the clear coat tint of the material.
  131612. * This is only use if tint is enabled
  131613. */
  131614. tintColor: Color3;
  131615. /**
  131616. * Defines the distance at which the tint color should be found in the
  131617. * clear coat media.
  131618. * This is only use if tint is enabled
  131619. */
  131620. tintColorAtDistance: number;
  131621. /**
  131622. * Defines the clear coat layer thickness.
  131623. * This is only use if tint is enabled
  131624. */
  131625. tintThickness: number;
  131626. private _tintTexture;
  131627. /**
  131628. * Stores the clear tint values in a texture.
  131629. * rgb is tint
  131630. * a is a thickness factor
  131631. */
  131632. tintTexture: Nullable<BaseTexture>;
  131633. /** @hidden */
  131634. private _internalMarkAllSubMeshesAsTexturesDirty;
  131635. /** @hidden */
  131636. _markAllSubMeshesAsTexturesDirty(): void;
  131637. /**
  131638. * Instantiate a new istance of clear coat configuration.
  131639. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  131640. */
  131641. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  131642. /**
  131643. * Gets wehter the submesh is ready to be used or not.
  131644. * @param defines the list of "defines" to update.
  131645. * @param scene defines the scene the material belongs to.
  131646. * @param engine defines the engine the material belongs to.
  131647. * @param disableBumpMap defines wether the material disables bump or not.
  131648. * @returns - boolean indicating that the submesh is ready or not.
  131649. */
  131650. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  131651. /**
  131652. * Checks to see if a texture is used in the material.
  131653. * @param defines the list of "defines" to update.
  131654. * @param scene defines the scene to the material belongs to.
  131655. */
  131656. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  131657. /**
  131658. * Binds the material data.
  131659. * @param uniformBuffer defines the Uniform buffer to fill in.
  131660. * @param scene defines the scene the material belongs to.
  131661. * @param engine defines the engine the material belongs to.
  131662. * @param disableBumpMap defines wether the material disables bump or not.
  131663. * @param isFrozen defines wether the material is frozen or not.
  131664. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  131665. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  131666. */
  131667. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  131668. /**
  131669. * Checks to see if a texture is used in the material.
  131670. * @param texture - Base texture to use.
  131671. * @returns - Boolean specifying if a texture is used in the material.
  131672. */
  131673. hasTexture(texture: BaseTexture): boolean;
  131674. /**
  131675. * Returns an array of the actively used textures.
  131676. * @param activeTextures Array of BaseTextures
  131677. */
  131678. getActiveTextures(activeTextures: BaseTexture[]): void;
  131679. /**
  131680. * Returns the animatable textures.
  131681. * @param animatables Array of animatable textures.
  131682. */
  131683. getAnimatables(animatables: IAnimatable[]): void;
  131684. /**
  131685. * Disposes the resources of the material.
  131686. * @param forceDisposeTextures - Forces the disposal of all textures.
  131687. */
  131688. dispose(forceDisposeTextures?: boolean): void;
  131689. /**
  131690. * Get the current class name of the texture useful for serialization or dynamic coding.
  131691. * @returns "PBRClearCoatConfiguration"
  131692. */
  131693. getClassName(): string;
  131694. /**
  131695. * Add fallbacks to the effect fallbacks list.
  131696. * @param defines defines the Base texture to use.
  131697. * @param fallbacks defines the current fallback list.
  131698. * @param currentRank defines the current fallback rank.
  131699. * @returns the new fallback rank.
  131700. */
  131701. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  131702. /**
  131703. * Add the required uniforms to the current list.
  131704. * @param uniforms defines the current uniform list.
  131705. */
  131706. static AddUniforms(uniforms: string[]): void;
  131707. /**
  131708. * Add the required samplers to the current list.
  131709. * @param samplers defines the current sampler list.
  131710. */
  131711. static AddSamplers(samplers: string[]): void;
  131712. /**
  131713. * Add the required uniforms to the current buffer.
  131714. * @param uniformBuffer defines the current uniform buffer.
  131715. */
  131716. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  131717. /**
  131718. * Makes a duplicate of the current configuration into another one.
  131719. * @param clearCoatConfiguration define the config where to copy the info
  131720. */
  131721. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  131722. /**
  131723. * Serializes this clear coat configuration.
  131724. * @returns - An object with the serialized config.
  131725. */
  131726. serialize(): any;
  131727. /**
  131728. * Parses a anisotropy Configuration from a serialized object.
  131729. * @param source - Serialized object.
  131730. * @param scene Defines the scene we are parsing for
  131731. * @param rootUrl Defines the rootUrl to load from
  131732. */
  131733. parse(source: any, scene: Scene, rootUrl: string): void;
  131734. }
  131735. }
  131736. declare module BABYLON {
  131737. /**
  131738. * @hidden
  131739. */
  131740. export interface IMaterialAnisotropicDefines {
  131741. ANISOTROPIC: boolean;
  131742. ANISOTROPIC_TEXTURE: boolean;
  131743. ANISOTROPIC_TEXTUREDIRECTUV: number;
  131744. MAINUV1: boolean;
  131745. _areTexturesDirty: boolean;
  131746. _needUVs: boolean;
  131747. }
  131748. /**
  131749. * Define the code related to the anisotropic parameters of the pbr material.
  131750. */
  131751. export class PBRAnisotropicConfiguration {
  131752. private _isEnabled;
  131753. /**
  131754. * Defines if the anisotropy is enabled in the material.
  131755. */
  131756. isEnabled: boolean;
  131757. /**
  131758. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  131759. */
  131760. intensity: number;
  131761. /**
  131762. * Defines if the effect is along the tangents, bitangents or in between.
  131763. * By default, the effect is "strectching" the highlights along the tangents.
  131764. */
  131765. direction: Vector2;
  131766. private _texture;
  131767. /**
  131768. * Stores the anisotropy values in a texture.
  131769. * rg is direction (like normal from -1 to 1)
  131770. * b is a intensity
  131771. */
  131772. texture: Nullable<BaseTexture>;
  131773. /** @hidden */
  131774. private _internalMarkAllSubMeshesAsTexturesDirty;
  131775. /** @hidden */
  131776. _markAllSubMeshesAsTexturesDirty(): void;
  131777. /**
  131778. * Instantiate a new istance of anisotropy configuration.
  131779. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  131780. */
  131781. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  131782. /**
  131783. * Specifies that the submesh is ready to be used.
  131784. * @param defines the list of "defines" to update.
  131785. * @param scene defines the scene the material belongs to.
  131786. * @returns - boolean indicating that the submesh is ready or not.
  131787. */
  131788. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  131789. /**
  131790. * Checks to see if a texture is used in the material.
  131791. * @param defines the list of "defines" to update.
  131792. * @param mesh the mesh we are preparing the defines for.
  131793. * @param scene defines the scene the material belongs to.
  131794. */
  131795. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  131796. /**
  131797. * Binds the material data.
  131798. * @param uniformBuffer defines the Uniform buffer to fill in.
  131799. * @param scene defines the scene the material belongs to.
  131800. * @param isFrozen defines wether the material is frozen or not.
  131801. */
  131802. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  131803. /**
  131804. * Checks to see if a texture is used in the material.
  131805. * @param texture - Base texture to use.
  131806. * @returns - Boolean specifying if a texture is used in the material.
  131807. */
  131808. hasTexture(texture: BaseTexture): boolean;
  131809. /**
  131810. * Returns an array of the actively used textures.
  131811. * @param activeTextures Array of BaseTextures
  131812. */
  131813. getActiveTextures(activeTextures: BaseTexture[]): void;
  131814. /**
  131815. * Returns the animatable textures.
  131816. * @param animatables Array of animatable textures.
  131817. */
  131818. getAnimatables(animatables: IAnimatable[]): void;
  131819. /**
  131820. * Disposes the resources of the material.
  131821. * @param forceDisposeTextures - Forces the disposal of all textures.
  131822. */
  131823. dispose(forceDisposeTextures?: boolean): void;
  131824. /**
  131825. * Get the current class name of the texture useful for serialization or dynamic coding.
  131826. * @returns "PBRAnisotropicConfiguration"
  131827. */
  131828. getClassName(): string;
  131829. /**
  131830. * Add fallbacks to the effect fallbacks list.
  131831. * @param defines defines the Base texture to use.
  131832. * @param fallbacks defines the current fallback list.
  131833. * @param currentRank defines the current fallback rank.
  131834. * @returns the new fallback rank.
  131835. */
  131836. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  131837. /**
  131838. * Add the required uniforms to the current list.
  131839. * @param uniforms defines the current uniform list.
  131840. */
  131841. static AddUniforms(uniforms: string[]): void;
  131842. /**
  131843. * Add the required uniforms to the current buffer.
  131844. * @param uniformBuffer defines the current uniform buffer.
  131845. */
  131846. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  131847. /**
  131848. * Add the required samplers to the current list.
  131849. * @param samplers defines the current sampler list.
  131850. */
  131851. static AddSamplers(samplers: string[]): void;
  131852. /**
  131853. * Makes a duplicate of the current configuration into another one.
  131854. * @param anisotropicConfiguration define the config where to copy the info
  131855. */
  131856. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  131857. /**
  131858. * Serializes this anisotropy configuration.
  131859. * @returns - An object with the serialized config.
  131860. */
  131861. serialize(): any;
  131862. /**
  131863. * Parses a anisotropy Configuration from a serialized object.
  131864. * @param source - Serialized object.
  131865. * @param scene Defines the scene we are parsing for
  131866. * @param rootUrl Defines the rootUrl to load from
  131867. */
  131868. parse(source: any, scene: Scene, rootUrl: string): void;
  131869. }
  131870. }
  131871. declare module BABYLON {
  131872. /**
  131873. * @hidden
  131874. */
  131875. export interface IMaterialBRDFDefines {
  131876. BRDF_V_HEIGHT_CORRELATED: boolean;
  131877. MS_BRDF_ENERGY_CONSERVATION: boolean;
  131878. SPHERICAL_HARMONICS: boolean;
  131879. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  131880. /** @hidden */
  131881. _areMiscDirty: boolean;
  131882. }
  131883. /**
  131884. * Define the code related to the BRDF parameters of the pbr material.
  131885. */
  131886. export class PBRBRDFConfiguration {
  131887. /**
  131888. * Default value used for the energy conservation.
  131889. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  131890. */
  131891. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  131892. /**
  131893. * Default value used for the Smith Visibility Height Correlated mode.
  131894. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  131895. */
  131896. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  131897. /**
  131898. * Default value used for the IBL diffuse part.
  131899. * This can help switching back to the polynomials mode globally which is a tiny bit
  131900. * less GPU intensive at the drawback of a lower quality.
  131901. */
  131902. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  131903. /**
  131904. * Default value used for activating energy conservation for the specular workflow.
  131905. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  131906. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  131907. */
  131908. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  131909. private _useEnergyConservation;
  131910. /**
  131911. * Defines if the material uses energy conservation.
  131912. */
  131913. useEnergyConservation: boolean;
  131914. private _useSmithVisibilityHeightCorrelated;
  131915. /**
  131916. * LEGACY Mode set to false
  131917. * Defines if the material uses height smith correlated visibility term.
  131918. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  131919. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  131920. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  131921. * Not relying on height correlated will also disable energy conservation.
  131922. */
  131923. useSmithVisibilityHeightCorrelated: boolean;
  131924. private _useSphericalHarmonics;
  131925. /**
  131926. * LEGACY Mode set to false
  131927. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  131928. * diffuse part of the IBL.
  131929. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  131930. * to the ground truth.
  131931. */
  131932. useSphericalHarmonics: boolean;
  131933. private _useSpecularGlossinessInputEnergyConservation;
  131934. /**
  131935. * Defines if the material uses energy conservation, when the specular workflow is active.
  131936. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  131937. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  131938. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  131939. */
  131940. useSpecularGlossinessInputEnergyConservation: boolean;
  131941. /** @hidden */
  131942. private _internalMarkAllSubMeshesAsMiscDirty;
  131943. /** @hidden */
  131944. _markAllSubMeshesAsMiscDirty(): void;
  131945. /**
  131946. * Instantiate a new istance of clear coat configuration.
  131947. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  131948. */
  131949. constructor(markAllSubMeshesAsMiscDirty: () => void);
  131950. /**
  131951. * Checks to see if a texture is used in the material.
  131952. * @param defines the list of "defines" to update.
  131953. */
  131954. prepareDefines(defines: IMaterialBRDFDefines): void;
  131955. /**
  131956. * Get the current class name of the texture useful for serialization or dynamic coding.
  131957. * @returns "PBRClearCoatConfiguration"
  131958. */
  131959. getClassName(): string;
  131960. /**
  131961. * Makes a duplicate of the current configuration into another one.
  131962. * @param brdfConfiguration define the config where to copy the info
  131963. */
  131964. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  131965. /**
  131966. * Serializes this BRDF configuration.
  131967. * @returns - An object with the serialized config.
  131968. */
  131969. serialize(): any;
  131970. /**
  131971. * Parses a anisotropy Configuration from a serialized object.
  131972. * @param source - Serialized object.
  131973. * @param scene Defines the scene we are parsing for
  131974. * @param rootUrl Defines the rootUrl to load from
  131975. */
  131976. parse(source: any, scene: Scene, rootUrl: string): void;
  131977. }
  131978. }
  131979. declare module BABYLON {
  131980. /**
  131981. * @hidden
  131982. */
  131983. export interface IMaterialSheenDefines {
  131984. SHEEN: boolean;
  131985. SHEEN_TEXTURE: boolean;
  131986. SHEEN_TEXTUREDIRECTUV: number;
  131987. SHEEN_LINKWITHALBEDO: boolean;
  131988. SHEEN_ROUGHNESS: boolean;
  131989. SHEEN_ALBEDOSCALING: boolean;
  131990. /** @hidden */
  131991. _areTexturesDirty: boolean;
  131992. }
  131993. /**
  131994. * Define the code related to the Sheen parameters of the pbr material.
  131995. */
  131996. export class PBRSheenConfiguration {
  131997. private _isEnabled;
  131998. /**
  131999. * Defines if the material uses sheen.
  132000. */
  132001. isEnabled: boolean;
  132002. private _linkSheenWithAlbedo;
  132003. /**
  132004. * Defines if the sheen is linked to the sheen color.
  132005. */
  132006. linkSheenWithAlbedo: boolean;
  132007. /**
  132008. * Defines the sheen intensity.
  132009. */
  132010. intensity: number;
  132011. /**
  132012. * Defines the sheen color.
  132013. */
  132014. color: Color3;
  132015. private _texture;
  132016. /**
  132017. * Stores the sheen tint values in a texture.
  132018. * rgb is tint
  132019. * a is a intensity
  132020. */
  132021. texture: Nullable<BaseTexture>;
  132022. private _roughness;
  132023. /**
  132024. * Defines the sheen roughness.
  132025. * It is not taken into account if linkSheenWithAlbedo is true.
  132026. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  132027. */
  132028. roughness: Nullable<number>;
  132029. private _albedoScaling;
  132030. /**
  132031. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  132032. * It allows the strength of the sheen effect to not depend on the base color of the material,
  132033. * making it easier to setup and tweak the effect
  132034. */
  132035. albedoScaling: boolean;
  132036. /** @hidden */
  132037. private _internalMarkAllSubMeshesAsTexturesDirty;
  132038. /** @hidden */
  132039. _markAllSubMeshesAsTexturesDirty(): void;
  132040. /**
  132041. * Instantiate a new istance of clear coat configuration.
  132042. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132043. */
  132044. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132045. /**
  132046. * Specifies that the submesh is ready to be used.
  132047. * @param defines the list of "defines" to update.
  132048. * @param scene defines the scene the material belongs to.
  132049. * @returns - boolean indicating that the submesh is ready or not.
  132050. */
  132051. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  132052. /**
  132053. * Checks to see if a texture is used in the material.
  132054. * @param defines the list of "defines" to update.
  132055. * @param scene defines the scene the material belongs to.
  132056. */
  132057. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  132058. /**
  132059. * Binds the material data.
  132060. * @param uniformBuffer defines the Uniform buffer to fill in.
  132061. * @param scene defines the scene the material belongs to.
  132062. * @param isFrozen defines wether the material is frozen or not.
  132063. */
  132064. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  132065. /**
  132066. * Checks to see if a texture is used in the material.
  132067. * @param texture - Base texture to use.
  132068. * @returns - Boolean specifying if a texture is used in the material.
  132069. */
  132070. hasTexture(texture: BaseTexture): boolean;
  132071. /**
  132072. * Returns an array of the actively used textures.
  132073. * @param activeTextures Array of BaseTextures
  132074. */
  132075. getActiveTextures(activeTextures: BaseTexture[]): void;
  132076. /**
  132077. * Returns the animatable textures.
  132078. * @param animatables Array of animatable textures.
  132079. */
  132080. getAnimatables(animatables: IAnimatable[]): void;
  132081. /**
  132082. * Disposes the resources of the material.
  132083. * @param forceDisposeTextures - Forces the disposal of all textures.
  132084. */
  132085. dispose(forceDisposeTextures?: boolean): void;
  132086. /**
  132087. * Get the current class name of the texture useful for serialization or dynamic coding.
  132088. * @returns "PBRSheenConfiguration"
  132089. */
  132090. getClassName(): string;
  132091. /**
  132092. * Add fallbacks to the effect fallbacks list.
  132093. * @param defines defines the Base texture to use.
  132094. * @param fallbacks defines the current fallback list.
  132095. * @param currentRank defines the current fallback rank.
  132096. * @returns the new fallback rank.
  132097. */
  132098. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132099. /**
  132100. * Add the required uniforms to the current list.
  132101. * @param uniforms defines the current uniform list.
  132102. */
  132103. static AddUniforms(uniforms: string[]): void;
  132104. /**
  132105. * Add the required uniforms to the current buffer.
  132106. * @param uniformBuffer defines the current uniform buffer.
  132107. */
  132108. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132109. /**
  132110. * Add the required samplers to the current list.
  132111. * @param samplers defines the current sampler list.
  132112. */
  132113. static AddSamplers(samplers: string[]): void;
  132114. /**
  132115. * Makes a duplicate of the current configuration into another one.
  132116. * @param sheenConfiguration define the config where to copy the info
  132117. */
  132118. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  132119. /**
  132120. * Serializes this BRDF configuration.
  132121. * @returns - An object with the serialized config.
  132122. */
  132123. serialize(): any;
  132124. /**
  132125. * Parses a anisotropy Configuration from a serialized object.
  132126. * @param source - Serialized object.
  132127. * @param scene Defines the scene we are parsing for
  132128. * @param rootUrl Defines the rootUrl to load from
  132129. */
  132130. parse(source: any, scene: Scene, rootUrl: string): void;
  132131. }
  132132. }
  132133. declare module BABYLON {
  132134. /**
  132135. * @hidden
  132136. */
  132137. export interface IMaterialSubSurfaceDefines {
  132138. SUBSURFACE: boolean;
  132139. SS_REFRACTION: boolean;
  132140. SS_TRANSLUCENCY: boolean;
  132141. SS_SCATTERING: boolean;
  132142. SS_THICKNESSANDMASK_TEXTURE: boolean;
  132143. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  132144. SS_REFRACTIONMAP_3D: boolean;
  132145. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  132146. SS_LODINREFRACTIONALPHA: boolean;
  132147. SS_GAMMAREFRACTION: boolean;
  132148. SS_RGBDREFRACTION: boolean;
  132149. SS_LINEARSPECULARREFRACTION: boolean;
  132150. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  132151. SS_ALBEDOFORREFRACTIONTINT: boolean;
  132152. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  132153. /** @hidden */
  132154. _areTexturesDirty: boolean;
  132155. }
  132156. /**
  132157. * Define the code related to the sub surface parameters of the pbr material.
  132158. */
  132159. export class PBRSubSurfaceConfiguration {
  132160. private _isRefractionEnabled;
  132161. /**
  132162. * Defines if the refraction is enabled in the material.
  132163. */
  132164. isRefractionEnabled: boolean;
  132165. private _isTranslucencyEnabled;
  132166. /**
  132167. * Defines if the translucency is enabled in the material.
  132168. */
  132169. isTranslucencyEnabled: boolean;
  132170. private _isScatteringEnabled;
  132171. /**
  132172. * Defines the refraction intensity of the material.
  132173. * The refraction when enabled replaces the Diffuse part of the material.
  132174. * The intensity helps transitionning between diffuse and refraction.
  132175. */
  132176. refractionIntensity: number;
  132177. /**
  132178. * Defines the translucency intensity of the material.
  132179. * When translucency has been enabled, this defines how much of the "translucency"
  132180. * is addded to the diffuse part of the material.
  132181. */
  132182. translucencyIntensity: number;
  132183. /**
  132184. * Defines the scattering intensity of the material.
  132185. * When scattering has been enabled, this defines how much of the "scattered light"
  132186. * is addded to the diffuse part of the material.
  132187. */
  132188. scatteringIntensity: number;
  132189. /**
  132190. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  132191. */
  132192. useAlbedoToTintRefraction: boolean;
  132193. private _thicknessTexture;
  132194. /**
  132195. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  132196. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  132197. * 0 would mean minimumThickness
  132198. * 1 would mean maximumThickness
  132199. * The other channels might be use as a mask to vary the different effects intensity.
  132200. */
  132201. thicknessTexture: Nullable<BaseTexture>;
  132202. private _refractionTexture;
  132203. /**
  132204. * Defines the texture to use for refraction.
  132205. */
  132206. refractionTexture: Nullable<BaseTexture>;
  132207. private _indexOfRefraction;
  132208. /**
  132209. * Index of refraction of the material base layer.
  132210. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132211. *
  132212. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  132213. *
  132214. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  132215. */
  132216. indexOfRefraction: number;
  132217. private _volumeIndexOfRefraction;
  132218. /**
  132219. * Index of refraction of the material's volume.
  132220. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132221. *
  132222. * This ONLY impacts refraction. If not provided or given a non-valid value,
  132223. * the volume will use the same IOR as the surface.
  132224. */
  132225. get volumeIndexOfRefraction(): number;
  132226. set volumeIndexOfRefraction(value: number);
  132227. private _invertRefractionY;
  132228. /**
  132229. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  132230. */
  132231. invertRefractionY: boolean;
  132232. private _linkRefractionWithTransparency;
  132233. /**
  132234. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  132235. * Materials half opaque for instance using refraction could benefit from this control.
  132236. */
  132237. linkRefractionWithTransparency: boolean;
  132238. /**
  132239. * Defines the minimum thickness stored in the thickness map.
  132240. * If no thickness map is defined, this value will be used to simulate thickness.
  132241. */
  132242. minimumThickness: number;
  132243. /**
  132244. * Defines the maximum thickness stored in the thickness map.
  132245. */
  132246. maximumThickness: number;
  132247. /**
  132248. * Defines the volume tint of the material.
  132249. * This is used for both translucency and scattering.
  132250. */
  132251. tintColor: Color3;
  132252. /**
  132253. * Defines the distance at which the tint color should be found in the media.
  132254. * This is used for refraction only.
  132255. */
  132256. tintColorAtDistance: number;
  132257. /**
  132258. * Defines how far each channel transmit through the media.
  132259. * It is defined as a color to simplify it selection.
  132260. */
  132261. diffusionDistance: Color3;
  132262. private _useMaskFromThicknessTexture;
  132263. /**
  132264. * Stores the intensity of the different subsurface effects in the thickness texture.
  132265. * * the green channel is the translucency intensity.
  132266. * * the blue channel is the scattering intensity.
  132267. * * the alpha channel is the refraction intensity.
  132268. */
  132269. useMaskFromThicknessTexture: boolean;
  132270. /** @hidden */
  132271. private _internalMarkAllSubMeshesAsTexturesDirty;
  132272. /** @hidden */
  132273. _markAllSubMeshesAsTexturesDirty(): void;
  132274. /**
  132275. * Instantiate a new istance of sub surface configuration.
  132276. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132277. */
  132278. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132279. /**
  132280. * Gets wehter the submesh is ready to be used or not.
  132281. * @param defines the list of "defines" to update.
  132282. * @param scene defines the scene the material belongs to.
  132283. * @returns - boolean indicating that the submesh is ready or not.
  132284. */
  132285. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  132286. /**
  132287. * Checks to see if a texture is used in the material.
  132288. * @param defines the list of "defines" to update.
  132289. * @param scene defines the scene to the material belongs to.
  132290. */
  132291. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  132292. /**
  132293. * Binds the material data.
  132294. * @param uniformBuffer defines the Uniform buffer to fill in.
  132295. * @param scene defines the scene the material belongs to.
  132296. * @param engine defines the engine the material belongs to.
  132297. * @param isFrozen defines whether the material is frozen or not.
  132298. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  132299. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  132300. */
  132301. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  132302. /**
  132303. * Unbinds the material from the mesh.
  132304. * @param activeEffect defines the effect that should be unbound from.
  132305. * @returns true if unbound, otherwise false
  132306. */
  132307. unbind(activeEffect: Effect): boolean;
  132308. /**
  132309. * Returns the texture used for refraction or null if none is used.
  132310. * @param scene defines the scene the material belongs to.
  132311. * @returns - Refraction texture if present. If no refraction texture and refraction
  132312. * is linked with transparency, returns environment texture. Otherwise, returns null.
  132313. */
  132314. private _getRefractionTexture;
  132315. /**
  132316. * Returns true if alpha blending should be disabled.
  132317. */
  132318. get disableAlphaBlending(): boolean;
  132319. /**
  132320. * Fills the list of render target textures.
  132321. * @param renderTargets the list of render targets to update
  132322. */
  132323. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  132324. /**
  132325. * Checks to see if a texture is used in the material.
  132326. * @param texture - Base texture to use.
  132327. * @returns - Boolean specifying if a texture is used in the material.
  132328. */
  132329. hasTexture(texture: BaseTexture): boolean;
  132330. /**
  132331. * Gets a boolean indicating that current material needs to register RTT
  132332. * @returns true if this uses a render target otherwise false.
  132333. */
  132334. hasRenderTargetTextures(): boolean;
  132335. /**
  132336. * Returns an array of the actively used textures.
  132337. * @param activeTextures Array of BaseTextures
  132338. */
  132339. getActiveTextures(activeTextures: BaseTexture[]): void;
  132340. /**
  132341. * Returns the animatable textures.
  132342. * @param animatables Array of animatable textures.
  132343. */
  132344. getAnimatables(animatables: IAnimatable[]): void;
  132345. /**
  132346. * Disposes the resources of the material.
  132347. * @param forceDisposeTextures - Forces the disposal of all textures.
  132348. */
  132349. dispose(forceDisposeTextures?: boolean): void;
  132350. /**
  132351. * Get the current class name of the texture useful for serialization or dynamic coding.
  132352. * @returns "PBRSubSurfaceConfiguration"
  132353. */
  132354. getClassName(): string;
  132355. /**
  132356. * Add fallbacks to the effect fallbacks list.
  132357. * @param defines defines the Base texture to use.
  132358. * @param fallbacks defines the current fallback list.
  132359. * @param currentRank defines the current fallback rank.
  132360. * @returns the new fallback rank.
  132361. */
  132362. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132363. /**
  132364. * Add the required uniforms to the current list.
  132365. * @param uniforms defines the current uniform list.
  132366. */
  132367. static AddUniforms(uniforms: string[]): void;
  132368. /**
  132369. * Add the required samplers to the current list.
  132370. * @param samplers defines the current sampler list.
  132371. */
  132372. static AddSamplers(samplers: string[]): void;
  132373. /**
  132374. * Add the required uniforms to the current buffer.
  132375. * @param uniformBuffer defines the current uniform buffer.
  132376. */
  132377. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132378. /**
  132379. * Makes a duplicate of the current configuration into another one.
  132380. * @param configuration define the config where to copy the info
  132381. */
  132382. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  132383. /**
  132384. * Serializes this Sub Surface configuration.
  132385. * @returns - An object with the serialized config.
  132386. */
  132387. serialize(): any;
  132388. /**
  132389. * Parses a anisotropy Configuration from a serialized object.
  132390. * @param source - Serialized object.
  132391. * @param scene Defines the scene we are parsing for
  132392. * @param rootUrl Defines the rootUrl to load from
  132393. */
  132394. parse(source: any, scene: Scene, rootUrl: string): void;
  132395. }
  132396. }
  132397. declare module BABYLON {
  132398. /** @hidden */
  132399. export var pbrFragmentDeclaration: {
  132400. name: string;
  132401. shader: string;
  132402. };
  132403. }
  132404. declare module BABYLON {
  132405. /** @hidden */
  132406. export var pbrUboDeclaration: {
  132407. name: string;
  132408. shader: string;
  132409. };
  132410. }
  132411. declare module BABYLON {
  132412. /** @hidden */
  132413. export var pbrFragmentExtraDeclaration: {
  132414. name: string;
  132415. shader: string;
  132416. };
  132417. }
  132418. declare module BABYLON {
  132419. /** @hidden */
  132420. export var pbrFragmentSamplersDeclaration: {
  132421. name: string;
  132422. shader: string;
  132423. };
  132424. }
  132425. declare module BABYLON {
  132426. /** @hidden */
  132427. export var importanceSampling: {
  132428. name: string;
  132429. shader: string;
  132430. };
  132431. }
  132432. declare module BABYLON {
  132433. /** @hidden */
  132434. export var pbrHelperFunctions: {
  132435. name: string;
  132436. shader: string;
  132437. };
  132438. }
  132439. declare module BABYLON {
  132440. /** @hidden */
  132441. export var harmonicsFunctions: {
  132442. name: string;
  132443. shader: string;
  132444. };
  132445. }
  132446. declare module BABYLON {
  132447. /** @hidden */
  132448. export var pbrDirectLightingSetupFunctions: {
  132449. name: string;
  132450. shader: string;
  132451. };
  132452. }
  132453. declare module BABYLON {
  132454. /** @hidden */
  132455. export var pbrDirectLightingFalloffFunctions: {
  132456. name: string;
  132457. shader: string;
  132458. };
  132459. }
  132460. declare module BABYLON {
  132461. /** @hidden */
  132462. export var pbrBRDFFunctions: {
  132463. name: string;
  132464. shader: string;
  132465. };
  132466. }
  132467. declare module BABYLON {
  132468. /** @hidden */
  132469. export var hdrFilteringFunctions: {
  132470. name: string;
  132471. shader: string;
  132472. };
  132473. }
  132474. declare module BABYLON {
  132475. /** @hidden */
  132476. export var pbrDirectLightingFunctions: {
  132477. name: string;
  132478. shader: string;
  132479. };
  132480. }
  132481. declare module BABYLON {
  132482. /** @hidden */
  132483. export var pbrIBLFunctions: {
  132484. name: string;
  132485. shader: string;
  132486. };
  132487. }
  132488. declare module BABYLON {
  132489. /** @hidden */
  132490. export var pbrBlockAlbedoOpacity: {
  132491. name: string;
  132492. shader: string;
  132493. };
  132494. }
  132495. declare module BABYLON {
  132496. /** @hidden */
  132497. export var pbrBlockReflectivity: {
  132498. name: string;
  132499. shader: string;
  132500. };
  132501. }
  132502. declare module BABYLON {
  132503. /** @hidden */
  132504. export var pbrBlockAmbientOcclusion: {
  132505. name: string;
  132506. shader: string;
  132507. };
  132508. }
  132509. declare module BABYLON {
  132510. /** @hidden */
  132511. export var pbrBlockAlphaFresnel: {
  132512. name: string;
  132513. shader: string;
  132514. };
  132515. }
  132516. declare module BABYLON {
  132517. /** @hidden */
  132518. export var pbrBlockAnisotropic: {
  132519. name: string;
  132520. shader: string;
  132521. };
  132522. }
  132523. declare module BABYLON {
  132524. /** @hidden */
  132525. export var pbrBlockReflection: {
  132526. name: string;
  132527. shader: string;
  132528. };
  132529. }
  132530. declare module BABYLON {
  132531. /** @hidden */
  132532. export var pbrBlockSheen: {
  132533. name: string;
  132534. shader: string;
  132535. };
  132536. }
  132537. declare module BABYLON {
  132538. /** @hidden */
  132539. export var pbrBlockClearcoat: {
  132540. name: string;
  132541. shader: string;
  132542. };
  132543. }
  132544. declare module BABYLON {
  132545. /** @hidden */
  132546. export var pbrBlockSubSurface: {
  132547. name: string;
  132548. shader: string;
  132549. };
  132550. }
  132551. declare module BABYLON {
  132552. /** @hidden */
  132553. export var pbrBlockNormalGeometric: {
  132554. name: string;
  132555. shader: string;
  132556. };
  132557. }
  132558. declare module BABYLON {
  132559. /** @hidden */
  132560. export var pbrBlockNormalFinal: {
  132561. name: string;
  132562. shader: string;
  132563. };
  132564. }
  132565. declare module BABYLON {
  132566. /** @hidden */
  132567. export var pbrBlockGeometryInfo: {
  132568. name: string;
  132569. shader: string;
  132570. };
  132571. }
  132572. declare module BABYLON {
  132573. /** @hidden */
  132574. export var pbrBlockReflectance0: {
  132575. name: string;
  132576. shader: string;
  132577. };
  132578. }
  132579. declare module BABYLON {
  132580. /** @hidden */
  132581. export var pbrBlockReflectance: {
  132582. name: string;
  132583. shader: string;
  132584. };
  132585. }
  132586. declare module BABYLON {
  132587. /** @hidden */
  132588. export var pbrBlockDirectLighting: {
  132589. name: string;
  132590. shader: string;
  132591. };
  132592. }
  132593. declare module BABYLON {
  132594. /** @hidden */
  132595. export var pbrBlockFinalLitComponents: {
  132596. name: string;
  132597. shader: string;
  132598. };
  132599. }
  132600. declare module BABYLON {
  132601. /** @hidden */
  132602. export var pbrBlockFinalUnlitComponents: {
  132603. name: string;
  132604. shader: string;
  132605. };
  132606. }
  132607. declare module BABYLON {
  132608. /** @hidden */
  132609. export var pbrBlockFinalColorComposition: {
  132610. name: string;
  132611. shader: string;
  132612. };
  132613. }
  132614. declare module BABYLON {
  132615. /** @hidden */
  132616. export var pbrBlockImageProcessing: {
  132617. name: string;
  132618. shader: string;
  132619. };
  132620. }
  132621. declare module BABYLON {
  132622. /** @hidden */
  132623. export var pbrDebug: {
  132624. name: string;
  132625. shader: string;
  132626. };
  132627. }
  132628. declare module BABYLON {
  132629. /** @hidden */
  132630. export var pbrPixelShader: {
  132631. name: string;
  132632. shader: string;
  132633. };
  132634. }
  132635. declare module BABYLON {
  132636. /** @hidden */
  132637. export var pbrVertexDeclaration: {
  132638. name: string;
  132639. shader: string;
  132640. };
  132641. }
  132642. declare module BABYLON {
  132643. /** @hidden */
  132644. export var pbrVertexShader: {
  132645. name: string;
  132646. shader: string;
  132647. };
  132648. }
  132649. declare module BABYLON {
  132650. /**
  132651. * Manages the defines for the PBR Material.
  132652. * @hidden
  132653. */
  132654. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  132655. PBR: boolean;
  132656. NUM_SAMPLES: string;
  132657. REALTIME_FILTERING: boolean;
  132658. MAINUV1: boolean;
  132659. MAINUV2: boolean;
  132660. UV1: boolean;
  132661. UV2: boolean;
  132662. ALBEDO: boolean;
  132663. GAMMAALBEDO: boolean;
  132664. ALBEDODIRECTUV: number;
  132665. VERTEXCOLOR: boolean;
  132666. DETAIL: boolean;
  132667. DETAILDIRECTUV: number;
  132668. DETAIL_NORMALBLENDMETHOD: number;
  132669. AMBIENT: boolean;
  132670. AMBIENTDIRECTUV: number;
  132671. AMBIENTINGRAYSCALE: boolean;
  132672. OPACITY: boolean;
  132673. VERTEXALPHA: boolean;
  132674. OPACITYDIRECTUV: number;
  132675. OPACITYRGB: boolean;
  132676. ALPHATEST: boolean;
  132677. DEPTHPREPASS: boolean;
  132678. ALPHABLEND: boolean;
  132679. ALPHAFROMALBEDO: boolean;
  132680. ALPHATESTVALUE: string;
  132681. SPECULAROVERALPHA: boolean;
  132682. RADIANCEOVERALPHA: boolean;
  132683. ALPHAFRESNEL: boolean;
  132684. LINEARALPHAFRESNEL: boolean;
  132685. PREMULTIPLYALPHA: boolean;
  132686. EMISSIVE: boolean;
  132687. EMISSIVEDIRECTUV: number;
  132688. REFLECTIVITY: boolean;
  132689. REFLECTIVITYDIRECTUV: number;
  132690. SPECULARTERM: boolean;
  132691. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  132692. MICROSURFACEAUTOMATIC: boolean;
  132693. LODBASEDMICROSFURACE: boolean;
  132694. MICROSURFACEMAP: boolean;
  132695. MICROSURFACEMAPDIRECTUV: number;
  132696. METALLICWORKFLOW: boolean;
  132697. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  132698. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  132699. METALLNESSSTOREINMETALMAPBLUE: boolean;
  132700. AOSTOREINMETALMAPRED: boolean;
  132701. METALLIC_REFLECTANCE: boolean;
  132702. METALLIC_REFLECTANCEDIRECTUV: number;
  132703. ENVIRONMENTBRDF: boolean;
  132704. ENVIRONMENTBRDF_RGBD: boolean;
  132705. NORMAL: boolean;
  132706. TANGENT: boolean;
  132707. BUMP: boolean;
  132708. BUMPDIRECTUV: number;
  132709. OBJECTSPACE_NORMALMAP: boolean;
  132710. PARALLAX: boolean;
  132711. PARALLAXOCCLUSION: boolean;
  132712. NORMALXYSCALE: boolean;
  132713. LIGHTMAP: boolean;
  132714. LIGHTMAPDIRECTUV: number;
  132715. USELIGHTMAPASSHADOWMAP: boolean;
  132716. GAMMALIGHTMAP: boolean;
  132717. RGBDLIGHTMAP: boolean;
  132718. REFLECTION: boolean;
  132719. REFLECTIONMAP_3D: boolean;
  132720. REFLECTIONMAP_SPHERICAL: boolean;
  132721. REFLECTIONMAP_PLANAR: boolean;
  132722. REFLECTIONMAP_CUBIC: boolean;
  132723. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  132724. REFLECTIONMAP_PROJECTION: boolean;
  132725. REFLECTIONMAP_SKYBOX: boolean;
  132726. REFLECTIONMAP_EXPLICIT: boolean;
  132727. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  132728. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  132729. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  132730. INVERTCUBICMAP: boolean;
  132731. USESPHERICALFROMREFLECTIONMAP: boolean;
  132732. USEIRRADIANCEMAP: boolean;
  132733. SPHERICAL_HARMONICS: boolean;
  132734. USESPHERICALINVERTEX: boolean;
  132735. REFLECTIONMAP_OPPOSITEZ: boolean;
  132736. LODINREFLECTIONALPHA: boolean;
  132737. GAMMAREFLECTION: boolean;
  132738. RGBDREFLECTION: boolean;
  132739. LINEARSPECULARREFLECTION: boolean;
  132740. RADIANCEOCCLUSION: boolean;
  132741. HORIZONOCCLUSION: boolean;
  132742. INSTANCES: boolean;
  132743. THIN_INSTANCES: boolean;
  132744. NUM_BONE_INFLUENCERS: number;
  132745. BonesPerMesh: number;
  132746. BONETEXTURE: boolean;
  132747. NONUNIFORMSCALING: boolean;
  132748. MORPHTARGETS: boolean;
  132749. MORPHTARGETS_NORMAL: boolean;
  132750. MORPHTARGETS_TANGENT: boolean;
  132751. MORPHTARGETS_UV: boolean;
  132752. NUM_MORPH_INFLUENCERS: number;
  132753. IMAGEPROCESSING: boolean;
  132754. VIGNETTE: boolean;
  132755. VIGNETTEBLENDMODEMULTIPLY: boolean;
  132756. VIGNETTEBLENDMODEOPAQUE: boolean;
  132757. TONEMAPPING: boolean;
  132758. TONEMAPPING_ACES: boolean;
  132759. CONTRAST: boolean;
  132760. COLORCURVES: boolean;
  132761. COLORGRADING: boolean;
  132762. COLORGRADING3D: boolean;
  132763. SAMPLER3DGREENDEPTH: boolean;
  132764. SAMPLER3DBGRMAP: boolean;
  132765. IMAGEPROCESSINGPOSTPROCESS: boolean;
  132766. EXPOSURE: boolean;
  132767. MULTIVIEW: boolean;
  132768. USEPHYSICALLIGHTFALLOFF: boolean;
  132769. USEGLTFLIGHTFALLOFF: boolean;
  132770. TWOSIDEDLIGHTING: boolean;
  132771. SHADOWFLOAT: boolean;
  132772. CLIPPLANE: boolean;
  132773. CLIPPLANE2: boolean;
  132774. CLIPPLANE3: boolean;
  132775. CLIPPLANE4: boolean;
  132776. CLIPPLANE5: boolean;
  132777. CLIPPLANE6: boolean;
  132778. POINTSIZE: boolean;
  132779. FOG: boolean;
  132780. LOGARITHMICDEPTH: boolean;
  132781. FORCENORMALFORWARD: boolean;
  132782. SPECULARAA: boolean;
  132783. CLEARCOAT: boolean;
  132784. CLEARCOAT_DEFAULTIOR: boolean;
  132785. CLEARCOAT_TEXTURE: boolean;
  132786. CLEARCOAT_TEXTUREDIRECTUV: number;
  132787. CLEARCOAT_BUMP: boolean;
  132788. CLEARCOAT_BUMPDIRECTUV: number;
  132789. CLEARCOAT_TINT: boolean;
  132790. CLEARCOAT_TINT_TEXTURE: boolean;
  132791. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  132792. ANISOTROPIC: boolean;
  132793. ANISOTROPIC_TEXTURE: boolean;
  132794. ANISOTROPIC_TEXTUREDIRECTUV: number;
  132795. BRDF_V_HEIGHT_CORRELATED: boolean;
  132796. MS_BRDF_ENERGY_CONSERVATION: boolean;
  132797. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  132798. SHEEN: boolean;
  132799. SHEEN_TEXTURE: boolean;
  132800. SHEEN_TEXTUREDIRECTUV: number;
  132801. SHEEN_LINKWITHALBEDO: boolean;
  132802. SHEEN_ROUGHNESS: boolean;
  132803. SHEEN_ALBEDOSCALING: boolean;
  132804. SUBSURFACE: boolean;
  132805. SS_REFRACTION: boolean;
  132806. SS_TRANSLUCENCY: boolean;
  132807. SS_SCATTERING: boolean;
  132808. SS_THICKNESSANDMASK_TEXTURE: boolean;
  132809. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  132810. SS_REFRACTIONMAP_3D: boolean;
  132811. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  132812. SS_LODINREFRACTIONALPHA: boolean;
  132813. SS_GAMMAREFRACTION: boolean;
  132814. SS_RGBDREFRACTION: boolean;
  132815. SS_LINEARSPECULARREFRACTION: boolean;
  132816. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  132817. SS_ALBEDOFORREFRACTIONTINT: boolean;
  132818. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  132819. UNLIT: boolean;
  132820. DEBUGMODE: number;
  132821. /**
  132822. * Initializes the PBR Material defines.
  132823. */
  132824. constructor();
  132825. /**
  132826. * Resets the PBR Material defines.
  132827. */
  132828. reset(): void;
  132829. }
  132830. /**
  132831. * The Physically based material base class of BJS.
  132832. *
  132833. * This offers the main features of a standard PBR material.
  132834. * For more information, please refer to the documentation :
  132835. * https://doc.babylonjs.com/how_to/physically_based_rendering
  132836. */
  132837. export abstract class PBRBaseMaterial extends PushMaterial {
  132838. /**
  132839. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  132840. */
  132841. static readonly PBRMATERIAL_OPAQUE: number;
  132842. /**
  132843. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  132844. */
  132845. static readonly PBRMATERIAL_ALPHATEST: number;
  132846. /**
  132847. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  132848. */
  132849. static readonly PBRMATERIAL_ALPHABLEND: number;
  132850. /**
  132851. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  132852. * They are also discarded below the alpha cutoff threshold to improve performances.
  132853. */
  132854. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  132855. /**
  132856. * Defines the default value of how much AO map is occluding the analytical lights
  132857. * (point spot...).
  132858. */
  132859. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  132860. /**
  132861. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  132862. */
  132863. static readonly LIGHTFALLOFF_PHYSICAL: number;
  132864. /**
  132865. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  132866. * to enhance interoperability with other engines.
  132867. */
  132868. static readonly LIGHTFALLOFF_GLTF: number;
  132869. /**
  132870. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  132871. * to enhance interoperability with other materials.
  132872. */
  132873. static readonly LIGHTFALLOFF_STANDARD: number;
  132874. /**
  132875. * Intensity of the direct lights e.g. the four lights available in your scene.
  132876. * This impacts both the direct diffuse and specular highlights.
  132877. */
  132878. protected _directIntensity: number;
  132879. /**
  132880. * Intensity of the emissive part of the material.
  132881. * This helps controlling the emissive effect without modifying the emissive color.
  132882. */
  132883. protected _emissiveIntensity: number;
  132884. /**
  132885. * Intensity of the environment e.g. how much the environment will light the object
  132886. * either through harmonics for rough material or through the refelction for shiny ones.
  132887. */
  132888. protected _environmentIntensity: number;
  132889. /**
  132890. * This is a special control allowing the reduction of the specular highlights coming from the
  132891. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  132892. */
  132893. protected _specularIntensity: number;
  132894. /**
  132895. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  132896. */
  132897. private _lightingInfos;
  132898. /**
  132899. * Debug Control allowing disabling the bump map on this material.
  132900. */
  132901. protected _disableBumpMap: boolean;
  132902. /**
  132903. * AKA Diffuse Texture in standard nomenclature.
  132904. */
  132905. protected _albedoTexture: Nullable<BaseTexture>;
  132906. /**
  132907. * AKA Occlusion Texture in other nomenclature.
  132908. */
  132909. protected _ambientTexture: Nullable<BaseTexture>;
  132910. /**
  132911. * AKA Occlusion Texture Intensity in other nomenclature.
  132912. */
  132913. protected _ambientTextureStrength: number;
  132914. /**
  132915. * Defines how much the AO map is occluding the analytical lights (point spot...).
  132916. * 1 means it completely occludes it
  132917. * 0 mean it has no impact
  132918. */
  132919. protected _ambientTextureImpactOnAnalyticalLights: number;
  132920. /**
  132921. * Stores the alpha values in a texture.
  132922. */
  132923. protected _opacityTexture: Nullable<BaseTexture>;
  132924. /**
  132925. * Stores the reflection values in a texture.
  132926. */
  132927. protected _reflectionTexture: Nullable<BaseTexture>;
  132928. /**
  132929. * Stores the emissive values in a texture.
  132930. */
  132931. protected _emissiveTexture: Nullable<BaseTexture>;
  132932. /**
  132933. * AKA Specular texture in other nomenclature.
  132934. */
  132935. protected _reflectivityTexture: Nullable<BaseTexture>;
  132936. /**
  132937. * Used to switch from specular/glossiness to metallic/roughness workflow.
  132938. */
  132939. protected _metallicTexture: Nullable<BaseTexture>;
  132940. /**
  132941. * Specifies the metallic scalar of the metallic/roughness workflow.
  132942. * Can also be used to scale the metalness values of the metallic texture.
  132943. */
  132944. protected _metallic: Nullable<number>;
  132945. /**
  132946. * Specifies the roughness scalar of the metallic/roughness workflow.
  132947. * Can also be used to scale the roughness values of the metallic texture.
  132948. */
  132949. protected _roughness: Nullable<number>;
  132950. /**
  132951. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  132952. * By default the indexOfrefraction is used to compute F0;
  132953. *
  132954. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  132955. *
  132956. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  132957. * F90 = metallicReflectanceColor;
  132958. */
  132959. protected _metallicF0Factor: number;
  132960. /**
  132961. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  132962. * By default the F90 is always 1;
  132963. *
  132964. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  132965. *
  132966. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  132967. * F90 = metallicReflectanceColor;
  132968. */
  132969. protected _metallicReflectanceColor: Color3;
  132970. /**
  132971. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  132972. * This is multiply against the scalar values defined in the material.
  132973. */
  132974. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  132975. /**
  132976. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  132977. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  132978. */
  132979. protected _microSurfaceTexture: Nullable<BaseTexture>;
  132980. /**
  132981. * Stores surface normal data used to displace a mesh in a texture.
  132982. */
  132983. protected _bumpTexture: Nullable<BaseTexture>;
  132984. /**
  132985. * Stores the pre-calculated light information of a mesh in a texture.
  132986. */
  132987. protected _lightmapTexture: Nullable<BaseTexture>;
  132988. /**
  132989. * The color of a material in ambient lighting.
  132990. */
  132991. protected _ambientColor: Color3;
  132992. /**
  132993. * AKA Diffuse Color in other nomenclature.
  132994. */
  132995. protected _albedoColor: Color3;
  132996. /**
  132997. * AKA Specular Color in other nomenclature.
  132998. */
  132999. protected _reflectivityColor: Color3;
  133000. /**
  133001. * The color applied when light is reflected from a material.
  133002. */
  133003. protected _reflectionColor: Color3;
  133004. /**
  133005. * The color applied when light is emitted from a material.
  133006. */
  133007. protected _emissiveColor: Color3;
  133008. /**
  133009. * AKA Glossiness in other nomenclature.
  133010. */
  133011. protected _microSurface: number;
  133012. /**
  133013. * Specifies that the material will use the light map as a show map.
  133014. */
  133015. protected _useLightmapAsShadowmap: boolean;
  133016. /**
  133017. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  133018. * makes the reflect vector face the model (under horizon).
  133019. */
  133020. protected _useHorizonOcclusion: boolean;
  133021. /**
  133022. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  133023. * too much the area relying on ambient texture to define their ambient occlusion.
  133024. */
  133025. protected _useRadianceOcclusion: boolean;
  133026. /**
  133027. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  133028. */
  133029. protected _useAlphaFromAlbedoTexture: boolean;
  133030. /**
  133031. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  133032. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  133033. */
  133034. protected _useSpecularOverAlpha: boolean;
  133035. /**
  133036. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  133037. */
  133038. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  133039. /**
  133040. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  133041. */
  133042. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  133043. /**
  133044. * Specifies if the metallic texture contains the roughness information in its green channel.
  133045. */
  133046. protected _useRoughnessFromMetallicTextureGreen: boolean;
  133047. /**
  133048. * Specifies if the metallic texture contains the metallness information in its blue channel.
  133049. */
  133050. protected _useMetallnessFromMetallicTextureBlue: boolean;
  133051. /**
  133052. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  133053. */
  133054. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  133055. /**
  133056. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  133057. */
  133058. protected _useAmbientInGrayScale: boolean;
  133059. /**
  133060. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  133061. * The material will try to infer what glossiness each pixel should be.
  133062. */
  133063. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  133064. /**
  133065. * Defines the falloff type used in this material.
  133066. * It by default is Physical.
  133067. */
  133068. protected _lightFalloff: number;
  133069. /**
  133070. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  133071. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  133072. */
  133073. protected _useRadianceOverAlpha: boolean;
  133074. /**
  133075. * Allows using an object space normal map (instead of tangent space).
  133076. */
  133077. protected _useObjectSpaceNormalMap: boolean;
  133078. /**
  133079. * Allows using the bump map in parallax mode.
  133080. */
  133081. protected _useParallax: boolean;
  133082. /**
  133083. * Allows using the bump map in parallax occlusion mode.
  133084. */
  133085. protected _useParallaxOcclusion: boolean;
  133086. /**
  133087. * Controls the scale bias of the parallax mode.
  133088. */
  133089. protected _parallaxScaleBias: number;
  133090. /**
  133091. * If sets to true, disables all the lights affecting the material.
  133092. */
  133093. protected _disableLighting: boolean;
  133094. /**
  133095. * Number of Simultaneous lights allowed on the material.
  133096. */
  133097. protected _maxSimultaneousLights: number;
  133098. /**
  133099. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  133100. */
  133101. protected _invertNormalMapX: boolean;
  133102. /**
  133103. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  133104. */
  133105. protected _invertNormalMapY: boolean;
  133106. /**
  133107. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  133108. */
  133109. protected _twoSidedLighting: boolean;
  133110. /**
  133111. * Defines the alpha limits in alpha test mode.
  133112. */
  133113. protected _alphaCutOff: number;
  133114. /**
  133115. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  133116. */
  133117. protected _forceAlphaTest: boolean;
  133118. /**
  133119. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133120. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  133121. */
  133122. protected _useAlphaFresnel: boolean;
  133123. /**
  133124. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133125. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  133126. */
  133127. protected _useLinearAlphaFresnel: boolean;
  133128. /**
  133129. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  133130. * from cos thetav and roughness:
  133131. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  133132. */
  133133. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  133134. /**
  133135. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  133136. */
  133137. protected _forceIrradianceInFragment: boolean;
  133138. private _realTimeFiltering;
  133139. /**
  133140. * Enables realtime filtering on the texture.
  133141. */
  133142. get realTimeFiltering(): boolean;
  133143. set realTimeFiltering(b: boolean);
  133144. private _realTimeFilteringQuality;
  133145. /**
  133146. * Quality switch for realtime filtering
  133147. */
  133148. get realTimeFilteringQuality(): number;
  133149. set realTimeFilteringQuality(n: number);
  133150. /**
  133151. * Force normal to face away from face.
  133152. */
  133153. protected _forceNormalForward: boolean;
  133154. /**
  133155. * Enables specular anti aliasing in the PBR shader.
  133156. * It will both interacts on the Geometry for analytical and IBL lighting.
  133157. * It also prefilter the roughness map based on the bump values.
  133158. */
  133159. protected _enableSpecularAntiAliasing: boolean;
  133160. /**
  133161. * Default configuration related to image processing available in the PBR Material.
  133162. */
  133163. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  133164. /**
  133165. * Keep track of the image processing observer to allow dispose and replace.
  133166. */
  133167. private _imageProcessingObserver;
  133168. /**
  133169. * Attaches a new image processing configuration to the PBR Material.
  133170. * @param configuration
  133171. */
  133172. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  133173. /**
  133174. * Stores the available render targets.
  133175. */
  133176. private _renderTargets;
  133177. /**
  133178. * Sets the global ambient color for the material used in lighting calculations.
  133179. */
  133180. private _globalAmbientColor;
  133181. /**
  133182. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  133183. */
  133184. private _useLogarithmicDepth;
  133185. /**
  133186. * If set to true, no lighting calculations will be applied.
  133187. */
  133188. private _unlit;
  133189. private _debugMode;
  133190. /**
  133191. * @hidden
  133192. * This is reserved for the inspector.
  133193. * Defines the material debug mode.
  133194. * It helps seeing only some components of the material while troubleshooting.
  133195. */
  133196. debugMode: number;
  133197. /**
  133198. * @hidden
  133199. * This is reserved for the inspector.
  133200. * Specify from where on screen the debug mode should start.
  133201. * The value goes from -1 (full screen) to 1 (not visible)
  133202. * It helps with side by side comparison against the final render
  133203. * This defaults to -1
  133204. */
  133205. private debugLimit;
  133206. /**
  133207. * @hidden
  133208. * This is reserved for the inspector.
  133209. * As the default viewing range might not be enough (if the ambient is really small for instance)
  133210. * You can use the factor to better multiply the final value.
  133211. */
  133212. private debugFactor;
  133213. /**
  133214. * Defines the clear coat layer parameters for the material.
  133215. */
  133216. readonly clearCoat: PBRClearCoatConfiguration;
  133217. /**
  133218. * Defines the anisotropic parameters for the material.
  133219. */
  133220. readonly anisotropy: PBRAnisotropicConfiguration;
  133221. /**
  133222. * Defines the BRDF parameters for the material.
  133223. */
  133224. readonly brdf: PBRBRDFConfiguration;
  133225. /**
  133226. * Defines the Sheen parameters for the material.
  133227. */
  133228. readonly sheen: PBRSheenConfiguration;
  133229. /**
  133230. * Defines the SubSurface parameters for the material.
  133231. */
  133232. readonly subSurface: PBRSubSurfaceConfiguration;
  133233. /**
  133234. * Defines the detail map parameters for the material.
  133235. */
  133236. readonly detailMap: DetailMapConfiguration;
  133237. protected _rebuildInParallel: boolean;
  133238. /**
  133239. * Instantiates a new PBRMaterial instance.
  133240. *
  133241. * @param name The material name
  133242. * @param scene The scene the material will be use in.
  133243. */
  133244. constructor(name: string, scene: Scene);
  133245. /**
  133246. * Gets a boolean indicating that current material needs to register RTT
  133247. */
  133248. get hasRenderTargetTextures(): boolean;
  133249. /**
  133250. * Gets the name of the material class.
  133251. */
  133252. getClassName(): string;
  133253. /**
  133254. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  133255. */
  133256. get useLogarithmicDepth(): boolean;
  133257. /**
  133258. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  133259. */
  133260. set useLogarithmicDepth(value: boolean);
  133261. /**
  133262. * Returns true if alpha blending should be disabled.
  133263. */
  133264. protected get _disableAlphaBlending(): boolean;
  133265. /**
  133266. * Specifies whether or not this material should be rendered in alpha blend mode.
  133267. */
  133268. needAlphaBlending(): boolean;
  133269. /**
  133270. * Specifies whether or not this material should be rendered in alpha test mode.
  133271. */
  133272. needAlphaTesting(): boolean;
  133273. /**
  133274. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  133275. */
  133276. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  133277. /**
  133278. * Gets the texture used for the alpha test.
  133279. */
  133280. getAlphaTestTexture(): Nullable<BaseTexture>;
  133281. /**
  133282. * Specifies that the submesh is ready to be used.
  133283. * @param mesh - BJS mesh.
  133284. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  133285. * @param useInstances - Specifies that instances should be used.
  133286. * @returns - boolean indicating that the submesh is ready or not.
  133287. */
  133288. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  133289. /**
  133290. * Specifies if the material uses metallic roughness workflow.
  133291. * @returns boolean specifiying if the material uses metallic roughness workflow.
  133292. */
  133293. isMetallicWorkflow(): boolean;
  133294. private _prepareEffect;
  133295. private _prepareDefines;
  133296. /**
  133297. * Force shader compilation
  133298. */
  133299. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  133300. /**
  133301. * Initializes the uniform buffer layout for the shader.
  133302. */
  133303. buildUniformLayout(): void;
  133304. /**
  133305. * Unbinds the material from the mesh
  133306. */
  133307. unbind(): void;
  133308. /**
  133309. * Binds the submesh data.
  133310. * @param world - The world matrix.
  133311. * @param mesh - The BJS mesh.
  133312. * @param subMesh - A submesh of the BJS mesh.
  133313. */
  133314. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  133315. /**
  133316. * Returns the animatable textures.
  133317. * @returns - Array of animatable textures.
  133318. */
  133319. getAnimatables(): IAnimatable[];
  133320. /**
  133321. * Returns the texture used for reflections.
  133322. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  133323. */
  133324. private _getReflectionTexture;
  133325. /**
  133326. * Returns an array of the actively used textures.
  133327. * @returns - Array of BaseTextures
  133328. */
  133329. getActiveTextures(): BaseTexture[];
  133330. /**
  133331. * Checks to see if a texture is used in the material.
  133332. * @param texture - Base texture to use.
  133333. * @returns - Boolean specifying if a texture is used in the material.
  133334. */
  133335. hasTexture(texture: BaseTexture): boolean;
  133336. /**
  133337. * Disposes the resources of the material.
  133338. * @param forceDisposeEffect - Forces the disposal of effects.
  133339. * @param forceDisposeTextures - Forces the disposal of all textures.
  133340. */
  133341. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  133342. }
  133343. }
  133344. declare module BABYLON {
  133345. /**
  133346. * The Physically based material of BJS.
  133347. *
  133348. * This offers the main features of a standard PBR material.
  133349. * For more information, please refer to the documentation :
  133350. * https://doc.babylonjs.com/how_to/physically_based_rendering
  133351. */
  133352. export class PBRMaterial extends PBRBaseMaterial {
  133353. /**
  133354. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  133355. */
  133356. static readonly PBRMATERIAL_OPAQUE: number;
  133357. /**
  133358. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  133359. */
  133360. static readonly PBRMATERIAL_ALPHATEST: number;
  133361. /**
  133362. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133363. */
  133364. static readonly PBRMATERIAL_ALPHABLEND: number;
  133365. /**
  133366. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133367. * They are also discarded below the alpha cutoff threshold to improve performances.
  133368. */
  133369. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  133370. /**
  133371. * Defines the default value of how much AO map is occluding the analytical lights
  133372. * (point spot...).
  133373. */
  133374. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  133375. /**
  133376. * Intensity of the direct lights e.g. the four lights available in your scene.
  133377. * This impacts both the direct diffuse and specular highlights.
  133378. */
  133379. directIntensity: number;
  133380. /**
  133381. * Intensity of the emissive part of the material.
  133382. * This helps controlling the emissive effect without modifying the emissive color.
  133383. */
  133384. emissiveIntensity: number;
  133385. /**
  133386. * Intensity of the environment e.g. how much the environment will light the object
  133387. * either through harmonics for rough material or through the refelction for shiny ones.
  133388. */
  133389. environmentIntensity: number;
  133390. /**
  133391. * This is a special control allowing the reduction of the specular highlights coming from the
  133392. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  133393. */
  133394. specularIntensity: number;
  133395. /**
  133396. * Debug Control allowing disabling the bump map on this material.
  133397. */
  133398. disableBumpMap: boolean;
  133399. /**
  133400. * AKA Diffuse Texture in standard nomenclature.
  133401. */
  133402. albedoTexture: BaseTexture;
  133403. /**
  133404. * AKA Occlusion Texture in other nomenclature.
  133405. */
  133406. ambientTexture: BaseTexture;
  133407. /**
  133408. * AKA Occlusion Texture Intensity in other nomenclature.
  133409. */
  133410. ambientTextureStrength: number;
  133411. /**
  133412. * Defines how much the AO map is occluding the analytical lights (point spot...).
  133413. * 1 means it completely occludes it
  133414. * 0 mean it has no impact
  133415. */
  133416. ambientTextureImpactOnAnalyticalLights: number;
  133417. /**
  133418. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  133419. */
  133420. opacityTexture: BaseTexture;
  133421. /**
  133422. * Stores the reflection values in a texture.
  133423. */
  133424. reflectionTexture: Nullable<BaseTexture>;
  133425. /**
  133426. * Stores the emissive values in a texture.
  133427. */
  133428. emissiveTexture: BaseTexture;
  133429. /**
  133430. * AKA Specular texture in other nomenclature.
  133431. */
  133432. reflectivityTexture: BaseTexture;
  133433. /**
  133434. * Used to switch from specular/glossiness to metallic/roughness workflow.
  133435. */
  133436. metallicTexture: BaseTexture;
  133437. /**
  133438. * Specifies the metallic scalar of the metallic/roughness workflow.
  133439. * Can also be used to scale the metalness values of the metallic texture.
  133440. */
  133441. metallic: Nullable<number>;
  133442. /**
  133443. * Specifies the roughness scalar of the metallic/roughness workflow.
  133444. * Can also be used to scale the roughness values of the metallic texture.
  133445. */
  133446. roughness: Nullable<number>;
  133447. /**
  133448. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  133449. * By default the indexOfrefraction is used to compute F0;
  133450. *
  133451. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  133452. *
  133453. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  133454. * F90 = metallicReflectanceColor;
  133455. */
  133456. metallicF0Factor: number;
  133457. /**
  133458. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  133459. * By default the F90 is always 1;
  133460. *
  133461. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  133462. *
  133463. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  133464. * F90 = metallicReflectanceColor;
  133465. */
  133466. metallicReflectanceColor: Color3;
  133467. /**
  133468. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  133469. * This is multiply against the scalar values defined in the material.
  133470. */
  133471. metallicReflectanceTexture: Nullable<BaseTexture>;
  133472. /**
  133473. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  133474. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  133475. */
  133476. microSurfaceTexture: BaseTexture;
  133477. /**
  133478. * Stores surface normal data used to displace a mesh in a texture.
  133479. */
  133480. bumpTexture: BaseTexture;
  133481. /**
  133482. * Stores the pre-calculated light information of a mesh in a texture.
  133483. */
  133484. lightmapTexture: BaseTexture;
  133485. /**
  133486. * Stores the refracted light information in a texture.
  133487. */
  133488. get refractionTexture(): Nullable<BaseTexture>;
  133489. set refractionTexture(value: Nullable<BaseTexture>);
  133490. /**
  133491. * The color of a material in ambient lighting.
  133492. */
  133493. ambientColor: Color3;
  133494. /**
  133495. * AKA Diffuse Color in other nomenclature.
  133496. */
  133497. albedoColor: Color3;
  133498. /**
  133499. * AKA Specular Color in other nomenclature.
  133500. */
  133501. reflectivityColor: Color3;
  133502. /**
  133503. * The color reflected from the material.
  133504. */
  133505. reflectionColor: Color3;
  133506. /**
  133507. * The color emitted from the material.
  133508. */
  133509. emissiveColor: Color3;
  133510. /**
  133511. * AKA Glossiness in other nomenclature.
  133512. */
  133513. microSurface: number;
  133514. /**
  133515. * Index of refraction of the material base layer.
  133516. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  133517. *
  133518. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  133519. *
  133520. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  133521. */
  133522. get indexOfRefraction(): number;
  133523. set indexOfRefraction(value: number);
  133524. /**
  133525. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  133526. */
  133527. get invertRefractionY(): boolean;
  133528. set invertRefractionY(value: boolean);
  133529. /**
  133530. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  133531. * Materials half opaque for instance using refraction could benefit from this control.
  133532. */
  133533. get linkRefractionWithTransparency(): boolean;
  133534. set linkRefractionWithTransparency(value: boolean);
  133535. /**
  133536. * If true, the light map contains occlusion information instead of lighting info.
  133537. */
  133538. useLightmapAsShadowmap: boolean;
  133539. /**
  133540. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  133541. */
  133542. useAlphaFromAlbedoTexture: boolean;
  133543. /**
  133544. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  133545. */
  133546. forceAlphaTest: boolean;
  133547. /**
  133548. * Defines the alpha limits in alpha test mode.
  133549. */
  133550. alphaCutOff: number;
  133551. /**
  133552. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  133553. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  133554. */
  133555. useSpecularOverAlpha: boolean;
  133556. /**
  133557. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  133558. */
  133559. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  133560. /**
  133561. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  133562. */
  133563. useRoughnessFromMetallicTextureAlpha: boolean;
  133564. /**
  133565. * Specifies if the metallic texture contains the roughness information in its green channel.
  133566. */
  133567. useRoughnessFromMetallicTextureGreen: boolean;
  133568. /**
  133569. * Specifies if the metallic texture contains the metallness information in its blue channel.
  133570. */
  133571. useMetallnessFromMetallicTextureBlue: boolean;
  133572. /**
  133573. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  133574. */
  133575. useAmbientOcclusionFromMetallicTextureRed: boolean;
  133576. /**
  133577. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  133578. */
  133579. useAmbientInGrayScale: boolean;
  133580. /**
  133581. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  133582. * The material will try to infer what glossiness each pixel should be.
  133583. */
  133584. useAutoMicroSurfaceFromReflectivityMap: boolean;
  133585. /**
  133586. * BJS is using an harcoded light falloff based on a manually sets up range.
  133587. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  133588. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  133589. */
  133590. get usePhysicalLightFalloff(): boolean;
  133591. /**
  133592. * BJS is using an harcoded light falloff based on a manually sets up range.
  133593. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  133594. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  133595. */
  133596. set usePhysicalLightFalloff(value: boolean);
  133597. /**
  133598. * In order to support the falloff compatibility with gltf, a special mode has been added
  133599. * to reproduce the gltf light falloff.
  133600. */
  133601. get useGLTFLightFalloff(): boolean;
  133602. /**
  133603. * In order to support the falloff compatibility with gltf, a special mode has been added
  133604. * to reproduce the gltf light falloff.
  133605. */
  133606. set useGLTFLightFalloff(value: boolean);
  133607. /**
  133608. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  133609. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  133610. */
  133611. useRadianceOverAlpha: boolean;
  133612. /**
  133613. * Allows using an object space normal map (instead of tangent space).
  133614. */
  133615. useObjectSpaceNormalMap: boolean;
  133616. /**
  133617. * Allows using the bump map in parallax mode.
  133618. */
  133619. useParallax: boolean;
  133620. /**
  133621. * Allows using the bump map in parallax occlusion mode.
  133622. */
  133623. useParallaxOcclusion: boolean;
  133624. /**
  133625. * Controls the scale bias of the parallax mode.
  133626. */
  133627. parallaxScaleBias: number;
  133628. /**
  133629. * If sets to true, disables all the lights affecting the material.
  133630. */
  133631. disableLighting: boolean;
  133632. /**
  133633. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  133634. */
  133635. forceIrradianceInFragment: boolean;
  133636. /**
  133637. * Number of Simultaneous lights allowed on the material.
  133638. */
  133639. maxSimultaneousLights: number;
  133640. /**
  133641. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  133642. */
  133643. invertNormalMapX: boolean;
  133644. /**
  133645. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  133646. */
  133647. invertNormalMapY: boolean;
  133648. /**
  133649. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  133650. */
  133651. twoSidedLighting: boolean;
  133652. /**
  133653. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133654. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  133655. */
  133656. useAlphaFresnel: boolean;
  133657. /**
  133658. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133659. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  133660. */
  133661. useLinearAlphaFresnel: boolean;
  133662. /**
  133663. * Let user defines the brdf lookup texture used for IBL.
  133664. * A default 8bit version is embedded but you could point at :
  133665. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  133666. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  133667. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  133668. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  133669. */
  133670. environmentBRDFTexture: Nullable<BaseTexture>;
  133671. /**
  133672. * Force normal to face away from face.
  133673. */
  133674. forceNormalForward: boolean;
  133675. /**
  133676. * Enables specular anti aliasing in the PBR shader.
  133677. * It will both interacts on the Geometry for analytical and IBL lighting.
  133678. * It also prefilter the roughness map based on the bump values.
  133679. */
  133680. enableSpecularAntiAliasing: boolean;
  133681. /**
  133682. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  133683. * makes the reflect vector face the model (under horizon).
  133684. */
  133685. useHorizonOcclusion: boolean;
  133686. /**
  133687. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  133688. * too much the area relying on ambient texture to define their ambient occlusion.
  133689. */
  133690. useRadianceOcclusion: boolean;
  133691. /**
  133692. * If set to true, no lighting calculations will be applied.
  133693. */
  133694. unlit: boolean;
  133695. /**
  133696. * Gets the image processing configuration used either in this material.
  133697. */
  133698. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  133699. /**
  133700. * Sets the Default image processing configuration used either in the this material.
  133701. *
  133702. * If sets to null, the scene one is in use.
  133703. */
  133704. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  133705. /**
  133706. * Gets wether the color curves effect is enabled.
  133707. */
  133708. get cameraColorCurvesEnabled(): boolean;
  133709. /**
  133710. * Sets wether the color curves effect is enabled.
  133711. */
  133712. set cameraColorCurvesEnabled(value: boolean);
  133713. /**
  133714. * Gets wether the color grading effect is enabled.
  133715. */
  133716. get cameraColorGradingEnabled(): boolean;
  133717. /**
  133718. * Gets wether the color grading effect is enabled.
  133719. */
  133720. set cameraColorGradingEnabled(value: boolean);
  133721. /**
  133722. * Gets wether tonemapping is enabled or not.
  133723. */
  133724. get cameraToneMappingEnabled(): boolean;
  133725. /**
  133726. * Sets wether tonemapping is enabled or not
  133727. */
  133728. set cameraToneMappingEnabled(value: boolean);
  133729. /**
  133730. * The camera exposure used on this material.
  133731. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133732. * This corresponds to a photographic exposure.
  133733. */
  133734. get cameraExposure(): number;
  133735. /**
  133736. * The camera exposure used on this material.
  133737. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133738. * This corresponds to a photographic exposure.
  133739. */
  133740. set cameraExposure(value: number);
  133741. /**
  133742. * Gets The camera contrast used on this material.
  133743. */
  133744. get cameraContrast(): number;
  133745. /**
  133746. * Sets The camera contrast used on this material.
  133747. */
  133748. set cameraContrast(value: number);
  133749. /**
  133750. * Gets the Color Grading 2D Lookup Texture.
  133751. */
  133752. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  133753. /**
  133754. * Sets the Color Grading 2D Lookup Texture.
  133755. */
  133756. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  133757. /**
  133758. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133759. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133760. * 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;
  133761. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133762. */
  133763. get cameraColorCurves(): Nullable<ColorCurves>;
  133764. /**
  133765. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133766. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133767. * 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;
  133768. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133769. */
  133770. set cameraColorCurves(value: Nullable<ColorCurves>);
  133771. /**
  133772. * Instantiates a new PBRMaterial instance.
  133773. *
  133774. * @param name The material name
  133775. * @param scene The scene the material will be use in.
  133776. */
  133777. constructor(name: string, scene: Scene);
  133778. /**
  133779. * Returns the name of this material class.
  133780. */
  133781. getClassName(): string;
  133782. /**
  133783. * Makes a duplicate of the current material.
  133784. * @param name - name to use for the new material.
  133785. */
  133786. clone(name: string): PBRMaterial;
  133787. /**
  133788. * Serializes this PBR Material.
  133789. * @returns - An object with the serialized material.
  133790. */
  133791. serialize(): any;
  133792. /**
  133793. * Parses a PBR Material from a serialized object.
  133794. * @param source - Serialized object.
  133795. * @param scene - BJS scene instance.
  133796. * @param rootUrl - url for the scene object
  133797. * @returns - PBRMaterial
  133798. */
  133799. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  133800. }
  133801. }
  133802. declare module BABYLON {
  133803. /**
  133804. * Direct draw surface info
  133805. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  133806. */
  133807. export interface DDSInfo {
  133808. /**
  133809. * Width of the texture
  133810. */
  133811. width: number;
  133812. /**
  133813. * Width of the texture
  133814. */
  133815. height: number;
  133816. /**
  133817. * Number of Mipmaps for the texture
  133818. * @see https://en.wikipedia.org/wiki/Mipmap
  133819. */
  133820. mipmapCount: number;
  133821. /**
  133822. * If the textures format is a known fourCC format
  133823. * @see https://www.fourcc.org/
  133824. */
  133825. isFourCC: boolean;
  133826. /**
  133827. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  133828. */
  133829. isRGB: boolean;
  133830. /**
  133831. * If the texture is a lumincance format
  133832. */
  133833. isLuminance: boolean;
  133834. /**
  133835. * If this is a cube texture
  133836. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  133837. */
  133838. isCube: boolean;
  133839. /**
  133840. * If the texture is a compressed format eg. FOURCC_DXT1
  133841. */
  133842. isCompressed: boolean;
  133843. /**
  133844. * The dxgiFormat of the texture
  133845. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  133846. */
  133847. dxgiFormat: number;
  133848. /**
  133849. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  133850. */
  133851. textureType: number;
  133852. /**
  133853. * Sphericle polynomial created for the dds texture
  133854. */
  133855. sphericalPolynomial?: SphericalPolynomial;
  133856. }
  133857. /**
  133858. * Class used to provide DDS decompression tools
  133859. */
  133860. export class DDSTools {
  133861. /**
  133862. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  133863. */
  133864. static StoreLODInAlphaChannel: boolean;
  133865. /**
  133866. * Gets DDS information from an array buffer
  133867. * @param data defines the array buffer view to read data from
  133868. * @returns the DDS information
  133869. */
  133870. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  133871. private static _FloatView;
  133872. private static _Int32View;
  133873. private static _ToHalfFloat;
  133874. private static _FromHalfFloat;
  133875. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  133876. private static _GetHalfFloatRGBAArrayBuffer;
  133877. private static _GetFloatRGBAArrayBuffer;
  133878. private static _GetFloatAsUIntRGBAArrayBuffer;
  133879. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  133880. private static _GetRGBAArrayBuffer;
  133881. private static _ExtractLongWordOrder;
  133882. private static _GetRGBArrayBuffer;
  133883. private static _GetLuminanceArrayBuffer;
  133884. /**
  133885. * Uploads DDS Levels to a Babylon Texture
  133886. * @hidden
  133887. */
  133888. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  133889. }
  133890. interface ThinEngine {
  133891. /**
  133892. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  133893. * @param rootUrl defines the url where the file to load is located
  133894. * @param scene defines the current scene
  133895. * @param lodScale defines scale to apply to the mip map selection
  133896. * @param lodOffset defines offset to apply to the mip map selection
  133897. * @param onLoad defines an optional callback raised when the texture is loaded
  133898. * @param onError defines an optional callback raised if there is an issue to load the texture
  133899. * @param format defines the format of the data
  133900. * @param forcedExtension defines the extension to use to pick the right loader
  133901. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  133902. * @returns the cube texture as an InternalTexture
  133903. */
  133904. 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;
  133905. }
  133906. }
  133907. declare module BABYLON {
  133908. /**
  133909. * Implementation of the DDS Texture Loader.
  133910. * @hidden
  133911. */
  133912. export class _DDSTextureLoader implements IInternalTextureLoader {
  133913. /**
  133914. * Defines wether the loader supports cascade loading the different faces.
  133915. */
  133916. readonly supportCascades: boolean;
  133917. /**
  133918. * This returns if the loader support the current file information.
  133919. * @param extension defines the file extension of the file being loaded
  133920. * @returns true if the loader can load the specified file
  133921. */
  133922. canLoad(extension: string): boolean;
  133923. /**
  133924. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  133925. * @param data contains the texture data
  133926. * @param texture defines the BabylonJS internal texture
  133927. * @param createPolynomials will be true if polynomials have been requested
  133928. * @param onLoad defines the callback to trigger once the texture is ready
  133929. * @param onError defines the callback to trigger in case of error
  133930. */
  133931. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  133932. /**
  133933. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  133934. * @param data contains the texture data
  133935. * @param texture defines the BabylonJS internal texture
  133936. * @param callback defines the method to call once ready to upload
  133937. */
  133938. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  133939. }
  133940. }
  133941. declare module BABYLON {
  133942. /**
  133943. * Implementation of the ENV Texture Loader.
  133944. * @hidden
  133945. */
  133946. export class _ENVTextureLoader implements IInternalTextureLoader {
  133947. /**
  133948. * Defines wether the loader supports cascade loading the different faces.
  133949. */
  133950. readonly supportCascades: boolean;
  133951. /**
  133952. * This returns if the loader support the current file information.
  133953. * @param extension defines the file extension of the file being loaded
  133954. * @returns true if the loader can load the specified file
  133955. */
  133956. canLoad(extension: string): boolean;
  133957. /**
  133958. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  133959. * @param data contains the texture data
  133960. * @param texture defines the BabylonJS internal texture
  133961. * @param createPolynomials will be true if polynomials have been requested
  133962. * @param onLoad defines the callback to trigger once the texture is ready
  133963. * @param onError defines the callback to trigger in case of error
  133964. */
  133965. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  133966. /**
  133967. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  133968. * @param data contains the texture data
  133969. * @param texture defines the BabylonJS internal texture
  133970. * @param callback defines the method to call once ready to upload
  133971. */
  133972. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  133973. }
  133974. }
  133975. declare module BABYLON {
  133976. /**
  133977. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  133978. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  133979. */
  133980. export class KhronosTextureContainer {
  133981. /** contents of the KTX container file */
  133982. data: ArrayBufferView;
  133983. private static HEADER_LEN;
  133984. private static COMPRESSED_2D;
  133985. private static COMPRESSED_3D;
  133986. private static TEX_2D;
  133987. private static TEX_3D;
  133988. /**
  133989. * Gets the openGL type
  133990. */
  133991. glType: number;
  133992. /**
  133993. * Gets the openGL type size
  133994. */
  133995. glTypeSize: number;
  133996. /**
  133997. * Gets the openGL format
  133998. */
  133999. glFormat: number;
  134000. /**
  134001. * Gets the openGL internal format
  134002. */
  134003. glInternalFormat: number;
  134004. /**
  134005. * Gets the base internal format
  134006. */
  134007. glBaseInternalFormat: number;
  134008. /**
  134009. * Gets image width in pixel
  134010. */
  134011. pixelWidth: number;
  134012. /**
  134013. * Gets image height in pixel
  134014. */
  134015. pixelHeight: number;
  134016. /**
  134017. * Gets image depth in pixels
  134018. */
  134019. pixelDepth: number;
  134020. /**
  134021. * Gets the number of array elements
  134022. */
  134023. numberOfArrayElements: number;
  134024. /**
  134025. * Gets the number of faces
  134026. */
  134027. numberOfFaces: number;
  134028. /**
  134029. * Gets the number of mipmap levels
  134030. */
  134031. numberOfMipmapLevels: number;
  134032. /**
  134033. * Gets the bytes of key value data
  134034. */
  134035. bytesOfKeyValueData: number;
  134036. /**
  134037. * Gets the load type
  134038. */
  134039. loadType: number;
  134040. /**
  134041. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  134042. */
  134043. isInvalid: boolean;
  134044. /**
  134045. * Creates a new KhronosTextureContainer
  134046. * @param data contents of the KTX container file
  134047. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  134048. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  134049. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  134050. */
  134051. constructor(
  134052. /** contents of the KTX container file */
  134053. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  134054. /**
  134055. * Uploads KTX content to a Babylon Texture.
  134056. * It is assumed that the texture has already been created & is currently bound
  134057. * @hidden
  134058. */
  134059. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  134060. private _upload2DCompressedLevels;
  134061. /**
  134062. * Checks if the given data starts with a KTX file identifier.
  134063. * @param data the data to check
  134064. * @returns true if the data is a KTX file or false otherwise
  134065. */
  134066. static IsValid(data: ArrayBufferView): boolean;
  134067. }
  134068. }
  134069. declare module BABYLON {
  134070. /**
  134071. * Class for loading KTX2 files
  134072. * !!! Experimental Extension Subject to Changes !!!
  134073. * @hidden
  134074. */
  134075. export class KhronosTextureContainer2 {
  134076. private static _ModulePromise;
  134077. private static _TranscodeFormat;
  134078. constructor(engine: ThinEngine);
  134079. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  134080. private _determineTranscodeFormat;
  134081. /**
  134082. * Checks if the given data starts with a KTX2 file identifier.
  134083. * @param data the data to check
  134084. * @returns true if the data is a KTX2 file or false otherwise
  134085. */
  134086. static IsValid(data: ArrayBufferView): boolean;
  134087. }
  134088. }
  134089. declare module BABYLON {
  134090. /**
  134091. * Implementation of the KTX Texture Loader.
  134092. * @hidden
  134093. */
  134094. export class _KTXTextureLoader implements IInternalTextureLoader {
  134095. /**
  134096. * Defines wether the loader supports cascade loading the different faces.
  134097. */
  134098. readonly supportCascades: boolean;
  134099. /**
  134100. * This returns if the loader support the current file information.
  134101. * @param extension defines the file extension of the file being loaded
  134102. * @returns true if the loader can load the specified file
  134103. */
  134104. canLoad(extension: string): boolean;
  134105. /**
  134106. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134107. * @param data contains the texture data
  134108. * @param texture defines the BabylonJS internal texture
  134109. * @param createPolynomials will be true if polynomials have been requested
  134110. * @param onLoad defines the callback to trigger once the texture is ready
  134111. * @param onError defines the callback to trigger in case of error
  134112. */
  134113. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134114. /**
  134115. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134116. * @param data contains the texture data
  134117. * @param texture defines the BabylonJS internal texture
  134118. * @param callback defines the method to call once ready to upload
  134119. */
  134120. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  134121. }
  134122. }
  134123. declare module BABYLON {
  134124. /** @hidden */
  134125. export var _forceSceneHelpersToBundle: boolean;
  134126. interface Scene {
  134127. /**
  134128. * Creates a default light for the scene.
  134129. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  134130. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  134131. */
  134132. createDefaultLight(replace?: boolean): void;
  134133. /**
  134134. * Creates a default camera for the scene.
  134135. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  134136. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  134137. * @param replace has default false, when true replaces the active camera in the scene
  134138. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  134139. */
  134140. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  134141. /**
  134142. * Creates a default camera and a default light.
  134143. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  134144. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  134145. * @param replace has the default false, when true replaces the active camera/light in the scene
  134146. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  134147. */
  134148. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  134149. /**
  134150. * Creates a new sky box
  134151. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  134152. * @param environmentTexture defines the texture to use as environment texture
  134153. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  134154. * @param scale defines the overall scale of the skybox
  134155. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  134156. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  134157. * @returns a new mesh holding the sky box
  134158. */
  134159. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  134160. /**
  134161. * Creates a new environment
  134162. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  134163. * @param options defines the options you can use to configure the environment
  134164. * @returns the new EnvironmentHelper
  134165. */
  134166. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  134167. /**
  134168. * Creates a new VREXperienceHelper
  134169. * @see http://doc.babylonjs.com/how_to/webvr_helper
  134170. * @param webVROptions defines the options used to create the new VREXperienceHelper
  134171. * @returns a new VREXperienceHelper
  134172. */
  134173. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  134174. /**
  134175. * Creates a new WebXRDefaultExperience
  134176. * @see http://doc.babylonjs.com/how_to/webxr
  134177. * @param options experience options
  134178. * @returns a promise for a new WebXRDefaultExperience
  134179. */
  134180. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  134181. }
  134182. }
  134183. declare module BABYLON {
  134184. /**
  134185. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  134186. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  134187. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  134188. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  134189. */
  134190. export class VideoDome extends TransformNode {
  134191. /**
  134192. * Define the video source as a Monoscopic panoramic 360 video.
  134193. */
  134194. static readonly MODE_MONOSCOPIC: number;
  134195. /**
  134196. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  134197. */
  134198. static readonly MODE_TOPBOTTOM: number;
  134199. /**
  134200. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  134201. */
  134202. static readonly MODE_SIDEBYSIDE: number;
  134203. private _halfDome;
  134204. private _useDirectMapping;
  134205. /**
  134206. * The video texture being displayed on the sphere
  134207. */
  134208. protected _videoTexture: VideoTexture;
  134209. /**
  134210. * Gets the video texture being displayed on the sphere
  134211. */
  134212. get videoTexture(): VideoTexture;
  134213. /**
  134214. * The skybox material
  134215. */
  134216. protected _material: BackgroundMaterial;
  134217. /**
  134218. * The surface used for the skybox
  134219. */
  134220. protected _mesh: Mesh;
  134221. /**
  134222. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  134223. */
  134224. private _halfDomeMask;
  134225. /**
  134226. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134227. * Also see the options.resolution property.
  134228. */
  134229. get fovMultiplier(): number;
  134230. set fovMultiplier(value: number);
  134231. private _videoMode;
  134232. /**
  134233. * Gets or set the current video mode for the video. It can be:
  134234. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  134235. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  134236. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  134237. */
  134238. get videoMode(): number;
  134239. set videoMode(value: number);
  134240. /**
  134241. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  134242. *
  134243. */
  134244. get halfDome(): boolean;
  134245. /**
  134246. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  134247. */
  134248. set halfDome(enabled: boolean);
  134249. /**
  134250. * Oberserver used in Stereoscopic VR Mode.
  134251. */
  134252. private _onBeforeCameraRenderObserver;
  134253. /**
  134254. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  134255. * @param name Element's name, child elements will append suffixes for their own names.
  134256. * @param urlsOrVideo defines the url(s) or the video element to use
  134257. * @param options An object containing optional or exposed sub element properties
  134258. */
  134259. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  134260. resolution?: number;
  134261. clickToPlay?: boolean;
  134262. autoPlay?: boolean;
  134263. loop?: boolean;
  134264. size?: number;
  134265. poster?: string;
  134266. faceForward?: boolean;
  134267. useDirectMapping?: boolean;
  134268. halfDomeMode?: boolean;
  134269. }, scene: Scene);
  134270. private _changeVideoMode;
  134271. /**
  134272. * Releases resources associated with this node.
  134273. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  134274. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  134275. */
  134276. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  134277. }
  134278. }
  134279. declare module BABYLON {
  134280. /**
  134281. * This class can be used to get instrumentation data from a Babylon engine
  134282. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  134283. */
  134284. export class EngineInstrumentation implements IDisposable {
  134285. /**
  134286. * Define the instrumented engine.
  134287. */
  134288. engine: Engine;
  134289. private _captureGPUFrameTime;
  134290. private _gpuFrameTimeToken;
  134291. private _gpuFrameTime;
  134292. private _captureShaderCompilationTime;
  134293. private _shaderCompilationTime;
  134294. private _onBeginFrameObserver;
  134295. private _onEndFrameObserver;
  134296. private _onBeforeShaderCompilationObserver;
  134297. private _onAfterShaderCompilationObserver;
  134298. /**
  134299. * Gets the perf counter used for GPU frame time
  134300. */
  134301. get gpuFrameTimeCounter(): PerfCounter;
  134302. /**
  134303. * Gets the GPU frame time capture status
  134304. */
  134305. get captureGPUFrameTime(): boolean;
  134306. /**
  134307. * Enable or disable the GPU frame time capture
  134308. */
  134309. set captureGPUFrameTime(value: boolean);
  134310. /**
  134311. * Gets the perf counter used for shader compilation time
  134312. */
  134313. get shaderCompilationTimeCounter(): PerfCounter;
  134314. /**
  134315. * Gets the shader compilation time capture status
  134316. */
  134317. get captureShaderCompilationTime(): boolean;
  134318. /**
  134319. * Enable or disable the shader compilation time capture
  134320. */
  134321. set captureShaderCompilationTime(value: boolean);
  134322. /**
  134323. * Instantiates a new engine instrumentation.
  134324. * This class can be used to get instrumentation data from a Babylon engine
  134325. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  134326. * @param engine Defines the engine to instrument
  134327. */
  134328. constructor(
  134329. /**
  134330. * Define the instrumented engine.
  134331. */
  134332. engine: Engine);
  134333. /**
  134334. * Dispose and release associated resources.
  134335. */
  134336. dispose(): void;
  134337. }
  134338. }
  134339. declare module BABYLON {
  134340. /**
  134341. * This class can be used to get instrumentation data from a Babylon engine
  134342. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  134343. */
  134344. export class SceneInstrumentation implements IDisposable {
  134345. /**
  134346. * Defines the scene to instrument
  134347. */
  134348. scene: Scene;
  134349. private _captureActiveMeshesEvaluationTime;
  134350. private _activeMeshesEvaluationTime;
  134351. private _captureRenderTargetsRenderTime;
  134352. private _renderTargetsRenderTime;
  134353. private _captureFrameTime;
  134354. private _frameTime;
  134355. private _captureRenderTime;
  134356. private _renderTime;
  134357. private _captureInterFrameTime;
  134358. private _interFrameTime;
  134359. private _captureParticlesRenderTime;
  134360. private _particlesRenderTime;
  134361. private _captureSpritesRenderTime;
  134362. private _spritesRenderTime;
  134363. private _capturePhysicsTime;
  134364. private _physicsTime;
  134365. private _captureAnimationsTime;
  134366. private _animationsTime;
  134367. private _captureCameraRenderTime;
  134368. private _cameraRenderTime;
  134369. private _onBeforeActiveMeshesEvaluationObserver;
  134370. private _onAfterActiveMeshesEvaluationObserver;
  134371. private _onBeforeRenderTargetsRenderObserver;
  134372. private _onAfterRenderTargetsRenderObserver;
  134373. private _onAfterRenderObserver;
  134374. private _onBeforeDrawPhaseObserver;
  134375. private _onAfterDrawPhaseObserver;
  134376. private _onBeforeAnimationsObserver;
  134377. private _onBeforeParticlesRenderingObserver;
  134378. private _onAfterParticlesRenderingObserver;
  134379. private _onBeforeSpritesRenderingObserver;
  134380. private _onAfterSpritesRenderingObserver;
  134381. private _onBeforePhysicsObserver;
  134382. private _onAfterPhysicsObserver;
  134383. private _onAfterAnimationsObserver;
  134384. private _onBeforeCameraRenderObserver;
  134385. private _onAfterCameraRenderObserver;
  134386. /**
  134387. * Gets the perf counter used for active meshes evaluation time
  134388. */
  134389. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  134390. /**
  134391. * Gets the active meshes evaluation time capture status
  134392. */
  134393. get captureActiveMeshesEvaluationTime(): boolean;
  134394. /**
  134395. * Enable or disable the active meshes evaluation time capture
  134396. */
  134397. set captureActiveMeshesEvaluationTime(value: boolean);
  134398. /**
  134399. * Gets the perf counter used for render targets render time
  134400. */
  134401. get renderTargetsRenderTimeCounter(): PerfCounter;
  134402. /**
  134403. * Gets the render targets render time capture status
  134404. */
  134405. get captureRenderTargetsRenderTime(): boolean;
  134406. /**
  134407. * Enable or disable the render targets render time capture
  134408. */
  134409. set captureRenderTargetsRenderTime(value: boolean);
  134410. /**
  134411. * Gets the perf counter used for particles render time
  134412. */
  134413. get particlesRenderTimeCounter(): PerfCounter;
  134414. /**
  134415. * Gets the particles render time capture status
  134416. */
  134417. get captureParticlesRenderTime(): boolean;
  134418. /**
  134419. * Enable or disable the particles render time capture
  134420. */
  134421. set captureParticlesRenderTime(value: boolean);
  134422. /**
  134423. * Gets the perf counter used for sprites render time
  134424. */
  134425. get spritesRenderTimeCounter(): PerfCounter;
  134426. /**
  134427. * Gets the sprites render time capture status
  134428. */
  134429. get captureSpritesRenderTime(): boolean;
  134430. /**
  134431. * Enable or disable the sprites render time capture
  134432. */
  134433. set captureSpritesRenderTime(value: boolean);
  134434. /**
  134435. * Gets the perf counter used for physics time
  134436. */
  134437. get physicsTimeCounter(): PerfCounter;
  134438. /**
  134439. * Gets the physics time capture status
  134440. */
  134441. get capturePhysicsTime(): boolean;
  134442. /**
  134443. * Enable or disable the physics time capture
  134444. */
  134445. set capturePhysicsTime(value: boolean);
  134446. /**
  134447. * Gets the perf counter used for animations time
  134448. */
  134449. get animationsTimeCounter(): PerfCounter;
  134450. /**
  134451. * Gets the animations time capture status
  134452. */
  134453. get captureAnimationsTime(): boolean;
  134454. /**
  134455. * Enable or disable the animations time capture
  134456. */
  134457. set captureAnimationsTime(value: boolean);
  134458. /**
  134459. * Gets the perf counter used for frame time capture
  134460. */
  134461. get frameTimeCounter(): PerfCounter;
  134462. /**
  134463. * Gets the frame time capture status
  134464. */
  134465. get captureFrameTime(): boolean;
  134466. /**
  134467. * Enable or disable the frame time capture
  134468. */
  134469. set captureFrameTime(value: boolean);
  134470. /**
  134471. * Gets the perf counter used for inter-frames time capture
  134472. */
  134473. get interFrameTimeCounter(): PerfCounter;
  134474. /**
  134475. * Gets the inter-frames time capture status
  134476. */
  134477. get captureInterFrameTime(): boolean;
  134478. /**
  134479. * Enable or disable the inter-frames time capture
  134480. */
  134481. set captureInterFrameTime(value: boolean);
  134482. /**
  134483. * Gets the perf counter used for render time capture
  134484. */
  134485. get renderTimeCounter(): PerfCounter;
  134486. /**
  134487. * Gets the render time capture status
  134488. */
  134489. get captureRenderTime(): boolean;
  134490. /**
  134491. * Enable or disable the render time capture
  134492. */
  134493. set captureRenderTime(value: boolean);
  134494. /**
  134495. * Gets the perf counter used for camera render time capture
  134496. */
  134497. get cameraRenderTimeCounter(): PerfCounter;
  134498. /**
  134499. * Gets the camera render time capture status
  134500. */
  134501. get captureCameraRenderTime(): boolean;
  134502. /**
  134503. * Enable or disable the camera render time capture
  134504. */
  134505. set captureCameraRenderTime(value: boolean);
  134506. /**
  134507. * Gets the perf counter used for draw calls
  134508. */
  134509. get drawCallsCounter(): PerfCounter;
  134510. /**
  134511. * Instantiates a new scene instrumentation.
  134512. * This class can be used to get instrumentation data from a Babylon engine
  134513. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  134514. * @param scene Defines the scene to instrument
  134515. */
  134516. constructor(
  134517. /**
  134518. * Defines the scene to instrument
  134519. */
  134520. scene: Scene);
  134521. /**
  134522. * Dispose and release associated resources.
  134523. */
  134524. dispose(): void;
  134525. }
  134526. }
  134527. declare module BABYLON {
  134528. /** @hidden */
  134529. export var glowMapGenerationPixelShader: {
  134530. name: string;
  134531. shader: string;
  134532. };
  134533. }
  134534. declare module BABYLON {
  134535. /** @hidden */
  134536. export var glowMapGenerationVertexShader: {
  134537. name: string;
  134538. shader: string;
  134539. };
  134540. }
  134541. declare module BABYLON {
  134542. /**
  134543. * Effect layer options. This helps customizing the behaviour
  134544. * of the effect layer.
  134545. */
  134546. export interface IEffectLayerOptions {
  134547. /**
  134548. * Multiplication factor apply to the canvas size to compute the render target size
  134549. * used to generated the objects (the smaller the faster).
  134550. */
  134551. mainTextureRatio: number;
  134552. /**
  134553. * Enforces a fixed size texture to ensure effect stability across devices.
  134554. */
  134555. mainTextureFixedSize?: number;
  134556. /**
  134557. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  134558. */
  134559. alphaBlendingMode: number;
  134560. /**
  134561. * The camera attached to the layer.
  134562. */
  134563. camera: Nullable<Camera>;
  134564. /**
  134565. * The rendering group to draw the layer in.
  134566. */
  134567. renderingGroupId: number;
  134568. }
  134569. /**
  134570. * The effect layer Helps adding post process effect blended with the main pass.
  134571. *
  134572. * This can be for instance use to generate glow or higlight effects on the scene.
  134573. *
  134574. * The effect layer class can not be used directly and is intented to inherited from to be
  134575. * customized per effects.
  134576. */
  134577. export abstract class EffectLayer {
  134578. private _vertexBuffers;
  134579. private _indexBuffer;
  134580. private _cachedDefines;
  134581. private _effectLayerMapGenerationEffect;
  134582. private _effectLayerOptions;
  134583. private _mergeEffect;
  134584. protected _scene: Scene;
  134585. protected _engine: Engine;
  134586. protected _maxSize: number;
  134587. protected _mainTextureDesiredSize: ISize;
  134588. protected _mainTexture: RenderTargetTexture;
  134589. protected _shouldRender: boolean;
  134590. protected _postProcesses: PostProcess[];
  134591. protected _textures: BaseTexture[];
  134592. protected _emissiveTextureAndColor: {
  134593. texture: Nullable<BaseTexture>;
  134594. color: Color4;
  134595. };
  134596. /**
  134597. * The name of the layer
  134598. */
  134599. name: string;
  134600. /**
  134601. * The clear color of the texture used to generate the glow map.
  134602. */
  134603. neutralColor: Color4;
  134604. /**
  134605. * Specifies whether the highlight layer is enabled or not.
  134606. */
  134607. isEnabled: boolean;
  134608. /**
  134609. * Gets the camera attached to the layer.
  134610. */
  134611. get camera(): Nullable<Camera>;
  134612. /**
  134613. * Gets the rendering group id the layer should render in.
  134614. */
  134615. get renderingGroupId(): number;
  134616. set renderingGroupId(renderingGroupId: number);
  134617. /**
  134618. * An event triggered when the effect layer has been disposed.
  134619. */
  134620. onDisposeObservable: Observable<EffectLayer>;
  134621. /**
  134622. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  134623. */
  134624. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  134625. /**
  134626. * An event triggered when the generated texture is being merged in the scene.
  134627. */
  134628. onBeforeComposeObservable: Observable<EffectLayer>;
  134629. /**
  134630. * An event triggered when the mesh is rendered into the effect render target.
  134631. */
  134632. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  134633. /**
  134634. * An event triggered after the mesh has been rendered into the effect render target.
  134635. */
  134636. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  134637. /**
  134638. * An event triggered when the generated texture has been merged in the scene.
  134639. */
  134640. onAfterComposeObservable: Observable<EffectLayer>;
  134641. /**
  134642. * An event triggered when the efffect layer changes its size.
  134643. */
  134644. onSizeChangedObservable: Observable<EffectLayer>;
  134645. /** @hidden */
  134646. static _SceneComponentInitialization: (scene: Scene) => void;
  134647. /**
  134648. * Instantiates a new effect Layer and references it in the scene.
  134649. * @param name The name of the layer
  134650. * @param scene The scene to use the layer in
  134651. */
  134652. constructor(
  134653. /** The Friendly of the effect in the scene */
  134654. name: string, scene: Scene);
  134655. /**
  134656. * Get the effect name of the layer.
  134657. * @return The effect name
  134658. */
  134659. abstract getEffectName(): string;
  134660. /**
  134661. * Checks for the readiness of the element composing the layer.
  134662. * @param subMesh the mesh to check for
  134663. * @param useInstances specify whether or not to use instances to render the mesh
  134664. * @return true if ready otherwise, false
  134665. */
  134666. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  134667. /**
  134668. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  134669. * @returns true if the effect requires stencil during the main canvas render pass.
  134670. */
  134671. abstract needStencil(): boolean;
  134672. /**
  134673. * Create the merge effect. This is the shader use to blit the information back
  134674. * to the main canvas at the end of the scene rendering.
  134675. * @returns The effect containing the shader used to merge the effect on the main canvas
  134676. */
  134677. protected abstract _createMergeEffect(): Effect;
  134678. /**
  134679. * Creates the render target textures and post processes used in the effect layer.
  134680. */
  134681. protected abstract _createTextureAndPostProcesses(): void;
  134682. /**
  134683. * Implementation specific of rendering the generating effect on the main canvas.
  134684. * @param effect The effect used to render through
  134685. */
  134686. protected abstract _internalRender(effect: Effect): void;
  134687. /**
  134688. * Sets the required values for both the emissive texture and and the main color.
  134689. */
  134690. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  134691. /**
  134692. * Free any resources and references associated to a mesh.
  134693. * Internal use
  134694. * @param mesh The mesh to free.
  134695. */
  134696. abstract _disposeMesh(mesh: Mesh): void;
  134697. /**
  134698. * Serializes this layer (Glow or Highlight for example)
  134699. * @returns a serialized layer object
  134700. */
  134701. abstract serialize?(): any;
  134702. /**
  134703. * Initializes the effect layer with the required options.
  134704. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  134705. */
  134706. protected _init(options: Partial<IEffectLayerOptions>): void;
  134707. /**
  134708. * Generates the index buffer of the full screen quad blending to the main canvas.
  134709. */
  134710. private _generateIndexBuffer;
  134711. /**
  134712. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  134713. */
  134714. private _generateVertexBuffer;
  134715. /**
  134716. * Sets the main texture desired size which is the closest power of two
  134717. * of the engine canvas size.
  134718. */
  134719. private _setMainTextureSize;
  134720. /**
  134721. * Creates the main texture for the effect layer.
  134722. */
  134723. protected _createMainTexture(): void;
  134724. /**
  134725. * Adds specific effects defines.
  134726. * @param defines The defines to add specifics to.
  134727. */
  134728. protected _addCustomEffectDefines(defines: string[]): void;
  134729. /**
  134730. * Checks for the readiness of the element composing the layer.
  134731. * @param subMesh the mesh to check for
  134732. * @param useInstances specify whether or not to use instances to render the mesh
  134733. * @param emissiveTexture the associated emissive texture used to generate the glow
  134734. * @return true if ready otherwise, false
  134735. */
  134736. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  134737. /**
  134738. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  134739. */
  134740. render(): void;
  134741. /**
  134742. * Determine if a given mesh will be used in the current effect.
  134743. * @param mesh mesh to test
  134744. * @returns true if the mesh will be used
  134745. */
  134746. hasMesh(mesh: AbstractMesh): boolean;
  134747. /**
  134748. * Returns true if the layer contains information to display, otherwise false.
  134749. * @returns true if the glow layer should be rendered
  134750. */
  134751. shouldRender(): boolean;
  134752. /**
  134753. * Returns true if the mesh should render, otherwise false.
  134754. * @param mesh The mesh to render
  134755. * @returns true if it should render otherwise false
  134756. */
  134757. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  134758. /**
  134759. * Returns true if the mesh can be rendered, otherwise false.
  134760. * @param mesh The mesh to render
  134761. * @param material The material used on the mesh
  134762. * @returns true if it can be rendered otherwise false
  134763. */
  134764. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  134765. /**
  134766. * Returns true if the mesh should render, otherwise false.
  134767. * @param mesh The mesh to render
  134768. * @returns true if it should render otherwise false
  134769. */
  134770. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  134771. /**
  134772. * Renders the submesh passed in parameter to the generation map.
  134773. */
  134774. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  134775. /**
  134776. * Defines whether the current material of the mesh should be use to render the effect.
  134777. * @param mesh defines the current mesh to render
  134778. */
  134779. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  134780. /**
  134781. * Rebuild the required buffers.
  134782. * @hidden Internal use only.
  134783. */
  134784. _rebuild(): void;
  134785. /**
  134786. * Dispose only the render target textures and post process.
  134787. */
  134788. private _disposeTextureAndPostProcesses;
  134789. /**
  134790. * Dispose the highlight layer and free resources.
  134791. */
  134792. dispose(): void;
  134793. /**
  134794. * Gets the class name of the effect layer
  134795. * @returns the string with the class name of the effect layer
  134796. */
  134797. getClassName(): string;
  134798. /**
  134799. * Creates an effect layer from parsed effect layer data
  134800. * @param parsedEffectLayer defines effect layer data
  134801. * @param scene defines the current scene
  134802. * @param rootUrl defines the root URL containing the effect layer information
  134803. * @returns a parsed effect Layer
  134804. */
  134805. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  134806. }
  134807. }
  134808. declare module BABYLON {
  134809. interface AbstractScene {
  134810. /**
  134811. * The list of effect layers (highlights/glow) added to the scene
  134812. * @see http://doc.babylonjs.com/how_to/highlight_layer
  134813. * @see http://doc.babylonjs.com/how_to/glow_layer
  134814. */
  134815. effectLayers: Array<EffectLayer>;
  134816. /**
  134817. * Removes the given effect layer from this scene.
  134818. * @param toRemove defines the effect layer to remove
  134819. * @returns the index of the removed effect layer
  134820. */
  134821. removeEffectLayer(toRemove: EffectLayer): number;
  134822. /**
  134823. * Adds the given effect layer to this scene
  134824. * @param newEffectLayer defines the effect layer to add
  134825. */
  134826. addEffectLayer(newEffectLayer: EffectLayer): void;
  134827. }
  134828. /**
  134829. * Defines the layer scene component responsible to manage any effect layers
  134830. * in a given scene.
  134831. */
  134832. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  134833. /**
  134834. * The component name helpfull to identify the component in the list of scene components.
  134835. */
  134836. readonly name: string;
  134837. /**
  134838. * The scene the component belongs to.
  134839. */
  134840. scene: Scene;
  134841. private _engine;
  134842. private _renderEffects;
  134843. private _needStencil;
  134844. private _previousStencilState;
  134845. /**
  134846. * Creates a new instance of the component for the given scene
  134847. * @param scene Defines the scene to register the component in
  134848. */
  134849. constructor(scene: Scene);
  134850. /**
  134851. * Registers the component in a given scene
  134852. */
  134853. register(): void;
  134854. /**
  134855. * Rebuilds the elements related to this component in case of
  134856. * context lost for instance.
  134857. */
  134858. rebuild(): void;
  134859. /**
  134860. * Serializes the component data to the specified json object
  134861. * @param serializationObject The object to serialize to
  134862. */
  134863. serialize(serializationObject: any): void;
  134864. /**
  134865. * Adds all the elements from the container to the scene
  134866. * @param container the container holding the elements
  134867. */
  134868. addFromContainer(container: AbstractScene): void;
  134869. /**
  134870. * Removes all the elements in the container from the scene
  134871. * @param container contains the elements to remove
  134872. * @param dispose if the removed element should be disposed (default: false)
  134873. */
  134874. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  134875. /**
  134876. * Disposes the component and the associated ressources.
  134877. */
  134878. dispose(): void;
  134879. private _isReadyForMesh;
  134880. private _renderMainTexture;
  134881. private _setStencil;
  134882. private _setStencilBack;
  134883. private _draw;
  134884. private _drawCamera;
  134885. private _drawRenderingGroup;
  134886. }
  134887. }
  134888. declare module BABYLON {
  134889. /** @hidden */
  134890. export var glowMapMergePixelShader: {
  134891. name: string;
  134892. shader: string;
  134893. };
  134894. }
  134895. declare module BABYLON {
  134896. /** @hidden */
  134897. export var glowMapMergeVertexShader: {
  134898. name: string;
  134899. shader: string;
  134900. };
  134901. }
  134902. declare module BABYLON {
  134903. interface AbstractScene {
  134904. /**
  134905. * Return a the first highlight layer of the scene with a given name.
  134906. * @param name The name of the highlight layer to look for.
  134907. * @return The highlight layer if found otherwise null.
  134908. */
  134909. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  134910. }
  134911. /**
  134912. * Glow layer options. This helps customizing the behaviour
  134913. * of the glow layer.
  134914. */
  134915. export interface IGlowLayerOptions {
  134916. /**
  134917. * Multiplication factor apply to the canvas size to compute the render target size
  134918. * used to generated the glowing objects (the smaller the faster).
  134919. */
  134920. mainTextureRatio: number;
  134921. /**
  134922. * Enforces a fixed size texture to ensure resize independant blur.
  134923. */
  134924. mainTextureFixedSize?: number;
  134925. /**
  134926. * How big is the kernel of the blur texture.
  134927. */
  134928. blurKernelSize: number;
  134929. /**
  134930. * The camera attached to the layer.
  134931. */
  134932. camera: Nullable<Camera>;
  134933. /**
  134934. * Enable MSAA by chosing the number of samples.
  134935. */
  134936. mainTextureSamples?: number;
  134937. /**
  134938. * The rendering group to draw the layer in.
  134939. */
  134940. renderingGroupId: number;
  134941. }
  134942. /**
  134943. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  134944. *
  134945. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  134946. *
  134947. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  134948. */
  134949. export class GlowLayer extends EffectLayer {
  134950. /**
  134951. * Effect Name of the layer.
  134952. */
  134953. static readonly EffectName: string;
  134954. /**
  134955. * The default blur kernel size used for the glow.
  134956. */
  134957. static DefaultBlurKernelSize: number;
  134958. /**
  134959. * The default texture size ratio used for the glow.
  134960. */
  134961. static DefaultTextureRatio: number;
  134962. /**
  134963. * Sets the kernel size of the blur.
  134964. */
  134965. set blurKernelSize(value: number);
  134966. /**
  134967. * Gets the kernel size of the blur.
  134968. */
  134969. get blurKernelSize(): number;
  134970. /**
  134971. * Sets the glow intensity.
  134972. */
  134973. set intensity(value: number);
  134974. /**
  134975. * Gets the glow intensity.
  134976. */
  134977. get intensity(): number;
  134978. private _options;
  134979. private _intensity;
  134980. private _horizontalBlurPostprocess1;
  134981. private _verticalBlurPostprocess1;
  134982. private _horizontalBlurPostprocess2;
  134983. private _verticalBlurPostprocess2;
  134984. private _blurTexture1;
  134985. private _blurTexture2;
  134986. private _postProcesses1;
  134987. private _postProcesses2;
  134988. private _includedOnlyMeshes;
  134989. private _excludedMeshes;
  134990. private _meshesUsingTheirOwnMaterials;
  134991. /**
  134992. * Callback used to let the user override the color selection on a per mesh basis
  134993. */
  134994. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  134995. /**
  134996. * Callback used to let the user override the texture selection on a per mesh basis
  134997. */
  134998. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  134999. /**
  135000. * Instantiates a new glow Layer and references it to the scene.
  135001. * @param name The name of the layer
  135002. * @param scene The scene to use the layer in
  135003. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  135004. */
  135005. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  135006. /**
  135007. * Get the effect name of the layer.
  135008. * @return The effect name
  135009. */
  135010. getEffectName(): string;
  135011. /**
  135012. * Create the merge effect. This is the shader use to blit the information back
  135013. * to the main canvas at the end of the scene rendering.
  135014. */
  135015. protected _createMergeEffect(): Effect;
  135016. /**
  135017. * Creates the render target textures and post processes used in the glow layer.
  135018. */
  135019. protected _createTextureAndPostProcesses(): void;
  135020. /**
  135021. * Checks for the readiness of the element composing the layer.
  135022. * @param subMesh the mesh to check for
  135023. * @param useInstances specify wether or not to use instances to render the mesh
  135024. * @param emissiveTexture the associated emissive texture used to generate the glow
  135025. * @return true if ready otherwise, false
  135026. */
  135027. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135028. /**
  135029. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  135030. */
  135031. needStencil(): boolean;
  135032. /**
  135033. * Returns true if the mesh can be rendered, otherwise false.
  135034. * @param mesh The mesh to render
  135035. * @param material The material used on the mesh
  135036. * @returns true if it can be rendered otherwise false
  135037. */
  135038. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  135039. /**
  135040. * Implementation specific of rendering the generating effect on the main canvas.
  135041. * @param effect The effect used to render through
  135042. */
  135043. protected _internalRender(effect: Effect): void;
  135044. /**
  135045. * Sets the required values for both the emissive texture and and the main color.
  135046. */
  135047. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  135048. /**
  135049. * Returns true if the mesh should render, otherwise false.
  135050. * @param mesh The mesh to render
  135051. * @returns true if it should render otherwise false
  135052. */
  135053. protected _shouldRenderMesh(mesh: Mesh): boolean;
  135054. /**
  135055. * Adds specific effects defines.
  135056. * @param defines The defines to add specifics to.
  135057. */
  135058. protected _addCustomEffectDefines(defines: string[]): void;
  135059. /**
  135060. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  135061. * @param mesh The mesh to exclude from the glow layer
  135062. */
  135063. addExcludedMesh(mesh: Mesh): void;
  135064. /**
  135065. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  135066. * @param mesh The mesh to remove
  135067. */
  135068. removeExcludedMesh(mesh: Mesh): void;
  135069. /**
  135070. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  135071. * @param mesh The mesh to include in the glow layer
  135072. */
  135073. addIncludedOnlyMesh(mesh: Mesh): void;
  135074. /**
  135075. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  135076. * @param mesh The mesh to remove
  135077. */
  135078. removeIncludedOnlyMesh(mesh: Mesh): void;
  135079. /**
  135080. * Determine if a given mesh will be used in the glow layer
  135081. * @param mesh The mesh to test
  135082. * @returns true if the mesh will be highlighted by the current glow layer
  135083. */
  135084. hasMesh(mesh: AbstractMesh): boolean;
  135085. /**
  135086. * Defines whether the current material of the mesh should be use to render the effect.
  135087. * @param mesh defines the current mesh to render
  135088. */
  135089. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  135090. /**
  135091. * Add a mesh to be rendered through its own material and not with emissive only.
  135092. * @param mesh The mesh for which we need to use its material
  135093. */
  135094. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  135095. /**
  135096. * Remove a mesh from being rendered through its own material and not with emissive only.
  135097. * @param mesh The mesh for which we need to not use its material
  135098. */
  135099. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  135100. /**
  135101. * Free any resources and references associated to a mesh.
  135102. * Internal use
  135103. * @param mesh The mesh to free.
  135104. * @hidden
  135105. */
  135106. _disposeMesh(mesh: Mesh): void;
  135107. /**
  135108. * Gets the class name of the effect layer
  135109. * @returns the string with the class name of the effect layer
  135110. */
  135111. getClassName(): string;
  135112. /**
  135113. * Serializes this glow layer
  135114. * @returns a serialized glow layer object
  135115. */
  135116. serialize(): any;
  135117. /**
  135118. * Creates a Glow Layer from parsed glow layer data
  135119. * @param parsedGlowLayer defines glow layer data
  135120. * @param scene defines the current scene
  135121. * @param rootUrl defines the root URL containing the glow layer information
  135122. * @returns a parsed Glow Layer
  135123. */
  135124. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  135125. }
  135126. }
  135127. declare module BABYLON {
  135128. /** @hidden */
  135129. export var glowBlurPostProcessPixelShader: {
  135130. name: string;
  135131. shader: string;
  135132. };
  135133. }
  135134. declare module BABYLON {
  135135. interface AbstractScene {
  135136. /**
  135137. * Return a the first highlight layer of the scene with a given name.
  135138. * @param name The name of the highlight layer to look for.
  135139. * @return The highlight layer if found otherwise null.
  135140. */
  135141. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  135142. }
  135143. /**
  135144. * Highlight layer options. This helps customizing the behaviour
  135145. * of the highlight layer.
  135146. */
  135147. export interface IHighlightLayerOptions {
  135148. /**
  135149. * Multiplication factor apply to the canvas size to compute the render target size
  135150. * used to generated the glowing objects (the smaller the faster).
  135151. */
  135152. mainTextureRatio: number;
  135153. /**
  135154. * Enforces a fixed size texture to ensure resize independant blur.
  135155. */
  135156. mainTextureFixedSize?: number;
  135157. /**
  135158. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  135159. * of the picture to blur (the smaller the faster).
  135160. */
  135161. blurTextureSizeRatio: number;
  135162. /**
  135163. * How big in texel of the blur texture is the vertical blur.
  135164. */
  135165. blurVerticalSize: number;
  135166. /**
  135167. * How big in texel of the blur texture is the horizontal blur.
  135168. */
  135169. blurHorizontalSize: number;
  135170. /**
  135171. * Alpha blending mode used to apply the blur. Default is combine.
  135172. */
  135173. alphaBlendingMode: number;
  135174. /**
  135175. * The camera attached to the layer.
  135176. */
  135177. camera: Nullable<Camera>;
  135178. /**
  135179. * Should we display highlight as a solid stroke?
  135180. */
  135181. isStroke?: boolean;
  135182. /**
  135183. * The rendering group to draw the layer in.
  135184. */
  135185. renderingGroupId: number;
  135186. }
  135187. /**
  135188. * The highlight layer Helps adding a glow effect around a mesh.
  135189. *
  135190. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  135191. * glowy meshes to your scene.
  135192. *
  135193. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  135194. */
  135195. export class HighlightLayer extends EffectLayer {
  135196. name: string;
  135197. /**
  135198. * Effect Name of the highlight layer.
  135199. */
  135200. static readonly EffectName: string;
  135201. /**
  135202. * The neutral color used during the preparation of the glow effect.
  135203. * This is black by default as the blend operation is a blend operation.
  135204. */
  135205. static NeutralColor: Color4;
  135206. /**
  135207. * Stencil value used for glowing meshes.
  135208. */
  135209. static GlowingMeshStencilReference: number;
  135210. /**
  135211. * Stencil value used for the other meshes in the scene.
  135212. */
  135213. static NormalMeshStencilReference: number;
  135214. /**
  135215. * Specifies whether or not the inner glow is ACTIVE in the layer.
  135216. */
  135217. innerGlow: boolean;
  135218. /**
  135219. * Specifies whether or not the outer glow is ACTIVE in the layer.
  135220. */
  135221. outerGlow: boolean;
  135222. /**
  135223. * Specifies the horizontal size of the blur.
  135224. */
  135225. set blurHorizontalSize(value: number);
  135226. /**
  135227. * Specifies the vertical size of the blur.
  135228. */
  135229. set blurVerticalSize(value: number);
  135230. /**
  135231. * Gets the horizontal size of the blur.
  135232. */
  135233. get blurHorizontalSize(): number;
  135234. /**
  135235. * Gets the vertical size of the blur.
  135236. */
  135237. get blurVerticalSize(): number;
  135238. /**
  135239. * An event triggered when the highlight layer is being blurred.
  135240. */
  135241. onBeforeBlurObservable: Observable<HighlightLayer>;
  135242. /**
  135243. * An event triggered when the highlight layer has been blurred.
  135244. */
  135245. onAfterBlurObservable: Observable<HighlightLayer>;
  135246. private _instanceGlowingMeshStencilReference;
  135247. private _options;
  135248. private _downSamplePostprocess;
  135249. private _horizontalBlurPostprocess;
  135250. private _verticalBlurPostprocess;
  135251. private _blurTexture;
  135252. private _meshes;
  135253. private _excludedMeshes;
  135254. /**
  135255. * Instantiates a new highlight Layer and references it to the scene..
  135256. * @param name The name of the layer
  135257. * @param scene The scene to use the layer in
  135258. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  135259. */
  135260. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  135261. /**
  135262. * Get the effect name of the layer.
  135263. * @return The effect name
  135264. */
  135265. getEffectName(): string;
  135266. /**
  135267. * Create the merge effect. This is the shader use to blit the information back
  135268. * to the main canvas at the end of the scene rendering.
  135269. */
  135270. protected _createMergeEffect(): Effect;
  135271. /**
  135272. * Creates the render target textures and post processes used in the highlight layer.
  135273. */
  135274. protected _createTextureAndPostProcesses(): void;
  135275. /**
  135276. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  135277. */
  135278. needStencil(): boolean;
  135279. /**
  135280. * Checks for the readiness of the element composing the layer.
  135281. * @param subMesh the mesh to check for
  135282. * @param useInstances specify wether or not to use instances to render the mesh
  135283. * @param emissiveTexture the associated emissive texture used to generate the glow
  135284. * @return true if ready otherwise, false
  135285. */
  135286. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135287. /**
  135288. * Implementation specific of rendering the generating effect on the main canvas.
  135289. * @param effect The effect used to render through
  135290. */
  135291. protected _internalRender(effect: Effect): void;
  135292. /**
  135293. * Returns true if the layer contains information to display, otherwise false.
  135294. */
  135295. shouldRender(): boolean;
  135296. /**
  135297. * Returns true if the mesh should render, otherwise false.
  135298. * @param mesh The mesh to render
  135299. * @returns true if it should render otherwise false
  135300. */
  135301. protected _shouldRenderMesh(mesh: Mesh): boolean;
  135302. /**
  135303. * Adds specific effects defines.
  135304. * @param defines The defines to add specifics to.
  135305. */
  135306. protected _addCustomEffectDefines(defines: string[]): void;
  135307. /**
  135308. * Sets the required values for both the emissive texture and and the main color.
  135309. */
  135310. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  135311. /**
  135312. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  135313. * @param mesh The mesh to exclude from the highlight layer
  135314. */
  135315. addExcludedMesh(mesh: Mesh): void;
  135316. /**
  135317. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  135318. * @param mesh The mesh to highlight
  135319. */
  135320. removeExcludedMesh(mesh: Mesh): void;
  135321. /**
  135322. * Determine if a given mesh will be highlighted by the current HighlightLayer
  135323. * @param mesh mesh to test
  135324. * @returns true if the mesh will be highlighted by the current HighlightLayer
  135325. */
  135326. hasMesh(mesh: AbstractMesh): boolean;
  135327. /**
  135328. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  135329. * @param mesh The mesh to highlight
  135330. * @param color The color of the highlight
  135331. * @param glowEmissiveOnly Extract the glow from the emissive texture
  135332. */
  135333. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  135334. /**
  135335. * Remove a mesh from the highlight layer in order to make it stop glowing.
  135336. * @param mesh The mesh to highlight
  135337. */
  135338. removeMesh(mesh: Mesh): void;
  135339. /**
  135340. * Remove all the meshes currently referenced in the highlight layer
  135341. */
  135342. removeAllMeshes(): void;
  135343. /**
  135344. * Force the stencil to the normal expected value for none glowing parts
  135345. */
  135346. private _defaultStencilReference;
  135347. /**
  135348. * Free any resources and references associated to a mesh.
  135349. * Internal use
  135350. * @param mesh The mesh to free.
  135351. * @hidden
  135352. */
  135353. _disposeMesh(mesh: Mesh): void;
  135354. /**
  135355. * Dispose the highlight layer and free resources.
  135356. */
  135357. dispose(): void;
  135358. /**
  135359. * Gets the class name of the effect layer
  135360. * @returns the string with the class name of the effect layer
  135361. */
  135362. getClassName(): string;
  135363. /**
  135364. * Serializes this Highlight layer
  135365. * @returns a serialized Highlight layer object
  135366. */
  135367. serialize(): any;
  135368. /**
  135369. * Creates a Highlight layer from parsed Highlight layer data
  135370. * @param parsedHightlightLayer defines the Highlight layer data
  135371. * @param scene defines the current scene
  135372. * @param rootUrl defines the root URL containing the Highlight layer information
  135373. * @returns a parsed Highlight layer
  135374. */
  135375. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  135376. }
  135377. }
  135378. declare module BABYLON {
  135379. interface AbstractScene {
  135380. /**
  135381. * The list of layers (background and foreground) of the scene
  135382. */
  135383. layers: Array<Layer>;
  135384. }
  135385. /**
  135386. * Defines the layer scene component responsible to manage any layers
  135387. * in a given scene.
  135388. */
  135389. export class LayerSceneComponent implements ISceneComponent {
  135390. /**
  135391. * The component name helpfull to identify the component in the list of scene components.
  135392. */
  135393. readonly name: string;
  135394. /**
  135395. * The scene the component belongs to.
  135396. */
  135397. scene: Scene;
  135398. private _engine;
  135399. /**
  135400. * Creates a new instance of the component for the given scene
  135401. * @param scene Defines the scene to register the component in
  135402. */
  135403. constructor(scene: Scene);
  135404. /**
  135405. * Registers the component in a given scene
  135406. */
  135407. register(): void;
  135408. /**
  135409. * Rebuilds the elements related to this component in case of
  135410. * context lost for instance.
  135411. */
  135412. rebuild(): void;
  135413. /**
  135414. * Disposes the component and the associated ressources.
  135415. */
  135416. dispose(): void;
  135417. private _draw;
  135418. private _drawCameraPredicate;
  135419. private _drawCameraBackground;
  135420. private _drawCameraForeground;
  135421. private _drawRenderTargetPredicate;
  135422. private _drawRenderTargetBackground;
  135423. private _drawRenderTargetForeground;
  135424. /**
  135425. * Adds all the elements from the container to the scene
  135426. * @param container the container holding the elements
  135427. */
  135428. addFromContainer(container: AbstractScene): void;
  135429. /**
  135430. * Removes all the elements in the container from the scene
  135431. * @param container contains the elements to remove
  135432. * @param dispose if the removed element should be disposed (default: false)
  135433. */
  135434. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135435. }
  135436. }
  135437. declare module BABYLON {
  135438. /** @hidden */
  135439. export var layerPixelShader: {
  135440. name: string;
  135441. shader: string;
  135442. };
  135443. }
  135444. declare module BABYLON {
  135445. /** @hidden */
  135446. export var layerVertexShader: {
  135447. name: string;
  135448. shader: string;
  135449. };
  135450. }
  135451. declare module BABYLON {
  135452. /**
  135453. * This represents a full screen 2d layer.
  135454. * This can be useful to display a picture in the background of your scene for instance.
  135455. * @see https://www.babylonjs-playground.com/#08A2BS#1
  135456. */
  135457. export class Layer {
  135458. /**
  135459. * Define the name of the layer.
  135460. */
  135461. name: string;
  135462. /**
  135463. * Define the texture the layer should display.
  135464. */
  135465. texture: Nullable<Texture>;
  135466. /**
  135467. * Is the layer in background or foreground.
  135468. */
  135469. isBackground: boolean;
  135470. /**
  135471. * Define the color of the layer (instead of texture).
  135472. */
  135473. color: Color4;
  135474. /**
  135475. * Define the scale of the layer in order to zoom in out of the texture.
  135476. */
  135477. scale: Vector2;
  135478. /**
  135479. * Define an offset for the layer in order to shift the texture.
  135480. */
  135481. offset: Vector2;
  135482. /**
  135483. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  135484. */
  135485. alphaBlendingMode: number;
  135486. /**
  135487. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  135488. * Alpha test will not mix with the background color in case of transparency.
  135489. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  135490. */
  135491. alphaTest: boolean;
  135492. /**
  135493. * Define a mask to restrict the layer to only some of the scene cameras.
  135494. */
  135495. layerMask: number;
  135496. /**
  135497. * Define the list of render target the layer is visible into.
  135498. */
  135499. renderTargetTextures: RenderTargetTexture[];
  135500. /**
  135501. * Define if the layer is only used in renderTarget or if it also
  135502. * renders in the main frame buffer of the canvas.
  135503. */
  135504. renderOnlyInRenderTargetTextures: boolean;
  135505. private _scene;
  135506. private _vertexBuffers;
  135507. private _indexBuffer;
  135508. private _effect;
  135509. private _previousDefines;
  135510. /**
  135511. * An event triggered when the layer is disposed.
  135512. */
  135513. onDisposeObservable: Observable<Layer>;
  135514. private _onDisposeObserver;
  135515. /**
  135516. * Back compatibility with callback before the onDisposeObservable existed.
  135517. * The set callback will be triggered when the layer has been disposed.
  135518. */
  135519. set onDispose(callback: () => void);
  135520. /**
  135521. * An event triggered before rendering the scene
  135522. */
  135523. onBeforeRenderObservable: Observable<Layer>;
  135524. private _onBeforeRenderObserver;
  135525. /**
  135526. * Back compatibility with callback before the onBeforeRenderObservable existed.
  135527. * The set callback will be triggered just before rendering the layer.
  135528. */
  135529. set onBeforeRender(callback: () => void);
  135530. /**
  135531. * An event triggered after rendering the scene
  135532. */
  135533. onAfterRenderObservable: Observable<Layer>;
  135534. private _onAfterRenderObserver;
  135535. /**
  135536. * Back compatibility with callback before the onAfterRenderObservable existed.
  135537. * The set callback will be triggered just after rendering the layer.
  135538. */
  135539. set onAfterRender(callback: () => void);
  135540. /**
  135541. * Instantiates a new layer.
  135542. * This represents a full screen 2d layer.
  135543. * This can be useful to display a picture in the background of your scene for instance.
  135544. * @see https://www.babylonjs-playground.com/#08A2BS#1
  135545. * @param name Define the name of the layer in the scene
  135546. * @param imgUrl Define the url of the texture to display in the layer
  135547. * @param scene Define the scene the layer belongs to
  135548. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  135549. * @param color Defines a color for the layer
  135550. */
  135551. constructor(
  135552. /**
  135553. * Define the name of the layer.
  135554. */
  135555. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  135556. private _createIndexBuffer;
  135557. /** @hidden */
  135558. _rebuild(): void;
  135559. /**
  135560. * Renders the layer in the scene.
  135561. */
  135562. render(): void;
  135563. /**
  135564. * Disposes and releases the associated ressources.
  135565. */
  135566. dispose(): void;
  135567. }
  135568. }
  135569. declare module BABYLON {
  135570. /** @hidden */
  135571. export var lensFlarePixelShader: {
  135572. name: string;
  135573. shader: string;
  135574. };
  135575. }
  135576. declare module BABYLON {
  135577. /** @hidden */
  135578. export var lensFlareVertexShader: {
  135579. name: string;
  135580. shader: string;
  135581. };
  135582. }
  135583. declare module BABYLON {
  135584. /**
  135585. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  135586. * It is usually composed of several `lensFlare`.
  135587. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135588. */
  135589. export class LensFlareSystem {
  135590. /**
  135591. * Define the name of the lens flare system
  135592. */
  135593. name: string;
  135594. /**
  135595. * List of lens flares used in this system.
  135596. */
  135597. lensFlares: LensFlare[];
  135598. /**
  135599. * Define a limit from the border the lens flare can be visible.
  135600. */
  135601. borderLimit: number;
  135602. /**
  135603. * Define a viewport border we do not want to see the lens flare in.
  135604. */
  135605. viewportBorder: number;
  135606. /**
  135607. * Define a predicate which could limit the list of meshes able to occlude the effect.
  135608. */
  135609. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  135610. /**
  135611. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  135612. */
  135613. layerMask: number;
  135614. /**
  135615. * Define the id of the lens flare system in the scene.
  135616. * (equal to name by default)
  135617. */
  135618. id: string;
  135619. private _scene;
  135620. private _emitter;
  135621. private _vertexBuffers;
  135622. private _indexBuffer;
  135623. private _effect;
  135624. private _positionX;
  135625. private _positionY;
  135626. private _isEnabled;
  135627. /** @hidden */
  135628. static _SceneComponentInitialization: (scene: Scene) => void;
  135629. /**
  135630. * Instantiates a lens flare system.
  135631. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  135632. * It is usually composed of several `lensFlare`.
  135633. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135634. * @param name Define the name of the lens flare system in the scene
  135635. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  135636. * @param scene Define the scene the lens flare system belongs to
  135637. */
  135638. constructor(
  135639. /**
  135640. * Define the name of the lens flare system
  135641. */
  135642. name: string, emitter: any, scene: Scene);
  135643. /**
  135644. * Define if the lens flare system is enabled.
  135645. */
  135646. get isEnabled(): boolean;
  135647. set isEnabled(value: boolean);
  135648. /**
  135649. * Get the scene the effects belongs to.
  135650. * @returns the scene holding the lens flare system
  135651. */
  135652. getScene(): Scene;
  135653. /**
  135654. * Get the emitter of the lens flare system.
  135655. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  135656. * @returns the emitter of the lens flare system
  135657. */
  135658. getEmitter(): any;
  135659. /**
  135660. * Set the emitter of the lens flare system.
  135661. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  135662. * @param newEmitter Define the new emitter of the system
  135663. */
  135664. setEmitter(newEmitter: any): void;
  135665. /**
  135666. * Get the lens flare system emitter position.
  135667. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  135668. * @returns the position
  135669. */
  135670. getEmitterPosition(): Vector3;
  135671. /**
  135672. * @hidden
  135673. */
  135674. computeEffectivePosition(globalViewport: Viewport): boolean;
  135675. /** @hidden */
  135676. _isVisible(): boolean;
  135677. /**
  135678. * @hidden
  135679. */
  135680. render(): boolean;
  135681. /**
  135682. * Dispose and release the lens flare with its associated resources.
  135683. */
  135684. dispose(): void;
  135685. /**
  135686. * Parse a lens flare system from a JSON repressentation
  135687. * @param parsedLensFlareSystem Define the JSON to parse
  135688. * @param scene Define the scene the parsed system should be instantiated in
  135689. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  135690. * @returns the parsed system
  135691. */
  135692. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  135693. /**
  135694. * Serialize the current Lens Flare System into a JSON representation.
  135695. * @returns the serialized JSON
  135696. */
  135697. serialize(): any;
  135698. }
  135699. }
  135700. declare module BABYLON {
  135701. /**
  135702. * This represents one of the lens effect in a `lensFlareSystem`.
  135703. * It controls one of the indiviual texture used in the effect.
  135704. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135705. */
  135706. export class LensFlare {
  135707. /**
  135708. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  135709. */
  135710. size: number;
  135711. /**
  135712. * 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.
  135713. */
  135714. position: number;
  135715. /**
  135716. * Define the lens color.
  135717. */
  135718. color: Color3;
  135719. /**
  135720. * Define the lens texture.
  135721. */
  135722. texture: Nullable<Texture>;
  135723. /**
  135724. * Define the alpha mode to render this particular lens.
  135725. */
  135726. alphaMode: number;
  135727. private _system;
  135728. /**
  135729. * Creates a new Lens Flare.
  135730. * This represents one of the lens effect in a `lensFlareSystem`.
  135731. * It controls one of the indiviual texture used in the effect.
  135732. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135733. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  135734. * @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.
  135735. * @param color Define the lens color
  135736. * @param imgUrl Define the lens texture url
  135737. * @param system Define the `lensFlareSystem` this flare is part of
  135738. * @returns The newly created Lens Flare
  135739. */
  135740. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  135741. /**
  135742. * Instantiates a new Lens Flare.
  135743. * This represents one of the lens effect in a `lensFlareSystem`.
  135744. * It controls one of the indiviual texture used in the effect.
  135745. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135746. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  135747. * @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.
  135748. * @param color Define the lens color
  135749. * @param imgUrl Define the lens texture url
  135750. * @param system Define the `lensFlareSystem` this flare is part of
  135751. */
  135752. constructor(
  135753. /**
  135754. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  135755. */
  135756. size: number,
  135757. /**
  135758. * 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.
  135759. */
  135760. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  135761. /**
  135762. * Dispose and release the lens flare with its associated resources.
  135763. */
  135764. dispose(): void;
  135765. }
  135766. }
  135767. declare module BABYLON {
  135768. interface AbstractScene {
  135769. /**
  135770. * The list of lens flare system added to the scene
  135771. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135772. */
  135773. lensFlareSystems: Array<LensFlareSystem>;
  135774. /**
  135775. * Removes the given lens flare system from this scene.
  135776. * @param toRemove The lens flare system to remove
  135777. * @returns The index of the removed lens flare system
  135778. */
  135779. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  135780. /**
  135781. * Adds the given lens flare system to this scene
  135782. * @param newLensFlareSystem The lens flare system to add
  135783. */
  135784. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  135785. /**
  135786. * Gets a lens flare system using its name
  135787. * @param name defines the name to look for
  135788. * @returns the lens flare system or null if not found
  135789. */
  135790. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  135791. /**
  135792. * Gets a lens flare system using its id
  135793. * @param id defines the id to look for
  135794. * @returns the lens flare system or null if not found
  135795. */
  135796. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  135797. }
  135798. /**
  135799. * Defines the lens flare scene component responsible to manage any lens flares
  135800. * in a given scene.
  135801. */
  135802. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  135803. /**
  135804. * The component name helpfull to identify the component in the list of scene components.
  135805. */
  135806. readonly name: string;
  135807. /**
  135808. * The scene the component belongs to.
  135809. */
  135810. scene: Scene;
  135811. /**
  135812. * Creates a new instance of the component for the given scene
  135813. * @param scene Defines the scene to register the component in
  135814. */
  135815. constructor(scene: Scene);
  135816. /**
  135817. * Registers the component in a given scene
  135818. */
  135819. register(): void;
  135820. /**
  135821. * Rebuilds the elements related to this component in case of
  135822. * context lost for instance.
  135823. */
  135824. rebuild(): void;
  135825. /**
  135826. * Adds all the elements from the container to the scene
  135827. * @param container the container holding the elements
  135828. */
  135829. addFromContainer(container: AbstractScene): void;
  135830. /**
  135831. * Removes all the elements in the container from the scene
  135832. * @param container contains the elements to remove
  135833. * @param dispose if the removed element should be disposed (default: false)
  135834. */
  135835. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135836. /**
  135837. * Serializes the component data to the specified json object
  135838. * @param serializationObject The object to serialize to
  135839. */
  135840. serialize(serializationObject: any): void;
  135841. /**
  135842. * Disposes the component and the associated ressources.
  135843. */
  135844. dispose(): void;
  135845. private _draw;
  135846. }
  135847. }
  135848. declare module BABYLON {
  135849. /** @hidden */
  135850. export var depthPixelShader: {
  135851. name: string;
  135852. shader: string;
  135853. };
  135854. }
  135855. declare module BABYLON {
  135856. /** @hidden */
  135857. export var depthVertexShader: {
  135858. name: string;
  135859. shader: string;
  135860. };
  135861. }
  135862. declare module BABYLON {
  135863. /**
  135864. * This represents a depth renderer in Babylon.
  135865. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  135866. */
  135867. export class DepthRenderer {
  135868. private _scene;
  135869. private _depthMap;
  135870. private _effect;
  135871. private readonly _storeNonLinearDepth;
  135872. private readonly _clearColor;
  135873. /** Get if the depth renderer is using packed depth or not */
  135874. readonly isPacked: boolean;
  135875. private _cachedDefines;
  135876. private _camera;
  135877. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  135878. enabled: boolean;
  135879. /**
  135880. * Specifiess that the depth renderer will only be used within
  135881. * the camera it is created for.
  135882. * This can help forcing its rendering during the camera processing.
  135883. */
  135884. useOnlyInActiveCamera: boolean;
  135885. /** @hidden */
  135886. static _SceneComponentInitialization: (scene: Scene) => void;
  135887. /**
  135888. * Instantiates a depth renderer
  135889. * @param scene The scene the renderer belongs to
  135890. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  135891. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  135892. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  135893. */
  135894. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  135895. /**
  135896. * Creates the depth rendering effect and checks if the effect is ready.
  135897. * @param subMesh The submesh to be used to render the depth map of
  135898. * @param useInstances If multiple world instances should be used
  135899. * @returns if the depth renderer is ready to render the depth map
  135900. */
  135901. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135902. /**
  135903. * Gets the texture which the depth map will be written to.
  135904. * @returns The depth map texture
  135905. */
  135906. getDepthMap(): RenderTargetTexture;
  135907. /**
  135908. * Disposes of the depth renderer.
  135909. */
  135910. dispose(): void;
  135911. }
  135912. }
  135913. declare module BABYLON {
  135914. /** @hidden */
  135915. export var minmaxReduxPixelShader: {
  135916. name: string;
  135917. shader: string;
  135918. };
  135919. }
  135920. declare module BABYLON {
  135921. /**
  135922. * This class computes a min/max reduction from a texture: it means it computes the minimum
  135923. * and maximum values from all values of the texture.
  135924. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  135925. * The source values are read from the red channel of the texture.
  135926. */
  135927. export class MinMaxReducer {
  135928. /**
  135929. * Observable triggered when the computation has been performed
  135930. */
  135931. onAfterReductionPerformed: Observable<{
  135932. min: number;
  135933. max: number;
  135934. }>;
  135935. protected _camera: Camera;
  135936. protected _sourceTexture: Nullable<RenderTargetTexture>;
  135937. protected _reductionSteps: Nullable<Array<PostProcess>>;
  135938. protected _postProcessManager: PostProcessManager;
  135939. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  135940. protected _forceFullscreenViewport: boolean;
  135941. /**
  135942. * Creates a min/max reducer
  135943. * @param camera The camera to use for the post processes
  135944. */
  135945. constructor(camera: Camera);
  135946. /**
  135947. * Gets the texture used to read the values from.
  135948. */
  135949. get sourceTexture(): Nullable<RenderTargetTexture>;
  135950. /**
  135951. * Sets the source texture to read the values from.
  135952. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  135953. * because in such textures '1' value must not be taken into account to compute the maximum
  135954. * as this value is used to clear the texture.
  135955. * Note that the computation is not activated by calling this function, you must call activate() for that!
  135956. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  135957. * @param depthRedux Indicates if the texture is a depth texture or not
  135958. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  135959. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  135960. */
  135961. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  135962. /**
  135963. * Defines the refresh rate of the computation.
  135964. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  135965. */
  135966. get refreshRate(): number;
  135967. set refreshRate(value: number);
  135968. protected _activated: boolean;
  135969. /**
  135970. * Gets the activation status of the reducer
  135971. */
  135972. get activated(): boolean;
  135973. /**
  135974. * Activates the reduction computation.
  135975. * When activated, the observers registered in onAfterReductionPerformed are
  135976. * called after the compuation is performed
  135977. */
  135978. activate(): void;
  135979. /**
  135980. * Deactivates the reduction computation.
  135981. */
  135982. deactivate(): void;
  135983. /**
  135984. * Disposes the min/max reducer
  135985. * @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.
  135986. */
  135987. dispose(disposeAll?: boolean): void;
  135988. }
  135989. }
  135990. declare module BABYLON {
  135991. /**
  135992. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  135993. */
  135994. export class DepthReducer extends MinMaxReducer {
  135995. private _depthRenderer;
  135996. private _depthRendererId;
  135997. /**
  135998. * Gets the depth renderer used for the computation.
  135999. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  136000. */
  136001. get depthRenderer(): Nullable<DepthRenderer>;
  136002. /**
  136003. * Creates a depth reducer
  136004. * @param camera The camera used to render the depth texture
  136005. */
  136006. constructor(camera: Camera);
  136007. /**
  136008. * Sets the depth renderer to use to generate the depth map
  136009. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  136010. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  136011. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  136012. */
  136013. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  136014. /** @hidden */
  136015. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  136016. /**
  136017. * Activates the reduction computation.
  136018. * When activated, the observers registered in onAfterReductionPerformed are
  136019. * called after the compuation is performed
  136020. */
  136021. activate(): void;
  136022. /**
  136023. * Deactivates the reduction computation.
  136024. */
  136025. deactivate(): void;
  136026. /**
  136027. * Disposes the depth reducer
  136028. * @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.
  136029. */
  136030. dispose(disposeAll?: boolean): void;
  136031. }
  136032. }
  136033. declare module BABYLON {
  136034. /**
  136035. * A CSM implementation allowing casting shadows on large scenes.
  136036. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  136037. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  136038. */
  136039. export class CascadedShadowGenerator extends ShadowGenerator {
  136040. private static readonly frustumCornersNDCSpace;
  136041. /**
  136042. * Name of the CSM class
  136043. */
  136044. static CLASSNAME: string;
  136045. /**
  136046. * Defines the default number of cascades used by the CSM.
  136047. */
  136048. static readonly DEFAULT_CASCADES_COUNT: number;
  136049. /**
  136050. * Defines the minimum number of cascades used by the CSM.
  136051. */
  136052. static readonly MIN_CASCADES_COUNT: number;
  136053. /**
  136054. * Defines the maximum number of cascades used by the CSM.
  136055. */
  136056. static readonly MAX_CASCADES_COUNT: number;
  136057. protected _validateFilter(filter: number): number;
  136058. /**
  136059. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  136060. */
  136061. penumbraDarkness: number;
  136062. private _numCascades;
  136063. /**
  136064. * Gets or set the number of cascades used by the CSM.
  136065. */
  136066. get numCascades(): number;
  136067. set numCascades(value: number);
  136068. /**
  136069. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  136070. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  136071. */
  136072. stabilizeCascades: boolean;
  136073. private _freezeShadowCastersBoundingInfo;
  136074. private _freezeShadowCastersBoundingInfoObservable;
  136075. /**
  136076. * Enables or disables the shadow casters bounding info computation.
  136077. * If your shadow casters don't move, you can disable this feature.
  136078. * If it is enabled, the bounding box computation is done every frame.
  136079. */
  136080. get freezeShadowCastersBoundingInfo(): boolean;
  136081. set freezeShadowCastersBoundingInfo(freeze: boolean);
  136082. private _scbiMin;
  136083. private _scbiMax;
  136084. protected _computeShadowCastersBoundingInfo(): void;
  136085. protected _shadowCastersBoundingInfo: BoundingInfo;
  136086. /**
  136087. * Gets or sets the shadow casters bounding info.
  136088. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  136089. * so that the system won't overwrite the bounds you provide
  136090. */
  136091. get shadowCastersBoundingInfo(): BoundingInfo;
  136092. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  136093. protected _breaksAreDirty: boolean;
  136094. protected _minDistance: number;
  136095. protected _maxDistance: number;
  136096. /**
  136097. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  136098. *
  136099. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  136100. * If you don't know these values, simply leave them to their defaults and don't call this function.
  136101. * @param min minimal distance for the breaks (default to 0.)
  136102. * @param max maximal distance for the breaks (default to 1.)
  136103. */
  136104. setMinMaxDistance(min: number, max: number): void;
  136105. /** Gets the minimal distance used in the cascade break computation */
  136106. get minDistance(): number;
  136107. /** Gets the maximal distance used in the cascade break computation */
  136108. get maxDistance(): number;
  136109. /**
  136110. * Gets the class name of that object
  136111. * @returns "CascadedShadowGenerator"
  136112. */
  136113. getClassName(): string;
  136114. private _cascadeMinExtents;
  136115. private _cascadeMaxExtents;
  136116. /**
  136117. * Gets a cascade minimum extents
  136118. * @param cascadeIndex index of the cascade
  136119. * @returns the minimum cascade extents
  136120. */
  136121. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  136122. /**
  136123. * Gets a cascade maximum extents
  136124. * @param cascadeIndex index of the cascade
  136125. * @returns the maximum cascade extents
  136126. */
  136127. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  136128. private _cascades;
  136129. private _currentLayer;
  136130. private _viewSpaceFrustumsZ;
  136131. private _viewMatrices;
  136132. private _projectionMatrices;
  136133. private _transformMatrices;
  136134. private _transformMatricesAsArray;
  136135. private _frustumLengths;
  136136. private _lightSizeUVCorrection;
  136137. private _depthCorrection;
  136138. private _frustumCornersWorldSpace;
  136139. private _frustumCenter;
  136140. private _shadowCameraPos;
  136141. private _shadowMaxZ;
  136142. /**
  136143. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  136144. * It defaults to camera.maxZ
  136145. */
  136146. get shadowMaxZ(): number;
  136147. /**
  136148. * Sets the shadow max z distance.
  136149. */
  136150. set shadowMaxZ(value: number);
  136151. protected _debug: boolean;
  136152. /**
  136153. * Gets or sets the debug flag.
  136154. * When enabled, the cascades are materialized by different colors on the screen.
  136155. */
  136156. get debug(): boolean;
  136157. set debug(dbg: boolean);
  136158. private _depthClamp;
  136159. /**
  136160. * Gets or sets the depth clamping value.
  136161. *
  136162. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  136163. * to account for the shadow casters far away.
  136164. *
  136165. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  136166. */
  136167. get depthClamp(): boolean;
  136168. set depthClamp(value: boolean);
  136169. private _cascadeBlendPercentage;
  136170. /**
  136171. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  136172. * It defaults to 0.1 (10% blending).
  136173. */
  136174. get cascadeBlendPercentage(): number;
  136175. set cascadeBlendPercentage(value: number);
  136176. private _lambda;
  136177. /**
  136178. * Gets or set the lambda parameter.
  136179. * This parameter is used to split the camera frustum and create the cascades.
  136180. * 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.
  136181. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  136182. */
  136183. get lambda(): number;
  136184. set lambda(value: number);
  136185. /**
  136186. * Gets the view matrix corresponding to a given cascade
  136187. * @param cascadeNum cascade to retrieve the view matrix from
  136188. * @returns the cascade view matrix
  136189. */
  136190. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  136191. /**
  136192. * Gets the projection matrix corresponding to a given cascade
  136193. * @param cascadeNum cascade to retrieve the projection matrix from
  136194. * @returns the cascade projection matrix
  136195. */
  136196. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  136197. /**
  136198. * Gets the transformation matrix corresponding to a given cascade
  136199. * @param cascadeNum cascade to retrieve the transformation matrix from
  136200. * @returns the cascade transformation matrix
  136201. */
  136202. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  136203. private _depthRenderer;
  136204. /**
  136205. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  136206. *
  136207. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  136208. *
  136209. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  136210. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  136211. * @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
  136212. */
  136213. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  136214. private _depthReducer;
  136215. private _autoCalcDepthBounds;
  136216. /**
  136217. * Gets or sets the autoCalcDepthBounds property.
  136218. *
  136219. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  136220. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  136221. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  136222. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  136223. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  136224. */
  136225. get autoCalcDepthBounds(): boolean;
  136226. set autoCalcDepthBounds(value: boolean);
  136227. /**
  136228. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  136229. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  136230. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  136231. * for setting the refresh rate on the renderer yourself!
  136232. */
  136233. get autoCalcDepthBoundsRefreshRate(): number;
  136234. set autoCalcDepthBoundsRefreshRate(value: number);
  136235. /**
  136236. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  136237. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  136238. * you change the camera near/far planes!
  136239. */
  136240. splitFrustum(): void;
  136241. private _splitFrustum;
  136242. private _computeMatrices;
  136243. private _computeFrustumInWorldSpace;
  136244. private _computeCascadeFrustum;
  136245. /**
  136246. * Support test.
  136247. */
  136248. static get IsSupported(): boolean;
  136249. /** @hidden */
  136250. static _SceneComponentInitialization: (scene: Scene) => void;
  136251. /**
  136252. * Creates a Cascaded Shadow Generator object.
  136253. * A ShadowGenerator is the required tool to use the shadows.
  136254. * Each directional light casting shadows needs to use its own ShadowGenerator.
  136255. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  136256. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  136257. * @param light The directional light object generating the shadows.
  136258. * @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.
  136259. */
  136260. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  136261. protected _initializeGenerator(): void;
  136262. protected _createTargetRenderTexture(): void;
  136263. protected _initializeShadowMap(): void;
  136264. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  136265. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  136266. /**
  136267. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  136268. * @param defines Defines of the material we want to update
  136269. * @param lightIndex Index of the light in the enabled light list of the material
  136270. */
  136271. prepareDefines(defines: any, lightIndex: number): void;
  136272. /**
  136273. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  136274. * defined in the generator but impacting the effect).
  136275. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  136276. * @param effect The effect we are binfing the information for
  136277. */
  136278. bindShadowLight(lightIndex: string, effect: Effect): void;
  136279. /**
  136280. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  136281. * (eq to view projection * shadow projection matrices)
  136282. * @returns The transform matrix used to create the shadow map
  136283. */
  136284. getTransformMatrix(): Matrix;
  136285. /**
  136286. * Disposes the ShadowGenerator.
  136287. * Returns nothing.
  136288. */
  136289. dispose(): void;
  136290. /**
  136291. * Serializes the shadow generator setup to a json object.
  136292. * @returns The serialized JSON object
  136293. */
  136294. serialize(): any;
  136295. /**
  136296. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  136297. * @param parsedShadowGenerator The JSON object to parse
  136298. * @param scene The scene to create the shadow map for
  136299. * @returns The parsed shadow generator
  136300. */
  136301. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  136302. }
  136303. }
  136304. declare module BABYLON {
  136305. /**
  136306. * Defines the shadow generator component responsible to manage any shadow generators
  136307. * in a given scene.
  136308. */
  136309. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  136310. /**
  136311. * The component name helpfull to identify the component in the list of scene components.
  136312. */
  136313. readonly name: string;
  136314. /**
  136315. * The scene the component belongs to.
  136316. */
  136317. scene: Scene;
  136318. /**
  136319. * Creates a new instance of the component for the given scene
  136320. * @param scene Defines the scene to register the component in
  136321. */
  136322. constructor(scene: Scene);
  136323. /**
  136324. * Registers the component in a given scene
  136325. */
  136326. register(): void;
  136327. /**
  136328. * Rebuilds the elements related to this component in case of
  136329. * context lost for instance.
  136330. */
  136331. rebuild(): void;
  136332. /**
  136333. * Serializes the component data to the specified json object
  136334. * @param serializationObject The object to serialize to
  136335. */
  136336. serialize(serializationObject: any): void;
  136337. /**
  136338. * Adds all the elements from the container to the scene
  136339. * @param container the container holding the elements
  136340. */
  136341. addFromContainer(container: AbstractScene): void;
  136342. /**
  136343. * Removes all the elements in the container from the scene
  136344. * @param container contains the elements to remove
  136345. * @param dispose if the removed element should be disposed (default: false)
  136346. */
  136347. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136348. /**
  136349. * Rebuilds the elements related to this component in case of
  136350. * context lost for instance.
  136351. */
  136352. dispose(): void;
  136353. private _gatherRenderTargets;
  136354. }
  136355. }
  136356. declare module BABYLON {
  136357. /**
  136358. * A point light is a light defined by an unique point in world space.
  136359. * The light is emitted in every direction from this point.
  136360. * A good example of a point light is a standard light bulb.
  136361. * Documentation: https://doc.babylonjs.com/babylon101/lights
  136362. */
  136363. export class PointLight extends ShadowLight {
  136364. private _shadowAngle;
  136365. /**
  136366. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  136367. * This specifies what angle the shadow will use to be created.
  136368. *
  136369. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  136370. */
  136371. get shadowAngle(): number;
  136372. /**
  136373. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  136374. * This specifies what angle the shadow will use to be created.
  136375. *
  136376. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  136377. */
  136378. set shadowAngle(value: number);
  136379. /**
  136380. * Gets the direction if it has been set.
  136381. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  136382. */
  136383. get direction(): Vector3;
  136384. /**
  136385. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  136386. */
  136387. set direction(value: Vector3);
  136388. /**
  136389. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  136390. * A PointLight emits the light in every direction.
  136391. * It can cast shadows.
  136392. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  136393. * ```javascript
  136394. * var pointLight = new PointLight("pl", camera.position, scene);
  136395. * ```
  136396. * Documentation : https://doc.babylonjs.com/babylon101/lights
  136397. * @param name The light friendly name
  136398. * @param position The position of the point light in the scene
  136399. * @param scene The scene the lights belongs to
  136400. */
  136401. constructor(name: string, position: Vector3, scene: Scene);
  136402. /**
  136403. * Returns the string "PointLight"
  136404. * @returns the class name
  136405. */
  136406. getClassName(): string;
  136407. /**
  136408. * Returns the integer 0.
  136409. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  136410. */
  136411. getTypeID(): number;
  136412. /**
  136413. * Specifies wether or not the shadowmap should be a cube texture.
  136414. * @returns true if the shadowmap needs to be a cube texture.
  136415. */
  136416. needCube(): boolean;
  136417. /**
  136418. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  136419. * @param faceIndex The index of the face we are computed the direction to generate shadow
  136420. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  136421. */
  136422. getShadowDirection(faceIndex?: number): Vector3;
  136423. /**
  136424. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  136425. * - fov = PI / 2
  136426. * - aspect ratio : 1.0
  136427. * - z-near and far equal to the active camera minZ and maxZ.
  136428. * Returns the PointLight.
  136429. */
  136430. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  136431. protected _buildUniformLayout(): void;
  136432. /**
  136433. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  136434. * @param effect The effect to update
  136435. * @param lightIndex The index of the light in the effect to update
  136436. * @returns The point light
  136437. */
  136438. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  136439. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  136440. /**
  136441. * Prepares the list of defines specific to the light type.
  136442. * @param defines the list of defines
  136443. * @param lightIndex defines the index of the light for the effect
  136444. */
  136445. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  136446. }
  136447. }
  136448. declare module BABYLON {
  136449. /**
  136450. * Header information of HDR texture files.
  136451. */
  136452. export interface HDRInfo {
  136453. /**
  136454. * The height of the texture in pixels.
  136455. */
  136456. height: number;
  136457. /**
  136458. * The width of the texture in pixels.
  136459. */
  136460. width: number;
  136461. /**
  136462. * The index of the beginning of the data in the binary file.
  136463. */
  136464. dataPosition: number;
  136465. }
  136466. /**
  136467. * This groups tools to convert HDR texture to native colors array.
  136468. */
  136469. export class HDRTools {
  136470. private static Ldexp;
  136471. private static Rgbe2float;
  136472. private static readStringLine;
  136473. /**
  136474. * Reads header information from an RGBE texture stored in a native array.
  136475. * More information on this format are available here:
  136476. * https://en.wikipedia.org/wiki/RGBE_image_format
  136477. *
  136478. * @param uint8array The binary file stored in native array.
  136479. * @return The header information.
  136480. */
  136481. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  136482. /**
  136483. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  136484. * This RGBE texture needs to store the information as a panorama.
  136485. *
  136486. * More information on this format are available here:
  136487. * https://en.wikipedia.org/wiki/RGBE_image_format
  136488. *
  136489. * @param buffer The binary file stored in an array buffer.
  136490. * @param size The expected size of the extracted cubemap.
  136491. * @return The Cube Map information.
  136492. */
  136493. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  136494. /**
  136495. * Returns the pixels data extracted from an RGBE texture.
  136496. * This pixels will be stored left to right up to down in the R G B order in one array.
  136497. *
  136498. * More information on this format are available here:
  136499. * https://en.wikipedia.org/wiki/RGBE_image_format
  136500. *
  136501. * @param uint8array The binary file stored in an array buffer.
  136502. * @param hdrInfo The header information of the file.
  136503. * @return The pixels data in RGB right to left up to down order.
  136504. */
  136505. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  136506. private static RGBE_ReadPixels_RLE;
  136507. }
  136508. }
  136509. declare module BABYLON {
  136510. /**
  136511. * Effect Render Options
  136512. */
  136513. export interface IEffectRendererOptions {
  136514. /**
  136515. * Defines the vertices positions.
  136516. */
  136517. positions?: number[];
  136518. /**
  136519. * Defines the indices.
  136520. */
  136521. indices?: number[];
  136522. }
  136523. /**
  136524. * Helper class to render one or more effects.
  136525. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  136526. */
  136527. export class EffectRenderer {
  136528. private engine;
  136529. private static _DefaultOptions;
  136530. private _vertexBuffers;
  136531. private _indexBuffer;
  136532. private _fullscreenViewport;
  136533. /**
  136534. * Creates an effect renderer
  136535. * @param engine the engine to use for rendering
  136536. * @param options defines the options of the effect renderer
  136537. */
  136538. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  136539. /**
  136540. * Sets the current viewport in normalized coordinates 0-1
  136541. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  136542. */
  136543. setViewport(viewport?: Viewport): void;
  136544. /**
  136545. * Binds the embedded attributes buffer to the effect.
  136546. * @param effect Defines the effect to bind the attributes for
  136547. */
  136548. bindBuffers(effect: Effect): void;
  136549. /**
  136550. * Sets the current effect wrapper to use during draw.
  136551. * The effect needs to be ready before calling this api.
  136552. * This also sets the default full screen position attribute.
  136553. * @param effectWrapper Defines the effect to draw with
  136554. */
  136555. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  136556. /**
  136557. * Restores engine states
  136558. */
  136559. restoreStates(): void;
  136560. /**
  136561. * Draws a full screen quad.
  136562. */
  136563. draw(): void;
  136564. private isRenderTargetTexture;
  136565. /**
  136566. * renders one or more effects to a specified texture
  136567. * @param effectWrapper the effect to renderer
  136568. * @param outputTexture texture to draw to, if null it will render to the screen.
  136569. */
  136570. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  136571. /**
  136572. * Disposes of the effect renderer
  136573. */
  136574. dispose(): void;
  136575. }
  136576. /**
  136577. * Options to create an EffectWrapper
  136578. */
  136579. interface EffectWrapperCreationOptions {
  136580. /**
  136581. * Engine to use to create the effect
  136582. */
  136583. engine: ThinEngine;
  136584. /**
  136585. * Fragment shader for the effect
  136586. */
  136587. fragmentShader: string;
  136588. /**
  136589. * Use the shader store instead of direct source code
  136590. */
  136591. useShaderStore?: boolean;
  136592. /**
  136593. * Vertex shader for the effect
  136594. */
  136595. vertexShader?: string;
  136596. /**
  136597. * Attributes to use in the shader
  136598. */
  136599. attributeNames?: Array<string>;
  136600. /**
  136601. * Uniforms to use in the shader
  136602. */
  136603. uniformNames?: Array<string>;
  136604. /**
  136605. * Texture sampler names to use in the shader
  136606. */
  136607. samplerNames?: Array<string>;
  136608. /**
  136609. * Defines to use in the shader
  136610. */
  136611. defines?: Array<string>;
  136612. /**
  136613. * Callback when effect is compiled
  136614. */
  136615. onCompiled?: Nullable<(effect: Effect) => void>;
  136616. /**
  136617. * The friendly name of the effect displayed in Spector.
  136618. */
  136619. name?: string;
  136620. }
  136621. /**
  136622. * Wraps an effect to be used for rendering
  136623. */
  136624. export class EffectWrapper {
  136625. /**
  136626. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  136627. */
  136628. onApplyObservable: Observable<{}>;
  136629. /**
  136630. * The underlying effect
  136631. */
  136632. effect: Effect;
  136633. /**
  136634. * Creates an effect to be renderer
  136635. * @param creationOptions options to create the effect
  136636. */
  136637. constructor(creationOptions: EffectWrapperCreationOptions);
  136638. /**
  136639. * Disposes of the effect wrapper
  136640. */
  136641. dispose(): void;
  136642. }
  136643. }
  136644. declare module BABYLON {
  136645. /** @hidden */
  136646. export var hdrFilteringVertexShader: {
  136647. name: string;
  136648. shader: string;
  136649. };
  136650. }
  136651. declare module BABYLON {
  136652. /** @hidden */
  136653. export var hdrFilteringPixelShader: {
  136654. name: string;
  136655. shader: string;
  136656. };
  136657. }
  136658. declare module BABYLON {
  136659. /**
  136660. * Options for texture filtering
  136661. */
  136662. interface IHDRFilteringOptions {
  136663. /**
  136664. * Scales pixel intensity for the input HDR map.
  136665. */
  136666. hdrScale?: number;
  136667. /**
  136668. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  136669. */
  136670. quality?: number;
  136671. }
  136672. /**
  136673. * Filters HDR maps to get correct renderings of PBR reflections
  136674. */
  136675. export class HDRFiltering {
  136676. private _engine;
  136677. private _effectRenderer;
  136678. private _effectWrapper;
  136679. private _lodGenerationOffset;
  136680. private _lodGenerationScale;
  136681. /**
  136682. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  136683. * you care about baking speed.
  136684. */
  136685. quality: number;
  136686. /**
  136687. * Scales pixel intensity for the input HDR map.
  136688. */
  136689. hdrScale: number;
  136690. /**
  136691. * Instantiates HDR filter for reflection maps
  136692. *
  136693. * @param engine Thin engine
  136694. * @param options Options
  136695. */
  136696. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  136697. private _createRenderTarget;
  136698. private _prefilterInternal;
  136699. private _createEffect;
  136700. /**
  136701. * Get a value indicating if the filter is ready to be used
  136702. * @param texture Texture to filter
  136703. * @returns true if the filter is ready
  136704. */
  136705. isReady(texture: BaseTexture): boolean;
  136706. /**
  136707. * Prefilters a cube texture to have mipmap levels representing roughness values.
  136708. * Prefiltering will be invoked at the end of next rendering pass.
  136709. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  136710. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  136711. * @param texture Texture to filter
  136712. * @param onFinished Callback when filtering is done
  136713. * @return Promise called when prefiltering is done
  136714. */
  136715. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  136716. }
  136717. }
  136718. declare module BABYLON {
  136719. /**
  136720. * This represents a texture coming from an HDR input.
  136721. *
  136722. * The only supported format is currently panorama picture stored in RGBE format.
  136723. * Example of such files can be found on HDRLib: http://hdrlib.com/
  136724. */
  136725. export class HDRCubeTexture extends BaseTexture {
  136726. private static _facesMapping;
  136727. private _generateHarmonics;
  136728. private _noMipmap;
  136729. private _prefilterOnLoad;
  136730. private _textureMatrix;
  136731. private _size;
  136732. private _onLoad;
  136733. private _onError;
  136734. /**
  136735. * The texture URL.
  136736. */
  136737. url: string;
  136738. /**
  136739. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  136740. */
  136741. coordinatesMode: number;
  136742. protected _isBlocking: boolean;
  136743. /**
  136744. * Sets wether or not the texture is blocking during loading.
  136745. */
  136746. set isBlocking(value: boolean);
  136747. /**
  136748. * Gets wether or not the texture is blocking during loading.
  136749. */
  136750. get isBlocking(): boolean;
  136751. protected _rotationY: number;
  136752. /**
  136753. * Sets texture matrix rotation angle around Y axis in radians.
  136754. */
  136755. set rotationY(value: number);
  136756. /**
  136757. * Gets texture matrix rotation angle around Y axis radians.
  136758. */
  136759. get rotationY(): number;
  136760. /**
  136761. * Gets or sets the center of the bounding box associated with the cube texture
  136762. * It must define where the camera used to render the texture was set
  136763. */
  136764. boundingBoxPosition: Vector3;
  136765. private _boundingBoxSize;
  136766. /**
  136767. * Gets or sets the size of the bounding box associated with the cube texture
  136768. * When defined, the cubemap will switch to local mode
  136769. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  136770. * @example https://www.babylonjs-playground.com/#RNASML
  136771. */
  136772. set boundingBoxSize(value: Vector3);
  136773. get boundingBoxSize(): Vector3;
  136774. /**
  136775. * Instantiates an HDRTexture from the following parameters.
  136776. *
  136777. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  136778. * @param sceneOrEngine The scene or engine the texture will be used in
  136779. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  136780. * @param noMipmap Forces to not generate the mipmap if true
  136781. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  136782. * @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)
  136783. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  136784. */
  136785. 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>);
  136786. /**
  136787. * Get the current class name of the texture useful for serialization or dynamic coding.
  136788. * @returns "HDRCubeTexture"
  136789. */
  136790. getClassName(): string;
  136791. /**
  136792. * Occurs when the file is raw .hdr file.
  136793. */
  136794. private loadTexture;
  136795. clone(): HDRCubeTexture;
  136796. delayLoad(): void;
  136797. /**
  136798. * Get the texture reflection matrix used to rotate/transform the reflection.
  136799. * @returns the reflection matrix
  136800. */
  136801. getReflectionTextureMatrix(): Matrix;
  136802. /**
  136803. * Set the texture reflection matrix used to rotate/transform the reflection.
  136804. * @param value Define the reflection matrix to set
  136805. */
  136806. setReflectionTextureMatrix(value: Matrix): void;
  136807. /**
  136808. * Parses a JSON representation of an HDR Texture in order to create the texture
  136809. * @param parsedTexture Define the JSON representation
  136810. * @param scene Define the scene the texture should be created in
  136811. * @param rootUrl Define the root url in case we need to load relative dependencies
  136812. * @returns the newly created texture after parsing
  136813. */
  136814. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  136815. serialize(): any;
  136816. }
  136817. }
  136818. declare module BABYLON {
  136819. /**
  136820. * Class used to control physics engine
  136821. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  136822. */
  136823. export class PhysicsEngine implements IPhysicsEngine {
  136824. private _physicsPlugin;
  136825. /**
  136826. * Global value used to control the smallest number supported by the simulation
  136827. */
  136828. static Epsilon: number;
  136829. private _impostors;
  136830. private _joints;
  136831. private _subTimeStep;
  136832. /**
  136833. * Gets the gravity vector used by the simulation
  136834. */
  136835. gravity: Vector3;
  136836. /**
  136837. * Factory used to create the default physics plugin.
  136838. * @returns The default physics plugin
  136839. */
  136840. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  136841. /**
  136842. * Creates a new Physics Engine
  136843. * @param gravity defines the gravity vector used by the simulation
  136844. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  136845. */
  136846. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  136847. /**
  136848. * Sets the gravity vector used by the simulation
  136849. * @param gravity defines the gravity vector to use
  136850. */
  136851. setGravity(gravity: Vector3): void;
  136852. /**
  136853. * Set the time step of the physics engine.
  136854. * Default is 1/60.
  136855. * To slow it down, enter 1/600 for example.
  136856. * To speed it up, 1/30
  136857. * @param newTimeStep defines the new timestep to apply to this world.
  136858. */
  136859. setTimeStep(newTimeStep?: number): void;
  136860. /**
  136861. * Get the time step of the physics engine.
  136862. * @returns the current time step
  136863. */
  136864. getTimeStep(): number;
  136865. /**
  136866. * Set the sub time step of the physics engine.
  136867. * Default is 0 meaning there is no sub steps
  136868. * To increase physics resolution precision, set a small value (like 1 ms)
  136869. * @param subTimeStep defines the new sub timestep used for physics resolution.
  136870. */
  136871. setSubTimeStep(subTimeStep?: number): void;
  136872. /**
  136873. * Get the sub time step of the physics engine.
  136874. * @returns the current sub time step
  136875. */
  136876. getSubTimeStep(): number;
  136877. /**
  136878. * Release all resources
  136879. */
  136880. dispose(): void;
  136881. /**
  136882. * Gets the name of the current physics plugin
  136883. * @returns the name of the plugin
  136884. */
  136885. getPhysicsPluginName(): string;
  136886. /**
  136887. * Adding a new impostor for the impostor tracking.
  136888. * This will be done by the impostor itself.
  136889. * @param impostor the impostor to add
  136890. */
  136891. addImpostor(impostor: PhysicsImpostor): void;
  136892. /**
  136893. * Remove an impostor from the engine.
  136894. * This impostor and its mesh will not longer be updated by the physics engine.
  136895. * @param impostor the impostor to remove
  136896. */
  136897. removeImpostor(impostor: PhysicsImpostor): void;
  136898. /**
  136899. * Add a joint to the physics engine
  136900. * @param mainImpostor defines the main impostor to which the joint is added.
  136901. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  136902. * @param joint defines the joint that will connect both impostors.
  136903. */
  136904. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  136905. /**
  136906. * Removes a joint from the simulation
  136907. * @param mainImpostor defines the impostor used with the joint
  136908. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  136909. * @param joint defines the joint to remove
  136910. */
  136911. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  136912. /**
  136913. * Called by the scene. No need to call it.
  136914. * @param delta defines the timespam between frames
  136915. */
  136916. _step(delta: number): void;
  136917. /**
  136918. * Gets the current plugin used to run the simulation
  136919. * @returns current plugin
  136920. */
  136921. getPhysicsPlugin(): IPhysicsEnginePlugin;
  136922. /**
  136923. * Gets the list of physic impostors
  136924. * @returns an array of PhysicsImpostor
  136925. */
  136926. getImpostors(): Array<PhysicsImpostor>;
  136927. /**
  136928. * Gets the impostor for a physics enabled object
  136929. * @param object defines the object impersonated by the impostor
  136930. * @returns the PhysicsImpostor or null if not found
  136931. */
  136932. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  136933. /**
  136934. * Gets the impostor for a physics body object
  136935. * @param body defines physics body used by the impostor
  136936. * @returns the PhysicsImpostor or null if not found
  136937. */
  136938. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  136939. /**
  136940. * Does a raycast in the physics world
  136941. * @param from when should the ray start?
  136942. * @param to when should the ray end?
  136943. * @returns PhysicsRaycastResult
  136944. */
  136945. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  136946. }
  136947. }
  136948. declare module BABYLON {
  136949. /** @hidden */
  136950. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  136951. private _useDeltaForWorldStep;
  136952. world: any;
  136953. name: string;
  136954. private _physicsMaterials;
  136955. private _fixedTimeStep;
  136956. private _cannonRaycastResult;
  136957. private _raycastResult;
  136958. private _physicsBodysToRemoveAfterStep;
  136959. private _firstFrame;
  136960. BJSCANNON: any;
  136961. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  136962. setGravity(gravity: Vector3): void;
  136963. setTimeStep(timeStep: number): void;
  136964. getTimeStep(): number;
  136965. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  136966. private _removeMarkedPhysicsBodiesFromWorld;
  136967. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136968. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136969. generatePhysicsBody(impostor: PhysicsImpostor): void;
  136970. private _processChildMeshes;
  136971. removePhysicsBody(impostor: PhysicsImpostor): void;
  136972. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  136973. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  136974. private _addMaterial;
  136975. private _checkWithEpsilon;
  136976. private _createShape;
  136977. private _createHeightmap;
  136978. private _minus90X;
  136979. private _plus90X;
  136980. private _tmpPosition;
  136981. private _tmpDeltaPosition;
  136982. private _tmpUnityRotation;
  136983. private _updatePhysicsBodyTransformation;
  136984. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  136985. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  136986. isSupported(): boolean;
  136987. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136988. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136989. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136990. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136991. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  136992. getBodyMass(impostor: PhysicsImpostor): number;
  136993. getBodyFriction(impostor: PhysicsImpostor): number;
  136994. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  136995. getBodyRestitution(impostor: PhysicsImpostor): number;
  136996. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  136997. sleepBody(impostor: PhysicsImpostor): void;
  136998. wakeUpBody(impostor: PhysicsImpostor): void;
  136999. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  137000. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  137001. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  137002. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137003. getRadius(impostor: PhysicsImpostor): number;
  137004. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137005. dispose(): void;
  137006. private _extendNamespace;
  137007. /**
  137008. * Does a raycast in the physics world
  137009. * @param from when should the ray start?
  137010. * @param to when should the ray end?
  137011. * @returns PhysicsRaycastResult
  137012. */
  137013. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137014. }
  137015. }
  137016. declare module BABYLON {
  137017. /** @hidden */
  137018. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  137019. private _useDeltaForWorldStep;
  137020. world: any;
  137021. name: string;
  137022. BJSOIMO: any;
  137023. private _raycastResult;
  137024. private _fixedTimeStep;
  137025. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  137026. setGravity(gravity: Vector3): void;
  137027. setTimeStep(timeStep: number): void;
  137028. getTimeStep(): number;
  137029. private _tmpImpostorsArray;
  137030. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137031. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137032. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137033. generatePhysicsBody(impostor: PhysicsImpostor): void;
  137034. private _tmpPositionVector;
  137035. removePhysicsBody(impostor: PhysicsImpostor): void;
  137036. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  137037. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  137038. isSupported(): boolean;
  137039. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  137040. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  137041. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137042. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137043. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137044. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137045. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  137046. getBodyMass(impostor: PhysicsImpostor): number;
  137047. getBodyFriction(impostor: PhysicsImpostor): number;
  137048. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  137049. getBodyRestitution(impostor: PhysicsImpostor): number;
  137050. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  137051. sleepBody(impostor: PhysicsImpostor): void;
  137052. wakeUpBody(impostor: PhysicsImpostor): void;
  137053. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  137054. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  137055. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  137056. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137057. getRadius(impostor: PhysicsImpostor): number;
  137058. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137059. dispose(): void;
  137060. /**
  137061. * Does a raycast in the physics world
  137062. * @param from when should the ray start?
  137063. * @param to when should the ray end?
  137064. * @returns PhysicsRaycastResult
  137065. */
  137066. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137067. }
  137068. }
  137069. declare module BABYLON {
  137070. /**
  137071. * Class containing static functions to help procedurally build meshes
  137072. */
  137073. export class RibbonBuilder {
  137074. /**
  137075. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  137076. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  137077. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  137078. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  137079. * * 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
  137080. * * 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
  137081. * * 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
  137082. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137083. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137084. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137085. * * 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
  137086. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  137087. * * 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
  137088. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  137089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137090. * @param name defines the name of the mesh
  137091. * @param options defines the options used to create the mesh
  137092. * @param scene defines the hosting scene
  137093. * @returns the ribbon mesh
  137094. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  137095. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137096. */
  137097. static CreateRibbon(name: string, options: {
  137098. pathArray: Vector3[][];
  137099. closeArray?: boolean;
  137100. closePath?: boolean;
  137101. offset?: number;
  137102. updatable?: boolean;
  137103. sideOrientation?: number;
  137104. frontUVs?: Vector4;
  137105. backUVs?: Vector4;
  137106. instance?: Mesh;
  137107. invertUV?: boolean;
  137108. uvs?: Vector2[];
  137109. colors?: Color4[];
  137110. }, scene?: Nullable<Scene>): Mesh;
  137111. }
  137112. }
  137113. declare module BABYLON {
  137114. /**
  137115. * Class containing static functions to help procedurally build meshes
  137116. */
  137117. export class ShapeBuilder {
  137118. /**
  137119. * 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.
  137120. * * 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.
  137121. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137122. * * 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.
  137123. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  137124. * * 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
  137125. * * 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
  137126. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  137127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137129. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  137130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  137131. * @param name defines the name of the mesh
  137132. * @param options defines the options used to create the mesh
  137133. * @param scene defines the hosting scene
  137134. * @returns the extruded shape mesh
  137135. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137136. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137137. */
  137138. static ExtrudeShape(name: string, options: {
  137139. shape: Vector3[];
  137140. path: Vector3[];
  137141. scale?: number;
  137142. rotation?: number;
  137143. cap?: number;
  137144. updatable?: boolean;
  137145. sideOrientation?: number;
  137146. frontUVs?: Vector4;
  137147. backUVs?: Vector4;
  137148. instance?: Mesh;
  137149. invertUV?: boolean;
  137150. }, scene?: Nullable<Scene>): Mesh;
  137151. /**
  137152. * Creates an custom extruded shape mesh.
  137153. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  137154. * * 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.
  137155. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137156. * * 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
  137157. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  137158. * * 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
  137159. * * It must returns a float value that will be the scale value applied to the shape on each path point
  137160. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  137161. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  137162. * * 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
  137163. * * 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
  137164. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  137165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137166. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137167. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137169. * @param name defines the name of the mesh
  137170. * @param options defines the options used to create the mesh
  137171. * @param scene defines the hosting scene
  137172. * @returns the custom extruded shape mesh
  137173. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  137174. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137175. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137176. */
  137177. static ExtrudeShapeCustom(name: string, options: {
  137178. shape: Vector3[];
  137179. path: Vector3[];
  137180. scaleFunction?: any;
  137181. rotationFunction?: any;
  137182. ribbonCloseArray?: boolean;
  137183. ribbonClosePath?: boolean;
  137184. cap?: number;
  137185. updatable?: boolean;
  137186. sideOrientation?: number;
  137187. frontUVs?: Vector4;
  137188. backUVs?: Vector4;
  137189. instance?: Mesh;
  137190. invertUV?: boolean;
  137191. }, scene?: Nullable<Scene>): Mesh;
  137192. private static _ExtrudeShapeGeneric;
  137193. }
  137194. }
  137195. declare module BABYLON {
  137196. /**
  137197. * AmmoJS Physics plugin
  137198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  137199. * @see https://github.com/kripken/ammo.js/
  137200. */
  137201. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  137202. private _useDeltaForWorldStep;
  137203. /**
  137204. * Reference to the Ammo library
  137205. */
  137206. bjsAMMO: any;
  137207. /**
  137208. * Created ammoJS world which physics bodies are added to
  137209. */
  137210. world: any;
  137211. /**
  137212. * Name of the plugin
  137213. */
  137214. name: string;
  137215. private _timeStep;
  137216. private _fixedTimeStep;
  137217. private _maxSteps;
  137218. private _tmpQuaternion;
  137219. private _tmpAmmoTransform;
  137220. private _tmpAmmoQuaternion;
  137221. private _tmpAmmoConcreteContactResultCallback;
  137222. private _collisionConfiguration;
  137223. private _dispatcher;
  137224. private _overlappingPairCache;
  137225. private _solver;
  137226. private _softBodySolver;
  137227. private _tmpAmmoVectorA;
  137228. private _tmpAmmoVectorB;
  137229. private _tmpAmmoVectorC;
  137230. private _tmpAmmoVectorD;
  137231. private _tmpContactCallbackResult;
  137232. private _tmpAmmoVectorRCA;
  137233. private _tmpAmmoVectorRCB;
  137234. private _raycastResult;
  137235. private static readonly DISABLE_COLLISION_FLAG;
  137236. private static readonly KINEMATIC_FLAG;
  137237. private static readonly DISABLE_DEACTIVATION_FLAG;
  137238. /**
  137239. * Initializes the ammoJS plugin
  137240. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  137241. * @param ammoInjection can be used to inject your own ammo reference
  137242. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  137243. */
  137244. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  137245. /**
  137246. * Sets the gravity of the physics world (m/(s^2))
  137247. * @param gravity Gravity to set
  137248. */
  137249. setGravity(gravity: Vector3): void;
  137250. /**
  137251. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  137252. * @param timeStep timestep to use in seconds
  137253. */
  137254. setTimeStep(timeStep: number): void;
  137255. /**
  137256. * 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)
  137257. * @param fixedTimeStep fixedTimeStep to use in seconds
  137258. */
  137259. setFixedTimeStep(fixedTimeStep: number): void;
  137260. /**
  137261. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  137262. * @param maxSteps the maximum number of steps by the physics engine per frame
  137263. */
  137264. setMaxSteps(maxSteps: number): void;
  137265. /**
  137266. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  137267. * @returns the current timestep in seconds
  137268. */
  137269. getTimeStep(): number;
  137270. /**
  137271. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  137272. */
  137273. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  137274. private _isImpostorInContact;
  137275. private _isImpostorPairInContact;
  137276. private _stepSimulation;
  137277. /**
  137278. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  137279. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  137280. * After the step the babylon meshes are set to the position of the physics imposters
  137281. * @param delta amount of time to step forward
  137282. * @param impostors array of imposters to update before/after the step
  137283. */
  137284. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137285. /**
  137286. * Update babylon mesh to match physics world object
  137287. * @param impostor imposter to match
  137288. */
  137289. private _afterSoftStep;
  137290. /**
  137291. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  137292. * @param impostor imposter to match
  137293. */
  137294. private _ropeStep;
  137295. /**
  137296. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  137297. * @param impostor imposter to match
  137298. */
  137299. private _softbodyOrClothStep;
  137300. private _tmpMatrix;
  137301. /**
  137302. * Applies an impulse on the imposter
  137303. * @param impostor imposter to apply impulse to
  137304. * @param force amount of force to be applied to the imposter
  137305. * @param contactPoint the location to apply the impulse on the imposter
  137306. */
  137307. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137308. /**
  137309. * Applies a force on the imposter
  137310. * @param impostor imposter to apply force
  137311. * @param force amount of force to be applied to the imposter
  137312. * @param contactPoint the location to apply the force on the imposter
  137313. */
  137314. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137315. /**
  137316. * Creates a physics body using the plugin
  137317. * @param impostor the imposter to create the physics body on
  137318. */
  137319. generatePhysicsBody(impostor: PhysicsImpostor): void;
  137320. /**
  137321. * Removes the physics body from the imposter and disposes of the body's memory
  137322. * @param impostor imposter to remove the physics body from
  137323. */
  137324. removePhysicsBody(impostor: PhysicsImpostor): void;
  137325. /**
  137326. * Generates a joint
  137327. * @param impostorJoint the imposter joint to create the joint with
  137328. */
  137329. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  137330. /**
  137331. * Removes a joint
  137332. * @param impostorJoint the imposter joint to remove the joint from
  137333. */
  137334. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  137335. private _addMeshVerts;
  137336. /**
  137337. * Initialise the soft body vertices to match its object's (mesh) vertices
  137338. * Softbody vertices (nodes) are in world space and to match this
  137339. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  137340. * @param impostor to create the softbody for
  137341. */
  137342. private _softVertexData;
  137343. /**
  137344. * Create an impostor's soft body
  137345. * @param impostor to create the softbody for
  137346. */
  137347. private _createSoftbody;
  137348. /**
  137349. * Create cloth for an impostor
  137350. * @param impostor to create the softbody for
  137351. */
  137352. private _createCloth;
  137353. /**
  137354. * Create rope for an impostor
  137355. * @param impostor to create the softbody for
  137356. */
  137357. private _createRope;
  137358. /**
  137359. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  137360. * @param impostor to create the custom physics shape for
  137361. */
  137362. private _createCustom;
  137363. private _addHullVerts;
  137364. private _createShape;
  137365. /**
  137366. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  137367. * @param impostor imposter containing the physics body and babylon object
  137368. */
  137369. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  137370. /**
  137371. * Sets the babylon object's position/rotation from the physics body's position/rotation
  137372. * @param impostor imposter containing the physics body and babylon object
  137373. * @param newPosition new position
  137374. * @param newRotation new rotation
  137375. */
  137376. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  137377. /**
  137378. * If this plugin is supported
  137379. * @returns true if its supported
  137380. */
  137381. isSupported(): boolean;
  137382. /**
  137383. * Sets the linear velocity of the physics body
  137384. * @param impostor imposter to set the velocity on
  137385. * @param velocity velocity to set
  137386. */
  137387. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137388. /**
  137389. * Sets the angular velocity of the physics body
  137390. * @param impostor imposter to set the velocity on
  137391. * @param velocity velocity to set
  137392. */
  137393. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137394. /**
  137395. * gets the linear velocity
  137396. * @param impostor imposter to get linear velocity from
  137397. * @returns linear velocity
  137398. */
  137399. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137400. /**
  137401. * gets the angular velocity
  137402. * @param impostor imposter to get angular velocity from
  137403. * @returns angular velocity
  137404. */
  137405. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137406. /**
  137407. * Sets the mass of physics body
  137408. * @param impostor imposter to set the mass on
  137409. * @param mass mass to set
  137410. */
  137411. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  137412. /**
  137413. * Gets the mass of the physics body
  137414. * @param impostor imposter to get the mass from
  137415. * @returns mass
  137416. */
  137417. getBodyMass(impostor: PhysicsImpostor): number;
  137418. /**
  137419. * Gets friction of the impostor
  137420. * @param impostor impostor to get friction from
  137421. * @returns friction value
  137422. */
  137423. getBodyFriction(impostor: PhysicsImpostor): number;
  137424. /**
  137425. * Sets friction of the impostor
  137426. * @param impostor impostor to set friction on
  137427. * @param friction friction value
  137428. */
  137429. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  137430. /**
  137431. * Gets restitution of the impostor
  137432. * @param impostor impostor to get restitution from
  137433. * @returns restitution value
  137434. */
  137435. getBodyRestitution(impostor: PhysicsImpostor): number;
  137436. /**
  137437. * Sets resitution of the impostor
  137438. * @param impostor impostor to set resitution on
  137439. * @param restitution resitution value
  137440. */
  137441. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  137442. /**
  137443. * Gets pressure inside the impostor
  137444. * @param impostor impostor to get pressure from
  137445. * @returns pressure value
  137446. */
  137447. getBodyPressure(impostor: PhysicsImpostor): number;
  137448. /**
  137449. * Sets pressure inside a soft body impostor
  137450. * Cloth and rope must remain 0 pressure
  137451. * @param impostor impostor to set pressure on
  137452. * @param pressure pressure value
  137453. */
  137454. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  137455. /**
  137456. * Gets stiffness of the impostor
  137457. * @param impostor impostor to get stiffness from
  137458. * @returns pressure value
  137459. */
  137460. getBodyStiffness(impostor: PhysicsImpostor): number;
  137461. /**
  137462. * Sets stiffness of the impostor
  137463. * @param impostor impostor to set stiffness on
  137464. * @param stiffness stiffness value from 0 to 1
  137465. */
  137466. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  137467. /**
  137468. * Gets velocityIterations of the impostor
  137469. * @param impostor impostor to get velocity iterations from
  137470. * @returns velocityIterations value
  137471. */
  137472. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  137473. /**
  137474. * Sets velocityIterations of the impostor
  137475. * @param impostor impostor to set velocity iterations on
  137476. * @param velocityIterations velocityIterations value
  137477. */
  137478. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  137479. /**
  137480. * Gets positionIterations of the impostor
  137481. * @param impostor impostor to get position iterations from
  137482. * @returns positionIterations value
  137483. */
  137484. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  137485. /**
  137486. * Sets positionIterations of the impostor
  137487. * @param impostor impostor to set position on
  137488. * @param positionIterations positionIterations value
  137489. */
  137490. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  137491. /**
  137492. * Append an anchor to a cloth object
  137493. * @param impostor is the cloth impostor to add anchor to
  137494. * @param otherImpostor is the rigid impostor to anchor to
  137495. * @param width ratio across width from 0 to 1
  137496. * @param height ratio up height from 0 to 1
  137497. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  137498. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  137499. */
  137500. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  137501. /**
  137502. * Append an hook to a rope object
  137503. * @param impostor is the rope impostor to add hook to
  137504. * @param otherImpostor is the rigid impostor to hook to
  137505. * @param length ratio along the rope from 0 to 1
  137506. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  137507. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  137508. */
  137509. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  137510. /**
  137511. * Sleeps the physics body and stops it from being active
  137512. * @param impostor impostor to sleep
  137513. */
  137514. sleepBody(impostor: PhysicsImpostor): void;
  137515. /**
  137516. * Activates the physics body
  137517. * @param impostor impostor to activate
  137518. */
  137519. wakeUpBody(impostor: PhysicsImpostor): void;
  137520. /**
  137521. * Updates the distance parameters of the joint
  137522. * @param joint joint to update
  137523. * @param maxDistance maximum distance of the joint
  137524. * @param minDistance minimum distance of the joint
  137525. */
  137526. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  137527. /**
  137528. * Sets a motor on the joint
  137529. * @param joint joint to set motor on
  137530. * @param speed speed of the motor
  137531. * @param maxForce maximum force of the motor
  137532. * @param motorIndex index of the motor
  137533. */
  137534. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  137535. /**
  137536. * Sets the motors limit
  137537. * @param joint joint to set limit on
  137538. * @param upperLimit upper limit
  137539. * @param lowerLimit lower limit
  137540. */
  137541. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  137542. /**
  137543. * Syncs the position and rotation of a mesh with the impostor
  137544. * @param mesh mesh to sync
  137545. * @param impostor impostor to update the mesh with
  137546. */
  137547. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137548. /**
  137549. * Gets the radius of the impostor
  137550. * @param impostor impostor to get radius from
  137551. * @returns the radius
  137552. */
  137553. getRadius(impostor: PhysicsImpostor): number;
  137554. /**
  137555. * Gets the box size of the impostor
  137556. * @param impostor impostor to get box size from
  137557. * @param result the resulting box size
  137558. */
  137559. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137560. /**
  137561. * Disposes of the impostor
  137562. */
  137563. dispose(): void;
  137564. /**
  137565. * Does a raycast in the physics world
  137566. * @param from when should the ray start?
  137567. * @param to when should the ray end?
  137568. * @returns PhysicsRaycastResult
  137569. */
  137570. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137571. }
  137572. }
  137573. declare module BABYLON {
  137574. interface AbstractScene {
  137575. /**
  137576. * The list of reflection probes added to the scene
  137577. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  137578. */
  137579. reflectionProbes: Array<ReflectionProbe>;
  137580. /**
  137581. * Removes the given reflection probe from this scene.
  137582. * @param toRemove The reflection probe to remove
  137583. * @returns The index of the removed reflection probe
  137584. */
  137585. removeReflectionProbe(toRemove: ReflectionProbe): number;
  137586. /**
  137587. * Adds the given reflection probe to this scene.
  137588. * @param newReflectionProbe The reflection probe to add
  137589. */
  137590. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  137591. }
  137592. /**
  137593. * Class used to generate realtime reflection / refraction cube textures
  137594. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  137595. */
  137596. export class ReflectionProbe {
  137597. /** defines the name of the probe */
  137598. name: string;
  137599. private _scene;
  137600. private _renderTargetTexture;
  137601. private _projectionMatrix;
  137602. private _viewMatrix;
  137603. private _target;
  137604. private _add;
  137605. private _attachedMesh;
  137606. private _invertYAxis;
  137607. /** Gets or sets probe position (center of the cube map) */
  137608. position: Vector3;
  137609. /**
  137610. * Creates a new reflection probe
  137611. * @param name defines the name of the probe
  137612. * @param size defines the texture resolution (for each face)
  137613. * @param scene defines the hosting scene
  137614. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  137615. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  137616. */
  137617. constructor(
  137618. /** defines the name of the probe */
  137619. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  137620. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  137621. get samples(): number;
  137622. set samples(value: number);
  137623. /** Gets or sets the refresh rate to use (on every frame by default) */
  137624. get refreshRate(): number;
  137625. set refreshRate(value: number);
  137626. /**
  137627. * Gets the hosting scene
  137628. * @returns a Scene
  137629. */
  137630. getScene(): Scene;
  137631. /** Gets the internal CubeTexture used to render to */
  137632. get cubeTexture(): RenderTargetTexture;
  137633. /** Gets the list of meshes to render */
  137634. get renderList(): Nullable<AbstractMesh[]>;
  137635. /**
  137636. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  137637. * @param mesh defines the mesh to attach to
  137638. */
  137639. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  137640. /**
  137641. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  137642. * @param renderingGroupId The rendering group id corresponding to its index
  137643. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  137644. */
  137645. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  137646. /**
  137647. * Clean all associated resources
  137648. */
  137649. dispose(): void;
  137650. /**
  137651. * Converts the reflection probe information to a readable string for debug purpose.
  137652. * @param fullDetails Supports for multiple levels of logging within scene loading
  137653. * @returns the human readable reflection probe info
  137654. */
  137655. toString(fullDetails?: boolean): string;
  137656. /**
  137657. * Get the class name of the relfection probe.
  137658. * @returns "ReflectionProbe"
  137659. */
  137660. getClassName(): string;
  137661. /**
  137662. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  137663. * @returns The JSON representation of the texture
  137664. */
  137665. serialize(): any;
  137666. /**
  137667. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  137668. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  137669. * @param scene Define the scene the parsed reflection probe should be instantiated in
  137670. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  137671. * @returns The parsed reflection probe if successful
  137672. */
  137673. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  137674. }
  137675. }
  137676. declare module BABYLON {
  137677. /** @hidden */
  137678. export var _BabylonLoaderRegistered: boolean;
  137679. /**
  137680. * Helps setting up some configuration for the babylon file loader.
  137681. */
  137682. export class BabylonFileLoaderConfiguration {
  137683. /**
  137684. * The loader does not allow injecting custom physix engine into the plugins.
  137685. * Unfortunately in ES6, we need to manually inject them into the plugin.
  137686. * So you could set this variable to your engine import to make it work.
  137687. */
  137688. static LoaderInjectedPhysicsEngine: any;
  137689. }
  137690. }
  137691. declare module BABYLON {
  137692. /**
  137693. * The Physically based simple base material of BJS.
  137694. *
  137695. * This enables better naming and convention enforcements on top of the pbrMaterial.
  137696. * It is used as the base class for both the specGloss and metalRough conventions.
  137697. */
  137698. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  137699. /**
  137700. * Number of Simultaneous lights allowed on the material.
  137701. */
  137702. maxSimultaneousLights: number;
  137703. /**
  137704. * If sets to true, disables all the lights affecting the material.
  137705. */
  137706. disableLighting: boolean;
  137707. /**
  137708. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  137709. */
  137710. environmentTexture: BaseTexture;
  137711. /**
  137712. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  137713. */
  137714. invertNormalMapX: boolean;
  137715. /**
  137716. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  137717. */
  137718. invertNormalMapY: boolean;
  137719. /**
  137720. * Normal map used in the model.
  137721. */
  137722. normalTexture: BaseTexture;
  137723. /**
  137724. * Emissivie color used to self-illuminate the model.
  137725. */
  137726. emissiveColor: Color3;
  137727. /**
  137728. * Emissivie texture used to self-illuminate the model.
  137729. */
  137730. emissiveTexture: BaseTexture;
  137731. /**
  137732. * Occlusion Channel Strenght.
  137733. */
  137734. occlusionStrength: number;
  137735. /**
  137736. * Occlusion Texture of the material (adding extra occlusion effects).
  137737. */
  137738. occlusionTexture: BaseTexture;
  137739. /**
  137740. * Defines the alpha limits in alpha test mode.
  137741. */
  137742. alphaCutOff: number;
  137743. /**
  137744. * Gets the current double sided mode.
  137745. */
  137746. get doubleSided(): boolean;
  137747. /**
  137748. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137749. */
  137750. set doubleSided(value: boolean);
  137751. /**
  137752. * Stores the pre-calculated light information of a mesh in a texture.
  137753. */
  137754. lightmapTexture: BaseTexture;
  137755. /**
  137756. * If true, the light map contains occlusion information instead of lighting info.
  137757. */
  137758. useLightmapAsShadowmap: boolean;
  137759. /**
  137760. * Instantiates a new PBRMaterial instance.
  137761. *
  137762. * @param name The material name
  137763. * @param scene The scene the material will be use in.
  137764. */
  137765. constructor(name: string, scene: Scene);
  137766. getClassName(): string;
  137767. }
  137768. }
  137769. declare module BABYLON {
  137770. /**
  137771. * The PBR material of BJS following the metal roughness convention.
  137772. *
  137773. * This fits to the PBR convention in the GLTF definition:
  137774. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  137775. */
  137776. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  137777. /**
  137778. * The base color has two different interpretations depending on the value of metalness.
  137779. * When the material is a metal, the base color is the specific measured reflectance value
  137780. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  137781. * of the material.
  137782. */
  137783. baseColor: Color3;
  137784. /**
  137785. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  137786. * well as opacity information in the alpha channel.
  137787. */
  137788. baseTexture: BaseTexture;
  137789. /**
  137790. * Specifies the metallic scalar value of the material.
  137791. * Can also be used to scale the metalness values of the metallic texture.
  137792. */
  137793. metallic: number;
  137794. /**
  137795. * Specifies the roughness scalar value of the material.
  137796. * Can also be used to scale the roughness values of the metallic texture.
  137797. */
  137798. roughness: number;
  137799. /**
  137800. * Texture containing both the metallic value in the B channel and the
  137801. * roughness value in the G channel to keep better precision.
  137802. */
  137803. metallicRoughnessTexture: BaseTexture;
  137804. /**
  137805. * Instantiates a new PBRMetalRoughnessMaterial instance.
  137806. *
  137807. * @param name The material name
  137808. * @param scene The scene the material will be use in.
  137809. */
  137810. constructor(name: string, scene: Scene);
  137811. /**
  137812. * Return the currrent class name of the material.
  137813. */
  137814. getClassName(): string;
  137815. /**
  137816. * Makes a duplicate of the current material.
  137817. * @param name - name to use for the new material.
  137818. */
  137819. clone(name: string): PBRMetallicRoughnessMaterial;
  137820. /**
  137821. * Serialize the material to a parsable JSON object.
  137822. */
  137823. serialize(): any;
  137824. /**
  137825. * Parses a JSON object correponding to the serialize function.
  137826. */
  137827. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  137828. }
  137829. }
  137830. declare module BABYLON {
  137831. /**
  137832. * The PBR material of BJS following the specular glossiness convention.
  137833. *
  137834. * This fits to the PBR convention in the GLTF definition:
  137835. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  137836. */
  137837. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  137838. /**
  137839. * Specifies the diffuse color of the material.
  137840. */
  137841. diffuseColor: Color3;
  137842. /**
  137843. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  137844. * channel.
  137845. */
  137846. diffuseTexture: BaseTexture;
  137847. /**
  137848. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  137849. */
  137850. specularColor: Color3;
  137851. /**
  137852. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  137853. */
  137854. glossiness: number;
  137855. /**
  137856. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  137857. */
  137858. specularGlossinessTexture: BaseTexture;
  137859. /**
  137860. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  137861. *
  137862. * @param name The material name
  137863. * @param scene The scene the material will be use in.
  137864. */
  137865. constructor(name: string, scene: Scene);
  137866. /**
  137867. * Return the currrent class name of the material.
  137868. */
  137869. getClassName(): string;
  137870. /**
  137871. * Makes a duplicate of the current material.
  137872. * @param name - name to use for the new material.
  137873. */
  137874. clone(name: string): PBRSpecularGlossinessMaterial;
  137875. /**
  137876. * Serialize the material to a parsable JSON object.
  137877. */
  137878. serialize(): any;
  137879. /**
  137880. * Parses a JSON object correponding to the serialize function.
  137881. */
  137882. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  137883. }
  137884. }
  137885. declare module BABYLON {
  137886. /**
  137887. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  137888. * It can help converting any input color in a desired output one. This can then be used to create effects
  137889. * from sepia, black and white to sixties or futuristic rendering...
  137890. *
  137891. * The only supported format is currently 3dl.
  137892. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  137893. */
  137894. export class ColorGradingTexture extends BaseTexture {
  137895. /**
  137896. * The texture URL.
  137897. */
  137898. url: string;
  137899. /**
  137900. * Empty line regex stored for GC.
  137901. */
  137902. private static _noneEmptyLineRegex;
  137903. private _textureMatrix;
  137904. private _onLoad;
  137905. /**
  137906. * Instantiates a ColorGradingTexture from the following parameters.
  137907. *
  137908. * @param url The location of the color gradind data (currently only supporting 3dl)
  137909. * @param sceneOrEngine The scene or engine the texture will be used in
  137910. * @param onLoad defines a callback triggered when the texture has been loaded
  137911. */
  137912. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  137913. /**
  137914. * Fires the onload event from the constructor if requested.
  137915. */
  137916. private _triggerOnLoad;
  137917. /**
  137918. * Returns the texture matrix used in most of the material.
  137919. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  137920. */
  137921. getTextureMatrix(): Matrix;
  137922. /**
  137923. * Occurs when the file being loaded is a .3dl LUT file.
  137924. */
  137925. private load3dlTexture;
  137926. /**
  137927. * Starts the loading process of the texture.
  137928. */
  137929. private loadTexture;
  137930. /**
  137931. * Clones the color gradind texture.
  137932. */
  137933. clone(): ColorGradingTexture;
  137934. /**
  137935. * Called during delayed load for textures.
  137936. */
  137937. delayLoad(): void;
  137938. /**
  137939. * Parses a color grading texture serialized by Babylon.
  137940. * @param parsedTexture The texture information being parsedTexture
  137941. * @param scene The scene to load the texture in
  137942. * @param rootUrl The root url of the data assets to load
  137943. * @return A color gradind texture
  137944. */
  137945. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  137946. /**
  137947. * Serializes the LUT texture to json format.
  137948. */
  137949. serialize(): any;
  137950. }
  137951. }
  137952. declare module BABYLON {
  137953. /**
  137954. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  137955. */
  137956. export class EquiRectangularCubeTexture extends BaseTexture {
  137957. /** The six faces of the cube. */
  137958. private static _FacesMapping;
  137959. private _noMipmap;
  137960. private _onLoad;
  137961. private _onError;
  137962. /** The size of the cubemap. */
  137963. private _size;
  137964. /** The buffer of the image. */
  137965. private _buffer;
  137966. /** The width of the input image. */
  137967. private _width;
  137968. /** The height of the input image. */
  137969. private _height;
  137970. /** The URL to the image. */
  137971. url: string;
  137972. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  137973. coordinatesMode: number;
  137974. /**
  137975. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  137976. * @param url The location of the image
  137977. * @param scene The scene the texture will be used in
  137978. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  137979. * @param noMipmap Forces to not generate the mipmap if true
  137980. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  137981. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  137982. * @param onLoad — defines a callback called when texture is loaded
  137983. * @param onError — defines a callback called if there is an error
  137984. */
  137985. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  137986. /**
  137987. * Load the image data, by putting the image on a canvas and extracting its buffer.
  137988. */
  137989. private loadImage;
  137990. /**
  137991. * Convert the image buffer into a cubemap and create a CubeTexture.
  137992. */
  137993. private loadTexture;
  137994. /**
  137995. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  137996. * @param buffer The ArrayBuffer that should be converted.
  137997. * @returns The buffer as Float32Array.
  137998. */
  137999. private getFloat32ArrayFromArrayBuffer;
  138000. /**
  138001. * Get the current class name of the texture useful for serialization or dynamic coding.
  138002. * @returns "EquiRectangularCubeTexture"
  138003. */
  138004. getClassName(): string;
  138005. /**
  138006. * Create a clone of the current EquiRectangularCubeTexture and return it.
  138007. * @returns A clone of the current EquiRectangularCubeTexture.
  138008. */
  138009. clone(): EquiRectangularCubeTexture;
  138010. }
  138011. }
  138012. declare module BABYLON {
  138013. /**
  138014. * Defines the options related to the creation of an HtmlElementTexture
  138015. */
  138016. export interface IHtmlElementTextureOptions {
  138017. /**
  138018. * Defines wether mip maps should be created or not.
  138019. */
  138020. generateMipMaps?: boolean;
  138021. /**
  138022. * Defines the sampling mode of the texture.
  138023. */
  138024. samplingMode?: number;
  138025. /**
  138026. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  138027. */
  138028. engine: Nullable<ThinEngine>;
  138029. /**
  138030. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  138031. */
  138032. scene: Nullable<Scene>;
  138033. }
  138034. /**
  138035. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  138036. * To be as efficient as possible depending on your constraints nothing aside the first upload
  138037. * is automatically managed.
  138038. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  138039. * in your application.
  138040. *
  138041. * As the update is not automatic, you need to call them manually.
  138042. */
  138043. export class HtmlElementTexture extends BaseTexture {
  138044. /**
  138045. * The texture URL.
  138046. */
  138047. element: HTMLVideoElement | HTMLCanvasElement;
  138048. private static readonly DefaultOptions;
  138049. private _textureMatrix;
  138050. private _isVideo;
  138051. private _generateMipMaps;
  138052. private _samplingMode;
  138053. /**
  138054. * Instantiates a HtmlElementTexture from the following parameters.
  138055. *
  138056. * @param name Defines the name of the texture
  138057. * @param element Defines the video or canvas the texture is filled with
  138058. * @param options Defines the other none mandatory texture creation options
  138059. */
  138060. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  138061. private _createInternalTexture;
  138062. /**
  138063. * Returns the texture matrix used in most of the material.
  138064. */
  138065. getTextureMatrix(): Matrix;
  138066. /**
  138067. * Updates the content of the texture.
  138068. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  138069. */
  138070. update(invertY?: Nullable<boolean>): void;
  138071. }
  138072. }
  138073. declare module BABYLON {
  138074. /**
  138075. * Based on jsTGALoader - Javascript loader for TGA file
  138076. * By Vincent Thibault
  138077. * @see http://blog.robrowser.com/javascript-tga-loader.html
  138078. */
  138079. export class TGATools {
  138080. private static _TYPE_INDEXED;
  138081. private static _TYPE_RGB;
  138082. private static _TYPE_GREY;
  138083. private static _TYPE_RLE_INDEXED;
  138084. private static _TYPE_RLE_RGB;
  138085. private static _TYPE_RLE_GREY;
  138086. private static _ORIGIN_MASK;
  138087. private static _ORIGIN_SHIFT;
  138088. private static _ORIGIN_BL;
  138089. private static _ORIGIN_BR;
  138090. private static _ORIGIN_UL;
  138091. private static _ORIGIN_UR;
  138092. /**
  138093. * Gets the header of a TGA file
  138094. * @param data defines the TGA data
  138095. * @returns the header
  138096. */
  138097. static GetTGAHeader(data: Uint8Array): any;
  138098. /**
  138099. * Uploads TGA content to a Babylon Texture
  138100. * @hidden
  138101. */
  138102. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  138103. /** @hidden */
  138104. 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;
  138105. /** @hidden */
  138106. 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;
  138107. /** @hidden */
  138108. 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;
  138109. /** @hidden */
  138110. 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;
  138111. /** @hidden */
  138112. 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;
  138113. /** @hidden */
  138114. 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;
  138115. }
  138116. }
  138117. declare module BABYLON {
  138118. /**
  138119. * Implementation of the TGA Texture Loader.
  138120. * @hidden
  138121. */
  138122. export class _TGATextureLoader implements IInternalTextureLoader {
  138123. /**
  138124. * Defines wether the loader supports cascade loading the different faces.
  138125. */
  138126. readonly supportCascades: boolean;
  138127. /**
  138128. * This returns if the loader support the current file information.
  138129. * @param extension defines the file extension of the file being loaded
  138130. * @returns true if the loader can load the specified file
  138131. */
  138132. canLoad(extension: string): boolean;
  138133. /**
  138134. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138135. * @param data contains the texture data
  138136. * @param texture defines the BabylonJS internal texture
  138137. * @param createPolynomials will be true if polynomials have been requested
  138138. * @param onLoad defines the callback to trigger once the texture is ready
  138139. * @param onError defines the callback to trigger in case of error
  138140. */
  138141. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138142. /**
  138143. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138144. * @param data contains the texture data
  138145. * @param texture defines the BabylonJS internal texture
  138146. * @param callback defines the method to call once ready to upload
  138147. */
  138148. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138149. }
  138150. }
  138151. declare module BABYLON {
  138152. /**
  138153. * Info about the .basis files
  138154. */
  138155. class BasisFileInfo {
  138156. /**
  138157. * If the file has alpha
  138158. */
  138159. hasAlpha: boolean;
  138160. /**
  138161. * Info about each image of the basis file
  138162. */
  138163. images: Array<{
  138164. levels: Array<{
  138165. width: number;
  138166. height: number;
  138167. transcodedPixels: ArrayBufferView;
  138168. }>;
  138169. }>;
  138170. }
  138171. /**
  138172. * Result of transcoding a basis file
  138173. */
  138174. class TranscodeResult {
  138175. /**
  138176. * Info about the .basis file
  138177. */
  138178. fileInfo: BasisFileInfo;
  138179. /**
  138180. * Format to use when loading the file
  138181. */
  138182. format: number;
  138183. }
  138184. /**
  138185. * Configuration options for the Basis transcoder
  138186. */
  138187. export class BasisTranscodeConfiguration {
  138188. /**
  138189. * Supported compression formats used to determine the supported output format of the transcoder
  138190. */
  138191. supportedCompressionFormats?: {
  138192. /**
  138193. * etc1 compression format
  138194. */
  138195. etc1?: boolean;
  138196. /**
  138197. * s3tc compression format
  138198. */
  138199. s3tc?: boolean;
  138200. /**
  138201. * pvrtc compression format
  138202. */
  138203. pvrtc?: boolean;
  138204. /**
  138205. * etc2 compression format
  138206. */
  138207. etc2?: boolean;
  138208. };
  138209. /**
  138210. * If mipmap levels should be loaded for transcoded images (Default: true)
  138211. */
  138212. loadMipmapLevels?: boolean;
  138213. /**
  138214. * Index of a single image to load (Default: all images)
  138215. */
  138216. loadSingleImage?: number;
  138217. }
  138218. /**
  138219. * Used to load .Basis files
  138220. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  138221. */
  138222. export class BasisTools {
  138223. private static _IgnoreSupportedFormats;
  138224. /**
  138225. * URL to use when loading the basis transcoder
  138226. */
  138227. static JSModuleURL: string;
  138228. /**
  138229. * URL to use when loading the wasm module for the transcoder
  138230. */
  138231. static WasmModuleURL: string;
  138232. /**
  138233. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  138234. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  138235. * @returns internal format corresponding to the Basis format
  138236. */
  138237. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  138238. private static _WorkerPromise;
  138239. private static _Worker;
  138240. private static _actionId;
  138241. private static _CreateWorkerAsync;
  138242. /**
  138243. * Transcodes a loaded image file to compressed pixel data
  138244. * @param data image data to transcode
  138245. * @param config configuration options for the transcoding
  138246. * @returns a promise resulting in the transcoded image
  138247. */
  138248. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  138249. /**
  138250. * Loads a texture from the transcode result
  138251. * @param texture texture load to
  138252. * @param transcodeResult the result of transcoding the basis file to load from
  138253. */
  138254. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  138255. }
  138256. }
  138257. declare module BABYLON {
  138258. /**
  138259. * Loader for .basis file format
  138260. */
  138261. export class _BasisTextureLoader implements IInternalTextureLoader {
  138262. /**
  138263. * Defines whether the loader supports cascade loading the different faces.
  138264. */
  138265. readonly supportCascades: boolean;
  138266. /**
  138267. * This returns if the loader support the current file information.
  138268. * @param extension defines the file extension of the file being loaded
  138269. * @returns true if the loader can load the specified file
  138270. */
  138271. canLoad(extension: string): boolean;
  138272. /**
  138273. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138274. * @param data contains the texture data
  138275. * @param texture defines the BabylonJS internal texture
  138276. * @param createPolynomials will be true if polynomials have been requested
  138277. * @param onLoad defines the callback to trigger once the texture is ready
  138278. * @param onError defines the callback to trigger in case of error
  138279. */
  138280. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138281. /**
  138282. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138283. * @param data contains the texture data
  138284. * @param texture defines the BabylonJS internal texture
  138285. * @param callback defines the method to call once ready to upload
  138286. */
  138287. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138288. }
  138289. }
  138290. declare module BABYLON {
  138291. /**
  138292. * Defines the basic options interface of a TexturePacker Frame
  138293. */
  138294. export interface ITexturePackerFrame {
  138295. /**
  138296. * The frame ID
  138297. */
  138298. id: number;
  138299. /**
  138300. * The frames Scale
  138301. */
  138302. scale: Vector2;
  138303. /**
  138304. * The Frames offset
  138305. */
  138306. offset: Vector2;
  138307. }
  138308. /**
  138309. * This is a support class for frame Data on texture packer sets.
  138310. */
  138311. export class TexturePackerFrame implements ITexturePackerFrame {
  138312. /**
  138313. * The frame ID
  138314. */
  138315. id: number;
  138316. /**
  138317. * The frames Scale
  138318. */
  138319. scale: Vector2;
  138320. /**
  138321. * The Frames offset
  138322. */
  138323. offset: Vector2;
  138324. /**
  138325. * Initializes a texture package frame.
  138326. * @param id The numerical frame identifier
  138327. * @param scale Scalar Vector2 for UV frame
  138328. * @param offset Vector2 for the frame position in UV units.
  138329. * @returns TexturePackerFrame
  138330. */
  138331. constructor(id: number, scale: Vector2, offset: Vector2);
  138332. }
  138333. }
  138334. declare module BABYLON {
  138335. /**
  138336. * Defines the basic options interface of a TexturePacker
  138337. */
  138338. export interface ITexturePackerOptions {
  138339. /**
  138340. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  138341. */
  138342. map?: string[];
  138343. /**
  138344. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  138345. */
  138346. uvsIn?: string;
  138347. /**
  138348. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  138349. */
  138350. uvsOut?: string;
  138351. /**
  138352. * number representing the layout style. Defaults to LAYOUT_STRIP
  138353. */
  138354. layout?: number;
  138355. /**
  138356. * number of columns if using custom column count layout(2). This defaults to 4.
  138357. */
  138358. colnum?: number;
  138359. /**
  138360. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  138361. */
  138362. updateInputMeshes?: boolean;
  138363. /**
  138364. * boolean flag to dispose all the source textures. Defaults to true.
  138365. */
  138366. disposeSources?: boolean;
  138367. /**
  138368. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  138369. */
  138370. fillBlanks?: boolean;
  138371. /**
  138372. * string value representing the context fill style color. Defaults to 'black'.
  138373. */
  138374. customFillColor?: string;
  138375. /**
  138376. * Width and Height Value of each Frame in the TexturePacker Sets
  138377. */
  138378. frameSize?: number;
  138379. /**
  138380. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  138381. */
  138382. paddingRatio?: number;
  138383. /**
  138384. * Number that declares the fill method for the padding gutter.
  138385. */
  138386. paddingMode?: number;
  138387. /**
  138388. * If in SUBUV_COLOR padding mode what color to use.
  138389. */
  138390. paddingColor?: Color3 | Color4;
  138391. }
  138392. /**
  138393. * Defines the basic interface of a TexturePacker JSON File
  138394. */
  138395. export interface ITexturePackerJSON {
  138396. /**
  138397. * The frame ID
  138398. */
  138399. name: string;
  138400. /**
  138401. * The base64 channel data
  138402. */
  138403. sets: any;
  138404. /**
  138405. * The options of the Packer
  138406. */
  138407. options: ITexturePackerOptions;
  138408. /**
  138409. * The frame data of the Packer
  138410. */
  138411. frames: Array<number>;
  138412. }
  138413. /**
  138414. * This is a support class that generates a series of packed texture sets.
  138415. * @see https://doc.babylonjs.com/babylon101/materials
  138416. */
  138417. export class TexturePacker {
  138418. /** Packer Layout Constant 0 */
  138419. static readonly LAYOUT_STRIP: number;
  138420. /** Packer Layout Constant 1 */
  138421. static readonly LAYOUT_POWER2: number;
  138422. /** Packer Layout Constant 2 */
  138423. static readonly LAYOUT_COLNUM: number;
  138424. /** Packer Layout Constant 0 */
  138425. static readonly SUBUV_WRAP: number;
  138426. /** Packer Layout Constant 1 */
  138427. static readonly SUBUV_EXTEND: number;
  138428. /** Packer Layout Constant 2 */
  138429. static readonly SUBUV_COLOR: number;
  138430. /** The Name of the Texture Package */
  138431. name: string;
  138432. /** The scene scope of the TexturePacker */
  138433. scene: Scene;
  138434. /** The Meshes to target */
  138435. meshes: AbstractMesh[];
  138436. /** Arguments passed with the Constructor */
  138437. options: ITexturePackerOptions;
  138438. /** The promise that is started upon initialization */
  138439. promise: Nullable<Promise<TexturePacker | string>>;
  138440. /** The Container object for the channel sets that are generated */
  138441. sets: object;
  138442. /** The Container array for the frames that are generated */
  138443. frames: TexturePackerFrame[];
  138444. /** The expected number of textures the system is parsing. */
  138445. private _expecting;
  138446. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  138447. private _paddingValue;
  138448. /**
  138449. * Initializes a texture package series from an array of meshes or a single mesh.
  138450. * @param name The name of the package
  138451. * @param meshes The target meshes to compose the package from
  138452. * @param options The arguments that texture packer should follow while building.
  138453. * @param scene The scene which the textures are scoped to.
  138454. * @returns TexturePacker
  138455. */
  138456. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  138457. /**
  138458. * Starts the package process
  138459. * @param resolve The promises resolution function
  138460. * @returns TexturePacker
  138461. */
  138462. private _createFrames;
  138463. /**
  138464. * Calculates the Size of the Channel Sets
  138465. * @returns Vector2
  138466. */
  138467. private _calculateSize;
  138468. /**
  138469. * Calculates the UV data for the frames.
  138470. * @param baseSize the base frameSize
  138471. * @param padding the base frame padding
  138472. * @param dtSize size of the Dynamic Texture for that channel
  138473. * @param dtUnits is 1/dtSize
  138474. * @param update flag to update the input meshes
  138475. */
  138476. private _calculateMeshUVFrames;
  138477. /**
  138478. * Calculates the frames Offset.
  138479. * @param index of the frame
  138480. * @returns Vector2
  138481. */
  138482. private _getFrameOffset;
  138483. /**
  138484. * Updates a Mesh to the frame data
  138485. * @param mesh that is the target
  138486. * @param frameID or the frame index
  138487. */
  138488. private _updateMeshUV;
  138489. /**
  138490. * Updates a Meshes materials to use the texture packer channels
  138491. * @param m is the mesh to target
  138492. * @param force all channels on the packer to be set.
  138493. */
  138494. private _updateTextureReferences;
  138495. /**
  138496. * Public method to set a Mesh to a frame
  138497. * @param m that is the target
  138498. * @param frameID or the frame index
  138499. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  138500. */
  138501. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  138502. /**
  138503. * Starts the async promise to compile the texture packer.
  138504. * @returns Promise<void>
  138505. */
  138506. processAsync(): Promise<void>;
  138507. /**
  138508. * Disposes all textures associated with this packer
  138509. */
  138510. dispose(): void;
  138511. /**
  138512. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  138513. * @param imageType is the image type to use.
  138514. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  138515. */
  138516. download(imageType?: string, quality?: number): void;
  138517. /**
  138518. * Public method to load a texturePacker JSON file.
  138519. * @param data of the JSON file in string format.
  138520. */
  138521. updateFromJSON(data: string): void;
  138522. }
  138523. }
  138524. declare module BABYLON {
  138525. /**
  138526. * 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.
  138527. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  138528. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  138529. */
  138530. export class CustomProceduralTexture extends ProceduralTexture {
  138531. private _animate;
  138532. private _time;
  138533. private _config;
  138534. private _texturePath;
  138535. /**
  138536. * Instantiates a new Custom Procedural Texture.
  138537. * 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.
  138538. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  138539. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  138540. * @param name Define the name of the texture
  138541. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  138542. * @param size Define the size of the texture to create
  138543. * @param scene Define the scene the texture belongs to
  138544. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  138545. * @param generateMipMaps Define if the texture should creates mip maps or not
  138546. */
  138547. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  138548. private _loadJson;
  138549. /**
  138550. * Is the texture ready to be used ? (rendered at least once)
  138551. * @returns true if ready, otherwise, false.
  138552. */
  138553. isReady(): boolean;
  138554. /**
  138555. * Render the texture to its associated render target.
  138556. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  138557. */
  138558. render(useCameraPostProcess?: boolean): void;
  138559. /**
  138560. * Update the list of dependant textures samplers in the shader.
  138561. */
  138562. updateTextures(): void;
  138563. /**
  138564. * Update the uniform values of the procedural texture in the shader.
  138565. */
  138566. updateShaderUniforms(): void;
  138567. /**
  138568. * Define if the texture animates or not.
  138569. */
  138570. get animate(): boolean;
  138571. set animate(value: boolean);
  138572. }
  138573. }
  138574. declare module BABYLON {
  138575. /** @hidden */
  138576. export var noisePixelShader: {
  138577. name: string;
  138578. shader: string;
  138579. };
  138580. }
  138581. declare module BABYLON {
  138582. /**
  138583. * Class used to generate noise procedural textures
  138584. */
  138585. export class NoiseProceduralTexture extends ProceduralTexture {
  138586. private _time;
  138587. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  138588. brightness: number;
  138589. /** Defines the number of octaves to process */
  138590. octaves: number;
  138591. /** Defines the level of persistence (0.8 by default) */
  138592. persistence: number;
  138593. /** Gets or sets animation speed factor (default is 1) */
  138594. animationSpeedFactor: number;
  138595. /**
  138596. * Creates a new NoiseProceduralTexture
  138597. * @param name defines the name fo the texture
  138598. * @param size defines the size of the texture (default is 256)
  138599. * @param scene defines the hosting scene
  138600. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  138601. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  138602. */
  138603. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  138604. private _updateShaderUniforms;
  138605. protected _getDefines(): string;
  138606. /** Generate the current state of the procedural texture */
  138607. render(useCameraPostProcess?: boolean): void;
  138608. /**
  138609. * Serializes this noise procedural texture
  138610. * @returns a serialized noise procedural texture object
  138611. */
  138612. serialize(): any;
  138613. /**
  138614. * Clone the texture.
  138615. * @returns the cloned texture
  138616. */
  138617. clone(): NoiseProceduralTexture;
  138618. /**
  138619. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  138620. * @param parsedTexture defines parsed texture data
  138621. * @param scene defines the current scene
  138622. * @param rootUrl defines the root URL containing noise procedural texture information
  138623. * @returns a parsed NoiseProceduralTexture
  138624. */
  138625. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  138626. }
  138627. }
  138628. declare module BABYLON {
  138629. /**
  138630. * Raw cube texture where the raw buffers are passed in
  138631. */
  138632. export class RawCubeTexture extends CubeTexture {
  138633. /**
  138634. * Creates a cube texture where the raw buffers are passed in.
  138635. * @param scene defines the scene the texture is attached to
  138636. * @param data defines the array of data to use to create each face
  138637. * @param size defines the size of the textures
  138638. * @param format defines the format of the data
  138639. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  138640. * @param generateMipMaps defines if the engine should generate the mip levels
  138641. * @param invertY defines if data must be stored with Y axis inverted
  138642. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  138643. * @param compression defines the compression used (null by default)
  138644. */
  138645. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  138646. /**
  138647. * Updates the raw cube texture.
  138648. * @param data defines the data to store
  138649. * @param format defines the data format
  138650. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  138651. * @param invertY defines if data must be stored with Y axis inverted
  138652. * @param compression defines the compression used (null by default)
  138653. * @param level defines which level of the texture to update
  138654. */
  138655. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  138656. /**
  138657. * Updates a raw cube texture with RGBD encoded data.
  138658. * @param data defines the array of data [mipmap][face] to use to create each face
  138659. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  138660. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  138661. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  138662. * @returns a promsie that resolves when the operation is complete
  138663. */
  138664. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  138665. /**
  138666. * Clones the raw cube texture.
  138667. * @return a new cube texture
  138668. */
  138669. clone(): CubeTexture;
  138670. /** @hidden */
  138671. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  138672. }
  138673. }
  138674. declare module BABYLON {
  138675. /**
  138676. * Class used to store 2D array textures containing user data
  138677. */
  138678. export class RawTexture2DArray extends Texture {
  138679. /** Gets or sets the texture format to use */
  138680. format: number;
  138681. /**
  138682. * Create a new RawTexture2DArray
  138683. * @param data defines the data of the texture
  138684. * @param width defines the width of the texture
  138685. * @param height defines the height of the texture
  138686. * @param depth defines the number of layers of the texture
  138687. * @param format defines the texture format to use
  138688. * @param scene defines the hosting scene
  138689. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  138690. * @param invertY defines if texture must be stored with Y axis inverted
  138691. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  138692. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  138693. */
  138694. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  138695. /** Gets or sets the texture format to use */
  138696. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  138697. /**
  138698. * Update the texture with new data
  138699. * @param data defines the data to store in the texture
  138700. */
  138701. update(data: ArrayBufferView): void;
  138702. }
  138703. }
  138704. declare module BABYLON {
  138705. /**
  138706. * Class used to store 3D textures containing user data
  138707. */
  138708. export class RawTexture3D extends Texture {
  138709. /** Gets or sets the texture format to use */
  138710. format: number;
  138711. /**
  138712. * Create a new RawTexture3D
  138713. * @param data defines the data of the texture
  138714. * @param width defines the width of the texture
  138715. * @param height defines the height of the texture
  138716. * @param depth defines the depth of the texture
  138717. * @param format defines the texture format to use
  138718. * @param scene defines the hosting scene
  138719. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  138720. * @param invertY defines if texture must be stored with Y axis inverted
  138721. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  138722. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  138723. */
  138724. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  138725. /** Gets or sets the texture format to use */
  138726. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  138727. /**
  138728. * Update the texture with new data
  138729. * @param data defines the data to store in the texture
  138730. */
  138731. update(data: ArrayBufferView): void;
  138732. }
  138733. }
  138734. declare module BABYLON {
  138735. /**
  138736. * Creates a refraction texture used by refraction channel of the standard material.
  138737. * It is like a mirror but to see through a material.
  138738. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  138739. */
  138740. export class RefractionTexture extends RenderTargetTexture {
  138741. /**
  138742. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  138743. * 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.
  138744. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  138745. */
  138746. refractionPlane: Plane;
  138747. /**
  138748. * Define how deep under the surface we should see.
  138749. */
  138750. depth: number;
  138751. /**
  138752. * Creates a refraction texture used by refraction channel of the standard material.
  138753. * It is like a mirror but to see through a material.
  138754. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  138755. * @param name Define the texture name
  138756. * @param size Define the size of the underlying texture
  138757. * @param scene Define the scene the refraction belongs to
  138758. * @param generateMipMaps Define if we need to generate mips level for the refraction
  138759. */
  138760. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  138761. /**
  138762. * Clone the refraction texture.
  138763. * @returns the cloned texture
  138764. */
  138765. clone(): RefractionTexture;
  138766. /**
  138767. * Serialize the texture to a JSON representation you could use in Parse later on
  138768. * @returns the serialized JSON representation
  138769. */
  138770. serialize(): any;
  138771. }
  138772. }
  138773. declare module BABYLON {
  138774. /**
  138775. * Block used to add support for vertex skinning (bones)
  138776. */
  138777. export class BonesBlock extends NodeMaterialBlock {
  138778. /**
  138779. * Creates a new BonesBlock
  138780. * @param name defines the block name
  138781. */
  138782. constructor(name: string);
  138783. /**
  138784. * Initialize the block and prepare the context for build
  138785. * @param state defines the state that will be used for the build
  138786. */
  138787. initialize(state: NodeMaterialBuildState): void;
  138788. /**
  138789. * Gets the current class name
  138790. * @returns the class name
  138791. */
  138792. getClassName(): string;
  138793. /**
  138794. * Gets the matrix indices input component
  138795. */
  138796. get matricesIndices(): NodeMaterialConnectionPoint;
  138797. /**
  138798. * Gets the matrix weights input component
  138799. */
  138800. get matricesWeights(): NodeMaterialConnectionPoint;
  138801. /**
  138802. * Gets the extra matrix indices input component
  138803. */
  138804. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  138805. /**
  138806. * Gets the extra matrix weights input component
  138807. */
  138808. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  138809. /**
  138810. * Gets the world input component
  138811. */
  138812. get world(): NodeMaterialConnectionPoint;
  138813. /**
  138814. * Gets the output component
  138815. */
  138816. get output(): NodeMaterialConnectionPoint;
  138817. autoConfigure(material: NodeMaterial): void;
  138818. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  138819. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138820. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138821. protected _buildBlock(state: NodeMaterialBuildState): this;
  138822. }
  138823. }
  138824. declare module BABYLON {
  138825. /**
  138826. * Block used to add support for instances
  138827. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  138828. */
  138829. export class InstancesBlock extends NodeMaterialBlock {
  138830. /**
  138831. * Creates a new InstancesBlock
  138832. * @param name defines the block name
  138833. */
  138834. constructor(name: string);
  138835. /**
  138836. * Gets the current class name
  138837. * @returns the class name
  138838. */
  138839. getClassName(): string;
  138840. /**
  138841. * Gets the first world row input component
  138842. */
  138843. get world0(): NodeMaterialConnectionPoint;
  138844. /**
  138845. * Gets the second world row input component
  138846. */
  138847. get world1(): NodeMaterialConnectionPoint;
  138848. /**
  138849. * Gets the third world row input component
  138850. */
  138851. get world2(): NodeMaterialConnectionPoint;
  138852. /**
  138853. * Gets the forth world row input component
  138854. */
  138855. get world3(): NodeMaterialConnectionPoint;
  138856. /**
  138857. * Gets the world input component
  138858. */
  138859. get world(): NodeMaterialConnectionPoint;
  138860. /**
  138861. * Gets the output component
  138862. */
  138863. get output(): NodeMaterialConnectionPoint;
  138864. /**
  138865. * Gets the isntanceID component
  138866. */
  138867. get instanceID(): NodeMaterialConnectionPoint;
  138868. autoConfigure(material: NodeMaterial): void;
  138869. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  138870. protected _buildBlock(state: NodeMaterialBuildState): this;
  138871. }
  138872. }
  138873. declare module BABYLON {
  138874. /**
  138875. * Block used to add morph targets support to vertex shader
  138876. */
  138877. export class MorphTargetsBlock extends NodeMaterialBlock {
  138878. private _repeatableContentAnchor;
  138879. /**
  138880. * Create a new MorphTargetsBlock
  138881. * @param name defines the block name
  138882. */
  138883. constructor(name: string);
  138884. /**
  138885. * Gets the current class name
  138886. * @returns the class name
  138887. */
  138888. getClassName(): string;
  138889. /**
  138890. * Gets the position input component
  138891. */
  138892. get position(): NodeMaterialConnectionPoint;
  138893. /**
  138894. * Gets the normal input component
  138895. */
  138896. get normal(): NodeMaterialConnectionPoint;
  138897. /**
  138898. * Gets the tangent input component
  138899. */
  138900. get tangent(): NodeMaterialConnectionPoint;
  138901. /**
  138902. * Gets the tangent input component
  138903. */
  138904. get uv(): NodeMaterialConnectionPoint;
  138905. /**
  138906. * Gets the position output component
  138907. */
  138908. get positionOutput(): NodeMaterialConnectionPoint;
  138909. /**
  138910. * Gets the normal output component
  138911. */
  138912. get normalOutput(): NodeMaterialConnectionPoint;
  138913. /**
  138914. * Gets the tangent output component
  138915. */
  138916. get tangentOutput(): NodeMaterialConnectionPoint;
  138917. /**
  138918. * Gets the tangent output component
  138919. */
  138920. get uvOutput(): NodeMaterialConnectionPoint;
  138921. initialize(state: NodeMaterialBuildState): void;
  138922. autoConfigure(material: NodeMaterial): void;
  138923. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138924. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138925. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  138926. protected _buildBlock(state: NodeMaterialBuildState): this;
  138927. }
  138928. }
  138929. declare module BABYLON {
  138930. /**
  138931. * Block used to get data information from a light
  138932. */
  138933. export class LightInformationBlock extends NodeMaterialBlock {
  138934. private _lightDataUniformName;
  138935. private _lightColorUniformName;
  138936. private _lightTypeDefineName;
  138937. /**
  138938. * Gets or sets the light associated with this block
  138939. */
  138940. light: Nullable<Light>;
  138941. /**
  138942. * Creates a new LightInformationBlock
  138943. * @param name defines the block name
  138944. */
  138945. constructor(name: string);
  138946. /**
  138947. * Gets the current class name
  138948. * @returns the class name
  138949. */
  138950. getClassName(): string;
  138951. /**
  138952. * Gets the world position input component
  138953. */
  138954. get worldPosition(): NodeMaterialConnectionPoint;
  138955. /**
  138956. * Gets the direction output component
  138957. */
  138958. get direction(): NodeMaterialConnectionPoint;
  138959. /**
  138960. * Gets the direction output component
  138961. */
  138962. get color(): NodeMaterialConnectionPoint;
  138963. /**
  138964. * Gets the direction output component
  138965. */
  138966. get intensity(): NodeMaterialConnectionPoint;
  138967. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138968. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138969. protected _buildBlock(state: NodeMaterialBuildState): this;
  138970. serialize(): any;
  138971. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138972. }
  138973. }
  138974. declare module BABYLON {
  138975. /**
  138976. * Block used to add image processing support to fragment shader
  138977. */
  138978. export class ImageProcessingBlock extends NodeMaterialBlock {
  138979. /**
  138980. * Create a new ImageProcessingBlock
  138981. * @param name defines the block name
  138982. */
  138983. constructor(name: string);
  138984. /**
  138985. * Gets the current class name
  138986. * @returns the class name
  138987. */
  138988. getClassName(): string;
  138989. /**
  138990. * Gets the color input component
  138991. */
  138992. get color(): NodeMaterialConnectionPoint;
  138993. /**
  138994. * Gets the output component
  138995. */
  138996. get output(): NodeMaterialConnectionPoint;
  138997. /**
  138998. * Initialize the block and prepare the context for build
  138999. * @param state defines the state that will be used for the build
  139000. */
  139001. initialize(state: NodeMaterialBuildState): void;
  139002. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  139003. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139004. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139005. protected _buildBlock(state: NodeMaterialBuildState): this;
  139006. }
  139007. }
  139008. declare module BABYLON {
  139009. /**
  139010. * Block used to pertub normals based on a normal map
  139011. */
  139012. export class PerturbNormalBlock extends NodeMaterialBlock {
  139013. private _tangentSpaceParameterName;
  139014. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  139015. invertX: boolean;
  139016. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  139017. invertY: boolean;
  139018. /**
  139019. * Create a new PerturbNormalBlock
  139020. * @param name defines the block name
  139021. */
  139022. constructor(name: string);
  139023. /**
  139024. * Gets the current class name
  139025. * @returns the class name
  139026. */
  139027. getClassName(): string;
  139028. /**
  139029. * Gets the world position input component
  139030. */
  139031. get worldPosition(): NodeMaterialConnectionPoint;
  139032. /**
  139033. * Gets the world normal input component
  139034. */
  139035. get worldNormal(): NodeMaterialConnectionPoint;
  139036. /**
  139037. * Gets the world tangent input component
  139038. */
  139039. get worldTangent(): NodeMaterialConnectionPoint;
  139040. /**
  139041. * Gets the uv input component
  139042. */
  139043. get uv(): NodeMaterialConnectionPoint;
  139044. /**
  139045. * Gets the normal map color input component
  139046. */
  139047. get normalMapColor(): NodeMaterialConnectionPoint;
  139048. /**
  139049. * Gets the strength input component
  139050. */
  139051. get strength(): NodeMaterialConnectionPoint;
  139052. /**
  139053. * Gets the output component
  139054. */
  139055. get output(): NodeMaterialConnectionPoint;
  139056. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139057. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139058. autoConfigure(material: NodeMaterial): void;
  139059. protected _buildBlock(state: NodeMaterialBuildState): this;
  139060. protected _dumpPropertiesCode(): string;
  139061. serialize(): any;
  139062. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139063. }
  139064. }
  139065. declare module BABYLON {
  139066. /**
  139067. * Block used to discard a pixel if a value is smaller than a cutoff
  139068. */
  139069. export class DiscardBlock extends NodeMaterialBlock {
  139070. /**
  139071. * Create a new DiscardBlock
  139072. * @param name defines the block name
  139073. */
  139074. constructor(name: string);
  139075. /**
  139076. * Gets the current class name
  139077. * @returns the class name
  139078. */
  139079. getClassName(): string;
  139080. /**
  139081. * Gets the color input component
  139082. */
  139083. get value(): NodeMaterialConnectionPoint;
  139084. /**
  139085. * Gets the cutoff input component
  139086. */
  139087. get cutoff(): NodeMaterialConnectionPoint;
  139088. protected _buildBlock(state: NodeMaterialBuildState): this;
  139089. }
  139090. }
  139091. declare module BABYLON {
  139092. /**
  139093. * Block used to test if the fragment shader is front facing
  139094. */
  139095. export class FrontFacingBlock extends NodeMaterialBlock {
  139096. /**
  139097. * Creates a new FrontFacingBlock
  139098. * @param name defines the block name
  139099. */
  139100. constructor(name: string);
  139101. /**
  139102. * Gets the current class name
  139103. * @returns the class name
  139104. */
  139105. getClassName(): string;
  139106. /**
  139107. * Gets the output component
  139108. */
  139109. get output(): NodeMaterialConnectionPoint;
  139110. protected _buildBlock(state: NodeMaterialBuildState): this;
  139111. }
  139112. }
  139113. declare module BABYLON {
  139114. /**
  139115. * Block used to get the derivative value on x and y of a given input
  139116. */
  139117. export class DerivativeBlock extends NodeMaterialBlock {
  139118. /**
  139119. * Create a new DerivativeBlock
  139120. * @param name defines the block name
  139121. */
  139122. constructor(name: string);
  139123. /**
  139124. * Gets the current class name
  139125. * @returns the class name
  139126. */
  139127. getClassName(): string;
  139128. /**
  139129. * Gets the input component
  139130. */
  139131. get input(): NodeMaterialConnectionPoint;
  139132. /**
  139133. * Gets the derivative output on x
  139134. */
  139135. get dx(): NodeMaterialConnectionPoint;
  139136. /**
  139137. * Gets the derivative output on y
  139138. */
  139139. get dy(): NodeMaterialConnectionPoint;
  139140. protected _buildBlock(state: NodeMaterialBuildState): this;
  139141. }
  139142. }
  139143. declare module BABYLON {
  139144. /**
  139145. * Block used to make gl_FragCoord available
  139146. */
  139147. export class FragCoordBlock extends NodeMaterialBlock {
  139148. /**
  139149. * Creates a new FragCoordBlock
  139150. * @param name defines the block name
  139151. */
  139152. constructor(name: string);
  139153. /**
  139154. * Gets the current class name
  139155. * @returns the class name
  139156. */
  139157. getClassName(): string;
  139158. /**
  139159. * Gets the xy component
  139160. */
  139161. get xy(): NodeMaterialConnectionPoint;
  139162. /**
  139163. * Gets the xyz component
  139164. */
  139165. get xyz(): NodeMaterialConnectionPoint;
  139166. /**
  139167. * Gets the xyzw component
  139168. */
  139169. get xyzw(): NodeMaterialConnectionPoint;
  139170. /**
  139171. * Gets the x component
  139172. */
  139173. get x(): NodeMaterialConnectionPoint;
  139174. /**
  139175. * Gets the y component
  139176. */
  139177. get y(): NodeMaterialConnectionPoint;
  139178. /**
  139179. * Gets the z component
  139180. */
  139181. get z(): NodeMaterialConnectionPoint;
  139182. /**
  139183. * Gets the w component
  139184. */
  139185. get output(): NodeMaterialConnectionPoint;
  139186. protected writeOutputs(state: NodeMaterialBuildState): string;
  139187. protected _buildBlock(state: NodeMaterialBuildState): this;
  139188. }
  139189. }
  139190. declare module BABYLON {
  139191. /**
  139192. * Block used to get the screen sizes
  139193. */
  139194. export class ScreenSizeBlock extends NodeMaterialBlock {
  139195. private _varName;
  139196. private _scene;
  139197. /**
  139198. * Creates a new ScreenSizeBlock
  139199. * @param name defines the block name
  139200. */
  139201. constructor(name: string);
  139202. /**
  139203. * Gets the current class name
  139204. * @returns the class name
  139205. */
  139206. getClassName(): string;
  139207. /**
  139208. * Gets the xy component
  139209. */
  139210. get xy(): NodeMaterialConnectionPoint;
  139211. /**
  139212. * Gets the x component
  139213. */
  139214. get x(): NodeMaterialConnectionPoint;
  139215. /**
  139216. * Gets the y component
  139217. */
  139218. get y(): NodeMaterialConnectionPoint;
  139219. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139220. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  139221. protected _buildBlock(state: NodeMaterialBuildState): this;
  139222. }
  139223. }
  139224. declare module BABYLON {
  139225. /**
  139226. * Block used to add support for scene fog
  139227. */
  139228. export class FogBlock extends NodeMaterialBlock {
  139229. private _fogDistanceName;
  139230. private _fogParameters;
  139231. /**
  139232. * Create a new FogBlock
  139233. * @param name defines the block name
  139234. */
  139235. constructor(name: string);
  139236. /**
  139237. * Gets the current class name
  139238. * @returns the class name
  139239. */
  139240. getClassName(): string;
  139241. /**
  139242. * Gets the world position input component
  139243. */
  139244. get worldPosition(): NodeMaterialConnectionPoint;
  139245. /**
  139246. * Gets the view input component
  139247. */
  139248. get view(): NodeMaterialConnectionPoint;
  139249. /**
  139250. * Gets the color input component
  139251. */
  139252. get input(): NodeMaterialConnectionPoint;
  139253. /**
  139254. * Gets the fog color input component
  139255. */
  139256. get fogColor(): NodeMaterialConnectionPoint;
  139257. /**
  139258. * Gets the output component
  139259. */
  139260. get output(): NodeMaterialConnectionPoint;
  139261. autoConfigure(material: NodeMaterial): void;
  139262. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139263. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139264. protected _buildBlock(state: NodeMaterialBuildState): this;
  139265. }
  139266. }
  139267. declare module BABYLON {
  139268. /**
  139269. * Block used to add light in the fragment shader
  139270. */
  139271. export class LightBlock extends NodeMaterialBlock {
  139272. private _lightId;
  139273. /**
  139274. * Gets or sets the light associated with this block
  139275. */
  139276. light: Nullable<Light>;
  139277. /**
  139278. * Create a new LightBlock
  139279. * @param name defines the block name
  139280. */
  139281. constructor(name: string);
  139282. /**
  139283. * Gets the current class name
  139284. * @returns the class name
  139285. */
  139286. getClassName(): string;
  139287. /**
  139288. * Gets the world position input component
  139289. */
  139290. get worldPosition(): NodeMaterialConnectionPoint;
  139291. /**
  139292. * Gets the world normal input component
  139293. */
  139294. get worldNormal(): NodeMaterialConnectionPoint;
  139295. /**
  139296. * Gets the camera (or eye) position component
  139297. */
  139298. get cameraPosition(): NodeMaterialConnectionPoint;
  139299. /**
  139300. * Gets the glossiness component
  139301. */
  139302. get glossiness(): NodeMaterialConnectionPoint;
  139303. /**
  139304. * Gets the glossinness power component
  139305. */
  139306. get glossPower(): NodeMaterialConnectionPoint;
  139307. /**
  139308. * Gets the diffuse color component
  139309. */
  139310. get diffuseColor(): NodeMaterialConnectionPoint;
  139311. /**
  139312. * Gets the specular color component
  139313. */
  139314. get specularColor(): NodeMaterialConnectionPoint;
  139315. /**
  139316. * Gets the diffuse output component
  139317. */
  139318. get diffuseOutput(): NodeMaterialConnectionPoint;
  139319. /**
  139320. * Gets the specular output component
  139321. */
  139322. get specularOutput(): NodeMaterialConnectionPoint;
  139323. /**
  139324. * Gets the shadow output component
  139325. */
  139326. get shadow(): NodeMaterialConnectionPoint;
  139327. autoConfigure(material: NodeMaterial): void;
  139328. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139329. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  139330. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139331. private _injectVertexCode;
  139332. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  139333. serialize(): any;
  139334. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139335. }
  139336. }
  139337. declare module BABYLON {
  139338. /**
  139339. * Block used to read a reflection texture from a sampler
  139340. */
  139341. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  139342. /**
  139343. * Create a new ReflectionTextureBlock
  139344. * @param name defines the block name
  139345. */
  139346. constructor(name: string);
  139347. /**
  139348. * Gets the current class name
  139349. * @returns the class name
  139350. */
  139351. getClassName(): string;
  139352. /**
  139353. * Gets the world position input component
  139354. */
  139355. get position(): NodeMaterialConnectionPoint;
  139356. /**
  139357. * Gets the world position input component
  139358. */
  139359. get worldPosition(): NodeMaterialConnectionPoint;
  139360. /**
  139361. * Gets the world normal input component
  139362. */
  139363. get worldNormal(): NodeMaterialConnectionPoint;
  139364. /**
  139365. * Gets the world input component
  139366. */
  139367. get world(): NodeMaterialConnectionPoint;
  139368. /**
  139369. * Gets the camera (or eye) position component
  139370. */
  139371. get cameraPosition(): NodeMaterialConnectionPoint;
  139372. /**
  139373. * Gets the view input component
  139374. */
  139375. get view(): NodeMaterialConnectionPoint;
  139376. /**
  139377. * Gets the rgb output component
  139378. */
  139379. get rgb(): NodeMaterialConnectionPoint;
  139380. /**
  139381. * Gets the r output component
  139382. */
  139383. get r(): NodeMaterialConnectionPoint;
  139384. /**
  139385. * Gets the g output component
  139386. */
  139387. get g(): NodeMaterialConnectionPoint;
  139388. /**
  139389. * Gets the b output component
  139390. */
  139391. get b(): NodeMaterialConnectionPoint;
  139392. autoConfigure(material: NodeMaterial): void;
  139393. protected _buildBlock(state: NodeMaterialBuildState): this;
  139394. }
  139395. }
  139396. declare module BABYLON {
  139397. /**
  139398. * Block used to add 2 vectors
  139399. */
  139400. export class AddBlock extends NodeMaterialBlock {
  139401. /**
  139402. * Creates a new AddBlock
  139403. * @param name defines the block name
  139404. */
  139405. constructor(name: string);
  139406. /**
  139407. * Gets the current class name
  139408. * @returns the class name
  139409. */
  139410. getClassName(): string;
  139411. /**
  139412. * Gets the left operand input component
  139413. */
  139414. get left(): NodeMaterialConnectionPoint;
  139415. /**
  139416. * Gets the right operand input component
  139417. */
  139418. get right(): NodeMaterialConnectionPoint;
  139419. /**
  139420. * Gets the output component
  139421. */
  139422. get output(): NodeMaterialConnectionPoint;
  139423. protected _buildBlock(state: NodeMaterialBuildState): this;
  139424. }
  139425. }
  139426. declare module BABYLON {
  139427. /**
  139428. * Block used to scale a vector by a float
  139429. */
  139430. export class ScaleBlock extends NodeMaterialBlock {
  139431. /**
  139432. * Creates a new ScaleBlock
  139433. * @param name defines the block name
  139434. */
  139435. constructor(name: string);
  139436. /**
  139437. * Gets the current class name
  139438. * @returns the class name
  139439. */
  139440. getClassName(): string;
  139441. /**
  139442. * Gets the input component
  139443. */
  139444. get input(): NodeMaterialConnectionPoint;
  139445. /**
  139446. * Gets the factor input component
  139447. */
  139448. get factor(): NodeMaterialConnectionPoint;
  139449. /**
  139450. * Gets the output component
  139451. */
  139452. get output(): NodeMaterialConnectionPoint;
  139453. protected _buildBlock(state: NodeMaterialBuildState): this;
  139454. }
  139455. }
  139456. declare module BABYLON {
  139457. /**
  139458. * Block used to clamp a float
  139459. */
  139460. export class ClampBlock extends NodeMaterialBlock {
  139461. /** Gets or sets the minimum range */
  139462. minimum: number;
  139463. /** Gets or sets the maximum range */
  139464. maximum: number;
  139465. /**
  139466. * Creates a new ClampBlock
  139467. * @param name defines the block name
  139468. */
  139469. constructor(name: string);
  139470. /**
  139471. * Gets the current class name
  139472. * @returns the class name
  139473. */
  139474. getClassName(): string;
  139475. /**
  139476. * Gets the value input component
  139477. */
  139478. get value(): NodeMaterialConnectionPoint;
  139479. /**
  139480. * Gets the output component
  139481. */
  139482. get output(): NodeMaterialConnectionPoint;
  139483. protected _buildBlock(state: NodeMaterialBuildState): this;
  139484. protected _dumpPropertiesCode(): string;
  139485. serialize(): any;
  139486. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139487. }
  139488. }
  139489. declare module BABYLON {
  139490. /**
  139491. * Block used to apply a cross product between 2 vectors
  139492. */
  139493. export class CrossBlock extends NodeMaterialBlock {
  139494. /**
  139495. * Creates a new CrossBlock
  139496. * @param name defines the block name
  139497. */
  139498. constructor(name: string);
  139499. /**
  139500. * Gets the current class name
  139501. * @returns the class name
  139502. */
  139503. getClassName(): string;
  139504. /**
  139505. * Gets the left operand input component
  139506. */
  139507. get left(): NodeMaterialConnectionPoint;
  139508. /**
  139509. * Gets the right operand input component
  139510. */
  139511. get right(): NodeMaterialConnectionPoint;
  139512. /**
  139513. * Gets the output component
  139514. */
  139515. get output(): NodeMaterialConnectionPoint;
  139516. protected _buildBlock(state: NodeMaterialBuildState): this;
  139517. }
  139518. }
  139519. declare module BABYLON {
  139520. /**
  139521. * Block used to apply a dot product between 2 vectors
  139522. */
  139523. export class DotBlock extends NodeMaterialBlock {
  139524. /**
  139525. * Creates a new DotBlock
  139526. * @param name defines the block name
  139527. */
  139528. constructor(name: string);
  139529. /**
  139530. * Gets the current class name
  139531. * @returns the class name
  139532. */
  139533. getClassName(): string;
  139534. /**
  139535. * Gets the left operand input component
  139536. */
  139537. get left(): NodeMaterialConnectionPoint;
  139538. /**
  139539. * Gets the right operand input component
  139540. */
  139541. get right(): NodeMaterialConnectionPoint;
  139542. /**
  139543. * Gets the output component
  139544. */
  139545. get output(): NodeMaterialConnectionPoint;
  139546. protected _buildBlock(state: NodeMaterialBuildState): this;
  139547. }
  139548. }
  139549. declare module BABYLON {
  139550. /**
  139551. * Block used to normalize a vector
  139552. */
  139553. export class NormalizeBlock extends NodeMaterialBlock {
  139554. /**
  139555. * Creates a new NormalizeBlock
  139556. * @param name defines the block name
  139557. */
  139558. constructor(name: string);
  139559. /**
  139560. * Gets the current class name
  139561. * @returns the class name
  139562. */
  139563. getClassName(): string;
  139564. /**
  139565. * Gets the input component
  139566. */
  139567. get input(): NodeMaterialConnectionPoint;
  139568. /**
  139569. * Gets the output component
  139570. */
  139571. get output(): NodeMaterialConnectionPoint;
  139572. protected _buildBlock(state: NodeMaterialBuildState): this;
  139573. }
  139574. }
  139575. declare module BABYLON {
  139576. /**
  139577. * Operations supported by the Trigonometry block
  139578. */
  139579. export enum TrigonometryBlockOperations {
  139580. /** Cos */
  139581. Cos = 0,
  139582. /** Sin */
  139583. Sin = 1,
  139584. /** Abs */
  139585. Abs = 2,
  139586. /** Exp */
  139587. Exp = 3,
  139588. /** Exp2 */
  139589. Exp2 = 4,
  139590. /** Round */
  139591. Round = 5,
  139592. /** Floor */
  139593. Floor = 6,
  139594. /** Ceiling */
  139595. Ceiling = 7,
  139596. /** Square root */
  139597. Sqrt = 8,
  139598. /** Log */
  139599. Log = 9,
  139600. /** Tangent */
  139601. Tan = 10,
  139602. /** Arc tangent */
  139603. ArcTan = 11,
  139604. /** Arc cosinus */
  139605. ArcCos = 12,
  139606. /** Arc sinus */
  139607. ArcSin = 13,
  139608. /** Fraction */
  139609. Fract = 14,
  139610. /** Sign */
  139611. Sign = 15,
  139612. /** To radians (from degrees) */
  139613. Radians = 16,
  139614. /** To degrees (from radians) */
  139615. Degrees = 17
  139616. }
  139617. /**
  139618. * Block used to apply trigonometry operation to floats
  139619. */
  139620. export class TrigonometryBlock extends NodeMaterialBlock {
  139621. /**
  139622. * Gets or sets the operation applied by the block
  139623. */
  139624. operation: TrigonometryBlockOperations;
  139625. /**
  139626. * Creates a new TrigonometryBlock
  139627. * @param name defines the block name
  139628. */
  139629. constructor(name: string);
  139630. /**
  139631. * Gets the current class name
  139632. * @returns the class name
  139633. */
  139634. getClassName(): string;
  139635. /**
  139636. * Gets the input component
  139637. */
  139638. get input(): NodeMaterialConnectionPoint;
  139639. /**
  139640. * Gets the output component
  139641. */
  139642. get output(): NodeMaterialConnectionPoint;
  139643. protected _buildBlock(state: NodeMaterialBuildState): this;
  139644. serialize(): any;
  139645. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139646. protected _dumpPropertiesCode(): string;
  139647. }
  139648. }
  139649. declare module BABYLON {
  139650. /**
  139651. * Block used to create a Color3/4 out of individual inputs (one for each component)
  139652. */
  139653. export class ColorMergerBlock extends NodeMaterialBlock {
  139654. /**
  139655. * Create a new ColorMergerBlock
  139656. * @param name defines the block name
  139657. */
  139658. constructor(name: string);
  139659. /**
  139660. * Gets the current class name
  139661. * @returns the class name
  139662. */
  139663. getClassName(): string;
  139664. /**
  139665. * Gets the rgb component (input)
  139666. */
  139667. get rgbIn(): NodeMaterialConnectionPoint;
  139668. /**
  139669. * Gets the r component (input)
  139670. */
  139671. get r(): NodeMaterialConnectionPoint;
  139672. /**
  139673. * Gets the g component (input)
  139674. */
  139675. get g(): NodeMaterialConnectionPoint;
  139676. /**
  139677. * Gets the b component (input)
  139678. */
  139679. get b(): NodeMaterialConnectionPoint;
  139680. /**
  139681. * Gets the a component (input)
  139682. */
  139683. get a(): NodeMaterialConnectionPoint;
  139684. /**
  139685. * Gets the rgba component (output)
  139686. */
  139687. get rgba(): NodeMaterialConnectionPoint;
  139688. /**
  139689. * Gets the rgb component (output)
  139690. */
  139691. get rgbOut(): NodeMaterialConnectionPoint;
  139692. /**
  139693. * Gets the rgb component (output)
  139694. * @deprecated Please use rgbOut instead.
  139695. */
  139696. get rgb(): NodeMaterialConnectionPoint;
  139697. protected _buildBlock(state: NodeMaterialBuildState): this;
  139698. }
  139699. }
  139700. declare module BABYLON {
  139701. /**
  139702. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  139703. */
  139704. export class VectorSplitterBlock extends NodeMaterialBlock {
  139705. /**
  139706. * Create a new VectorSplitterBlock
  139707. * @param name defines the block name
  139708. */
  139709. constructor(name: string);
  139710. /**
  139711. * Gets the current class name
  139712. * @returns the class name
  139713. */
  139714. getClassName(): string;
  139715. /**
  139716. * Gets the xyzw component (input)
  139717. */
  139718. get xyzw(): NodeMaterialConnectionPoint;
  139719. /**
  139720. * Gets the xyz component (input)
  139721. */
  139722. get xyzIn(): NodeMaterialConnectionPoint;
  139723. /**
  139724. * Gets the xy component (input)
  139725. */
  139726. get xyIn(): NodeMaterialConnectionPoint;
  139727. /**
  139728. * Gets the xyz component (output)
  139729. */
  139730. get xyzOut(): NodeMaterialConnectionPoint;
  139731. /**
  139732. * Gets the xy component (output)
  139733. */
  139734. get xyOut(): NodeMaterialConnectionPoint;
  139735. /**
  139736. * Gets the x component (output)
  139737. */
  139738. get x(): NodeMaterialConnectionPoint;
  139739. /**
  139740. * Gets the y component (output)
  139741. */
  139742. get y(): NodeMaterialConnectionPoint;
  139743. /**
  139744. * Gets the z component (output)
  139745. */
  139746. get z(): NodeMaterialConnectionPoint;
  139747. /**
  139748. * Gets the w component (output)
  139749. */
  139750. get w(): NodeMaterialConnectionPoint;
  139751. protected _inputRename(name: string): string;
  139752. protected _outputRename(name: string): string;
  139753. protected _buildBlock(state: NodeMaterialBuildState): this;
  139754. }
  139755. }
  139756. declare module BABYLON {
  139757. /**
  139758. * Block used to lerp between 2 values
  139759. */
  139760. export class LerpBlock extends NodeMaterialBlock {
  139761. /**
  139762. * Creates a new LerpBlock
  139763. * @param name defines the block name
  139764. */
  139765. constructor(name: string);
  139766. /**
  139767. * Gets the current class name
  139768. * @returns the class name
  139769. */
  139770. getClassName(): string;
  139771. /**
  139772. * Gets the left operand input component
  139773. */
  139774. get left(): NodeMaterialConnectionPoint;
  139775. /**
  139776. * Gets the right operand input component
  139777. */
  139778. get right(): NodeMaterialConnectionPoint;
  139779. /**
  139780. * Gets the gradient operand input component
  139781. */
  139782. get gradient(): NodeMaterialConnectionPoint;
  139783. /**
  139784. * Gets the output component
  139785. */
  139786. get output(): NodeMaterialConnectionPoint;
  139787. protected _buildBlock(state: NodeMaterialBuildState): this;
  139788. }
  139789. }
  139790. declare module BABYLON {
  139791. /**
  139792. * Block used to divide 2 vectors
  139793. */
  139794. export class DivideBlock extends NodeMaterialBlock {
  139795. /**
  139796. * Creates a new DivideBlock
  139797. * @param name defines the block name
  139798. */
  139799. constructor(name: string);
  139800. /**
  139801. * Gets the current class name
  139802. * @returns the class name
  139803. */
  139804. getClassName(): string;
  139805. /**
  139806. * Gets the left operand input component
  139807. */
  139808. get left(): NodeMaterialConnectionPoint;
  139809. /**
  139810. * Gets the right operand input component
  139811. */
  139812. get right(): NodeMaterialConnectionPoint;
  139813. /**
  139814. * Gets the output component
  139815. */
  139816. get output(): NodeMaterialConnectionPoint;
  139817. protected _buildBlock(state: NodeMaterialBuildState): this;
  139818. }
  139819. }
  139820. declare module BABYLON {
  139821. /**
  139822. * Block used to subtract 2 vectors
  139823. */
  139824. export class SubtractBlock extends NodeMaterialBlock {
  139825. /**
  139826. * Creates a new SubtractBlock
  139827. * @param name defines the block name
  139828. */
  139829. constructor(name: string);
  139830. /**
  139831. * Gets the current class name
  139832. * @returns the class name
  139833. */
  139834. getClassName(): string;
  139835. /**
  139836. * Gets the left operand input component
  139837. */
  139838. get left(): NodeMaterialConnectionPoint;
  139839. /**
  139840. * Gets the right operand input component
  139841. */
  139842. get right(): NodeMaterialConnectionPoint;
  139843. /**
  139844. * Gets the output component
  139845. */
  139846. get output(): NodeMaterialConnectionPoint;
  139847. protected _buildBlock(state: NodeMaterialBuildState): this;
  139848. }
  139849. }
  139850. declare module BABYLON {
  139851. /**
  139852. * Block used to step a value
  139853. */
  139854. export class StepBlock extends NodeMaterialBlock {
  139855. /**
  139856. * Creates a new StepBlock
  139857. * @param name defines the block name
  139858. */
  139859. constructor(name: string);
  139860. /**
  139861. * Gets the current class name
  139862. * @returns the class name
  139863. */
  139864. getClassName(): string;
  139865. /**
  139866. * Gets the value operand input component
  139867. */
  139868. get value(): NodeMaterialConnectionPoint;
  139869. /**
  139870. * Gets the edge operand input component
  139871. */
  139872. get edge(): NodeMaterialConnectionPoint;
  139873. /**
  139874. * Gets the output component
  139875. */
  139876. get output(): NodeMaterialConnectionPoint;
  139877. protected _buildBlock(state: NodeMaterialBuildState): this;
  139878. }
  139879. }
  139880. declare module BABYLON {
  139881. /**
  139882. * Block used to get the opposite (1 - x) of a value
  139883. */
  139884. export class OneMinusBlock extends NodeMaterialBlock {
  139885. /**
  139886. * Creates a new OneMinusBlock
  139887. * @param name defines the block name
  139888. */
  139889. constructor(name: string);
  139890. /**
  139891. * Gets the current class name
  139892. * @returns the class name
  139893. */
  139894. getClassName(): string;
  139895. /**
  139896. * Gets the input component
  139897. */
  139898. get input(): NodeMaterialConnectionPoint;
  139899. /**
  139900. * Gets the output component
  139901. */
  139902. get output(): NodeMaterialConnectionPoint;
  139903. protected _buildBlock(state: NodeMaterialBuildState): this;
  139904. }
  139905. }
  139906. declare module BABYLON {
  139907. /**
  139908. * Block used to get the view direction
  139909. */
  139910. export class ViewDirectionBlock extends NodeMaterialBlock {
  139911. /**
  139912. * Creates a new ViewDirectionBlock
  139913. * @param name defines the block name
  139914. */
  139915. constructor(name: string);
  139916. /**
  139917. * Gets the current class name
  139918. * @returns the class name
  139919. */
  139920. getClassName(): string;
  139921. /**
  139922. * Gets the world position component
  139923. */
  139924. get worldPosition(): NodeMaterialConnectionPoint;
  139925. /**
  139926. * Gets the camera position component
  139927. */
  139928. get cameraPosition(): NodeMaterialConnectionPoint;
  139929. /**
  139930. * Gets the output component
  139931. */
  139932. get output(): NodeMaterialConnectionPoint;
  139933. autoConfigure(material: NodeMaterial): void;
  139934. protected _buildBlock(state: NodeMaterialBuildState): this;
  139935. }
  139936. }
  139937. declare module BABYLON {
  139938. /**
  139939. * Block used to compute fresnel value
  139940. */
  139941. export class FresnelBlock extends NodeMaterialBlock {
  139942. /**
  139943. * Create a new FresnelBlock
  139944. * @param name defines the block name
  139945. */
  139946. constructor(name: string);
  139947. /**
  139948. * Gets the current class name
  139949. * @returns the class name
  139950. */
  139951. getClassName(): string;
  139952. /**
  139953. * Gets the world normal input component
  139954. */
  139955. get worldNormal(): NodeMaterialConnectionPoint;
  139956. /**
  139957. * Gets the view direction input component
  139958. */
  139959. get viewDirection(): NodeMaterialConnectionPoint;
  139960. /**
  139961. * Gets the bias input component
  139962. */
  139963. get bias(): NodeMaterialConnectionPoint;
  139964. /**
  139965. * Gets the camera (or eye) position component
  139966. */
  139967. get power(): NodeMaterialConnectionPoint;
  139968. /**
  139969. * Gets the fresnel output component
  139970. */
  139971. get fresnel(): NodeMaterialConnectionPoint;
  139972. autoConfigure(material: NodeMaterial): void;
  139973. protected _buildBlock(state: NodeMaterialBuildState): this;
  139974. }
  139975. }
  139976. declare module BABYLON {
  139977. /**
  139978. * Block used to get the max of 2 values
  139979. */
  139980. export class MaxBlock extends NodeMaterialBlock {
  139981. /**
  139982. * Creates a new MaxBlock
  139983. * @param name defines the block name
  139984. */
  139985. constructor(name: string);
  139986. /**
  139987. * Gets the current class name
  139988. * @returns the class name
  139989. */
  139990. getClassName(): string;
  139991. /**
  139992. * Gets the left operand input component
  139993. */
  139994. get left(): NodeMaterialConnectionPoint;
  139995. /**
  139996. * Gets the right operand input component
  139997. */
  139998. get right(): NodeMaterialConnectionPoint;
  139999. /**
  140000. * Gets the output component
  140001. */
  140002. get output(): NodeMaterialConnectionPoint;
  140003. protected _buildBlock(state: NodeMaterialBuildState): this;
  140004. }
  140005. }
  140006. declare module BABYLON {
  140007. /**
  140008. * Block used to get the min of 2 values
  140009. */
  140010. export class MinBlock extends NodeMaterialBlock {
  140011. /**
  140012. * Creates a new MinBlock
  140013. * @param name defines the block name
  140014. */
  140015. constructor(name: string);
  140016. /**
  140017. * Gets the current class name
  140018. * @returns the class name
  140019. */
  140020. getClassName(): string;
  140021. /**
  140022. * Gets the left operand input component
  140023. */
  140024. get left(): NodeMaterialConnectionPoint;
  140025. /**
  140026. * Gets the right operand input component
  140027. */
  140028. get right(): NodeMaterialConnectionPoint;
  140029. /**
  140030. * Gets the output component
  140031. */
  140032. get output(): NodeMaterialConnectionPoint;
  140033. protected _buildBlock(state: NodeMaterialBuildState): this;
  140034. }
  140035. }
  140036. declare module BABYLON {
  140037. /**
  140038. * Block used to get the distance between 2 values
  140039. */
  140040. export class DistanceBlock extends NodeMaterialBlock {
  140041. /**
  140042. * Creates a new DistanceBlock
  140043. * @param name defines the block name
  140044. */
  140045. constructor(name: string);
  140046. /**
  140047. * Gets the current class name
  140048. * @returns the class name
  140049. */
  140050. getClassName(): string;
  140051. /**
  140052. * Gets the left operand input component
  140053. */
  140054. get left(): NodeMaterialConnectionPoint;
  140055. /**
  140056. * Gets the right operand input component
  140057. */
  140058. get right(): NodeMaterialConnectionPoint;
  140059. /**
  140060. * Gets the output component
  140061. */
  140062. get output(): NodeMaterialConnectionPoint;
  140063. protected _buildBlock(state: NodeMaterialBuildState): this;
  140064. }
  140065. }
  140066. declare module BABYLON {
  140067. /**
  140068. * Block used to get the length of a vector
  140069. */
  140070. export class LengthBlock extends NodeMaterialBlock {
  140071. /**
  140072. * Creates a new LengthBlock
  140073. * @param name defines the block name
  140074. */
  140075. constructor(name: string);
  140076. /**
  140077. * Gets the current class name
  140078. * @returns the class name
  140079. */
  140080. getClassName(): string;
  140081. /**
  140082. * Gets the value input component
  140083. */
  140084. get value(): NodeMaterialConnectionPoint;
  140085. /**
  140086. * Gets the output component
  140087. */
  140088. get output(): NodeMaterialConnectionPoint;
  140089. protected _buildBlock(state: NodeMaterialBuildState): this;
  140090. }
  140091. }
  140092. declare module BABYLON {
  140093. /**
  140094. * Block used to get negative version of a value (i.e. x * -1)
  140095. */
  140096. export class NegateBlock extends NodeMaterialBlock {
  140097. /**
  140098. * Creates a new NegateBlock
  140099. * @param name defines the block name
  140100. */
  140101. constructor(name: string);
  140102. /**
  140103. * Gets the current class name
  140104. * @returns the class name
  140105. */
  140106. getClassName(): string;
  140107. /**
  140108. * Gets the value input component
  140109. */
  140110. get value(): NodeMaterialConnectionPoint;
  140111. /**
  140112. * Gets the output component
  140113. */
  140114. get output(): NodeMaterialConnectionPoint;
  140115. protected _buildBlock(state: NodeMaterialBuildState): this;
  140116. }
  140117. }
  140118. declare module BABYLON {
  140119. /**
  140120. * Block used to get the value of the first parameter raised to the power of the second
  140121. */
  140122. export class PowBlock extends NodeMaterialBlock {
  140123. /**
  140124. * Creates a new PowBlock
  140125. * @param name defines the block name
  140126. */
  140127. constructor(name: string);
  140128. /**
  140129. * Gets the current class name
  140130. * @returns the class name
  140131. */
  140132. getClassName(): string;
  140133. /**
  140134. * Gets the value operand input component
  140135. */
  140136. get value(): NodeMaterialConnectionPoint;
  140137. /**
  140138. * Gets the power operand input component
  140139. */
  140140. get power(): NodeMaterialConnectionPoint;
  140141. /**
  140142. * Gets the output component
  140143. */
  140144. get output(): NodeMaterialConnectionPoint;
  140145. protected _buildBlock(state: NodeMaterialBuildState): this;
  140146. }
  140147. }
  140148. declare module BABYLON {
  140149. /**
  140150. * Block used to get a random number
  140151. */
  140152. export class RandomNumberBlock extends NodeMaterialBlock {
  140153. /**
  140154. * Creates a new RandomNumberBlock
  140155. * @param name defines the block name
  140156. */
  140157. constructor(name: string);
  140158. /**
  140159. * Gets the current class name
  140160. * @returns the class name
  140161. */
  140162. getClassName(): string;
  140163. /**
  140164. * Gets the seed input component
  140165. */
  140166. get seed(): NodeMaterialConnectionPoint;
  140167. /**
  140168. * Gets the output component
  140169. */
  140170. get output(): NodeMaterialConnectionPoint;
  140171. protected _buildBlock(state: NodeMaterialBuildState): this;
  140172. }
  140173. }
  140174. declare module BABYLON {
  140175. /**
  140176. * Block used to compute arc tangent of 2 values
  140177. */
  140178. export class ArcTan2Block extends NodeMaterialBlock {
  140179. /**
  140180. * Creates a new ArcTan2Block
  140181. * @param name defines the block name
  140182. */
  140183. constructor(name: string);
  140184. /**
  140185. * Gets the current class name
  140186. * @returns the class name
  140187. */
  140188. getClassName(): string;
  140189. /**
  140190. * Gets the x operand input component
  140191. */
  140192. get x(): NodeMaterialConnectionPoint;
  140193. /**
  140194. * Gets the y operand input component
  140195. */
  140196. get y(): NodeMaterialConnectionPoint;
  140197. /**
  140198. * Gets the output component
  140199. */
  140200. get output(): NodeMaterialConnectionPoint;
  140201. protected _buildBlock(state: NodeMaterialBuildState): this;
  140202. }
  140203. }
  140204. declare module BABYLON {
  140205. /**
  140206. * Block used to smooth step a value
  140207. */
  140208. export class SmoothStepBlock extends NodeMaterialBlock {
  140209. /**
  140210. * Creates a new SmoothStepBlock
  140211. * @param name defines the block name
  140212. */
  140213. constructor(name: string);
  140214. /**
  140215. * Gets the current class name
  140216. * @returns the class name
  140217. */
  140218. getClassName(): string;
  140219. /**
  140220. * Gets the value operand input component
  140221. */
  140222. get value(): NodeMaterialConnectionPoint;
  140223. /**
  140224. * Gets the first edge operand input component
  140225. */
  140226. get edge0(): NodeMaterialConnectionPoint;
  140227. /**
  140228. * Gets the second edge operand input component
  140229. */
  140230. get edge1(): NodeMaterialConnectionPoint;
  140231. /**
  140232. * Gets the output component
  140233. */
  140234. get output(): NodeMaterialConnectionPoint;
  140235. protected _buildBlock(state: NodeMaterialBuildState): this;
  140236. }
  140237. }
  140238. declare module BABYLON {
  140239. /**
  140240. * Block used to get the reciprocal (1 / x) of a value
  140241. */
  140242. export class ReciprocalBlock extends NodeMaterialBlock {
  140243. /**
  140244. * Creates a new ReciprocalBlock
  140245. * @param name defines the block name
  140246. */
  140247. constructor(name: string);
  140248. /**
  140249. * Gets the current class name
  140250. * @returns the class name
  140251. */
  140252. getClassName(): string;
  140253. /**
  140254. * Gets the input component
  140255. */
  140256. get input(): NodeMaterialConnectionPoint;
  140257. /**
  140258. * Gets the output component
  140259. */
  140260. get output(): NodeMaterialConnectionPoint;
  140261. protected _buildBlock(state: NodeMaterialBuildState): this;
  140262. }
  140263. }
  140264. declare module BABYLON {
  140265. /**
  140266. * Block used to replace a color by another one
  140267. */
  140268. export class ReplaceColorBlock extends NodeMaterialBlock {
  140269. /**
  140270. * Creates a new ReplaceColorBlock
  140271. * @param name defines the block name
  140272. */
  140273. constructor(name: string);
  140274. /**
  140275. * Gets the current class name
  140276. * @returns the class name
  140277. */
  140278. getClassName(): string;
  140279. /**
  140280. * Gets the value input component
  140281. */
  140282. get value(): NodeMaterialConnectionPoint;
  140283. /**
  140284. * Gets the reference input component
  140285. */
  140286. get reference(): NodeMaterialConnectionPoint;
  140287. /**
  140288. * Gets the distance input component
  140289. */
  140290. get distance(): NodeMaterialConnectionPoint;
  140291. /**
  140292. * Gets the replacement input component
  140293. */
  140294. get replacement(): NodeMaterialConnectionPoint;
  140295. /**
  140296. * Gets the output component
  140297. */
  140298. get output(): NodeMaterialConnectionPoint;
  140299. protected _buildBlock(state: NodeMaterialBuildState): this;
  140300. }
  140301. }
  140302. declare module BABYLON {
  140303. /**
  140304. * Block used to posterize a value
  140305. * @see https://en.wikipedia.org/wiki/Posterization
  140306. */
  140307. export class PosterizeBlock extends NodeMaterialBlock {
  140308. /**
  140309. * Creates a new PosterizeBlock
  140310. * @param name defines the block name
  140311. */
  140312. constructor(name: string);
  140313. /**
  140314. * Gets the current class name
  140315. * @returns the class name
  140316. */
  140317. getClassName(): string;
  140318. /**
  140319. * Gets the value input component
  140320. */
  140321. get value(): NodeMaterialConnectionPoint;
  140322. /**
  140323. * Gets the steps input component
  140324. */
  140325. get steps(): NodeMaterialConnectionPoint;
  140326. /**
  140327. * Gets the output component
  140328. */
  140329. get output(): NodeMaterialConnectionPoint;
  140330. protected _buildBlock(state: NodeMaterialBuildState): this;
  140331. }
  140332. }
  140333. declare module BABYLON {
  140334. /**
  140335. * Operations supported by the Wave block
  140336. */
  140337. export enum WaveBlockKind {
  140338. /** SawTooth */
  140339. SawTooth = 0,
  140340. /** Square */
  140341. Square = 1,
  140342. /** Triangle */
  140343. Triangle = 2
  140344. }
  140345. /**
  140346. * Block used to apply wave operation to floats
  140347. */
  140348. export class WaveBlock extends NodeMaterialBlock {
  140349. /**
  140350. * Gets or sets the kibnd of wave to be applied by the block
  140351. */
  140352. kind: WaveBlockKind;
  140353. /**
  140354. * Creates a new WaveBlock
  140355. * @param name defines the block name
  140356. */
  140357. constructor(name: string);
  140358. /**
  140359. * Gets the current class name
  140360. * @returns the class name
  140361. */
  140362. getClassName(): string;
  140363. /**
  140364. * Gets the input component
  140365. */
  140366. get input(): NodeMaterialConnectionPoint;
  140367. /**
  140368. * Gets the output component
  140369. */
  140370. get output(): NodeMaterialConnectionPoint;
  140371. protected _buildBlock(state: NodeMaterialBuildState): this;
  140372. serialize(): any;
  140373. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140374. }
  140375. }
  140376. declare module BABYLON {
  140377. /**
  140378. * Class used to store a color step for the GradientBlock
  140379. */
  140380. export class GradientBlockColorStep {
  140381. /**
  140382. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  140383. */
  140384. step: number;
  140385. /**
  140386. * Gets or sets the color associated with this step
  140387. */
  140388. color: Color3;
  140389. /**
  140390. * Creates a new GradientBlockColorStep
  140391. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  140392. * @param color defines the color associated with this step
  140393. */
  140394. constructor(
  140395. /**
  140396. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  140397. */
  140398. step: number,
  140399. /**
  140400. * Gets or sets the color associated with this step
  140401. */
  140402. color: Color3);
  140403. }
  140404. /**
  140405. * Block used to return a color from a gradient based on an input value between 0 and 1
  140406. */
  140407. export class GradientBlock extends NodeMaterialBlock {
  140408. /**
  140409. * Gets or sets the list of color steps
  140410. */
  140411. colorSteps: GradientBlockColorStep[];
  140412. /**
  140413. * Creates a new GradientBlock
  140414. * @param name defines the block name
  140415. */
  140416. constructor(name: string);
  140417. /**
  140418. * Gets the current class name
  140419. * @returns the class name
  140420. */
  140421. getClassName(): string;
  140422. /**
  140423. * Gets the gradient input component
  140424. */
  140425. get gradient(): NodeMaterialConnectionPoint;
  140426. /**
  140427. * Gets the output component
  140428. */
  140429. get output(): NodeMaterialConnectionPoint;
  140430. private _writeColorConstant;
  140431. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140432. serialize(): any;
  140433. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140434. protected _dumpPropertiesCode(): string;
  140435. }
  140436. }
  140437. declare module BABYLON {
  140438. /**
  140439. * Block used to normalize lerp between 2 values
  140440. */
  140441. export class NLerpBlock extends NodeMaterialBlock {
  140442. /**
  140443. * Creates a new NLerpBlock
  140444. * @param name defines the block name
  140445. */
  140446. constructor(name: string);
  140447. /**
  140448. * Gets the current class name
  140449. * @returns the class name
  140450. */
  140451. getClassName(): string;
  140452. /**
  140453. * Gets the left operand input component
  140454. */
  140455. get left(): NodeMaterialConnectionPoint;
  140456. /**
  140457. * Gets the right operand input component
  140458. */
  140459. get right(): NodeMaterialConnectionPoint;
  140460. /**
  140461. * Gets the gradient operand input component
  140462. */
  140463. get gradient(): NodeMaterialConnectionPoint;
  140464. /**
  140465. * Gets the output component
  140466. */
  140467. get output(): NodeMaterialConnectionPoint;
  140468. protected _buildBlock(state: NodeMaterialBuildState): this;
  140469. }
  140470. }
  140471. declare module BABYLON {
  140472. /**
  140473. * block used to Generate a Worley Noise 3D Noise Pattern
  140474. */
  140475. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  140476. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  140477. manhattanDistance: boolean;
  140478. /**
  140479. * Creates a new WorleyNoise3DBlock
  140480. * @param name defines the block name
  140481. */
  140482. constructor(name: string);
  140483. /**
  140484. * Gets the current class name
  140485. * @returns the class name
  140486. */
  140487. getClassName(): string;
  140488. /**
  140489. * Gets the seed input component
  140490. */
  140491. get seed(): NodeMaterialConnectionPoint;
  140492. /**
  140493. * Gets the jitter input component
  140494. */
  140495. get jitter(): NodeMaterialConnectionPoint;
  140496. /**
  140497. * Gets the output component
  140498. */
  140499. get output(): NodeMaterialConnectionPoint;
  140500. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140501. /**
  140502. * Exposes the properties to the UI?
  140503. */
  140504. protected _dumpPropertiesCode(): string;
  140505. /**
  140506. * Exposes the properties to the Seralize?
  140507. */
  140508. serialize(): any;
  140509. /**
  140510. * Exposes the properties to the deseralize?
  140511. */
  140512. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140513. }
  140514. }
  140515. declare module BABYLON {
  140516. /**
  140517. * block used to Generate a Simplex Perlin 3d Noise Pattern
  140518. */
  140519. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  140520. /**
  140521. * Creates a new SimplexPerlin3DBlock
  140522. * @param name defines the block name
  140523. */
  140524. constructor(name: string);
  140525. /**
  140526. * Gets the current class name
  140527. * @returns the class name
  140528. */
  140529. getClassName(): string;
  140530. /**
  140531. * Gets the seed operand input component
  140532. */
  140533. get seed(): NodeMaterialConnectionPoint;
  140534. /**
  140535. * Gets the output component
  140536. */
  140537. get output(): NodeMaterialConnectionPoint;
  140538. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140539. }
  140540. }
  140541. declare module BABYLON {
  140542. /**
  140543. * Block used to blend normals
  140544. */
  140545. export class NormalBlendBlock extends NodeMaterialBlock {
  140546. /**
  140547. * Creates a new NormalBlendBlock
  140548. * @param name defines the block name
  140549. */
  140550. constructor(name: string);
  140551. /**
  140552. * Gets the current class name
  140553. * @returns the class name
  140554. */
  140555. getClassName(): string;
  140556. /**
  140557. * Gets the first input component
  140558. */
  140559. get normalMap0(): NodeMaterialConnectionPoint;
  140560. /**
  140561. * Gets the second input component
  140562. */
  140563. get normalMap1(): NodeMaterialConnectionPoint;
  140564. /**
  140565. * Gets the output component
  140566. */
  140567. get output(): NodeMaterialConnectionPoint;
  140568. protected _buildBlock(state: NodeMaterialBuildState): this;
  140569. }
  140570. }
  140571. declare module BABYLON {
  140572. /**
  140573. * Block used to rotate a 2d vector by a given angle
  140574. */
  140575. export class Rotate2dBlock extends NodeMaterialBlock {
  140576. /**
  140577. * Creates a new Rotate2dBlock
  140578. * @param name defines the block name
  140579. */
  140580. constructor(name: string);
  140581. /**
  140582. * Gets the current class name
  140583. * @returns the class name
  140584. */
  140585. getClassName(): string;
  140586. /**
  140587. * Gets the input vector
  140588. */
  140589. get input(): NodeMaterialConnectionPoint;
  140590. /**
  140591. * Gets the input angle
  140592. */
  140593. get angle(): NodeMaterialConnectionPoint;
  140594. /**
  140595. * Gets the output component
  140596. */
  140597. get output(): NodeMaterialConnectionPoint;
  140598. autoConfigure(material: NodeMaterial): void;
  140599. protected _buildBlock(state: NodeMaterialBuildState): this;
  140600. }
  140601. }
  140602. declare module BABYLON {
  140603. /**
  140604. * Block used to get the reflected vector from a direction and a normal
  140605. */
  140606. export class ReflectBlock extends NodeMaterialBlock {
  140607. /**
  140608. * Creates a new ReflectBlock
  140609. * @param name defines the block name
  140610. */
  140611. constructor(name: string);
  140612. /**
  140613. * Gets the current class name
  140614. * @returns the class name
  140615. */
  140616. getClassName(): string;
  140617. /**
  140618. * Gets the incident component
  140619. */
  140620. get incident(): NodeMaterialConnectionPoint;
  140621. /**
  140622. * Gets the normal component
  140623. */
  140624. get normal(): NodeMaterialConnectionPoint;
  140625. /**
  140626. * Gets the output component
  140627. */
  140628. get output(): NodeMaterialConnectionPoint;
  140629. protected _buildBlock(state: NodeMaterialBuildState): this;
  140630. }
  140631. }
  140632. declare module BABYLON {
  140633. /**
  140634. * Block used to get the refracted vector from a direction and a normal
  140635. */
  140636. export class RefractBlock extends NodeMaterialBlock {
  140637. /**
  140638. * Creates a new RefractBlock
  140639. * @param name defines the block name
  140640. */
  140641. constructor(name: string);
  140642. /**
  140643. * Gets the current class name
  140644. * @returns the class name
  140645. */
  140646. getClassName(): string;
  140647. /**
  140648. * Gets the incident component
  140649. */
  140650. get incident(): NodeMaterialConnectionPoint;
  140651. /**
  140652. * Gets the normal component
  140653. */
  140654. get normal(): NodeMaterialConnectionPoint;
  140655. /**
  140656. * Gets the index of refraction component
  140657. */
  140658. get ior(): NodeMaterialConnectionPoint;
  140659. /**
  140660. * Gets the output component
  140661. */
  140662. get output(): NodeMaterialConnectionPoint;
  140663. protected _buildBlock(state: NodeMaterialBuildState): this;
  140664. }
  140665. }
  140666. declare module BABYLON {
  140667. /**
  140668. * Block used to desaturate a color
  140669. */
  140670. export class DesaturateBlock extends NodeMaterialBlock {
  140671. /**
  140672. * Creates a new DesaturateBlock
  140673. * @param name defines the block name
  140674. */
  140675. constructor(name: string);
  140676. /**
  140677. * Gets the current class name
  140678. * @returns the class name
  140679. */
  140680. getClassName(): string;
  140681. /**
  140682. * Gets the color operand input component
  140683. */
  140684. get color(): NodeMaterialConnectionPoint;
  140685. /**
  140686. * Gets the level operand input component
  140687. */
  140688. get level(): NodeMaterialConnectionPoint;
  140689. /**
  140690. * Gets the output component
  140691. */
  140692. get output(): NodeMaterialConnectionPoint;
  140693. protected _buildBlock(state: NodeMaterialBuildState): this;
  140694. }
  140695. }
  140696. declare module BABYLON {
  140697. /**
  140698. * Block used to implement the ambient occlusion module of the PBR material
  140699. */
  140700. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  140701. /**
  140702. * Create a new AmbientOcclusionBlock
  140703. * @param name defines the block name
  140704. */
  140705. constructor(name: string);
  140706. /**
  140707. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  140708. */
  140709. useAmbientInGrayScale: boolean;
  140710. /**
  140711. * Initialize the block and prepare the context for build
  140712. * @param state defines the state that will be used for the build
  140713. */
  140714. initialize(state: NodeMaterialBuildState): void;
  140715. /**
  140716. * Gets the current class name
  140717. * @returns the class name
  140718. */
  140719. getClassName(): string;
  140720. /**
  140721. * Gets the texture input component
  140722. */
  140723. get texture(): NodeMaterialConnectionPoint;
  140724. /**
  140725. * Gets the texture intensity component
  140726. */
  140727. get intensity(): NodeMaterialConnectionPoint;
  140728. /**
  140729. * Gets the direct light intensity input component
  140730. */
  140731. get directLightIntensity(): NodeMaterialConnectionPoint;
  140732. /**
  140733. * Gets the ambient occlusion object output component
  140734. */
  140735. get ambientOcclusion(): NodeMaterialConnectionPoint;
  140736. /**
  140737. * Gets the main code of the block (fragment side)
  140738. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  140739. * @returns the shader code
  140740. */
  140741. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  140742. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140743. protected _buildBlock(state: NodeMaterialBuildState): this;
  140744. protected _dumpPropertiesCode(): string;
  140745. serialize(): any;
  140746. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140747. }
  140748. }
  140749. declare module BABYLON {
  140750. /**
  140751. * Block used to implement the reflection module of the PBR material
  140752. */
  140753. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  140754. /** @hidden */
  140755. _defineLODReflectionAlpha: string;
  140756. /** @hidden */
  140757. _defineLinearSpecularReflection: string;
  140758. private _vEnvironmentIrradianceName;
  140759. /** @hidden */
  140760. _vReflectionMicrosurfaceInfosName: string;
  140761. /** @hidden */
  140762. _vReflectionInfosName: string;
  140763. /** @hidden */
  140764. _vReflectionFilteringInfoName: string;
  140765. private _scene;
  140766. /**
  140767. * The three properties below are set by the main PBR block prior to calling methods of this class.
  140768. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  140769. * It's less burden on the user side in the editor part.
  140770. */
  140771. /** @hidden */
  140772. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  140773. /** @hidden */
  140774. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  140775. /** @hidden */
  140776. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  140777. /**
  140778. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  140779. * diffuse part of the IBL.
  140780. */
  140781. useSphericalHarmonics: boolean;
  140782. /**
  140783. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  140784. */
  140785. forceIrradianceInFragment: boolean;
  140786. /**
  140787. * Create a new ReflectionBlock
  140788. * @param name defines the block name
  140789. */
  140790. constructor(name: string);
  140791. /**
  140792. * Gets the current class name
  140793. * @returns the class name
  140794. */
  140795. getClassName(): string;
  140796. /**
  140797. * Gets the position input component
  140798. */
  140799. get position(): NodeMaterialConnectionPoint;
  140800. /**
  140801. * Gets the world position input component
  140802. */
  140803. get worldPosition(): NodeMaterialConnectionPoint;
  140804. /**
  140805. * Gets the world normal input component
  140806. */
  140807. get worldNormal(): NodeMaterialConnectionPoint;
  140808. /**
  140809. * Gets the world input component
  140810. */
  140811. get world(): NodeMaterialConnectionPoint;
  140812. /**
  140813. * Gets the camera (or eye) position component
  140814. */
  140815. get cameraPosition(): NodeMaterialConnectionPoint;
  140816. /**
  140817. * Gets the view input component
  140818. */
  140819. get view(): NodeMaterialConnectionPoint;
  140820. /**
  140821. * Gets the color input component
  140822. */
  140823. get color(): NodeMaterialConnectionPoint;
  140824. /**
  140825. * Gets the reflection object output component
  140826. */
  140827. get reflection(): NodeMaterialConnectionPoint;
  140828. /**
  140829. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  140830. */
  140831. get hasTexture(): boolean;
  140832. /**
  140833. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  140834. */
  140835. get reflectionColor(): string;
  140836. protected _getTexture(): Nullable<BaseTexture>;
  140837. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140838. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  140839. /**
  140840. * Gets the code to inject in the vertex shader
  140841. * @param state current state of the node material building
  140842. * @returns the shader code
  140843. */
  140844. handleVertexSide(state: NodeMaterialBuildState): string;
  140845. /**
  140846. * Gets the main code of the block (fragment side)
  140847. * @param state current state of the node material building
  140848. * @param normalVarName name of the existing variable corresponding to the normal
  140849. * @returns the shader code
  140850. */
  140851. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  140852. protected _buildBlock(state: NodeMaterialBuildState): this;
  140853. protected _dumpPropertiesCode(): string;
  140854. serialize(): any;
  140855. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140856. }
  140857. }
  140858. declare module BABYLON {
  140859. /**
  140860. * Block used to implement the sheen module of the PBR material
  140861. */
  140862. export class SheenBlock extends NodeMaterialBlock {
  140863. /**
  140864. * Create a new SheenBlock
  140865. * @param name defines the block name
  140866. */
  140867. constructor(name: string);
  140868. /**
  140869. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  140870. * It allows the strength of the sheen effect to not depend on the base color of the material,
  140871. * making it easier to setup and tweak the effect
  140872. */
  140873. albedoScaling: boolean;
  140874. /**
  140875. * Defines if the sheen is linked to the sheen color.
  140876. */
  140877. linkSheenWithAlbedo: boolean;
  140878. /**
  140879. * Initialize the block and prepare the context for build
  140880. * @param state defines the state that will be used for the build
  140881. */
  140882. initialize(state: NodeMaterialBuildState): void;
  140883. /**
  140884. * Gets the current class name
  140885. * @returns the class name
  140886. */
  140887. getClassName(): string;
  140888. /**
  140889. * Gets the intensity input component
  140890. */
  140891. get intensity(): NodeMaterialConnectionPoint;
  140892. /**
  140893. * Gets the color input component
  140894. */
  140895. get color(): NodeMaterialConnectionPoint;
  140896. /**
  140897. * Gets the roughness input component
  140898. */
  140899. get roughness(): NodeMaterialConnectionPoint;
  140900. /**
  140901. * Gets the sheen object output component
  140902. */
  140903. get sheen(): NodeMaterialConnectionPoint;
  140904. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140905. /**
  140906. * Gets the main code of the block (fragment side)
  140907. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  140908. * @returns the shader code
  140909. */
  140910. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  140911. protected _buildBlock(state: NodeMaterialBuildState): this;
  140912. protected _dumpPropertiesCode(): string;
  140913. serialize(): any;
  140914. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140915. }
  140916. }
  140917. declare module BABYLON {
  140918. /**
  140919. * Block used to implement the reflectivity module of the PBR material
  140920. */
  140921. export class ReflectivityBlock extends NodeMaterialBlock {
  140922. private _metallicReflectanceColor;
  140923. private _metallicF0Factor;
  140924. /** @hidden */
  140925. _vMetallicReflectanceFactorsName: string;
  140926. /**
  140927. * The property below is set by the main PBR block prior to calling methods of this class.
  140928. */
  140929. /** @hidden */
  140930. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  140931. /**
  140932. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  140933. */
  140934. useAmbientOcclusionFromMetallicTextureRed: boolean;
  140935. /**
  140936. * Specifies if the metallic texture contains the metallness information in its blue channel.
  140937. */
  140938. useMetallnessFromMetallicTextureBlue: boolean;
  140939. /**
  140940. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  140941. */
  140942. useRoughnessFromMetallicTextureAlpha: boolean;
  140943. /**
  140944. * Specifies if the metallic texture contains the roughness information in its green channel.
  140945. */
  140946. useRoughnessFromMetallicTextureGreen: boolean;
  140947. /**
  140948. * Create a new ReflectivityBlock
  140949. * @param name defines the block name
  140950. */
  140951. constructor(name: string);
  140952. /**
  140953. * Initialize the block and prepare the context for build
  140954. * @param state defines the state that will be used for the build
  140955. */
  140956. initialize(state: NodeMaterialBuildState): void;
  140957. /**
  140958. * Gets the current class name
  140959. * @returns the class name
  140960. */
  140961. getClassName(): string;
  140962. /**
  140963. * Gets the metallic input component
  140964. */
  140965. get metallic(): NodeMaterialConnectionPoint;
  140966. /**
  140967. * Gets the roughness input component
  140968. */
  140969. get roughness(): NodeMaterialConnectionPoint;
  140970. /**
  140971. * Gets the texture input component
  140972. */
  140973. get texture(): NodeMaterialConnectionPoint;
  140974. /**
  140975. * Gets the reflectivity object output component
  140976. */
  140977. get reflectivity(): NodeMaterialConnectionPoint;
  140978. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  140979. /**
  140980. * Gets the main code of the block (fragment side)
  140981. * @param state current state of the node material building
  140982. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  140983. * @returns the shader code
  140984. */
  140985. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  140986. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140987. protected _buildBlock(state: NodeMaterialBuildState): this;
  140988. protected _dumpPropertiesCode(): string;
  140989. serialize(): any;
  140990. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140991. }
  140992. }
  140993. declare module BABYLON {
  140994. /**
  140995. * Block used to implement the anisotropy module of the PBR material
  140996. */
  140997. export class AnisotropyBlock extends NodeMaterialBlock {
  140998. /**
  140999. * The two properties below are set by the main PBR block prior to calling methods of this class.
  141000. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  141001. * It's less burden on the user side in the editor part.
  141002. */
  141003. /** @hidden */
  141004. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  141005. /** @hidden */
  141006. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  141007. /**
  141008. * Create a new AnisotropyBlock
  141009. * @param name defines the block name
  141010. */
  141011. constructor(name: string);
  141012. /**
  141013. * Initialize the block and prepare the context for build
  141014. * @param state defines the state that will be used for the build
  141015. */
  141016. initialize(state: NodeMaterialBuildState): void;
  141017. /**
  141018. * Gets the current class name
  141019. * @returns the class name
  141020. */
  141021. getClassName(): string;
  141022. /**
  141023. * Gets the intensity input component
  141024. */
  141025. get intensity(): NodeMaterialConnectionPoint;
  141026. /**
  141027. * Gets the direction input component
  141028. */
  141029. get direction(): NodeMaterialConnectionPoint;
  141030. /**
  141031. * Gets the texture input component
  141032. */
  141033. get texture(): NodeMaterialConnectionPoint;
  141034. /**
  141035. * Gets the uv input component
  141036. */
  141037. get uv(): NodeMaterialConnectionPoint;
  141038. /**
  141039. * Gets the worldTangent input component
  141040. */
  141041. get worldTangent(): NodeMaterialConnectionPoint;
  141042. /**
  141043. * Gets the anisotropy object output component
  141044. */
  141045. get anisotropy(): NodeMaterialConnectionPoint;
  141046. private _generateTBNSpace;
  141047. /**
  141048. * Gets the main code of the block (fragment side)
  141049. * @param state current state of the node material building
  141050. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  141051. * @returns the shader code
  141052. */
  141053. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  141054. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141055. protected _buildBlock(state: NodeMaterialBuildState): this;
  141056. }
  141057. }
  141058. declare module BABYLON {
  141059. /**
  141060. * Block used to implement the clear coat module of the PBR material
  141061. */
  141062. export class ClearCoatBlock extends NodeMaterialBlock {
  141063. private _scene;
  141064. /**
  141065. * Create a new ClearCoatBlock
  141066. * @param name defines the block name
  141067. */
  141068. constructor(name: string);
  141069. /**
  141070. * Initialize the block and prepare the context for build
  141071. * @param state defines the state that will be used for the build
  141072. */
  141073. initialize(state: NodeMaterialBuildState): void;
  141074. /**
  141075. * Gets the current class name
  141076. * @returns the class name
  141077. */
  141078. getClassName(): string;
  141079. /**
  141080. * Gets the intensity input component
  141081. */
  141082. get intensity(): NodeMaterialConnectionPoint;
  141083. /**
  141084. * Gets the roughness input component
  141085. */
  141086. get roughness(): NodeMaterialConnectionPoint;
  141087. /**
  141088. * Gets the ior input component
  141089. */
  141090. get ior(): NodeMaterialConnectionPoint;
  141091. /**
  141092. * Gets the texture input component
  141093. */
  141094. get texture(): NodeMaterialConnectionPoint;
  141095. /**
  141096. * Gets the bump texture input component
  141097. */
  141098. get bumpTexture(): NodeMaterialConnectionPoint;
  141099. /**
  141100. * Gets the uv input component
  141101. */
  141102. get uv(): NodeMaterialConnectionPoint;
  141103. /**
  141104. * Gets the tint color input component
  141105. */
  141106. get tintColor(): NodeMaterialConnectionPoint;
  141107. /**
  141108. * Gets the tint "at distance" input component
  141109. */
  141110. get tintAtDistance(): NodeMaterialConnectionPoint;
  141111. /**
  141112. * Gets the tint thickness input component
  141113. */
  141114. get tintThickness(): NodeMaterialConnectionPoint;
  141115. /**
  141116. * Gets the world tangent input component
  141117. */
  141118. get worldTangent(): NodeMaterialConnectionPoint;
  141119. /**
  141120. * Gets the clear coat object output component
  141121. */
  141122. get clearcoat(): NodeMaterialConnectionPoint;
  141123. autoConfigure(material: NodeMaterial): void;
  141124. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141125. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141126. private _generateTBNSpace;
  141127. /**
  141128. * Gets the main code of the block (fragment side)
  141129. * @param state current state of the node material building
  141130. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  141131. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141132. * @param worldPosVarName name of the variable holding the world position
  141133. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  141134. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  141135. * @param worldNormalVarName name of the variable holding the world normal
  141136. * @returns the shader code
  141137. */
  141138. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  141139. protected _buildBlock(state: NodeMaterialBuildState): this;
  141140. }
  141141. }
  141142. declare module BABYLON {
  141143. /**
  141144. * Block used to implement the sub surface module of the PBR material
  141145. */
  141146. export class SubSurfaceBlock extends NodeMaterialBlock {
  141147. /**
  141148. * Create a new SubSurfaceBlock
  141149. * @param name defines the block name
  141150. */
  141151. constructor(name: string);
  141152. /**
  141153. * Stores the intensity of the different subsurface effects in the thickness texture.
  141154. * * the green channel is the translucency intensity.
  141155. * * the blue channel is the scattering intensity.
  141156. * * the alpha channel is the refraction intensity.
  141157. */
  141158. useMaskFromThicknessTexture: boolean;
  141159. /**
  141160. * Initialize the block and prepare the context for build
  141161. * @param state defines the state that will be used for the build
  141162. */
  141163. initialize(state: NodeMaterialBuildState): void;
  141164. /**
  141165. * Gets the current class name
  141166. * @returns the class name
  141167. */
  141168. getClassName(): string;
  141169. /**
  141170. * Gets the min thickness input component
  141171. */
  141172. get minThickness(): NodeMaterialConnectionPoint;
  141173. /**
  141174. * Gets the max thickness input component
  141175. */
  141176. get maxThickness(): NodeMaterialConnectionPoint;
  141177. /**
  141178. * Gets the thickness texture component
  141179. */
  141180. get thicknessTexture(): NodeMaterialConnectionPoint;
  141181. /**
  141182. * Gets the tint color input component
  141183. */
  141184. get tintColor(): NodeMaterialConnectionPoint;
  141185. /**
  141186. * Gets the translucency intensity input component
  141187. */
  141188. get translucencyIntensity(): NodeMaterialConnectionPoint;
  141189. /**
  141190. * Gets the translucency diffusion distance input component
  141191. */
  141192. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  141193. /**
  141194. * Gets the refraction object parameters
  141195. */
  141196. get refraction(): NodeMaterialConnectionPoint;
  141197. /**
  141198. * Gets the sub surface object output component
  141199. */
  141200. get subsurface(): NodeMaterialConnectionPoint;
  141201. autoConfigure(material: NodeMaterial): void;
  141202. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141203. /**
  141204. * Gets the main code of the block (fragment side)
  141205. * @param state current state of the node material building
  141206. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  141207. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141208. * @param worldPosVarName name of the variable holding the world position
  141209. * @returns the shader code
  141210. */
  141211. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  141212. protected _buildBlock(state: NodeMaterialBuildState): this;
  141213. }
  141214. }
  141215. declare module BABYLON {
  141216. /**
  141217. * Block used to implement the PBR metallic/roughness model
  141218. */
  141219. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  141220. /**
  141221. * Gets or sets the light associated with this block
  141222. */
  141223. light: Nullable<Light>;
  141224. private _lightId;
  141225. private _scene;
  141226. private _environmentBRDFTexture;
  141227. private _environmentBrdfSamplerName;
  141228. private _vNormalWName;
  141229. private _invertNormalName;
  141230. /**
  141231. * Create a new ReflectionBlock
  141232. * @param name defines the block name
  141233. */
  141234. constructor(name: string);
  141235. /**
  141236. * Intensity of the direct lights e.g. the four lights available in your scene.
  141237. * This impacts both the direct diffuse and specular highlights.
  141238. */
  141239. directIntensity: number;
  141240. /**
  141241. * Intensity of the environment e.g. how much the environment will light the object
  141242. * either through harmonics for rough material or through the refelction for shiny ones.
  141243. */
  141244. environmentIntensity: number;
  141245. /**
  141246. * This is a special control allowing the reduction of the specular highlights coming from the
  141247. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  141248. */
  141249. specularIntensity: number;
  141250. /**
  141251. * Defines the falloff type used in this material.
  141252. * It by default is Physical.
  141253. */
  141254. lightFalloff: number;
  141255. /**
  141256. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  141257. */
  141258. useAlphaFromAlbedoTexture: boolean;
  141259. /**
  141260. * Specifies that alpha test should be used
  141261. */
  141262. useAlphaTest: boolean;
  141263. /**
  141264. * Defines the alpha limits in alpha test mode.
  141265. */
  141266. alphaTestCutoff: number;
  141267. /**
  141268. * Specifies that alpha blending should be used
  141269. */
  141270. useAlphaBlending: boolean;
  141271. /**
  141272. * Defines if the alpha value should be determined via the rgb values.
  141273. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  141274. */
  141275. opacityRGB: boolean;
  141276. /**
  141277. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  141278. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  141279. */
  141280. useRadianceOverAlpha: boolean;
  141281. /**
  141282. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  141283. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  141284. */
  141285. useSpecularOverAlpha: boolean;
  141286. /**
  141287. * Enables specular anti aliasing in the PBR shader.
  141288. * It will both interacts on the Geometry for analytical and IBL lighting.
  141289. * It also prefilter the roughness map based on the bump values.
  141290. */
  141291. enableSpecularAntiAliasing: boolean;
  141292. /**
  141293. * Enables realtime filtering on the texture.
  141294. */
  141295. realTimeFiltering: boolean;
  141296. /**
  141297. * Quality switch for realtime filtering
  141298. */
  141299. realTimeFilteringQuality: number;
  141300. /**
  141301. * Defines if the material uses energy conservation.
  141302. */
  141303. useEnergyConservation: boolean;
  141304. /**
  141305. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  141306. * too much the area relying on ambient texture to define their ambient occlusion.
  141307. */
  141308. useRadianceOcclusion: boolean;
  141309. /**
  141310. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  141311. * makes the reflect vector face the model (under horizon).
  141312. */
  141313. useHorizonOcclusion: boolean;
  141314. /**
  141315. * If set to true, no lighting calculations will be applied.
  141316. */
  141317. unlit: boolean;
  141318. /**
  141319. * Force normal to face away from face.
  141320. */
  141321. forceNormalForward: boolean;
  141322. /**
  141323. * Defines the material debug mode.
  141324. * It helps seeing only some components of the material while troubleshooting.
  141325. */
  141326. debugMode: number;
  141327. /**
  141328. * Specify from where on screen the debug mode should start.
  141329. * The value goes from -1 (full screen) to 1 (not visible)
  141330. * It helps with side by side comparison against the final render
  141331. * This defaults to 0
  141332. */
  141333. debugLimit: number;
  141334. /**
  141335. * As the default viewing range might not be enough (if the ambient is really small for instance)
  141336. * You can use the factor to better multiply the final value.
  141337. */
  141338. debugFactor: number;
  141339. /**
  141340. * Initialize the block and prepare the context for build
  141341. * @param state defines the state that will be used for the build
  141342. */
  141343. initialize(state: NodeMaterialBuildState): void;
  141344. /**
  141345. * Gets the current class name
  141346. * @returns the class name
  141347. */
  141348. getClassName(): string;
  141349. /**
  141350. * Gets the world position input component
  141351. */
  141352. get worldPosition(): NodeMaterialConnectionPoint;
  141353. /**
  141354. * Gets the world normal input component
  141355. */
  141356. get worldNormal(): NodeMaterialConnectionPoint;
  141357. /**
  141358. * Gets the perturbed normal input component
  141359. */
  141360. get perturbedNormal(): NodeMaterialConnectionPoint;
  141361. /**
  141362. * Gets the camera position input component
  141363. */
  141364. get cameraPosition(): NodeMaterialConnectionPoint;
  141365. /**
  141366. * Gets the base color input component
  141367. */
  141368. get baseColor(): NodeMaterialConnectionPoint;
  141369. /**
  141370. * Gets the opacity texture input component
  141371. */
  141372. get opacityTexture(): NodeMaterialConnectionPoint;
  141373. /**
  141374. * Gets the ambient color input component
  141375. */
  141376. get ambientColor(): NodeMaterialConnectionPoint;
  141377. /**
  141378. * Gets the reflectivity object parameters
  141379. */
  141380. get reflectivity(): NodeMaterialConnectionPoint;
  141381. /**
  141382. * Gets the ambient occlusion object parameters
  141383. */
  141384. get ambientOcclusion(): NodeMaterialConnectionPoint;
  141385. /**
  141386. * Gets the reflection object parameters
  141387. */
  141388. get reflection(): NodeMaterialConnectionPoint;
  141389. /**
  141390. * Gets the sheen object parameters
  141391. */
  141392. get sheen(): NodeMaterialConnectionPoint;
  141393. /**
  141394. * Gets the clear coat object parameters
  141395. */
  141396. get clearcoat(): NodeMaterialConnectionPoint;
  141397. /**
  141398. * Gets the sub surface object parameters
  141399. */
  141400. get subsurface(): NodeMaterialConnectionPoint;
  141401. /**
  141402. * Gets the anisotropy object parameters
  141403. */
  141404. get anisotropy(): NodeMaterialConnectionPoint;
  141405. /**
  141406. * Gets the ambient output component
  141407. */
  141408. get ambient(): NodeMaterialConnectionPoint;
  141409. /**
  141410. * Gets the diffuse output component
  141411. */
  141412. get diffuse(): NodeMaterialConnectionPoint;
  141413. /**
  141414. * Gets the specular output component
  141415. */
  141416. get specular(): NodeMaterialConnectionPoint;
  141417. /**
  141418. * Gets the sheen output component
  141419. */
  141420. get sheenDir(): NodeMaterialConnectionPoint;
  141421. /**
  141422. * Gets the clear coat output component
  141423. */
  141424. get clearcoatDir(): NodeMaterialConnectionPoint;
  141425. /**
  141426. * Gets the indirect diffuse output component
  141427. */
  141428. get diffuseIndirect(): NodeMaterialConnectionPoint;
  141429. /**
  141430. * Gets the indirect specular output component
  141431. */
  141432. get specularIndirect(): NodeMaterialConnectionPoint;
  141433. /**
  141434. * Gets the indirect sheen output component
  141435. */
  141436. get sheenIndirect(): NodeMaterialConnectionPoint;
  141437. /**
  141438. * Gets the indirect clear coat output component
  141439. */
  141440. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  141441. /**
  141442. * Gets the refraction output component
  141443. */
  141444. get refraction(): NodeMaterialConnectionPoint;
  141445. /**
  141446. * Gets the global lighting output component
  141447. */
  141448. get lighting(): NodeMaterialConnectionPoint;
  141449. /**
  141450. * Gets the shadow output component
  141451. */
  141452. get shadow(): NodeMaterialConnectionPoint;
  141453. /**
  141454. * Gets the alpha output component
  141455. */
  141456. get alpha(): NodeMaterialConnectionPoint;
  141457. autoConfigure(material: NodeMaterial): void;
  141458. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141459. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  141460. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141461. private _injectVertexCode;
  141462. /**
  141463. * Gets the code corresponding to the albedo/opacity module
  141464. * @returns the shader code
  141465. */
  141466. getAlbedoOpacityCode(): string;
  141467. protected _buildBlock(state: NodeMaterialBuildState): this;
  141468. protected _dumpPropertiesCode(): string;
  141469. serialize(): any;
  141470. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141471. }
  141472. }
  141473. declare module BABYLON {
  141474. /**
  141475. * Block used to compute value of one parameter modulo another
  141476. */
  141477. export class ModBlock extends NodeMaterialBlock {
  141478. /**
  141479. * Creates a new ModBlock
  141480. * @param name defines the block name
  141481. */
  141482. constructor(name: string);
  141483. /**
  141484. * Gets the current class name
  141485. * @returns the class name
  141486. */
  141487. getClassName(): string;
  141488. /**
  141489. * Gets the left operand input component
  141490. */
  141491. get left(): NodeMaterialConnectionPoint;
  141492. /**
  141493. * Gets the right operand input component
  141494. */
  141495. get right(): NodeMaterialConnectionPoint;
  141496. /**
  141497. * Gets the output component
  141498. */
  141499. get output(): NodeMaterialConnectionPoint;
  141500. protected _buildBlock(state: NodeMaterialBuildState): this;
  141501. }
  141502. }
  141503. declare module BABYLON {
  141504. /**
  141505. * Helper class to push actions to a pool of workers.
  141506. */
  141507. export class WorkerPool implements IDisposable {
  141508. private _workerInfos;
  141509. private _pendingActions;
  141510. /**
  141511. * Constructor
  141512. * @param workers Array of workers to use for actions
  141513. */
  141514. constructor(workers: Array<Worker>);
  141515. /**
  141516. * Terminates all workers and clears any pending actions.
  141517. */
  141518. dispose(): void;
  141519. /**
  141520. * Pushes an action to the worker pool. If all the workers are active, the action will be
  141521. * pended until a worker has completed its action.
  141522. * @param action The action to perform. Call onComplete when the action is complete.
  141523. */
  141524. push(action: (worker: Worker, onComplete: () => void) => void): void;
  141525. private _execute;
  141526. }
  141527. }
  141528. declare module BABYLON {
  141529. /**
  141530. * Configuration for Draco compression
  141531. */
  141532. export interface IDracoCompressionConfiguration {
  141533. /**
  141534. * Configuration for the decoder.
  141535. */
  141536. decoder: {
  141537. /**
  141538. * The url to the WebAssembly module.
  141539. */
  141540. wasmUrl?: string;
  141541. /**
  141542. * The url to the WebAssembly binary.
  141543. */
  141544. wasmBinaryUrl?: string;
  141545. /**
  141546. * The url to the fallback JavaScript module.
  141547. */
  141548. fallbackUrl?: string;
  141549. };
  141550. }
  141551. /**
  141552. * Draco compression (https://google.github.io/draco/)
  141553. *
  141554. * This class wraps the Draco module.
  141555. *
  141556. * **Encoder**
  141557. *
  141558. * The encoder is not currently implemented.
  141559. *
  141560. * **Decoder**
  141561. *
  141562. * 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.
  141563. *
  141564. * To update the configuration, use the following code:
  141565. * ```javascript
  141566. * DracoCompression.Configuration = {
  141567. * decoder: {
  141568. * wasmUrl: "<url to the WebAssembly library>",
  141569. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  141570. * fallbackUrl: "<url to the fallback JavaScript library>",
  141571. * }
  141572. * };
  141573. * ```
  141574. *
  141575. * 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.
  141576. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  141577. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  141578. *
  141579. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  141580. * ```javascript
  141581. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  141582. * ```
  141583. *
  141584. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  141585. */
  141586. export class DracoCompression implements IDisposable {
  141587. private _workerPoolPromise?;
  141588. private _decoderModulePromise?;
  141589. /**
  141590. * The configuration. Defaults to the following urls:
  141591. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  141592. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  141593. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  141594. */
  141595. static Configuration: IDracoCompressionConfiguration;
  141596. /**
  141597. * Returns true if the decoder configuration is available.
  141598. */
  141599. static get DecoderAvailable(): boolean;
  141600. /**
  141601. * Default number of workers to create when creating the draco compression object.
  141602. */
  141603. static DefaultNumWorkers: number;
  141604. private static GetDefaultNumWorkers;
  141605. private static _Default;
  141606. /**
  141607. * Default instance for the draco compression object.
  141608. */
  141609. static get Default(): DracoCompression;
  141610. /**
  141611. * Constructor
  141612. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  141613. */
  141614. constructor(numWorkers?: number);
  141615. /**
  141616. * Stop all async operations and release resources.
  141617. */
  141618. dispose(): void;
  141619. /**
  141620. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  141621. * @returns a promise that resolves when ready
  141622. */
  141623. whenReadyAsync(): Promise<void>;
  141624. /**
  141625. * Decode Draco compressed mesh data to vertex data.
  141626. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  141627. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  141628. * @returns A promise that resolves with the decoded vertex data
  141629. */
  141630. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  141631. [kind: string]: number;
  141632. }): Promise<VertexData>;
  141633. }
  141634. }
  141635. declare module BABYLON {
  141636. /**
  141637. * Class for building Constructive Solid Geometry
  141638. */
  141639. export class CSG {
  141640. private polygons;
  141641. /**
  141642. * The world matrix
  141643. */
  141644. matrix: Matrix;
  141645. /**
  141646. * Stores the position
  141647. */
  141648. position: Vector3;
  141649. /**
  141650. * Stores the rotation
  141651. */
  141652. rotation: Vector3;
  141653. /**
  141654. * Stores the rotation quaternion
  141655. */
  141656. rotationQuaternion: Nullable<Quaternion>;
  141657. /**
  141658. * Stores the scaling vector
  141659. */
  141660. scaling: Vector3;
  141661. /**
  141662. * Convert the Mesh to CSG
  141663. * @param mesh The Mesh to convert to CSG
  141664. * @returns A new CSG from the Mesh
  141665. */
  141666. static FromMesh(mesh: Mesh): CSG;
  141667. /**
  141668. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  141669. * @param polygons Polygons used to construct a CSG solid
  141670. */
  141671. private static FromPolygons;
  141672. /**
  141673. * Clones, or makes a deep copy, of the CSG
  141674. * @returns A new CSG
  141675. */
  141676. clone(): CSG;
  141677. /**
  141678. * Unions this CSG with another CSG
  141679. * @param csg The CSG to union against this CSG
  141680. * @returns The unioned CSG
  141681. */
  141682. union(csg: CSG): CSG;
  141683. /**
  141684. * Unions this CSG with another CSG in place
  141685. * @param csg The CSG to union against this CSG
  141686. */
  141687. unionInPlace(csg: CSG): void;
  141688. /**
  141689. * Subtracts this CSG with another CSG
  141690. * @param csg The CSG to subtract against this CSG
  141691. * @returns A new CSG
  141692. */
  141693. subtract(csg: CSG): CSG;
  141694. /**
  141695. * Subtracts this CSG with another CSG in place
  141696. * @param csg The CSG to subtact against this CSG
  141697. */
  141698. subtractInPlace(csg: CSG): void;
  141699. /**
  141700. * Intersect this CSG with another CSG
  141701. * @param csg The CSG to intersect against this CSG
  141702. * @returns A new CSG
  141703. */
  141704. intersect(csg: CSG): CSG;
  141705. /**
  141706. * Intersects this CSG with another CSG in place
  141707. * @param csg The CSG to intersect against this CSG
  141708. */
  141709. intersectInPlace(csg: CSG): void;
  141710. /**
  141711. * Return a new CSG solid with solid and empty space switched. This solid is
  141712. * not modified.
  141713. * @returns A new CSG solid with solid and empty space switched
  141714. */
  141715. inverse(): CSG;
  141716. /**
  141717. * Inverses the CSG in place
  141718. */
  141719. inverseInPlace(): void;
  141720. /**
  141721. * This is used to keep meshes transformations so they can be restored
  141722. * when we build back a Babylon Mesh
  141723. * NB : All CSG operations are performed in world coordinates
  141724. * @param csg The CSG to copy the transform attributes from
  141725. * @returns This CSG
  141726. */
  141727. copyTransformAttributes(csg: CSG): CSG;
  141728. /**
  141729. * Build Raw mesh from CSG
  141730. * Coordinates here are in world space
  141731. * @param name The name of the mesh geometry
  141732. * @param scene The Scene
  141733. * @param keepSubMeshes Specifies if the submeshes should be kept
  141734. * @returns A new Mesh
  141735. */
  141736. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  141737. /**
  141738. * Build Mesh from CSG taking material and transforms into account
  141739. * @param name The name of the Mesh
  141740. * @param material The material of the Mesh
  141741. * @param scene The Scene
  141742. * @param keepSubMeshes Specifies if submeshes should be kept
  141743. * @returns The new Mesh
  141744. */
  141745. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  141746. }
  141747. }
  141748. declare module BABYLON {
  141749. /**
  141750. * Class used to create a trail following a mesh
  141751. */
  141752. export class TrailMesh extends Mesh {
  141753. private _generator;
  141754. private _autoStart;
  141755. private _running;
  141756. private _diameter;
  141757. private _length;
  141758. private _sectionPolygonPointsCount;
  141759. private _sectionVectors;
  141760. private _sectionNormalVectors;
  141761. private _beforeRenderObserver;
  141762. /**
  141763. * @constructor
  141764. * @param name The value used by scene.getMeshByName() to do a lookup.
  141765. * @param generator The mesh or transform node to generate a trail.
  141766. * @param scene The scene to add this mesh to.
  141767. * @param diameter Diameter of trailing mesh. Default is 1.
  141768. * @param length Length of trailing mesh. Default is 60.
  141769. * @param autoStart Automatically start trailing mesh. Default true.
  141770. */
  141771. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  141772. /**
  141773. * "TrailMesh"
  141774. * @returns "TrailMesh"
  141775. */
  141776. getClassName(): string;
  141777. private _createMesh;
  141778. /**
  141779. * Start trailing mesh.
  141780. */
  141781. start(): void;
  141782. /**
  141783. * Stop trailing mesh.
  141784. */
  141785. stop(): void;
  141786. /**
  141787. * Update trailing mesh geometry.
  141788. */
  141789. update(): void;
  141790. /**
  141791. * Returns a new TrailMesh object.
  141792. * @param name is a string, the name given to the new mesh
  141793. * @param newGenerator use new generator object for cloned trail mesh
  141794. * @returns a new mesh
  141795. */
  141796. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  141797. /**
  141798. * Serializes this trail mesh
  141799. * @param serializationObject object to write serialization to
  141800. */
  141801. serialize(serializationObject: any): void;
  141802. /**
  141803. * Parses a serialized trail mesh
  141804. * @param parsedMesh the serialized mesh
  141805. * @param scene the scene to create the trail mesh in
  141806. * @returns the created trail mesh
  141807. */
  141808. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  141809. }
  141810. }
  141811. declare module BABYLON {
  141812. /**
  141813. * Class containing static functions to help procedurally build meshes
  141814. */
  141815. export class TiledBoxBuilder {
  141816. /**
  141817. * Creates a box mesh
  141818. * 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)
  141819. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  141820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141821. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141823. * @param name defines the name of the mesh
  141824. * @param options defines the options used to create the mesh
  141825. * @param scene defines the hosting scene
  141826. * @returns the box mesh
  141827. */
  141828. static CreateTiledBox(name: string, options: {
  141829. pattern?: number;
  141830. width?: number;
  141831. height?: number;
  141832. depth?: number;
  141833. tileSize?: number;
  141834. tileWidth?: number;
  141835. tileHeight?: number;
  141836. alignHorizontal?: number;
  141837. alignVertical?: number;
  141838. faceUV?: Vector4[];
  141839. faceColors?: Color4[];
  141840. sideOrientation?: number;
  141841. updatable?: boolean;
  141842. }, scene?: Nullable<Scene>): Mesh;
  141843. }
  141844. }
  141845. declare module BABYLON {
  141846. /**
  141847. * Class containing static functions to help procedurally build meshes
  141848. */
  141849. export class TorusKnotBuilder {
  141850. /**
  141851. * Creates a torus knot mesh
  141852. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  141853. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  141854. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  141855. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  141856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141857. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141859. * @param name defines the name of the mesh
  141860. * @param options defines the options used to create the mesh
  141861. * @param scene defines the hosting scene
  141862. * @returns the torus knot mesh
  141863. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  141864. */
  141865. static CreateTorusKnot(name: string, options: {
  141866. radius?: number;
  141867. tube?: number;
  141868. radialSegments?: number;
  141869. tubularSegments?: number;
  141870. p?: number;
  141871. q?: number;
  141872. updatable?: boolean;
  141873. sideOrientation?: number;
  141874. frontUVs?: Vector4;
  141875. backUVs?: Vector4;
  141876. }, scene: any): Mesh;
  141877. }
  141878. }
  141879. declare module BABYLON {
  141880. /**
  141881. * Polygon
  141882. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  141883. */
  141884. export class Polygon {
  141885. /**
  141886. * Creates a rectangle
  141887. * @param xmin bottom X coord
  141888. * @param ymin bottom Y coord
  141889. * @param xmax top X coord
  141890. * @param ymax top Y coord
  141891. * @returns points that make the resulting rectation
  141892. */
  141893. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  141894. /**
  141895. * Creates a circle
  141896. * @param radius radius of circle
  141897. * @param cx scale in x
  141898. * @param cy scale in y
  141899. * @param numberOfSides number of sides that make up the circle
  141900. * @returns points that make the resulting circle
  141901. */
  141902. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  141903. /**
  141904. * Creates a polygon from input string
  141905. * @param input Input polygon data
  141906. * @returns the parsed points
  141907. */
  141908. static Parse(input: string): Vector2[];
  141909. /**
  141910. * Starts building a polygon from x and y coordinates
  141911. * @param x x coordinate
  141912. * @param y y coordinate
  141913. * @returns the started path2
  141914. */
  141915. static StartingAt(x: number, y: number): Path2;
  141916. }
  141917. /**
  141918. * Builds a polygon
  141919. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  141920. */
  141921. export class PolygonMeshBuilder {
  141922. private _points;
  141923. private _outlinepoints;
  141924. private _holes;
  141925. private _name;
  141926. private _scene;
  141927. private _epoints;
  141928. private _eholes;
  141929. private _addToepoint;
  141930. /**
  141931. * Babylon reference to the earcut plugin.
  141932. */
  141933. bjsEarcut: any;
  141934. /**
  141935. * Creates a PolygonMeshBuilder
  141936. * @param name name of the builder
  141937. * @param contours Path of the polygon
  141938. * @param scene scene to add to when creating the mesh
  141939. * @param earcutInjection can be used to inject your own earcut reference
  141940. */
  141941. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  141942. /**
  141943. * Adds a whole within the polygon
  141944. * @param hole Array of points defining the hole
  141945. * @returns this
  141946. */
  141947. addHole(hole: Vector2[]): PolygonMeshBuilder;
  141948. /**
  141949. * Creates the polygon
  141950. * @param updatable If the mesh should be updatable
  141951. * @param depth The depth of the mesh created
  141952. * @returns the created mesh
  141953. */
  141954. build(updatable?: boolean, depth?: number): Mesh;
  141955. /**
  141956. * Creates the polygon
  141957. * @param depth The depth of the mesh created
  141958. * @returns the created VertexData
  141959. */
  141960. buildVertexData(depth?: number): VertexData;
  141961. /**
  141962. * Adds a side to the polygon
  141963. * @param positions points that make the polygon
  141964. * @param normals normals of the polygon
  141965. * @param uvs uvs of the polygon
  141966. * @param indices indices of the polygon
  141967. * @param bounds bounds of the polygon
  141968. * @param points points of the polygon
  141969. * @param depth depth of the polygon
  141970. * @param flip flip of the polygon
  141971. */
  141972. private addSide;
  141973. }
  141974. }
  141975. declare module BABYLON {
  141976. /**
  141977. * Class containing static functions to help procedurally build meshes
  141978. */
  141979. export class PolygonBuilder {
  141980. /**
  141981. * Creates a polygon mesh
  141982. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  141983. * * 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
  141984. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  141985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141986. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  141987. * * Remember you can only change the shape positions, not their number when updating a polygon
  141988. * @param name defines the name of the mesh
  141989. * @param options defines the options used to create the mesh
  141990. * @param scene defines the hosting scene
  141991. * @param earcutInjection can be used to inject your own earcut reference
  141992. * @returns the polygon mesh
  141993. */
  141994. static CreatePolygon(name: string, options: {
  141995. shape: Vector3[];
  141996. holes?: Vector3[][];
  141997. depth?: number;
  141998. faceUV?: Vector4[];
  141999. faceColors?: Color4[];
  142000. updatable?: boolean;
  142001. sideOrientation?: number;
  142002. frontUVs?: Vector4;
  142003. backUVs?: Vector4;
  142004. wrap?: boolean;
  142005. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142006. /**
  142007. * Creates an extruded polygon mesh, with depth in the Y direction.
  142008. * * 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)
  142009. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142010. * @param name defines the name of the mesh
  142011. * @param options defines the options used to create the mesh
  142012. * @param scene defines the hosting scene
  142013. * @param earcutInjection can be used to inject your own earcut reference
  142014. * @returns the polygon mesh
  142015. */
  142016. static ExtrudePolygon(name: string, options: {
  142017. shape: Vector3[];
  142018. holes?: Vector3[][];
  142019. depth?: number;
  142020. faceUV?: Vector4[];
  142021. faceColors?: Color4[];
  142022. updatable?: boolean;
  142023. sideOrientation?: number;
  142024. frontUVs?: Vector4;
  142025. backUVs?: Vector4;
  142026. wrap?: boolean;
  142027. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142028. }
  142029. }
  142030. declare module BABYLON {
  142031. /**
  142032. * Class containing static functions to help procedurally build meshes
  142033. */
  142034. export class LatheBuilder {
  142035. /**
  142036. * Creates lathe mesh.
  142037. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  142038. * * 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
  142039. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  142040. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  142041. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  142042. * * 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
  142043. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  142044. * * 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
  142045. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142046. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142047. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142049. * @param name defines the name of the mesh
  142050. * @param options defines the options used to create the mesh
  142051. * @param scene defines the hosting scene
  142052. * @returns the lathe mesh
  142053. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  142054. */
  142055. static CreateLathe(name: string, options: {
  142056. shape: Vector3[];
  142057. radius?: number;
  142058. tessellation?: number;
  142059. clip?: number;
  142060. arc?: number;
  142061. closed?: boolean;
  142062. updatable?: boolean;
  142063. sideOrientation?: number;
  142064. frontUVs?: Vector4;
  142065. backUVs?: Vector4;
  142066. cap?: number;
  142067. invertUV?: boolean;
  142068. }, scene?: Nullable<Scene>): Mesh;
  142069. }
  142070. }
  142071. declare module BABYLON {
  142072. /**
  142073. * Class containing static functions to help procedurally build meshes
  142074. */
  142075. export class TiledPlaneBuilder {
  142076. /**
  142077. * Creates a tiled plane mesh
  142078. * * The parameter `pattern` will, depending on value, do nothing or
  142079. * * * flip (reflect about central vertical) alternate tiles across and up
  142080. * * * flip every tile on alternate rows
  142081. * * * rotate (180 degs) alternate tiles across and up
  142082. * * * rotate every tile on alternate rows
  142083. * * * flip and rotate alternate tiles across and up
  142084. * * * flip and rotate every tile on alternate rows
  142085. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  142086. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  142087. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142088. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  142089. * * 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)
  142090. * * 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)
  142091. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  142092. * @param name defines the name of the mesh
  142093. * @param options defines the options used to create the mesh
  142094. * @param scene defines the hosting scene
  142095. * @returns the box mesh
  142096. */
  142097. static CreateTiledPlane(name: string, options: {
  142098. pattern?: number;
  142099. tileSize?: number;
  142100. tileWidth?: number;
  142101. tileHeight?: number;
  142102. size?: number;
  142103. width?: number;
  142104. height?: number;
  142105. alignHorizontal?: number;
  142106. alignVertical?: number;
  142107. sideOrientation?: number;
  142108. frontUVs?: Vector4;
  142109. backUVs?: Vector4;
  142110. updatable?: boolean;
  142111. }, scene?: Nullable<Scene>): Mesh;
  142112. }
  142113. }
  142114. declare module BABYLON {
  142115. /**
  142116. * Class containing static functions to help procedurally build meshes
  142117. */
  142118. export class TubeBuilder {
  142119. /**
  142120. * Creates a tube mesh.
  142121. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  142122. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  142123. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  142124. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  142125. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  142126. * * 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)
  142127. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  142128. * * 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
  142129. * * 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
  142130. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142131. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142132. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142134. * @param name defines the name of the mesh
  142135. * @param options defines the options used to create the mesh
  142136. * @param scene defines the hosting scene
  142137. * @returns the tube mesh
  142138. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142139. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  142140. */
  142141. static CreateTube(name: string, options: {
  142142. path: Vector3[];
  142143. radius?: number;
  142144. tessellation?: number;
  142145. radiusFunction?: {
  142146. (i: number, distance: number): number;
  142147. };
  142148. cap?: number;
  142149. arc?: number;
  142150. updatable?: boolean;
  142151. sideOrientation?: number;
  142152. frontUVs?: Vector4;
  142153. backUVs?: Vector4;
  142154. instance?: Mesh;
  142155. invertUV?: boolean;
  142156. }, scene?: Nullable<Scene>): Mesh;
  142157. }
  142158. }
  142159. declare module BABYLON {
  142160. /**
  142161. * Class containing static functions to help procedurally build meshes
  142162. */
  142163. export class IcoSphereBuilder {
  142164. /**
  142165. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  142166. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  142167. * * 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`)
  142168. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  142169. * * 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
  142170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142171. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142173. * @param name defines the name of the mesh
  142174. * @param options defines the options used to create the mesh
  142175. * @param scene defines the hosting scene
  142176. * @returns the icosahedron mesh
  142177. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  142178. */
  142179. static CreateIcoSphere(name: string, options: {
  142180. radius?: number;
  142181. radiusX?: number;
  142182. radiusY?: number;
  142183. radiusZ?: number;
  142184. flat?: boolean;
  142185. subdivisions?: number;
  142186. sideOrientation?: number;
  142187. frontUVs?: Vector4;
  142188. backUVs?: Vector4;
  142189. updatable?: boolean;
  142190. }, scene?: Nullable<Scene>): Mesh;
  142191. }
  142192. }
  142193. declare module BABYLON {
  142194. /**
  142195. * Class containing static functions to help procedurally build meshes
  142196. */
  142197. export class DecalBuilder {
  142198. /**
  142199. * Creates a decal mesh.
  142200. * 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
  142201. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  142202. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  142203. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  142204. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  142205. * @param name defines the name of the mesh
  142206. * @param sourceMesh defines the mesh where the decal must be applied
  142207. * @param options defines the options used to create the mesh
  142208. * @param scene defines the hosting scene
  142209. * @returns the decal mesh
  142210. * @see https://doc.babylonjs.com/how_to/decals
  142211. */
  142212. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  142213. position?: Vector3;
  142214. normal?: Vector3;
  142215. size?: Vector3;
  142216. angle?: number;
  142217. }): Mesh;
  142218. }
  142219. }
  142220. declare module BABYLON {
  142221. /**
  142222. * Class containing static functions to help procedurally build meshes
  142223. */
  142224. export class MeshBuilder {
  142225. /**
  142226. * Creates a box mesh
  142227. * * The parameter `size` sets the size (float) of each box side (default 1)
  142228. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  142229. * * 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)
  142230. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142232. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142234. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  142235. * @param name defines the name of the mesh
  142236. * @param options defines the options used to create the mesh
  142237. * @param scene defines the hosting scene
  142238. * @returns the box mesh
  142239. */
  142240. static CreateBox(name: string, options: {
  142241. size?: number;
  142242. width?: number;
  142243. height?: number;
  142244. depth?: number;
  142245. faceUV?: Vector4[];
  142246. faceColors?: Color4[];
  142247. sideOrientation?: number;
  142248. frontUVs?: Vector4;
  142249. backUVs?: Vector4;
  142250. wrap?: boolean;
  142251. topBaseAt?: number;
  142252. bottomBaseAt?: number;
  142253. updatable?: boolean;
  142254. }, scene?: Nullable<Scene>): Mesh;
  142255. /**
  142256. * Creates a tiled box mesh
  142257. * * faceTiles sets the pattern, tile size and number of tiles for a face
  142258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142259. * @param name defines the name of the mesh
  142260. * @param options defines the options used to create the mesh
  142261. * @param scene defines the hosting scene
  142262. * @returns the tiled box mesh
  142263. */
  142264. static CreateTiledBox(name: string, options: {
  142265. pattern?: number;
  142266. size?: number;
  142267. width?: number;
  142268. height?: number;
  142269. depth: number;
  142270. tileSize?: number;
  142271. tileWidth?: number;
  142272. tileHeight?: number;
  142273. faceUV?: Vector4[];
  142274. faceColors?: Color4[];
  142275. alignHorizontal?: number;
  142276. alignVertical?: number;
  142277. sideOrientation?: number;
  142278. updatable?: boolean;
  142279. }, scene?: Nullable<Scene>): Mesh;
  142280. /**
  142281. * Creates a sphere mesh
  142282. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  142283. * * 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`)
  142284. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  142285. * * 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
  142286. * * 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)
  142287. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142288. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142290. * @param name defines the name of the mesh
  142291. * @param options defines the options used to create the mesh
  142292. * @param scene defines the hosting scene
  142293. * @returns the sphere mesh
  142294. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  142295. */
  142296. static CreateSphere(name: string, options: {
  142297. segments?: number;
  142298. diameter?: number;
  142299. diameterX?: number;
  142300. diameterY?: number;
  142301. diameterZ?: number;
  142302. arc?: number;
  142303. slice?: number;
  142304. sideOrientation?: number;
  142305. frontUVs?: Vector4;
  142306. backUVs?: Vector4;
  142307. updatable?: boolean;
  142308. }, scene?: Nullable<Scene>): Mesh;
  142309. /**
  142310. * Creates a plane polygonal mesh. By default, this is a disc
  142311. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  142312. * * 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
  142313. * * 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
  142314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142315. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142317. * @param name defines the name of the mesh
  142318. * @param options defines the options used to create the mesh
  142319. * @param scene defines the hosting scene
  142320. * @returns the plane polygonal mesh
  142321. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  142322. */
  142323. static CreateDisc(name: string, options: {
  142324. radius?: number;
  142325. tessellation?: number;
  142326. arc?: number;
  142327. updatable?: boolean;
  142328. sideOrientation?: number;
  142329. frontUVs?: Vector4;
  142330. backUVs?: Vector4;
  142331. }, scene?: Nullable<Scene>): Mesh;
  142332. /**
  142333. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  142334. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  142335. * * 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`)
  142336. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  142337. * * 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
  142338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142339. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142341. * @param name defines the name of the mesh
  142342. * @param options defines the options used to create the mesh
  142343. * @param scene defines the hosting scene
  142344. * @returns the icosahedron mesh
  142345. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  142346. */
  142347. static CreateIcoSphere(name: string, options: {
  142348. radius?: number;
  142349. radiusX?: number;
  142350. radiusY?: number;
  142351. radiusZ?: number;
  142352. flat?: boolean;
  142353. subdivisions?: number;
  142354. sideOrientation?: number;
  142355. frontUVs?: Vector4;
  142356. backUVs?: Vector4;
  142357. updatable?: boolean;
  142358. }, scene?: Nullable<Scene>): Mesh;
  142359. /**
  142360. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  142361. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  142362. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  142363. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  142364. * * 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
  142365. * * 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
  142366. * * 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
  142367. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142368. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142369. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142370. * * 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
  142371. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  142372. * * 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
  142373. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  142374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142375. * @param name defines the name of the mesh
  142376. * @param options defines the options used to create the mesh
  142377. * @param scene defines the hosting scene
  142378. * @returns the ribbon mesh
  142379. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  142380. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142381. */
  142382. static CreateRibbon(name: string, options: {
  142383. pathArray: Vector3[][];
  142384. closeArray?: boolean;
  142385. closePath?: boolean;
  142386. offset?: number;
  142387. updatable?: boolean;
  142388. sideOrientation?: number;
  142389. frontUVs?: Vector4;
  142390. backUVs?: Vector4;
  142391. instance?: Mesh;
  142392. invertUV?: boolean;
  142393. uvs?: Vector2[];
  142394. colors?: Color4[];
  142395. }, scene?: Nullable<Scene>): Mesh;
  142396. /**
  142397. * Creates a cylinder or a cone mesh
  142398. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  142399. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  142400. * * 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.
  142401. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  142402. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  142403. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  142404. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  142405. * * 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).
  142406. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  142407. * * 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).
  142408. * * 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
  142409. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  142410. * * 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
  142411. * * 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.
  142412. * * If `enclose` is false, a ring surface is one element.
  142413. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  142414. * * 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
  142415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142416. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142418. * @param name defines the name of the mesh
  142419. * @param options defines the options used to create the mesh
  142420. * @param scene defines the hosting scene
  142421. * @returns the cylinder mesh
  142422. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  142423. */
  142424. static CreateCylinder(name: string, options: {
  142425. height?: number;
  142426. diameterTop?: number;
  142427. diameterBottom?: number;
  142428. diameter?: number;
  142429. tessellation?: number;
  142430. subdivisions?: number;
  142431. arc?: number;
  142432. faceColors?: Color4[];
  142433. faceUV?: Vector4[];
  142434. updatable?: boolean;
  142435. hasRings?: boolean;
  142436. enclose?: boolean;
  142437. cap?: number;
  142438. sideOrientation?: number;
  142439. frontUVs?: Vector4;
  142440. backUVs?: Vector4;
  142441. }, scene?: Nullable<Scene>): Mesh;
  142442. /**
  142443. * Creates a torus mesh
  142444. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  142445. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  142446. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  142447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142448. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142450. * @param name defines the name of the mesh
  142451. * @param options defines the options used to create the mesh
  142452. * @param scene defines the hosting scene
  142453. * @returns the torus mesh
  142454. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  142455. */
  142456. static CreateTorus(name: string, options: {
  142457. diameter?: number;
  142458. thickness?: number;
  142459. tessellation?: number;
  142460. updatable?: boolean;
  142461. sideOrientation?: number;
  142462. frontUVs?: Vector4;
  142463. backUVs?: Vector4;
  142464. }, scene?: Nullable<Scene>): Mesh;
  142465. /**
  142466. * Creates a torus knot mesh
  142467. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  142468. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  142469. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  142470. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  142471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142472. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142474. * @param name defines the name of the mesh
  142475. * @param options defines the options used to create the mesh
  142476. * @param scene defines the hosting scene
  142477. * @returns the torus knot mesh
  142478. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  142479. */
  142480. static CreateTorusKnot(name: string, options: {
  142481. radius?: number;
  142482. tube?: number;
  142483. radialSegments?: number;
  142484. tubularSegments?: number;
  142485. p?: number;
  142486. q?: number;
  142487. updatable?: boolean;
  142488. sideOrientation?: number;
  142489. frontUVs?: Vector4;
  142490. backUVs?: Vector4;
  142491. }, scene?: Nullable<Scene>): Mesh;
  142492. /**
  142493. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  142494. * * 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
  142495. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  142496. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  142497. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  142498. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  142499. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  142500. * * 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
  142501. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  142502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142503. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  142504. * @param name defines the name of the new line system
  142505. * @param options defines the options used to create the line system
  142506. * @param scene defines the hosting scene
  142507. * @returns a new line system mesh
  142508. */
  142509. static CreateLineSystem(name: string, options: {
  142510. lines: Vector3[][];
  142511. updatable?: boolean;
  142512. instance?: Nullable<LinesMesh>;
  142513. colors?: Nullable<Color4[][]>;
  142514. useVertexAlpha?: boolean;
  142515. }, scene: Nullable<Scene>): LinesMesh;
  142516. /**
  142517. * Creates a line mesh
  142518. * 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
  142519. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  142520. * * The parameter `points` is an array successive Vector3
  142521. * * 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
  142522. * * The optional parameter `colors` is an array of successive Color4, one per line point
  142523. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  142524. * * When updating an instance, remember that only point positions can change, not the number of points
  142525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142526. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  142527. * @param name defines the name of the new line system
  142528. * @param options defines the options used to create the line system
  142529. * @param scene defines the hosting scene
  142530. * @returns a new line mesh
  142531. */
  142532. static CreateLines(name: string, options: {
  142533. points: Vector3[];
  142534. updatable?: boolean;
  142535. instance?: Nullable<LinesMesh>;
  142536. colors?: Color4[];
  142537. useVertexAlpha?: boolean;
  142538. }, scene?: Nullable<Scene>): LinesMesh;
  142539. /**
  142540. * Creates a dashed line mesh
  142541. * * 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
  142542. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  142543. * * The parameter `points` is an array successive Vector3
  142544. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  142545. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  142546. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  142547. * * 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
  142548. * * When updating an instance, remember that only point positions can change, not the number of points
  142549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142550. * @param name defines the name of the mesh
  142551. * @param options defines the options used to create the mesh
  142552. * @param scene defines the hosting scene
  142553. * @returns the dashed line mesh
  142554. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  142555. */
  142556. static CreateDashedLines(name: string, options: {
  142557. points: Vector3[];
  142558. dashSize?: number;
  142559. gapSize?: number;
  142560. dashNb?: number;
  142561. updatable?: boolean;
  142562. instance?: LinesMesh;
  142563. }, scene?: Nullable<Scene>): LinesMesh;
  142564. /**
  142565. * 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.
  142566. * * 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.
  142567. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  142568. * * 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.
  142569. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  142570. * * 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
  142571. * * 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
  142572. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  142573. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142574. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142575. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  142576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142577. * @param name defines the name of the mesh
  142578. * @param options defines the options used to create the mesh
  142579. * @param scene defines the hosting scene
  142580. * @returns the extruded shape mesh
  142581. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142582. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  142583. */
  142584. static ExtrudeShape(name: string, options: {
  142585. shape: Vector3[];
  142586. path: Vector3[];
  142587. scale?: number;
  142588. rotation?: number;
  142589. cap?: number;
  142590. updatable?: boolean;
  142591. sideOrientation?: number;
  142592. frontUVs?: Vector4;
  142593. backUVs?: Vector4;
  142594. instance?: Mesh;
  142595. invertUV?: boolean;
  142596. }, scene?: Nullable<Scene>): Mesh;
  142597. /**
  142598. * Creates an custom extruded shape mesh.
  142599. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  142600. * * 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.
  142601. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  142602. * * 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
  142603. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  142604. * * 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
  142605. * * It must returns a float value that will be the scale value applied to the shape on each path point
  142606. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  142607. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  142608. * * 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
  142609. * * 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
  142610. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  142611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142612. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142613. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142615. * @param name defines the name of the mesh
  142616. * @param options defines the options used to create the mesh
  142617. * @param scene defines the hosting scene
  142618. * @returns the custom extruded shape mesh
  142619. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  142620. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142621. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  142622. */
  142623. static ExtrudeShapeCustom(name: string, options: {
  142624. shape: Vector3[];
  142625. path: Vector3[];
  142626. scaleFunction?: any;
  142627. rotationFunction?: any;
  142628. ribbonCloseArray?: boolean;
  142629. ribbonClosePath?: boolean;
  142630. cap?: number;
  142631. updatable?: boolean;
  142632. sideOrientation?: number;
  142633. frontUVs?: Vector4;
  142634. backUVs?: Vector4;
  142635. instance?: Mesh;
  142636. invertUV?: boolean;
  142637. }, scene?: Nullable<Scene>): Mesh;
  142638. /**
  142639. * Creates lathe mesh.
  142640. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  142641. * * 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
  142642. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  142643. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  142644. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  142645. * * 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
  142646. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  142647. * * 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
  142648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142649. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142650. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142652. * @param name defines the name of the mesh
  142653. * @param options defines the options used to create the mesh
  142654. * @param scene defines the hosting scene
  142655. * @returns the lathe mesh
  142656. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  142657. */
  142658. static CreateLathe(name: string, options: {
  142659. shape: Vector3[];
  142660. radius?: number;
  142661. tessellation?: number;
  142662. clip?: number;
  142663. arc?: number;
  142664. closed?: boolean;
  142665. updatable?: boolean;
  142666. sideOrientation?: number;
  142667. frontUVs?: Vector4;
  142668. backUVs?: Vector4;
  142669. cap?: number;
  142670. invertUV?: boolean;
  142671. }, scene?: Nullable<Scene>): Mesh;
  142672. /**
  142673. * Creates a tiled plane mesh
  142674. * * You can set a limited pattern arrangement with the tiles
  142675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142676. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142678. * @param name defines the name of the mesh
  142679. * @param options defines the options used to create the mesh
  142680. * @param scene defines the hosting scene
  142681. * @returns the plane mesh
  142682. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  142683. */
  142684. static CreateTiledPlane(name: string, options: {
  142685. pattern?: number;
  142686. tileSize?: number;
  142687. tileWidth?: number;
  142688. tileHeight?: number;
  142689. size?: number;
  142690. width?: number;
  142691. height?: number;
  142692. alignHorizontal?: number;
  142693. alignVertical?: number;
  142694. sideOrientation?: number;
  142695. frontUVs?: Vector4;
  142696. backUVs?: Vector4;
  142697. updatable?: boolean;
  142698. }, scene?: Nullable<Scene>): Mesh;
  142699. /**
  142700. * Creates a plane mesh
  142701. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  142702. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  142703. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  142704. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142705. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142707. * @param name defines the name of the mesh
  142708. * @param options defines the options used to create the mesh
  142709. * @param scene defines the hosting scene
  142710. * @returns the plane mesh
  142711. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  142712. */
  142713. static CreatePlane(name: string, options: {
  142714. size?: number;
  142715. width?: number;
  142716. height?: number;
  142717. sideOrientation?: number;
  142718. frontUVs?: Vector4;
  142719. backUVs?: Vector4;
  142720. updatable?: boolean;
  142721. sourcePlane?: Plane;
  142722. }, scene?: Nullable<Scene>): Mesh;
  142723. /**
  142724. * Creates a ground mesh
  142725. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  142726. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  142727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142728. * @param name defines the name of the mesh
  142729. * @param options defines the options used to create the mesh
  142730. * @param scene defines the hosting scene
  142731. * @returns the ground mesh
  142732. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  142733. */
  142734. static CreateGround(name: string, options: {
  142735. width?: number;
  142736. height?: number;
  142737. subdivisions?: number;
  142738. subdivisionsX?: number;
  142739. subdivisionsY?: number;
  142740. updatable?: boolean;
  142741. }, scene?: Nullable<Scene>): Mesh;
  142742. /**
  142743. * Creates a tiled ground mesh
  142744. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  142745. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  142746. * * 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
  142747. * * 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
  142748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142749. * @param name defines the name of the mesh
  142750. * @param options defines the options used to create the mesh
  142751. * @param scene defines the hosting scene
  142752. * @returns the tiled ground mesh
  142753. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  142754. */
  142755. static CreateTiledGround(name: string, options: {
  142756. xmin: number;
  142757. zmin: number;
  142758. xmax: number;
  142759. zmax: number;
  142760. subdivisions?: {
  142761. w: number;
  142762. h: number;
  142763. };
  142764. precision?: {
  142765. w: number;
  142766. h: number;
  142767. };
  142768. updatable?: boolean;
  142769. }, scene?: Nullable<Scene>): Mesh;
  142770. /**
  142771. * Creates a ground mesh from a height map
  142772. * * The parameter `url` sets the URL of the height map image resource.
  142773. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  142774. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  142775. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  142776. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  142777. * * 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.
  142778. * * 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).
  142779. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  142780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142781. * @param name defines the name of the mesh
  142782. * @param url defines the url to the height map
  142783. * @param options defines the options used to create the mesh
  142784. * @param scene defines the hosting scene
  142785. * @returns the ground mesh
  142786. * @see https://doc.babylonjs.com/babylon101/height_map
  142787. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  142788. */
  142789. static CreateGroundFromHeightMap(name: string, url: string, options: {
  142790. width?: number;
  142791. height?: number;
  142792. subdivisions?: number;
  142793. minHeight?: number;
  142794. maxHeight?: number;
  142795. colorFilter?: Color3;
  142796. alphaFilter?: number;
  142797. updatable?: boolean;
  142798. onReady?: (mesh: GroundMesh) => void;
  142799. }, scene?: Nullable<Scene>): GroundMesh;
  142800. /**
  142801. * Creates a polygon mesh
  142802. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  142803. * * 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
  142804. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  142805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142806. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  142807. * * Remember you can only change the shape positions, not their number when updating a polygon
  142808. * @param name defines the name of the mesh
  142809. * @param options defines the options used to create the mesh
  142810. * @param scene defines the hosting scene
  142811. * @param earcutInjection can be used to inject your own earcut reference
  142812. * @returns the polygon mesh
  142813. */
  142814. static CreatePolygon(name: string, options: {
  142815. shape: Vector3[];
  142816. holes?: Vector3[][];
  142817. depth?: number;
  142818. faceUV?: Vector4[];
  142819. faceColors?: Color4[];
  142820. updatable?: boolean;
  142821. sideOrientation?: number;
  142822. frontUVs?: Vector4;
  142823. backUVs?: Vector4;
  142824. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142825. /**
  142826. * Creates an extruded polygon mesh, with depth in the Y direction.
  142827. * * 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)
  142828. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142829. * @param name defines the name of the mesh
  142830. * @param options defines the options used to create the mesh
  142831. * @param scene defines the hosting scene
  142832. * @param earcutInjection can be used to inject your own earcut reference
  142833. * @returns the polygon mesh
  142834. */
  142835. static ExtrudePolygon(name: string, options: {
  142836. shape: Vector3[];
  142837. holes?: Vector3[][];
  142838. depth?: number;
  142839. faceUV?: Vector4[];
  142840. faceColors?: Color4[];
  142841. updatable?: boolean;
  142842. sideOrientation?: number;
  142843. frontUVs?: Vector4;
  142844. backUVs?: Vector4;
  142845. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142846. /**
  142847. * Creates a tube mesh.
  142848. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  142849. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  142850. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  142851. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  142852. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  142853. * * 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)
  142854. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  142855. * * 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
  142856. * * 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
  142857. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142858. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142859. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142861. * @param name defines the name of the mesh
  142862. * @param options defines the options used to create the mesh
  142863. * @param scene defines the hosting scene
  142864. * @returns the tube mesh
  142865. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142866. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  142867. */
  142868. static CreateTube(name: string, options: {
  142869. path: Vector3[];
  142870. radius?: number;
  142871. tessellation?: number;
  142872. radiusFunction?: {
  142873. (i: number, distance: number): number;
  142874. };
  142875. cap?: number;
  142876. arc?: number;
  142877. updatable?: boolean;
  142878. sideOrientation?: number;
  142879. frontUVs?: Vector4;
  142880. backUVs?: Vector4;
  142881. instance?: Mesh;
  142882. invertUV?: boolean;
  142883. }, scene?: Nullable<Scene>): Mesh;
  142884. /**
  142885. * Creates a polyhedron mesh
  142886. * * 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
  142887. * * The parameter `size` (positive float, default 1) sets the polygon size
  142888. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  142889. * * 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`
  142890. * * 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
  142891. * * 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)`)
  142892. * * 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
  142893. * * 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
  142894. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142895. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142897. * @param name defines the name of the mesh
  142898. * @param options defines the options used to create the mesh
  142899. * @param scene defines the hosting scene
  142900. * @returns the polyhedron mesh
  142901. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  142902. */
  142903. static CreatePolyhedron(name: string, options: {
  142904. type?: number;
  142905. size?: number;
  142906. sizeX?: number;
  142907. sizeY?: number;
  142908. sizeZ?: number;
  142909. custom?: any;
  142910. faceUV?: Vector4[];
  142911. faceColors?: Color4[];
  142912. flat?: boolean;
  142913. updatable?: boolean;
  142914. sideOrientation?: number;
  142915. frontUVs?: Vector4;
  142916. backUVs?: Vector4;
  142917. }, scene?: Nullable<Scene>): Mesh;
  142918. /**
  142919. * Creates a decal mesh.
  142920. * 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
  142921. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  142922. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  142923. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  142924. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  142925. * @param name defines the name of the mesh
  142926. * @param sourceMesh defines the mesh where the decal must be applied
  142927. * @param options defines the options used to create the mesh
  142928. * @param scene defines the hosting scene
  142929. * @returns the decal mesh
  142930. * @see https://doc.babylonjs.com/how_to/decals
  142931. */
  142932. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  142933. position?: Vector3;
  142934. normal?: Vector3;
  142935. size?: Vector3;
  142936. angle?: number;
  142937. }): Mesh;
  142938. }
  142939. }
  142940. declare module BABYLON {
  142941. /**
  142942. * A simplifier interface for future simplification implementations
  142943. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142944. */
  142945. export interface ISimplifier {
  142946. /**
  142947. * Simplification of a given mesh according to the given settings.
  142948. * Since this requires computation, it is assumed that the function runs async.
  142949. * @param settings The settings of the simplification, including quality and distance
  142950. * @param successCallback A callback that will be called after the mesh was simplified.
  142951. * @param errorCallback in case of an error, this callback will be called. optional.
  142952. */
  142953. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  142954. }
  142955. /**
  142956. * Expected simplification settings.
  142957. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  142958. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142959. */
  142960. export interface ISimplificationSettings {
  142961. /**
  142962. * Gets or sets the expected quality
  142963. */
  142964. quality: number;
  142965. /**
  142966. * Gets or sets the distance when this optimized version should be used
  142967. */
  142968. distance: number;
  142969. /**
  142970. * Gets an already optimized mesh
  142971. */
  142972. optimizeMesh?: boolean;
  142973. }
  142974. /**
  142975. * Class used to specify simplification options
  142976. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142977. */
  142978. export class SimplificationSettings implements ISimplificationSettings {
  142979. /** expected quality */
  142980. quality: number;
  142981. /** distance when this optimized version should be used */
  142982. distance: number;
  142983. /** already optimized mesh */
  142984. optimizeMesh?: boolean | undefined;
  142985. /**
  142986. * Creates a SimplificationSettings
  142987. * @param quality expected quality
  142988. * @param distance distance when this optimized version should be used
  142989. * @param optimizeMesh already optimized mesh
  142990. */
  142991. constructor(
  142992. /** expected quality */
  142993. quality: number,
  142994. /** distance when this optimized version should be used */
  142995. distance: number,
  142996. /** already optimized mesh */
  142997. optimizeMesh?: boolean | undefined);
  142998. }
  142999. /**
  143000. * Interface used to define a simplification task
  143001. */
  143002. export interface ISimplificationTask {
  143003. /**
  143004. * Array of settings
  143005. */
  143006. settings: Array<ISimplificationSettings>;
  143007. /**
  143008. * Simplification type
  143009. */
  143010. simplificationType: SimplificationType;
  143011. /**
  143012. * Mesh to simplify
  143013. */
  143014. mesh: Mesh;
  143015. /**
  143016. * Callback called on success
  143017. */
  143018. successCallback?: () => void;
  143019. /**
  143020. * Defines if parallel processing can be used
  143021. */
  143022. parallelProcessing: boolean;
  143023. }
  143024. /**
  143025. * Queue used to order the simplification tasks
  143026. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143027. */
  143028. export class SimplificationQueue {
  143029. private _simplificationArray;
  143030. /**
  143031. * Gets a boolean indicating that the process is still running
  143032. */
  143033. running: boolean;
  143034. /**
  143035. * Creates a new queue
  143036. */
  143037. constructor();
  143038. /**
  143039. * Adds a new simplification task
  143040. * @param task defines a task to add
  143041. */
  143042. addTask(task: ISimplificationTask): void;
  143043. /**
  143044. * Execute next task
  143045. */
  143046. executeNext(): void;
  143047. /**
  143048. * Execute a simplification task
  143049. * @param task defines the task to run
  143050. */
  143051. runSimplification(task: ISimplificationTask): void;
  143052. private getSimplifier;
  143053. }
  143054. /**
  143055. * The implemented types of simplification
  143056. * At the moment only Quadratic Error Decimation is implemented
  143057. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143058. */
  143059. export enum SimplificationType {
  143060. /** Quadratic error decimation */
  143061. QUADRATIC = 0
  143062. }
  143063. /**
  143064. * An implementation of the Quadratic Error simplification algorithm.
  143065. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  143066. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  143067. * @author RaananW
  143068. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143069. */
  143070. export class QuadraticErrorSimplification implements ISimplifier {
  143071. private _mesh;
  143072. private triangles;
  143073. private vertices;
  143074. private references;
  143075. private _reconstructedMesh;
  143076. /** Gets or sets the number pf sync interations */
  143077. syncIterations: number;
  143078. /** Gets or sets the aggressiveness of the simplifier */
  143079. aggressiveness: number;
  143080. /** Gets or sets the number of allowed iterations for decimation */
  143081. decimationIterations: number;
  143082. /** Gets or sets the espilon to use for bounding box computation */
  143083. boundingBoxEpsilon: number;
  143084. /**
  143085. * Creates a new QuadraticErrorSimplification
  143086. * @param _mesh defines the target mesh
  143087. */
  143088. constructor(_mesh: Mesh);
  143089. /**
  143090. * Simplification of a given mesh according to the given settings.
  143091. * Since this requires computation, it is assumed that the function runs async.
  143092. * @param settings The settings of the simplification, including quality and distance
  143093. * @param successCallback A callback that will be called after the mesh was simplified.
  143094. */
  143095. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  143096. private runDecimation;
  143097. private initWithMesh;
  143098. private init;
  143099. private reconstructMesh;
  143100. private initDecimatedMesh;
  143101. private isFlipped;
  143102. private updateTriangles;
  143103. private identifyBorder;
  143104. private updateMesh;
  143105. private vertexError;
  143106. private calculateError;
  143107. }
  143108. }
  143109. declare module BABYLON {
  143110. interface Scene {
  143111. /** @hidden (Backing field) */
  143112. _simplificationQueue: SimplificationQueue;
  143113. /**
  143114. * Gets or sets the simplification queue attached to the scene
  143115. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143116. */
  143117. simplificationQueue: SimplificationQueue;
  143118. }
  143119. interface Mesh {
  143120. /**
  143121. * Simplify the mesh according to the given array of settings.
  143122. * Function will return immediately and will simplify async
  143123. * @param settings a collection of simplification settings
  143124. * @param parallelProcessing should all levels calculate parallel or one after the other
  143125. * @param simplificationType the type of simplification to run
  143126. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  143127. * @returns the current mesh
  143128. */
  143129. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  143130. }
  143131. /**
  143132. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  143133. * created in a scene
  143134. */
  143135. export class SimplicationQueueSceneComponent implements ISceneComponent {
  143136. /**
  143137. * The component name helpfull to identify the component in the list of scene components.
  143138. */
  143139. readonly name: string;
  143140. /**
  143141. * The scene the component belongs to.
  143142. */
  143143. scene: Scene;
  143144. /**
  143145. * Creates a new instance of the component for the given scene
  143146. * @param scene Defines the scene to register the component in
  143147. */
  143148. constructor(scene: Scene);
  143149. /**
  143150. * Registers the component in a given scene
  143151. */
  143152. register(): void;
  143153. /**
  143154. * Rebuilds the elements related to this component in case of
  143155. * context lost for instance.
  143156. */
  143157. rebuild(): void;
  143158. /**
  143159. * Disposes the component and the associated ressources
  143160. */
  143161. dispose(): void;
  143162. private _beforeCameraUpdate;
  143163. }
  143164. }
  143165. declare module BABYLON {
  143166. interface Mesh {
  143167. /**
  143168. * Creates a new thin instance
  143169. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  143170. * @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
  143171. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  143172. */
  143173. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  143174. /**
  143175. * Adds the transformation (matrix) of the current mesh as a thin instance
  143176. * @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
  143177. * @returns the thin instance index number
  143178. */
  143179. thinInstanceAddSelf(refresh: boolean): number;
  143180. /**
  143181. * Registers a custom attribute to be used with thin instances
  143182. * @param kind name of the attribute
  143183. * @param stride size in floats of the attribute
  143184. */
  143185. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  143186. /**
  143187. * Sets the matrix of a thin instance
  143188. * @param index index of the thin instance
  143189. * @param matrix matrix to set
  143190. * @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
  143191. */
  143192. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  143193. /**
  143194. * Sets the value of a custom attribute for a thin instance
  143195. * @param kind name of the attribute
  143196. * @param index index of the thin instance
  143197. * @param value value to set
  143198. * @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
  143199. */
  143200. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  143201. /**
  143202. * 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.
  143203. */
  143204. thinInstanceCount: number;
  143205. /**
  143206. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  143207. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  143208. * @param buffer buffer to set
  143209. * @param stride size in floats of each value of the buffer
  143210. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  143211. */
  143212. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  143213. /**
  143214. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  143215. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  143216. */
  143217. thinInstanceBufferUpdated(kind: string): void;
  143218. /**
  143219. * Refreshes the bounding info, taking into account all the thin instances defined
  143220. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  143221. */
  143222. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  143223. /** @hidden */
  143224. _thinInstanceInitializeUserStorage(): void;
  143225. /** @hidden */
  143226. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  143227. /** @hidden */
  143228. _userThinInstanceBuffersStorage: {
  143229. data: {
  143230. [key: string]: Float32Array;
  143231. };
  143232. sizes: {
  143233. [key: string]: number;
  143234. };
  143235. vertexBuffers: {
  143236. [key: string]: Nullable<VertexBuffer>;
  143237. };
  143238. strides: {
  143239. [key: string]: number;
  143240. };
  143241. };
  143242. }
  143243. }
  143244. declare module BABYLON {
  143245. /**
  143246. * Navigation plugin interface to add navigation constrained by a navigation mesh
  143247. */
  143248. export interface INavigationEnginePlugin {
  143249. /**
  143250. * plugin name
  143251. */
  143252. name: string;
  143253. /**
  143254. * Creates a navigation mesh
  143255. * @param meshes array of all the geometry used to compute the navigatio mesh
  143256. * @param parameters bunch of parameters used to filter geometry
  143257. */
  143258. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  143259. /**
  143260. * Create a navigation mesh debug mesh
  143261. * @param scene is where the mesh will be added
  143262. * @returns debug display mesh
  143263. */
  143264. createDebugNavMesh(scene: Scene): Mesh;
  143265. /**
  143266. * Get a navigation mesh constrained position, closest to the parameter position
  143267. * @param position world position
  143268. * @returns the closest point to position constrained by the navigation mesh
  143269. */
  143270. getClosestPoint(position: Vector3): Vector3;
  143271. /**
  143272. * Get a navigation mesh constrained position, closest to the parameter position
  143273. * @param position world position
  143274. * @param result output the closest point to position constrained by the navigation mesh
  143275. */
  143276. getClosestPointToRef(position: Vector3, result: Vector3): void;
  143277. /**
  143278. * Get a navigation mesh constrained position, within a particular radius
  143279. * @param position world position
  143280. * @param maxRadius the maximum distance to the constrained world position
  143281. * @returns the closest point to position constrained by the navigation mesh
  143282. */
  143283. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  143284. /**
  143285. * Get a navigation mesh constrained position, within a particular radius
  143286. * @param position world position
  143287. * @param maxRadius the maximum distance to the constrained world position
  143288. * @param result output the closest point to position constrained by the navigation mesh
  143289. */
  143290. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  143291. /**
  143292. * Compute the final position from a segment made of destination-position
  143293. * @param position world position
  143294. * @param destination world position
  143295. * @returns the resulting point along the navmesh
  143296. */
  143297. moveAlong(position: Vector3, destination: Vector3): Vector3;
  143298. /**
  143299. * Compute the final position from a segment made of destination-position
  143300. * @param position world position
  143301. * @param destination world position
  143302. * @param result output the resulting point along the navmesh
  143303. */
  143304. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  143305. /**
  143306. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  143307. * @param start world position
  143308. * @param end world position
  143309. * @returns array containing world position composing the path
  143310. */
  143311. computePath(start: Vector3, end: Vector3): Vector3[];
  143312. /**
  143313. * If this plugin is supported
  143314. * @returns true if plugin is supported
  143315. */
  143316. isSupported(): boolean;
  143317. /**
  143318. * Create a new Crowd so you can add agents
  143319. * @param maxAgents the maximum agent count in the crowd
  143320. * @param maxAgentRadius the maximum radius an agent can have
  143321. * @param scene to attach the crowd to
  143322. * @returns the crowd you can add agents to
  143323. */
  143324. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  143325. /**
  143326. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  143327. * The queries will try to find a solution within those bounds
  143328. * default is (1,1,1)
  143329. * @param extent x,y,z value that define the extent around the queries point of reference
  143330. */
  143331. setDefaultQueryExtent(extent: Vector3): void;
  143332. /**
  143333. * Get the Bounding box extent specified by setDefaultQueryExtent
  143334. * @returns the box extent values
  143335. */
  143336. getDefaultQueryExtent(): Vector3;
  143337. /**
  143338. * build the navmesh from a previously saved state using getNavmeshData
  143339. * @param data the Uint8Array returned by getNavmeshData
  143340. */
  143341. buildFromNavmeshData(data: Uint8Array): void;
  143342. /**
  143343. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  143344. * @returns data the Uint8Array that can be saved and reused
  143345. */
  143346. getNavmeshData(): Uint8Array;
  143347. /**
  143348. * Get the Bounding box extent result specified by setDefaultQueryExtent
  143349. * @param result output the box extent values
  143350. */
  143351. getDefaultQueryExtentToRef(result: Vector3): void;
  143352. /**
  143353. * Release all resources
  143354. */
  143355. dispose(): void;
  143356. }
  143357. /**
  143358. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  143359. */
  143360. export interface ICrowd {
  143361. /**
  143362. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  143363. * You can attach anything to that node. The node position is updated in the scene update tick.
  143364. * @param pos world position that will be constrained by the navigation mesh
  143365. * @param parameters agent parameters
  143366. * @param transform hooked to the agent that will be update by the scene
  143367. * @returns agent index
  143368. */
  143369. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  143370. /**
  143371. * Returns the agent position in world space
  143372. * @param index agent index returned by addAgent
  143373. * @returns world space position
  143374. */
  143375. getAgentPosition(index: number): Vector3;
  143376. /**
  143377. * Gets the agent position result in world space
  143378. * @param index agent index returned by addAgent
  143379. * @param result output world space position
  143380. */
  143381. getAgentPositionToRef(index: number, result: Vector3): void;
  143382. /**
  143383. * Gets the agent velocity in world space
  143384. * @param index agent index returned by addAgent
  143385. * @returns world space velocity
  143386. */
  143387. getAgentVelocity(index: number): Vector3;
  143388. /**
  143389. * Gets the agent velocity result in world space
  143390. * @param index agent index returned by addAgent
  143391. * @param result output world space velocity
  143392. */
  143393. getAgentVelocityToRef(index: number, result: Vector3): void;
  143394. /**
  143395. * remove a particular agent previously created
  143396. * @param index agent index returned by addAgent
  143397. */
  143398. removeAgent(index: number): void;
  143399. /**
  143400. * get the list of all agents attached to this crowd
  143401. * @returns list of agent indices
  143402. */
  143403. getAgents(): number[];
  143404. /**
  143405. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  143406. * @param deltaTime in seconds
  143407. */
  143408. update(deltaTime: number): void;
  143409. /**
  143410. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  143411. * @param index agent index returned by addAgent
  143412. * @param destination targeted world position
  143413. */
  143414. agentGoto(index: number, destination: Vector3): void;
  143415. /**
  143416. * Teleport the agent to a new position
  143417. * @param index agent index returned by addAgent
  143418. * @param destination targeted world position
  143419. */
  143420. agentTeleport(index: number, destination: Vector3): void;
  143421. /**
  143422. * Update agent parameters
  143423. * @param index agent index returned by addAgent
  143424. * @param parameters agent parameters
  143425. */
  143426. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  143427. /**
  143428. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  143429. * The queries will try to find a solution within those bounds
  143430. * default is (1,1,1)
  143431. * @param extent x,y,z value that define the extent around the queries point of reference
  143432. */
  143433. setDefaultQueryExtent(extent: Vector3): void;
  143434. /**
  143435. * Get the Bounding box extent specified by setDefaultQueryExtent
  143436. * @returns the box extent values
  143437. */
  143438. getDefaultQueryExtent(): Vector3;
  143439. /**
  143440. * Get the Bounding box extent result specified by setDefaultQueryExtent
  143441. * @param result output the box extent values
  143442. */
  143443. getDefaultQueryExtentToRef(result: Vector3): void;
  143444. /**
  143445. * Release all resources
  143446. */
  143447. dispose(): void;
  143448. }
  143449. /**
  143450. * Configures an agent
  143451. */
  143452. export interface IAgentParameters {
  143453. /**
  143454. * Agent radius. [Limit: >= 0]
  143455. */
  143456. radius: number;
  143457. /**
  143458. * Agent height. [Limit: > 0]
  143459. */
  143460. height: number;
  143461. /**
  143462. * Maximum allowed acceleration. [Limit: >= 0]
  143463. */
  143464. maxAcceleration: number;
  143465. /**
  143466. * Maximum allowed speed. [Limit: >= 0]
  143467. */
  143468. maxSpeed: number;
  143469. /**
  143470. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  143471. */
  143472. collisionQueryRange: number;
  143473. /**
  143474. * The path visibility optimization range. [Limit: > 0]
  143475. */
  143476. pathOptimizationRange: number;
  143477. /**
  143478. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  143479. */
  143480. separationWeight: number;
  143481. }
  143482. /**
  143483. * Configures the navigation mesh creation
  143484. */
  143485. export interface INavMeshParameters {
  143486. /**
  143487. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  143488. */
  143489. cs: number;
  143490. /**
  143491. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  143492. */
  143493. ch: number;
  143494. /**
  143495. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  143496. */
  143497. walkableSlopeAngle: number;
  143498. /**
  143499. * Minimum floor to 'ceiling' height that will still allow the floor area to
  143500. * be considered walkable. [Limit: >= 3] [Units: vx]
  143501. */
  143502. walkableHeight: number;
  143503. /**
  143504. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  143505. */
  143506. walkableClimb: number;
  143507. /**
  143508. * The distance to erode/shrink the walkable area of the heightfield away from
  143509. * obstructions. [Limit: >=0] [Units: vx]
  143510. */
  143511. walkableRadius: number;
  143512. /**
  143513. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  143514. */
  143515. maxEdgeLen: number;
  143516. /**
  143517. * The maximum distance a simplfied contour's border edges should deviate
  143518. * the original raw contour. [Limit: >=0] [Units: vx]
  143519. */
  143520. maxSimplificationError: number;
  143521. /**
  143522. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  143523. */
  143524. minRegionArea: number;
  143525. /**
  143526. * Any regions with a span count smaller than this value will, if possible,
  143527. * be merged with larger regions. [Limit: >=0] [Units: vx]
  143528. */
  143529. mergeRegionArea: number;
  143530. /**
  143531. * The maximum number of vertices allowed for polygons generated during the
  143532. * contour to polygon conversion process. [Limit: >= 3]
  143533. */
  143534. maxVertsPerPoly: number;
  143535. /**
  143536. * Sets the sampling distance to use when generating the detail mesh.
  143537. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  143538. */
  143539. detailSampleDist: number;
  143540. /**
  143541. * The maximum distance the detail mesh surface should deviate from heightfield
  143542. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  143543. */
  143544. detailSampleMaxError: number;
  143545. }
  143546. }
  143547. declare module BABYLON {
  143548. /**
  143549. * RecastJS navigation plugin
  143550. */
  143551. export class RecastJSPlugin implements INavigationEnginePlugin {
  143552. /**
  143553. * Reference to the Recast library
  143554. */
  143555. bjsRECAST: any;
  143556. /**
  143557. * plugin name
  143558. */
  143559. name: string;
  143560. /**
  143561. * the first navmesh created. We might extend this to support multiple navmeshes
  143562. */
  143563. navMesh: any;
  143564. /**
  143565. * Initializes the recastJS plugin
  143566. * @param recastInjection can be used to inject your own recast reference
  143567. */
  143568. constructor(recastInjection?: any);
  143569. /**
  143570. * Creates a navigation mesh
  143571. * @param meshes array of all the geometry used to compute the navigatio mesh
  143572. * @param parameters bunch of parameters used to filter geometry
  143573. */
  143574. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  143575. /**
  143576. * Create a navigation mesh debug mesh
  143577. * @param scene is where the mesh will be added
  143578. * @returns debug display mesh
  143579. */
  143580. createDebugNavMesh(scene: Scene): Mesh;
  143581. /**
  143582. * Get a navigation mesh constrained position, closest to the parameter position
  143583. * @param position world position
  143584. * @returns the closest point to position constrained by the navigation mesh
  143585. */
  143586. getClosestPoint(position: Vector3): Vector3;
  143587. /**
  143588. * Get a navigation mesh constrained position, closest to the parameter position
  143589. * @param position world position
  143590. * @param result output the closest point to position constrained by the navigation mesh
  143591. */
  143592. getClosestPointToRef(position: Vector3, result: Vector3): void;
  143593. /**
  143594. * Get a navigation mesh constrained position, within a particular radius
  143595. * @param position world position
  143596. * @param maxRadius the maximum distance to the constrained world position
  143597. * @returns the closest point to position constrained by the navigation mesh
  143598. */
  143599. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  143600. /**
  143601. * Get a navigation mesh constrained position, within a particular radius
  143602. * @param position world position
  143603. * @param maxRadius the maximum distance to the constrained world position
  143604. * @param result output the closest point to position constrained by the navigation mesh
  143605. */
  143606. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  143607. /**
  143608. * Compute the final position from a segment made of destination-position
  143609. * @param position world position
  143610. * @param destination world position
  143611. * @returns the resulting point along the navmesh
  143612. */
  143613. moveAlong(position: Vector3, destination: Vector3): Vector3;
  143614. /**
  143615. * Compute the final position from a segment made of destination-position
  143616. * @param position world position
  143617. * @param destination world position
  143618. * @param result output the resulting point along the navmesh
  143619. */
  143620. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  143621. /**
  143622. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  143623. * @param start world position
  143624. * @param end world position
  143625. * @returns array containing world position composing the path
  143626. */
  143627. computePath(start: Vector3, end: Vector3): Vector3[];
  143628. /**
  143629. * Create a new Crowd so you can add agents
  143630. * @param maxAgents the maximum agent count in the crowd
  143631. * @param maxAgentRadius the maximum radius an agent can have
  143632. * @param scene to attach the crowd to
  143633. * @returns the crowd you can add agents to
  143634. */
  143635. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  143636. /**
  143637. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  143638. * The queries will try to find a solution within those bounds
  143639. * default is (1,1,1)
  143640. * @param extent x,y,z value that define the extent around the queries point of reference
  143641. */
  143642. setDefaultQueryExtent(extent: Vector3): void;
  143643. /**
  143644. * Get the Bounding box extent specified by setDefaultQueryExtent
  143645. * @returns the box extent values
  143646. */
  143647. getDefaultQueryExtent(): Vector3;
  143648. /**
  143649. * build the navmesh from a previously saved state using getNavmeshData
  143650. * @param data the Uint8Array returned by getNavmeshData
  143651. */
  143652. buildFromNavmeshData(data: Uint8Array): void;
  143653. /**
  143654. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  143655. * @returns data the Uint8Array that can be saved and reused
  143656. */
  143657. getNavmeshData(): Uint8Array;
  143658. /**
  143659. * Get the Bounding box extent result specified by setDefaultQueryExtent
  143660. * @param result output the box extent values
  143661. */
  143662. getDefaultQueryExtentToRef(result: Vector3): void;
  143663. /**
  143664. * Disposes
  143665. */
  143666. dispose(): void;
  143667. /**
  143668. * If this plugin is supported
  143669. * @returns true if plugin is supported
  143670. */
  143671. isSupported(): boolean;
  143672. }
  143673. /**
  143674. * Recast detour crowd implementation
  143675. */
  143676. export class RecastJSCrowd implements ICrowd {
  143677. /**
  143678. * Recast/detour plugin
  143679. */
  143680. bjsRECASTPlugin: RecastJSPlugin;
  143681. /**
  143682. * Link to the detour crowd
  143683. */
  143684. recastCrowd: any;
  143685. /**
  143686. * One transform per agent
  143687. */
  143688. transforms: TransformNode[];
  143689. /**
  143690. * All agents created
  143691. */
  143692. agents: number[];
  143693. /**
  143694. * Link to the scene is kept to unregister the crowd from the scene
  143695. */
  143696. private _scene;
  143697. /**
  143698. * Observer for crowd updates
  143699. */
  143700. private _onBeforeAnimationsObserver;
  143701. /**
  143702. * Constructor
  143703. * @param plugin recastJS plugin
  143704. * @param maxAgents the maximum agent count in the crowd
  143705. * @param maxAgentRadius the maximum radius an agent can have
  143706. * @param scene to attach the crowd to
  143707. * @returns the crowd you can add agents to
  143708. */
  143709. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  143710. /**
  143711. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  143712. * You can attach anything to that node. The node position is updated in the scene update tick.
  143713. * @param pos world position that will be constrained by the navigation mesh
  143714. * @param parameters agent parameters
  143715. * @param transform hooked to the agent that will be update by the scene
  143716. * @returns agent index
  143717. */
  143718. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  143719. /**
  143720. * Returns the agent position in world space
  143721. * @param index agent index returned by addAgent
  143722. * @returns world space position
  143723. */
  143724. getAgentPosition(index: number): Vector3;
  143725. /**
  143726. * Returns the agent position result in world space
  143727. * @param index agent index returned by addAgent
  143728. * @param result output world space position
  143729. */
  143730. getAgentPositionToRef(index: number, result: Vector3): void;
  143731. /**
  143732. * Returns the agent velocity in world space
  143733. * @param index agent index returned by addAgent
  143734. * @returns world space velocity
  143735. */
  143736. getAgentVelocity(index: number): Vector3;
  143737. /**
  143738. * Returns the agent velocity result in world space
  143739. * @param index agent index returned by addAgent
  143740. * @param result output world space velocity
  143741. */
  143742. getAgentVelocityToRef(index: number, result: Vector3): void;
  143743. /**
  143744. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  143745. * @param index agent index returned by addAgent
  143746. * @param destination targeted world position
  143747. */
  143748. agentGoto(index: number, destination: Vector3): void;
  143749. /**
  143750. * Teleport the agent to a new position
  143751. * @param index agent index returned by addAgent
  143752. * @param destination targeted world position
  143753. */
  143754. agentTeleport(index: number, destination: Vector3): void;
  143755. /**
  143756. * Update agent parameters
  143757. * @param index agent index returned by addAgent
  143758. * @param parameters agent parameters
  143759. */
  143760. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  143761. /**
  143762. * remove a particular agent previously created
  143763. * @param index agent index returned by addAgent
  143764. */
  143765. removeAgent(index: number): void;
  143766. /**
  143767. * get the list of all agents attached to this crowd
  143768. * @returns list of agent indices
  143769. */
  143770. getAgents(): number[];
  143771. /**
  143772. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  143773. * @param deltaTime in seconds
  143774. */
  143775. update(deltaTime: number): void;
  143776. /**
  143777. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  143778. * The queries will try to find a solution within those bounds
  143779. * default is (1,1,1)
  143780. * @param extent x,y,z value that define the extent around the queries point of reference
  143781. */
  143782. setDefaultQueryExtent(extent: Vector3): void;
  143783. /**
  143784. * Get the Bounding box extent specified by setDefaultQueryExtent
  143785. * @returns the box extent values
  143786. */
  143787. getDefaultQueryExtent(): Vector3;
  143788. /**
  143789. * Get the Bounding box extent result specified by setDefaultQueryExtent
  143790. * @param result output the box extent values
  143791. */
  143792. getDefaultQueryExtentToRef(result: Vector3): void;
  143793. /**
  143794. * Release all resources
  143795. */
  143796. dispose(): void;
  143797. }
  143798. }
  143799. declare module BABYLON {
  143800. /**
  143801. * Class used to enable access to IndexedDB
  143802. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  143803. */
  143804. export class Database implements IOfflineProvider {
  143805. private _callbackManifestChecked;
  143806. private _currentSceneUrl;
  143807. private _db;
  143808. private _enableSceneOffline;
  143809. private _enableTexturesOffline;
  143810. private _manifestVersionFound;
  143811. private _mustUpdateRessources;
  143812. private _hasReachedQuota;
  143813. private _isSupported;
  143814. private _idbFactory;
  143815. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  143816. private static IsUASupportingBlobStorage;
  143817. /**
  143818. * Gets a boolean indicating if Database storate is enabled (off by default)
  143819. */
  143820. static IDBStorageEnabled: boolean;
  143821. /**
  143822. * Gets a boolean indicating if scene must be saved in the database
  143823. */
  143824. get enableSceneOffline(): boolean;
  143825. /**
  143826. * Gets a boolean indicating if textures must be saved in the database
  143827. */
  143828. get enableTexturesOffline(): boolean;
  143829. /**
  143830. * Creates a new Database
  143831. * @param urlToScene defines the url to load the scene
  143832. * @param callbackManifestChecked defines the callback to use when manifest is checked
  143833. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  143834. */
  143835. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  143836. private static _ParseURL;
  143837. private static _ReturnFullUrlLocation;
  143838. private _checkManifestFile;
  143839. /**
  143840. * Open the database and make it available
  143841. * @param successCallback defines the callback to call on success
  143842. * @param errorCallback defines the callback to call on error
  143843. */
  143844. open(successCallback: () => void, errorCallback: () => void): void;
  143845. /**
  143846. * Loads an image from the database
  143847. * @param url defines the url to load from
  143848. * @param image defines the target DOM image
  143849. */
  143850. loadImage(url: string, image: HTMLImageElement): void;
  143851. private _loadImageFromDBAsync;
  143852. private _saveImageIntoDBAsync;
  143853. private _checkVersionFromDB;
  143854. private _loadVersionFromDBAsync;
  143855. private _saveVersionIntoDBAsync;
  143856. /**
  143857. * Loads a file from database
  143858. * @param url defines the URL to load from
  143859. * @param sceneLoaded defines a callback to call on success
  143860. * @param progressCallBack defines a callback to call when progress changed
  143861. * @param errorCallback defines a callback to call on error
  143862. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  143863. */
  143864. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  143865. private _loadFileAsync;
  143866. private _saveFileAsync;
  143867. /**
  143868. * Validates if xhr data is correct
  143869. * @param xhr defines the request to validate
  143870. * @param dataType defines the expected data type
  143871. * @returns true if data is correct
  143872. */
  143873. private static _ValidateXHRData;
  143874. }
  143875. }
  143876. declare module BABYLON {
  143877. /** @hidden */
  143878. export var gpuUpdateParticlesPixelShader: {
  143879. name: string;
  143880. shader: string;
  143881. };
  143882. }
  143883. declare module BABYLON {
  143884. /** @hidden */
  143885. export var gpuUpdateParticlesVertexShader: {
  143886. name: string;
  143887. shader: string;
  143888. };
  143889. }
  143890. declare module BABYLON {
  143891. /** @hidden */
  143892. export var clipPlaneFragmentDeclaration2: {
  143893. name: string;
  143894. shader: string;
  143895. };
  143896. }
  143897. declare module BABYLON {
  143898. /** @hidden */
  143899. export var gpuRenderParticlesPixelShader: {
  143900. name: string;
  143901. shader: string;
  143902. };
  143903. }
  143904. declare module BABYLON {
  143905. /** @hidden */
  143906. export var clipPlaneVertexDeclaration2: {
  143907. name: string;
  143908. shader: string;
  143909. };
  143910. }
  143911. declare module BABYLON {
  143912. /** @hidden */
  143913. export var gpuRenderParticlesVertexShader: {
  143914. name: string;
  143915. shader: string;
  143916. };
  143917. }
  143918. declare module BABYLON {
  143919. /**
  143920. * This represents a GPU particle system in Babylon
  143921. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  143922. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  143923. */
  143924. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  143925. /**
  143926. * The layer mask we are rendering the particles through.
  143927. */
  143928. layerMask: number;
  143929. private _capacity;
  143930. private _activeCount;
  143931. private _currentActiveCount;
  143932. private _accumulatedCount;
  143933. private _renderEffect;
  143934. private _updateEffect;
  143935. private _buffer0;
  143936. private _buffer1;
  143937. private _spriteBuffer;
  143938. private _updateVAO;
  143939. private _renderVAO;
  143940. private _targetIndex;
  143941. private _sourceBuffer;
  143942. private _targetBuffer;
  143943. private _engine;
  143944. private _currentRenderId;
  143945. private _started;
  143946. private _stopped;
  143947. private _timeDelta;
  143948. private _randomTexture;
  143949. private _randomTexture2;
  143950. private _attributesStrideSize;
  143951. private _updateEffectOptions;
  143952. private _randomTextureSize;
  143953. private _actualFrame;
  143954. private _customEffect;
  143955. private readonly _rawTextureWidth;
  143956. /**
  143957. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  143958. */
  143959. static get IsSupported(): boolean;
  143960. /**
  143961. * An event triggered when the system is disposed.
  143962. */
  143963. onDisposeObservable: Observable<IParticleSystem>;
  143964. /**
  143965. * Gets the maximum number of particles active at the same time.
  143966. * @returns The max number of active particles.
  143967. */
  143968. getCapacity(): number;
  143969. /**
  143970. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  143971. * to override the particles.
  143972. */
  143973. forceDepthWrite: boolean;
  143974. /**
  143975. * Gets or set the number of active particles
  143976. */
  143977. get activeParticleCount(): number;
  143978. set activeParticleCount(value: number);
  143979. private _preWarmDone;
  143980. /**
  143981. * Specifies if the particles are updated in emitter local space or world space.
  143982. */
  143983. isLocal: boolean;
  143984. /**
  143985. * Is this system ready to be used/rendered
  143986. * @return true if the system is ready
  143987. */
  143988. isReady(): boolean;
  143989. /**
  143990. * Gets if the system has been started. (Note: this will still be true after stop is called)
  143991. * @returns True if it has been started, otherwise false.
  143992. */
  143993. isStarted(): boolean;
  143994. /**
  143995. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  143996. * @returns True if it has been stopped, otherwise false.
  143997. */
  143998. isStopped(): boolean;
  143999. /**
  144000. * Gets a boolean indicating that the system is stopping
  144001. * @returns true if the system is currently stopping
  144002. */
  144003. isStopping(): boolean;
  144004. /**
  144005. * Gets the number of particles active at the same time.
  144006. * @returns The number of active particles.
  144007. */
  144008. getActiveCount(): number;
  144009. /**
  144010. * Starts the particle system and begins to emit
  144011. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  144012. */
  144013. start(delay?: number): void;
  144014. /**
  144015. * Stops the particle system.
  144016. */
  144017. stop(): void;
  144018. /**
  144019. * Remove all active particles
  144020. */
  144021. reset(): void;
  144022. /**
  144023. * Returns the string "GPUParticleSystem"
  144024. * @returns a string containing the class name
  144025. */
  144026. getClassName(): string;
  144027. /**
  144028. * Gets the custom effect used to render the particles
  144029. * @param blendMode Blend mode for which the effect should be retrieved
  144030. * @returns The effect
  144031. */
  144032. getCustomEffect(blendMode?: number): Nullable<Effect>;
  144033. /**
  144034. * Sets the custom effect used to render the particles
  144035. * @param effect The effect to set
  144036. * @param blendMode Blend mode for which the effect should be set
  144037. */
  144038. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  144039. /** @hidden */
  144040. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  144041. /**
  144042. * Observable that will be called just before the particles are drawn
  144043. */
  144044. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  144045. /**
  144046. * Gets the name of the particle vertex shader
  144047. */
  144048. get vertexShaderName(): string;
  144049. private _colorGradientsTexture;
  144050. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  144051. /**
  144052. * Adds a new color gradient
  144053. * @param gradient defines the gradient to use (between 0 and 1)
  144054. * @param color1 defines the color to affect to the specified gradient
  144055. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  144056. * @returns the current particle system
  144057. */
  144058. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  144059. private _refreshColorGradient;
  144060. /** Force the system to rebuild all gradients that need to be resync */
  144061. forceRefreshGradients(): void;
  144062. /**
  144063. * Remove a specific color gradient
  144064. * @param gradient defines the gradient to remove
  144065. * @returns the current particle system
  144066. */
  144067. removeColorGradient(gradient: number): GPUParticleSystem;
  144068. private _angularSpeedGradientsTexture;
  144069. private _sizeGradientsTexture;
  144070. private _velocityGradientsTexture;
  144071. private _limitVelocityGradientsTexture;
  144072. private _dragGradientsTexture;
  144073. private _addFactorGradient;
  144074. /**
  144075. * Adds a new size gradient
  144076. * @param gradient defines the gradient to use (between 0 and 1)
  144077. * @param factor defines the size factor to affect to the specified gradient
  144078. * @returns the current particle system
  144079. */
  144080. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  144081. /**
  144082. * Remove a specific size gradient
  144083. * @param gradient defines the gradient to remove
  144084. * @returns the current particle system
  144085. */
  144086. removeSizeGradient(gradient: number): GPUParticleSystem;
  144087. private _refreshFactorGradient;
  144088. /**
  144089. * Adds a new angular speed gradient
  144090. * @param gradient defines the gradient to use (between 0 and 1)
  144091. * @param factor defines the angular speed to affect to the specified gradient
  144092. * @returns the current particle system
  144093. */
  144094. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  144095. /**
  144096. * Remove a specific angular speed gradient
  144097. * @param gradient defines the gradient to remove
  144098. * @returns the current particle system
  144099. */
  144100. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  144101. /**
  144102. * Adds a new velocity gradient
  144103. * @param gradient defines the gradient to use (between 0 and 1)
  144104. * @param factor defines the velocity to affect to the specified gradient
  144105. * @returns the current particle system
  144106. */
  144107. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  144108. /**
  144109. * Remove a specific velocity gradient
  144110. * @param gradient defines the gradient to remove
  144111. * @returns the current particle system
  144112. */
  144113. removeVelocityGradient(gradient: number): GPUParticleSystem;
  144114. /**
  144115. * Adds a new limit velocity gradient
  144116. * @param gradient defines the gradient to use (between 0 and 1)
  144117. * @param factor defines the limit velocity value to affect to the specified gradient
  144118. * @returns the current particle system
  144119. */
  144120. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  144121. /**
  144122. * Remove a specific limit velocity gradient
  144123. * @param gradient defines the gradient to remove
  144124. * @returns the current particle system
  144125. */
  144126. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  144127. /**
  144128. * Adds a new drag gradient
  144129. * @param gradient defines the gradient to use (between 0 and 1)
  144130. * @param factor defines the drag value to affect to the specified gradient
  144131. * @returns the current particle system
  144132. */
  144133. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  144134. /**
  144135. * Remove a specific drag gradient
  144136. * @param gradient defines the gradient to remove
  144137. * @returns the current particle system
  144138. */
  144139. removeDragGradient(gradient: number): GPUParticleSystem;
  144140. /**
  144141. * Not supported by GPUParticleSystem
  144142. * @param gradient defines the gradient to use (between 0 and 1)
  144143. * @param factor defines the emit rate value to affect to the specified gradient
  144144. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144145. * @returns the current particle system
  144146. */
  144147. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144148. /**
  144149. * Not supported by GPUParticleSystem
  144150. * @param gradient defines the gradient to remove
  144151. * @returns the current particle system
  144152. */
  144153. removeEmitRateGradient(gradient: number): IParticleSystem;
  144154. /**
  144155. * Not supported by GPUParticleSystem
  144156. * @param gradient defines the gradient to use (between 0 and 1)
  144157. * @param factor defines the start size value to affect to the specified gradient
  144158. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144159. * @returns the current particle system
  144160. */
  144161. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144162. /**
  144163. * Not supported by GPUParticleSystem
  144164. * @param gradient defines the gradient to remove
  144165. * @returns the current particle system
  144166. */
  144167. removeStartSizeGradient(gradient: number): IParticleSystem;
  144168. /**
  144169. * Not supported by GPUParticleSystem
  144170. * @param gradient defines the gradient to use (between 0 and 1)
  144171. * @param min defines the color remap minimal range
  144172. * @param max defines the color remap maximal range
  144173. * @returns the current particle system
  144174. */
  144175. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  144176. /**
  144177. * Not supported by GPUParticleSystem
  144178. * @param gradient defines the gradient to remove
  144179. * @returns the current particle system
  144180. */
  144181. removeColorRemapGradient(): IParticleSystem;
  144182. /**
  144183. * Not supported by GPUParticleSystem
  144184. * @param gradient defines the gradient to use (between 0 and 1)
  144185. * @param min defines the alpha remap minimal range
  144186. * @param max defines the alpha remap maximal range
  144187. * @returns the current particle system
  144188. */
  144189. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  144190. /**
  144191. * Not supported by GPUParticleSystem
  144192. * @param gradient defines the gradient to remove
  144193. * @returns the current particle system
  144194. */
  144195. removeAlphaRemapGradient(): IParticleSystem;
  144196. /**
  144197. * Not supported by GPUParticleSystem
  144198. * @param gradient defines the gradient to use (between 0 and 1)
  144199. * @param color defines the color to affect to the specified gradient
  144200. * @returns the current particle system
  144201. */
  144202. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  144203. /**
  144204. * Not supported by GPUParticleSystem
  144205. * @param gradient defines the gradient to remove
  144206. * @returns the current particle system
  144207. */
  144208. removeRampGradient(): IParticleSystem;
  144209. /**
  144210. * Not supported by GPUParticleSystem
  144211. * @returns the list of ramp gradients
  144212. */
  144213. getRampGradients(): Nullable<Array<Color3Gradient>>;
  144214. /**
  144215. * Not supported by GPUParticleSystem
  144216. * Gets or sets a boolean indicating that ramp gradients must be used
  144217. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  144218. */
  144219. get useRampGradients(): boolean;
  144220. set useRampGradients(value: boolean);
  144221. /**
  144222. * Not supported by GPUParticleSystem
  144223. * @param gradient defines the gradient to use (between 0 and 1)
  144224. * @param factor defines the life time factor to affect to the specified gradient
  144225. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144226. * @returns the current particle system
  144227. */
  144228. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144229. /**
  144230. * Not supported by GPUParticleSystem
  144231. * @param gradient defines the gradient to remove
  144232. * @returns the current particle system
  144233. */
  144234. removeLifeTimeGradient(gradient: number): IParticleSystem;
  144235. /**
  144236. * Instantiates a GPU particle system.
  144237. * 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.
  144238. * @param name The name of the particle system
  144239. * @param options The options used to create the system
  144240. * @param scene The scene the particle system belongs to
  144241. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  144242. * @param customEffect a custom effect used to change the way particles are rendered by default
  144243. */
  144244. constructor(name: string, options: Partial<{
  144245. capacity: number;
  144246. randomTextureSize: number;
  144247. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  144248. protected _reset(): void;
  144249. private _createUpdateVAO;
  144250. private _createRenderVAO;
  144251. private _initialize;
  144252. /** @hidden */
  144253. _recreateUpdateEffect(): void;
  144254. private _getEffect;
  144255. /**
  144256. * Fill the defines array according to the current settings of the particle system
  144257. * @param defines Array to be updated
  144258. * @param blendMode blend mode to take into account when updating the array
  144259. */
  144260. fillDefines(defines: Array<string>, blendMode?: number): void;
  144261. /**
  144262. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  144263. * @param uniforms Uniforms array to fill
  144264. * @param attributes Attributes array to fill
  144265. * @param samplers Samplers array to fill
  144266. */
  144267. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  144268. /** @hidden */
  144269. _recreateRenderEffect(): Effect;
  144270. /**
  144271. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  144272. * @param preWarm defines if we are in the pre-warmimg phase
  144273. */
  144274. animate(preWarm?: boolean): void;
  144275. private _createFactorGradientTexture;
  144276. private _createSizeGradientTexture;
  144277. private _createAngularSpeedGradientTexture;
  144278. private _createVelocityGradientTexture;
  144279. private _createLimitVelocityGradientTexture;
  144280. private _createDragGradientTexture;
  144281. private _createColorGradientTexture;
  144282. /**
  144283. * Renders the particle system in its current state
  144284. * @param preWarm defines if the system should only update the particles but not render them
  144285. * @returns the current number of particles
  144286. */
  144287. render(preWarm?: boolean): number;
  144288. /**
  144289. * Rebuilds the particle system
  144290. */
  144291. rebuild(): void;
  144292. private _releaseBuffers;
  144293. private _releaseVAOs;
  144294. /**
  144295. * Disposes the particle system and free the associated resources
  144296. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  144297. */
  144298. dispose(disposeTexture?: boolean): void;
  144299. /**
  144300. * Clones the particle system.
  144301. * @param name The name of the cloned object
  144302. * @param newEmitter The new emitter to use
  144303. * @returns the cloned particle system
  144304. */
  144305. clone(name: string, newEmitter: any): GPUParticleSystem;
  144306. /**
  144307. * Serializes the particle system to a JSON object
  144308. * @param serializeTexture defines if the texture must be serialized as well
  144309. * @returns the JSON object
  144310. */
  144311. serialize(serializeTexture?: boolean): any;
  144312. /**
  144313. * Parses a JSON object to create a GPU particle system.
  144314. * @param parsedParticleSystem The JSON object to parse
  144315. * @param scene The scene to create the particle system in
  144316. * @param rootUrl The root url to use to load external dependencies like texture
  144317. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  144318. * @returns the parsed GPU particle system
  144319. */
  144320. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  144321. }
  144322. }
  144323. declare module BABYLON {
  144324. /**
  144325. * Represents a set of particle systems working together to create a specific effect
  144326. */
  144327. export class ParticleSystemSet implements IDisposable {
  144328. /**
  144329. * Gets or sets base Assets URL
  144330. */
  144331. static BaseAssetsUrl: string;
  144332. private _emitterCreationOptions;
  144333. private _emitterNode;
  144334. /**
  144335. * Gets the particle system list
  144336. */
  144337. systems: IParticleSystem[];
  144338. /**
  144339. * Gets the emitter node used with this set
  144340. */
  144341. get emitterNode(): Nullable<TransformNode>;
  144342. /**
  144343. * Creates a new emitter mesh as a sphere
  144344. * @param options defines the options used to create the sphere
  144345. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  144346. * @param scene defines the hosting scene
  144347. */
  144348. setEmitterAsSphere(options: {
  144349. diameter: number;
  144350. segments: number;
  144351. color: Color3;
  144352. }, renderingGroupId: number, scene: Scene): void;
  144353. /**
  144354. * Starts all particle systems of the set
  144355. * @param emitter defines an optional mesh to use as emitter for the particle systems
  144356. */
  144357. start(emitter?: AbstractMesh): void;
  144358. /**
  144359. * Release all associated resources
  144360. */
  144361. dispose(): void;
  144362. /**
  144363. * Serialize the set into a JSON compatible object
  144364. * @param serializeTexture defines if the texture must be serialized as well
  144365. * @returns a JSON compatible representation of the set
  144366. */
  144367. serialize(serializeTexture?: boolean): any;
  144368. /**
  144369. * Parse a new ParticleSystemSet from a serialized source
  144370. * @param data defines a JSON compatible representation of the set
  144371. * @param scene defines the hosting scene
  144372. * @param gpu defines if we want GPU particles or CPU particles
  144373. * @returns a new ParticleSystemSet
  144374. */
  144375. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  144376. }
  144377. }
  144378. declare module BABYLON {
  144379. /**
  144380. * This class is made for on one-liner static method to help creating particle system set.
  144381. */
  144382. export class ParticleHelper {
  144383. /**
  144384. * Gets or sets base Assets URL
  144385. */
  144386. static BaseAssetsUrl: string;
  144387. /** Define the Url to load snippets */
  144388. static SnippetUrl: string;
  144389. /**
  144390. * Create a default particle system that you can tweak
  144391. * @param emitter defines the emitter to use
  144392. * @param capacity defines the system capacity (default is 500 particles)
  144393. * @param scene defines the hosting scene
  144394. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  144395. * @returns the new Particle system
  144396. */
  144397. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  144398. /**
  144399. * This is the main static method (one-liner) of this helper to create different particle systems
  144400. * @param type This string represents the type to the particle system to create
  144401. * @param scene The scene where the particle system should live
  144402. * @param gpu If the system will use gpu
  144403. * @returns the ParticleSystemSet created
  144404. */
  144405. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  144406. /**
  144407. * Static function used to export a particle system to a ParticleSystemSet variable.
  144408. * Please note that the emitter shape is not exported
  144409. * @param systems defines the particle systems to export
  144410. * @returns the created particle system set
  144411. */
  144412. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  144413. /**
  144414. * Creates a particle system from a snippet saved in a remote file
  144415. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  144416. * @param url defines the url to load from
  144417. * @param scene defines the hosting scene
  144418. * @param gpu If the system will use gpu
  144419. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  144420. * @returns a promise that will resolve to the new particle system
  144421. */
  144422. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  144423. /**
  144424. * Creates a particle system from a snippet saved by the particle system editor
  144425. * @param snippetId defines the snippet to load
  144426. * @param scene defines the hosting scene
  144427. * @param gpu If the system will use gpu
  144428. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  144429. * @returns a promise that will resolve to the new particle system
  144430. */
  144431. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  144432. }
  144433. }
  144434. declare module BABYLON {
  144435. interface Engine {
  144436. /**
  144437. * Create an effect to use with particle systems.
  144438. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  144439. * the particle system for which you want to create a custom effect in the last parameter
  144440. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  144441. * @param uniformsNames defines a list of attribute names
  144442. * @param samplers defines an array of string used to represent textures
  144443. * @param defines defines the string containing the defines to use to compile the shaders
  144444. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  144445. * @param onCompiled defines a function to call when the effect creation is successful
  144446. * @param onError defines a function to call when the effect creation has failed
  144447. * @param particleSystem the particle system you want to create the effect for
  144448. * @returns the new Effect
  144449. */
  144450. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  144451. }
  144452. interface Mesh {
  144453. /**
  144454. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  144455. * @returns an array of IParticleSystem
  144456. */
  144457. getEmittedParticleSystems(): IParticleSystem[];
  144458. /**
  144459. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  144460. * @returns an array of IParticleSystem
  144461. */
  144462. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  144463. }
  144464. }
  144465. declare module BABYLON {
  144466. /** Defines the 4 color options */
  144467. export enum PointColor {
  144468. /** color value */
  144469. Color = 2,
  144470. /** uv value */
  144471. UV = 1,
  144472. /** random value */
  144473. Random = 0,
  144474. /** stated value */
  144475. Stated = 3
  144476. }
  144477. /**
  144478. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  144479. * 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.
  144480. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  144481. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  144482. *
  144483. * Full documentation here : TO BE ENTERED
  144484. */
  144485. export class PointsCloudSystem implements IDisposable {
  144486. /**
  144487. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  144488. * Example : var p = SPS.particles[i];
  144489. */
  144490. particles: CloudPoint[];
  144491. /**
  144492. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  144493. */
  144494. nbParticles: number;
  144495. /**
  144496. * This a counter for your own usage. It's not set by any SPS functions.
  144497. */
  144498. counter: number;
  144499. /**
  144500. * The PCS name. This name is also given to the underlying mesh.
  144501. */
  144502. name: string;
  144503. /**
  144504. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  144505. */
  144506. mesh: Mesh;
  144507. /**
  144508. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  144509. * Please read :
  144510. */
  144511. vars: any;
  144512. /**
  144513. * @hidden
  144514. */
  144515. _size: number;
  144516. private _scene;
  144517. private _promises;
  144518. private _positions;
  144519. private _indices;
  144520. private _normals;
  144521. private _colors;
  144522. private _uvs;
  144523. private _indices32;
  144524. private _positions32;
  144525. private _colors32;
  144526. private _uvs32;
  144527. private _updatable;
  144528. private _isVisibilityBoxLocked;
  144529. private _alwaysVisible;
  144530. private _groups;
  144531. private _groupCounter;
  144532. private _computeParticleColor;
  144533. private _computeParticleTexture;
  144534. private _computeParticleRotation;
  144535. private _computeBoundingBox;
  144536. private _isReady;
  144537. /**
  144538. * Creates a PCS (Points Cloud System) object
  144539. * @param name (String) is the PCS name, this will be the underlying mesh name
  144540. * @param pointSize (number) is the size for each point
  144541. * @param scene (Scene) is the scene in which the PCS is added
  144542. * @param options defines the options of the PCS e.g.
  144543. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  144544. */
  144545. constructor(name: string, pointSize: number, scene: Scene, options?: {
  144546. updatable?: boolean;
  144547. });
  144548. /**
  144549. * Builds the PCS underlying mesh. Returns a standard Mesh.
  144550. * If no points were added to the PCS, the returned mesh is just a single point.
  144551. * @returns a promise for the created mesh
  144552. */
  144553. buildMeshAsync(): Promise<Mesh>;
  144554. /**
  144555. * @hidden
  144556. */
  144557. private _buildMesh;
  144558. private _addParticle;
  144559. private _randomUnitVector;
  144560. private _getColorIndicesForCoord;
  144561. private _setPointsColorOrUV;
  144562. private _colorFromTexture;
  144563. private _calculateDensity;
  144564. /**
  144565. * Adds points to the PCS in random positions within a unit sphere
  144566. * @param nb (positive integer) the number of particles to be created from this model
  144567. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  144568. * @returns the number of groups in the system
  144569. */
  144570. addPoints(nb: number, pointFunction?: any): number;
  144571. /**
  144572. * Adds points to the PCS from the surface of the model shape
  144573. * @param mesh is any Mesh object that will be used as a surface model for the points
  144574. * @param nb (positive integer) the number of particles to be created from this model
  144575. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  144576. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  144577. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  144578. * @returns the number of groups in the system
  144579. */
  144580. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  144581. /**
  144582. * Adds points to the PCS inside the model shape
  144583. * @param mesh is any Mesh object that will be used as a surface model for the points
  144584. * @param nb (positive integer) the number of particles to be created from this model
  144585. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  144586. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  144587. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  144588. * @returns the number of groups in the system
  144589. */
  144590. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  144591. /**
  144592. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  144593. * This method calls `updateParticle()` for each particle of the SPS.
  144594. * For an animated SPS, it is usually called within the render loop.
  144595. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  144596. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  144597. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  144598. * @returns the PCS.
  144599. */
  144600. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  144601. /**
  144602. * Disposes the PCS.
  144603. */
  144604. dispose(): void;
  144605. /**
  144606. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  144607. * doc :
  144608. * @returns the PCS.
  144609. */
  144610. refreshVisibleSize(): PointsCloudSystem;
  144611. /**
  144612. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  144613. * @param size the size (float) of the visibility box
  144614. * note : this doesn't lock the PCS mesh bounding box.
  144615. * doc :
  144616. */
  144617. setVisibilityBox(size: number): void;
  144618. /**
  144619. * Gets whether the PCS is always visible or not
  144620. * doc :
  144621. */
  144622. get isAlwaysVisible(): boolean;
  144623. /**
  144624. * Sets the PCS as always visible or not
  144625. * doc :
  144626. */
  144627. set isAlwaysVisible(val: boolean);
  144628. /**
  144629. * Tells to `setParticles()` to compute the particle rotations or not
  144630. * Default value : false. The PCS is faster when it's set to false
  144631. * Note : particle rotations are only applied to parent particles
  144632. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  144633. */
  144634. set computeParticleRotation(val: boolean);
  144635. /**
  144636. * Tells to `setParticles()` to compute the particle colors or not.
  144637. * Default value : true. The PCS is faster when it's set to false.
  144638. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  144639. */
  144640. set computeParticleColor(val: boolean);
  144641. set computeParticleTexture(val: boolean);
  144642. /**
  144643. * Gets if `setParticles()` computes the particle colors or not.
  144644. * Default value : false. The PCS is faster when it's set to false.
  144645. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  144646. */
  144647. get computeParticleColor(): boolean;
  144648. /**
  144649. * Gets if `setParticles()` computes the particle textures or not.
  144650. * Default value : false. The PCS is faster when it's set to false.
  144651. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  144652. */
  144653. get computeParticleTexture(): boolean;
  144654. /**
  144655. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  144656. */
  144657. set computeBoundingBox(val: boolean);
  144658. /**
  144659. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  144660. */
  144661. get computeBoundingBox(): boolean;
  144662. /**
  144663. * This function does nothing. It may be overwritten to set all the particle first values.
  144664. * The PCS doesn't call this function, you may have to call it by your own.
  144665. * doc :
  144666. */
  144667. initParticles(): void;
  144668. /**
  144669. * This function does nothing. It may be overwritten to recycle a particle
  144670. * The PCS doesn't call this function, you can to call it
  144671. * doc :
  144672. * @param particle The particle to recycle
  144673. * @returns the recycled particle
  144674. */
  144675. recycleParticle(particle: CloudPoint): CloudPoint;
  144676. /**
  144677. * Updates a particle : this function should be overwritten by the user.
  144678. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  144679. * doc :
  144680. * @example : just set a particle position or velocity and recycle conditions
  144681. * @param particle The particle to update
  144682. * @returns the updated particle
  144683. */
  144684. updateParticle(particle: CloudPoint): CloudPoint;
  144685. /**
  144686. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  144687. * This does nothing and may be overwritten by the user.
  144688. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  144689. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  144690. * @param update the boolean update value actually passed to setParticles()
  144691. */
  144692. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  144693. /**
  144694. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  144695. * This will be passed three parameters.
  144696. * This does nothing and may be overwritten by the user.
  144697. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  144698. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  144699. * @param update the boolean update value actually passed to setParticles()
  144700. */
  144701. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  144702. }
  144703. }
  144704. declare module BABYLON {
  144705. /**
  144706. * Represents one particle of a points cloud system.
  144707. */
  144708. export class CloudPoint {
  144709. /**
  144710. * particle global index
  144711. */
  144712. idx: number;
  144713. /**
  144714. * The color of the particle
  144715. */
  144716. color: Nullable<Color4>;
  144717. /**
  144718. * The world space position of the particle.
  144719. */
  144720. position: Vector3;
  144721. /**
  144722. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  144723. */
  144724. rotation: Vector3;
  144725. /**
  144726. * The world space rotation quaternion of the particle.
  144727. */
  144728. rotationQuaternion: Nullable<Quaternion>;
  144729. /**
  144730. * The uv of the particle.
  144731. */
  144732. uv: Nullable<Vector2>;
  144733. /**
  144734. * The current speed of the particle.
  144735. */
  144736. velocity: Vector3;
  144737. /**
  144738. * The pivot point in the particle local space.
  144739. */
  144740. pivot: Vector3;
  144741. /**
  144742. * Must the particle be translated from its pivot point in its local space ?
  144743. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  144744. * Default : false
  144745. */
  144746. translateFromPivot: boolean;
  144747. /**
  144748. * Index of this particle in the global "positions" array (Internal use)
  144749. * @hidden
  144750. */
  144751. _pos: number;
  144752. /**
  144753. * @hidden Index of this particle in the global "indices" array (Internal use)
  144754. */
  144755. _ind: number;
  144756. /**
  144757. * Group this particle belongs to
  144758. */
  144759. _group: PointsGroup;
  144760. /**
  144761. * Group id of this particle
  144762. */
  144763. groupId: number;
  144764. /**
  144765. * Index of the particle in its group id (Internal use)
  144766. */
  144767. idxInGroup: number;
  144768. /**
  144769. * @hidden Particle BoundingInfo object (Internal use)
  144770. */
  144771. _boundingInfo: BoundingInfo;
  144772. /**
  144773. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  144774. */
  144775. _pcs: PointsCloudSystem;
  144776. /**
  144777. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  144778. */
  144779. _stillInvisible: boolean;
  144780. /**
  144781. * @hidden Last computed particle rotation matrix
  144782. */
  144783. _rotationMatrix: number[];
  144784. /**
  144785. * Parent particle Id, if any.
  144786. * Default null.
  144787. */
  144788. parentId: Nullable<number>;
  144789. /**
  144790. * @hidden Internal global position in the PCS.
  144791. */
  144792. _globalPosition: Vector3;
  144793. /**
  144794. * Creates a Point Cloud object.
  144795. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  144796. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  144797. * @param group (PointsGroup) is the group the particle belongs to
  144798. * @param groupId (integer) is the group identifier in the PCS.
  144799. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  144800. * @param pcs defines the PCS it is associated to
  144801. */
  144802. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  144803. /**
  144804. * get point size
  144805. */
  144806. get size(): Vector3;
  144807. /**
  144808. * Set point size
  144809. */
  144810. set size(scale: Vector3);
  144811. /**
  144812. * Legacy support, changed quaternion to rotationQuaternion
  144813. */
  144814. get quaternion(): Nullable<Quaternion>;
  144815. /**
  144816. * Legacy support, changed quaternion to rotationQuaternion
  144817. */
  144818. set quaternion(q: Nullable<Quaternion>);
  144819. /**
  144820. * Returns a boolean. True if the particle intersects a mesh, else false
  144821. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  144822. * @param target is the object (point or mesh) what the intersection is computed against
  144823. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  144824. * @returns true if it intersects
  144825. */
  144826. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  144827. /**
  144828. * get the rotation matrix of the particle
  144829. * @hidden
  144830. */
  144831. getRotationMatrix(m: Matrix): void;
  144832. }
  144833. /**
  144834. * Represents a group of points in a points cloud system
  144835. * * PCS internal tool, don't use it manually.
  144836. */
  144837. export class PointsGroup {
  144838. /**
  144839. * The group id
  144840. * @hidden
  144841. */
  144842. groupID: number;
  144843. /**
  144844. * image data for group (internal use)
  144845. * @hidden
  144846. */
  144847. _groupImageData: Nullable<ArrayBufferView>;
  144848. /**
  144849. * Image Width (internal use)
  144850. * @hidden
  144851. */
  144852. _groupImgWidth: number;
  144853. /**
  144854. * Image Height (internal use)
  144855. * @hidden
  144856. */
  144857. _groupImgHeight: number;
  144858. /**
  144859. * Custom position function (internal use)
  144860. * @hidden
  144861. */
  144862. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  144863. /**
  144864. * density per facet for surface points
  144865. * @hidden
  144866. */
  144867. _groupDensity: number[];
  144868. /**
  144869. * Only when points are colored by texture carries pointer to texture list array
  144870. * @hidden
  144871. */
  144872. _textureNb: number;
  144873. /**
  144874. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  144875. * PCS internal tool, don't use it manually.
  144876. * @hidden
  144877. */
  144878. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  144879. }
  144880. }
  144881. declare module BABYLON {
  144882. interface Scene {
  144883. /** @hidden (Backing field) */
  144884. _physicsEngine: Nullable<IPhysicsEngine>;
  144885. /** @hidden */
  144886. _physicsTimeAccumulator: number;
  144887. /**
  144888. * Gets the current physics engine
  144889. * @returns a IPhysicsEngine or null if none attached
  144890. */
  144891. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  144892. /**
  144893. * Enables physics to the current scene
  144894. * @param gravity defines the scene's gravity for the physics engine
  144895. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  144896. * @return a boolean indicating if the physics engine was initialized
  144897. */
  144898. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  144899. /**
  144900. * Disables and disposes the physics engine associated with the scene
  144901. */
  144902. disablePhysicsEngine(): void;
  144903. /**
  144904. * Gets a boolean indicating if there is an active physics engine
  144905. * @returns a boolean indicating if there is an active physics engine
  144906. */
  144907. isPhysicsEnabled(): boolean;
  144908. /**
  144909. * Deletes a physics compound impostor
  144910. * @param compound defines the compound to delete
  144911. */
  144912. deleteCompoundImpostor(compound: any): void;
  144913. /**
  144914. * An event triggered when physic simulation is about to be run
  144915. */
  144916. onBeforePhysicsObservable: Observable<Scene>;
  144917. /**
  144918. * An event triggered when physic simulation has been done
  144919. */
  144920. onAfterPhysicsObservable: Observable<Scene>;
  144921. }
  144922. interface AbstractMesh {
  144923. /** @hidden */
  144924. _physicsImpostor: Nullable<PhysicsImpostor>;
  144925. /**
  144926. * Gets or sets impostor used for physic simulation
  144927. * @see http://doc.babylonjs.com/features/physics_engine
  144928. */
  144929. physicsImpostor: Nullable<PhysicsImpostor>;
  144930. /**
  144931. * Gets the current physics impostor
  144932. * @see http://doc.babylonjs.com/features/physics_engine
  144933. * @returns a physics impostor or null
  144934. */
  144935. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  144936. /** Apply a physic impulse to the mesh
  144937. * @param force defines the force to apply
  144938. * @param contactPoint defines where to apply the force
  144939. * @returns the current mesh
  144940. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  144941. */
  144942. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  144943. /**
  144944. * Creates a physic joint between two meshes
  144945. * @param otherMesh defines the other mesh to use
  144946. * @param pivot1 defines the pivot to use on this mesh
  144947. * @param pivot2 defines the pivot to use on the other mesh
  144948. * @param options defines additional options (can be plugin dependent)
  144949. * @returns the current mesh
  144950. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  144951. */
  144952. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  144953. /** @hidden */
  144954. _disposePhysicsObserver: Nullable<Observer<Node>>;
  144955. }
  144956. /**
  144957. * Defines the physics engine scene component responsible to manage a physics engine
  144958. */
  144959. export class PhysicsEngineSceneComponent implements ISceneComponent {
  144960. /**
  144961. * The component name helpful to identify the component in the list of scene components.
  144962. */
  144963. readonly name: string;
  144964. /**
  144965. * The scene the component belongs to.
  144966. */
  144967. scene: Scene;
  144968. /**
  144969. * Creates a new instance of the component for the given scene
  144970. * @param scene Defines the scene to register the component in
  144971. */
  144972. constructor(scene: Scene);
  144973. /**
  144974. * Registers the component in a given scene
  144975. */
  144976. register(): void;
  144977. /**
  144978. * Rebuilds the elements related to this component in case of
  144979. * context lost for instance.
  144980. */
  144981. rebuild(): void;
  144982. /**
  144983. * Disposes the component and the associated ressources
  144984. */
  144985. dispose(): void;
  144986. }
  144987. }
  144988. declare module BABYLON {
  144989. /**
  144990. * A helper for physics simulations
  144991. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144992. */
  144993. export class PhysicsHelper {
  144994. private _scene;
  144995. private _physicsEngine;
  144996. /**
  144997. * Initializes the Physics helper
  144998. * @param scene Babylon.js scene
  144999. */
  145000. constructor(scene: Scene);
  145001. /**
  145002. * Applies a radial explosion impulse
  145003. * @param origin the origin of the explosion
  145004. * @param radiusOrEventOptions the radius or the options of radial explosion
  145005. * @param strength the explosion strength
  145006. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145007. * @returns A physics radial explosion event, or null
  145008. */
  145009. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  145010. /**
  145011. * Applies a radial explosion force
  145012. * @param origin the origin of the explosion
  145013. * @param radiusOrEventOptions the radius or the options of radial explosion
  145014. * @param strength the explosion strength
  145015. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145016. * @returns A physics radial explosion event, or null
  145017. */
  145018. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  145019. /**
  145020. * Creates a gravitational field
  145021. * @param origin the origin of the explosion
  145022. * @param radiusOrEventOptions the radius or the options of radial explosion
  145023. * @param strength the explosion strength
  145024. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145025. * @returns A physics gravitational field event, or null
  145026. */
  145027. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  145028. /**
  145029. * Creates a physics updraft event
  145030. * @param origin the origin of the updraft
  145031. * @param radiusOrEventOptions the radius or the options of the updraft
  145032. * @param strength the strength of the updraft
  145033. * @param height the height of the updraft
  145034. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  145035. * @returns A physics updraft event, or null
  145036. */
  145037. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  145038. /**
  145039. * Creates a physics vortex event
  145040. * @param origin the of the vortex
  145041. * @param radiusOrEventOptions the radius or the options of the vortex
  145042. * @param strength the strength of the vortex
  145043. * @param height the height of the vortex
  145044. * @returns a Physics vortex event, or null
  145045. * A physics vortex event or null
  145046. */
  145047. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  145048. }
  145049. /**
  145050. * Represents a physics radial explosion event
  145051. */
  145052. class PhysicsRadialExplosionEvent {
  145053. private _scene;
  145054. private _options;
  145055. private _sphere;
  145056. private _dataFetched;
  145057. /**
  145058. * Initializes a radial explosioin event
  145059. * @param _scene BabylonJS scene
  145060. * @param _options The options for the vortex event
  145061. */
  145062. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  145063. /**
  145064. * Returns the data related to the radial explosion event (sphere).
  145065. * @returns The radial explosion event data
  145066. */
  145067. getData(): PhysicsRadialExplosionEventData;
  145068. /**
  145069. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  145070. * @param impostor A physics imposter
  145071. * @param origin the origin of the explosion
  145072. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  145073. */
  145074. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  145075. /**
  145076. * Triggers affecterd impostors callbacks
  145077. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  145078. */
  145079. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  145080. /**
  145081. * Disposes the sphere.
  145082. * @param force Specifies if the sphere should be disposed by force
  145083. */
  145084. dispose(force?: boolean): void;
  145085. /*** Helpers ***/
  145086. private _prepareSphere;
  145087. private _intersectsWithSphere;
  145088. }
  145089. /**
  145090. * Represents a gravitational field event
  145091. */
  145092. class PhysicsGravitationalFieldEvent {
  145093. private _physicsHelper;
  145094. private _scene;
  145095. private _origin;
  145096. private _options;
  145097. private _tickCallback;
  145098. private _sphere;
  145099. private _dataFetched;
  145100. /**
  145101. * Initializes the physics gravitational field event
  145102. * @param _physicsHelper A physics helper
  145103. * @param _scene BabylonJS scene
  145104. * @param _origin The origin position of the gravitational field event
  145105. * @param _options The options for the vortex event
  145106. */
  145107. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  145108. /**
  145109. * Returns the data related to the gravitational field event (sphere).
  145110. * @returns A gravitational field event
  145111. */
  145112. getData(): PhysicsGravitationalFieldEventData;
  145113. /**
  145114. * Enables the gravitational field.
  145115. */
  145116. enable(): void;
  145117. /**
  145118. * Disables the gravitational field.
  145119. */
  145120. disable(): void;
  145121. /**
  145122. * Disposes the sphere.
  145123. * @param force The force to dispose from the gravitational field event
  145124. */
  145125. dispose(force?: boolean): void;
  145126. private _tick;
  145127. }
  145128. /**
  145129. * Represents a physics updraft event
  145130. */
  145131. class PhysicsUpdraftEvent {
  145132. private _scene;
  145133. private _origin;
  145134. private _options;
  145135. private _physicsEngine;
  145136. private _originTop;
  145137. private _originDirection;
  145138. private _tickCallback;
  145139. private _cylinder;
  145140. private _cylinderPosition;
  145141. private _dataFetched;
  145142. /**
  145143. * Initializes the physics updraft event
  145144. * @param _scene BabylonJS scene
  145145. * @param _origin The origin position of the updraft
  145146. * @param _options The options for the updraft event
  145147. */
  145148. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  145149. /**
  145150. * Returns the data related to the updraft event (cylinder).
  145151. * @returns A physics updraft event
  145152. */
  145153. getData(): PhysicsUpdraftEventData;
  145154. /**
  145155. * Enables the updraft.
  145156. */
  145157. enable(): void;
  145158. /**
  145159. * Disables the updraft.
  145160. */
  145161. disable(): void;
  145162. /**
  145163. * Disposes the cylinder.
  145164. * @param force Specifies if the updraft should be disposed by force
  145165. */
  145166. dispose(force?: boolean): void;
  145167. private getImpostorHitData;
  145168. private _tick;
  145169. /*** Helpers ***/
  145170. private _prepareCylinder;
  145171. private _intersectsWithCylinder;
  145172. }
  145173. /**
  145174. * Represents a physics vortex event
  145175. */
  145176. class PhysicsVortexEvent {
  145177. private _scene;
  145178. private _origin;
  145179. private _options;
  145180. private _physicsEngine;
  145181. private _originTop;
  145182. private _tickCallback;
  145183. private _cylinder;
  145184. private _cylinderPosition;
  145185. private _dataFetched;
  145186. /**
  145187. * Initializes the physics vortex event
  145188. * @param _scene The BabylonJS scene
  145189. * @param _origin The origin position of the vortex
  145190. * @param _options The options for the vortex event
  145191. */
  145192. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  145193. /**
  145194. * Returns the data related to the vortex event (cylinder).
  145195. * @returns The physics vortex event data
  145196. */
  145197. getData(): PhysicsVortexEventData;
  145198. /**
  145199. * Enables the vortex.
  145200. */
  145201. enable(): void;
  145202. /**
  145203. * Disables the cortex.
  145204. */
  145205. disable(): void;
  145206. /**
  145207. * Disposes the sphere.
  145208. * @param force
  145209. */
  145210. dispose(force?: boolean): void;
  145211. private getImpostorHitData;
  145212. private _tick;
  145213. /*** Helpers ***/
  145214. private _prepareCylinder;
  145215. private _intersectsWithCylinder;
  145216. }
  145217. /**
  145218. * Options fot the radial explosion event
  145219. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145220. */
  145221. export class PhysicsRadialExplosionEventOptions {
  145222. /**
  145223. * The radius of the sphere for the radial explosion.
  145224. */
  145225. radius: number;
  145226. /**
  145227. * The strenth of the explosion.
  145228. */
  145229. strength: number;
  145230. /**
  145231. * The strenght of the force in correspondence to the distance of the affected object
  145232. */
  145233. falloff: PhysicsRadialImpulseFalloff;
  145234. /**
  145235. * Sphere options for the radial explosion.
  145236. */
  145237. sphere: {
  145238. segments: number;
  145239. diameter: number;
  145240. };
  145241. /**
  145242. * Sphere options for the radial explosion.
  145243. */
  145244. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  145245. }
  145246. /**
  145247. * Options fot the updraft event
  145248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145249. */
  145250. export class PhysicsUpdraftEventOptions {
  145251. /**
  145252. * The radius of the cylinder for the vortex
  145253. */
  145254. radius: number;
  145255. /**
  145256. * The strenth of the updraft.
  145257. */
  145258. strength: number;
  145259. /**
  145260. * The height of the cylinder for the updraft.
  145261. */
  145262. height: number;
  145263. /**
  145264. * The mode for the the updraft.
  145265. */
  145266. updraftMode: PhysicsUpdraftMode;
  145267. }
  145268. /**
  145269. * Options fot the vortex event
  145270. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145271. */
  145272. export class PhysicsVortexEventOptions {
  145273. /**
  145274. * The radius of the cylinder for the vortex
  145275. */
  145276. radius: number;
  145277. /**
  145278. * The strenth of the vortex.
  145279. */
  145280. strength: number;
  145281. /**
  145282. * The height of the cylinder for the vortex.
  145283. */
  145284. height: number;
  145285. /**
  145286. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  145287. */
  145288. centripetalForceThreshold: number;
  145289. /**
  145290. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  145291. */
  145292. centripetalForceMultiplier: number;
  145293. /**
  145294. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  145295. */
  145296. centrifugalForceMultiplier: number;
  145297. /**
  145298. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  145299. */
  145300. updraftForceMultiplier: number;
  145301. }
  145302. /**
  145303. * The strenght of the force in correspondence to the distance of the affected object
  145304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145305. */
  145306. export enum PhysicsRadialImpulseFalloff {
  145307. /** Defines that impulse is constant in strength across it's whole radius */
  145308. Constant = 0,
  145309. /** Defines that impulse gets weaker if it's further from the origin */
  145310. Linear = 1
  145311. }
  145312. /**
  145313. * The strength of the force in correspondence to the distance of the affected object
  145314. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145315. */
  145316. export enum PhysicsUpdraftMode {
  145317. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  145318. Center = 0,
  145319. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  145320. Perpendicular = 1
  145321. }
  145322. /**
  145323. * Interface for a physics hit data
  145324. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145325. */
  145326. export interface PhysicsHitData {
  145327. /**
  145328. * The force applied at the contact point
  145329. */
  145330. force: Vector3;
  145331. /**
  145332. * The contact point
  145333. */
  145334. contactPoint: Vector3;
  145335. /**
  145336. * The distance from the origin to the contact point
  145337. */
  145338. distanceFromOrigin: number;
  145339. }
  145340. /**
  145341. * Interface for radial explosion event data
  145342. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145343. */
  145344. export interface PhysicsRadialExplosionEventData {
  145345. /**
  145346. * A sphere used for the radial explosion event
  145347. */
  145348. sphere: Mesh;
  145349. }
  145350. /**
  145351. * Interface for gravitational field event data
  145352. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145353. */
  145354. export interface PhysicsGravitationalFieldEventData {
  145355. /**
  145356. * A sphere mesh used for the gravitational field event
  145357. */
  145358. sphere: Mesh;
  145359. }
  145360. /**
  145361. * Interface for updraft event data
  145362. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145363. */
  145364. export interface PhysicsUpdraftEventData {
  145365. /**
  145366. * A cylinder used for the updraft event
  145367. */
  145368. cylinder: Mesh;
  145369. }
  145370. /**
  145371. * Interface for vortex event data
  145372. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145373. */
  145374. export interface PhysicsVortexEventData {
  145375. /**
  145376. * A cylinder used for the vortex event
  145377. */
  145378. cylinder: Mesh;
  145379. }
  145380. /**
  145381. * Interface for an affected physics impostor
  145382. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145383. */
  145384. export interface PhysicsAffectedImpostorWithData {
  145385. /**
  145386. * The impostor affected by the effect
  145387. */
  145388. impostor: PhysicsImpostor;
  145389. /**
  145390. * The data about the hit/horce from the explosion
  145391. */
  145392. hitData: PhysicsHitData;
  145393. }
  145394. }
  145395. declare module BABYLON {
  145396. /** @hidden */
  145397. export var blackAndWhitePixelShader: {
  145398. name: string;
  145399. shader: string;
  145400. };
  145401. }
  145402. declare module BABYLON {
  145403. /**
  145404. * Post process used to render in black and white
  145405. */
  145406. export class BlackAndWhitePostProcess extends PostProcess {
  145407. /**
  145408. * Linear about to convert he result to black and white (default: 1)
  145409. */
  145410. degree: number;
  145411. /**
  145412. * Creates a black and white post process
  145413. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  145414. * @param name The name of the effect.
  145415. * @param options The required width/height ratio to downsize to before computing the render pass.
  145416. * @param camera The camera to apply the render pass to.
  145417. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145418. * @param engine The engine which the post process will be applied. (default: current engine)
  145419. * @param reusable If the post process can be reused on the same frame. (default: false)
  145420. */
  145421. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  145422. }
  145423. }
  145424. declare module BABYLON {
  145425. /**
  145426. * This represents a set of one or more post processes in Babylon.
  145427. * A post process can be used to apply a shader to a texture after it is rendered.
  145428. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145429. */
  145430. export class PostProcessRenderEffect {
  145431. private _postProcesses;
  145432. private _getPostProcesses;
  145433. private _singleInstance;
  145434. private _cameras;
  145435. private _indicesForCamera;
  145436. /**
  145437. * Name of the effect
  145438. * @hidden
  145439. */
  145440. _name: string;
  145441. /**
  145442. * Instantiates a post process render effect.
  145443. * A post process can be used to apply a shader to a texture after it is rendered.
  145444. * @param engine The engine the effect is tied to
  145445. * @param name The name of the effect
  145446. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  145447. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  145448. */
  145449. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  145450. /**
  145451. * Checks if all the post processes in the effect are supported.
  145452. */
  145453. get isSupported(): boolean;
  145454. /**
  145455. * Updates the current state of the effect
  145456. * @hidden
  145457. */
  145458. _update(): void;
  145459. /**
  145460. * Attaches the effect on cameras
  145461. * @param cameras The camera to attach to.
  145462. * @hidden
  145463. */
  145464. _attachCameras(cameras: Camera): void;
  145465. /**
  145466. * Attaches the effect on cameras
  145467. * @param cameras The camera to attach to.
  145468. * @hidden
  145469. */
  145470. _attachCameras(cameras: Camera[]): void;
  145471. /**
  145472. * Detaches the effect on cameras
  145473. * @param cameras The camera to detatch from.
  145474. * @hidden
  145475. */
  145476. _detachCameras(cameras: Camera): void;
  145477. /**
  145478. * Detatches the effect on cameras
  145479. * @param cameras The camera to detatch from.
  145480. * @hidden
  145481. */
  145482. _detachCameras(cameras: Camera[]): void;
  145483. /**
  145484. * Enables the effect on given cameras
  145485. * @param cameras The camera to enable.
  145486. * @hidden
  145487. */
  145488. _enable(cameras: Camera): void;
  145489. /**
  145490. * Enables the effect on given cameras
  145491. * @param cameras The camera to enable.
  145492. * @hidden
  145493. */
  145494. _enable(cameras: Nullable<Camera[]>): void;
  145495. /**
  145496. * Disables the effect on the given cameras
  145497. * @param cameras The camera to disable.
  145498. * @hidden
  145499. */
  145500. _disable(cameras: Camera): void;
  145501. /**
  145502. * Disables the effect on the given cameras
  145503. * @param cameras The camera to disable.
  145504. * @hidden
  145505. */
  145506. _disable(cameras: Nullable<Camera[]>): void;
  145507. /**
  145508. * Gets a list of the post processes contained in the effect.
  145509. * @param camera The camera to get the post processes on.
  145510. * @returns The list of the post processes in the effect.
  145511. */
  145512. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  145513. }
  145514. }
  145515. declare module BABYLON {
  145516. /** @hidden */
  145517. export var extractHighlightsPixelShader: {
  145518. name: string;
  145519. shader: string;
  145520. };
  145521. }
  145522. declare module BABYLON {
  145523. /**
  145524. * 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.
  145525. */
  145526. export class ExtractHighlightsPostProcess extends PostProcess {
  145527. /**
  145528. * The luminance threshold, pixels below this value will be set to black.
  145529. */
  145530. threshold: number;
  145531. /** @hidden */
  145532. _exposure: number;
  145533. /**
  145534. * Post process which has the input texture to be used when performing highlight extraction
  145535. * @hidden
  145536. */
  145537. _inputPostProcess: Nullable<PostProcess>;
  145538. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145539. }
  145540. }
  145541. declare module BABYLON {
  145542. /** @hidden */
  145543. export var bloomMergePixelShader: {
  145544. name: string;
  145545. shader: string;
  145546. };
  145547. }
  145548. declare module BABYLON {
  145549. /**
  145550. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  145551. */
  145552. export class BloomMergePostProcess extends PostProcess {
  145553. /** Weight of the bloom to be added to the original input. */
  145554. weight: number;
  145555. /**
  145556. * Creates a new instance of @see BloomMergePostProcess
  145557. * @param name The name of the effect.
  145558. * @param originalFromInput Post process which's input will be used for the merge.
  145559. * @param blurred Blurred highlights post process which's output will be used.
  145560. * @param weight Weight of the bloom to be added to the original input.
  145561. * @param options The required width/height ratio to downsize to before computing the render pass.
  145562. * @param camera The camera to apply the render pass to.
  145563. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145564. * @param engine The engine which the post process will be applied. (default: current engine)
  145565. * @param reusable If the post process can be reused on the same frame. (default: false)
  145566. * @param textureType Type of textures used when performing the post process. (default: 0)
  145567. * @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)
  145568. */
  145569. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  145570. /** Weight of the bloom to be added to the original input. */
  145571. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145572. }
  145573. }
  145574. declare module BABYLON {
  145575. /**
  145576. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  145577. */
  145578. export class BloomEffect extends PostProcessRenderEffect {
  145579. private bloomScale;
  145580. /**
  145581. * @hidden Internal
  145582. */
  145583. _effects: Array<PostProcess>;
  145584. /**
  145585. * @hidden Internal
  145586. */
  145587. _downscale: ExtractHighlightsPostProcess;
  145588. private _blurX;
  145589. private _blurY;
  145590. private _merge;
  145591. /**
  145592. * The luminance threshold to find bright areas of the image to bloom.
  145593. */
  145594. get threshold(): number;
  145595. set threshold(value: number);
  145596. /**
  145597. * The strength of the bloom.
  145598. */
  145599. get weight(): number;
  145600. set weight(value: number);
  145601. /**
  145602. * Specifies the size of the bloom blur kernel, relative to the final output size
  145603. */
  145604. get kernel(): number;
  145605. set kernel(value: number);
  145606. /**
  145607. * Creates a new instance of @see BloomEffect
  145608. * @param scene The scene the effect belongs to.
  145609. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  145610. * @param bloomKernel The size of the kernel to be used when applying the blur.
  145611. * @param bloomWeight The the strength of bloom.
  145612. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  145613. * @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)
  145614. */
  145615. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  145616. /**
  145617. * Disposes each of the internal effects for a given camera.
  145618. * @param camera The camera to dispose the effect on.
  145619. */
  145620. disposeEffects(camera: Camera): void;
  145621. /**
  145622. * @hidden Internal
  145623. */
  145624. _updateEffects(): void;
  145625. /**
  145626. * Internal
  145627. * @returns if all the contained post processes are ready.
  145628. * @hidden
  145629. */
  145630. _isReady(): boolean;
  145631. }
  145632. }
  145633. declare module BABYLON {
  145634. /** @hidden */
  145635. export var chromaticAberrationPixelShader: {
  145636. name: string;
  145637. shader: string;
  145638. };
  145639. }
  145640. declare module BABYLON {
  145641. /**
  145642. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  145643. */
  145644. export class ChromaticAberrationPostProcess extends PostProcess {
  145645. /**
  145646. * The amount of seperation of rgb channels (default: 30)
  145647. */
  145648. aberrationAmount: number;
  145649. /**
  145650. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  145651. */
  145652. radialIntensity: number;
  145653. /**
  145654. * 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))
  145655. */
  145656. direction: Vector2;
  145657. /**
  145658. * 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))
  145659. */
  145660. centerPosition: Vector2;
  145661. /**
  145662. * Creates a new instance ChromaticAberrationPostProcess
  145663. * @param name The name of the effect.
  145664. * @param screenWidth The width of the screen to apply the effect on.
  145665. * @param screenHeight The height of the screen to apply the effect on.
  145666. * @param options The required width/height ratio to downsize to before computing the render pass.
  145667. * @param camera The camera to apply the render pass to.
  145668. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145669. * @param engine The engine which the post process will be applied. (default: current engine)
  145670. * @param reusable If the post process can be reused on the same frame. (default: false)
  145671. * @param textureType Type of textures used when performing the post process. (default: 0)
  145672. * @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)
  145673. */
  145674. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145675. }
  145676. }
  145677. declare module BABYLON {
  145678. /** @hidden */
  145679. export var circleOfConfusionPixelShader: {
  145680. name: string;
  145681. shader: string;
  145682. };
  145683. }
  145684. declare module BABYLON {
  145685. /**
  145686. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  145687. */
  145688. export class CircleOfConfusionPostProcess extends PostProcess {
  145689. /**
  145690. * 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.
  145691. */
  145692. lensSize: number;
  145693. /**
  145694. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  145695. */
  145696. fStop: number;
  145697. /**
  145698. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  145699. */
  145700. focusDistance: number;
  145701. /**
  145702. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  145703. */
  145704. focalLength: number;
  145705. private _depthTexture;
  145706. /**
  145707. * Creates a new instance CircleOfConfusionPostProcess
  145708. * @param name The name of the effect.
  145709. * @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.
  145710. * @param options The required width/height ratio to downsize to before computing the render pass.
  145711. * @param camera The camera to apply the render pass to.
  145712. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145713. * @param engine The engine which the post process will be applied. (default: current engine)
  145714. * @param reusable If the post process can be reused on the same frame. (default: false)
  145715. * @param textureType Type of textures used when performing the post process. (default: 0)
  145716. * @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)
  145717. */
  145718. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145719. /**
  145720. * 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.
  145721. */
  145722. set depthTexture(value: RenderTargetTexture);
  145723. }
  145724. }
  145725. declare module BABYLON {
  145726. /** @hidden */
  145727. export var colorCorrectionPixelShader: {
  145728. name: string;
  145729. shader: string;
  145730. };
  145731. }
  145732. declare module BABYLON {
  145733. /**
  145734. *
  145735. * This post-process allows the modification of rendered colors by using
  145736. * a 'look-up table' (LUT). This effect is also called Color Grading.
  145737. *
  145738. * The object needs to be provided an url to a texture containing the color
  145739. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  145740. * Use an image editing software to tweak the LUT to match your needs.
  145741. *
  145742. * For an example of a color LUT, see here:
  145743. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  145744. * For explanations on color grading, see here:
  145745. * @see http://udn.epicgames.com/Three/ColorGrading.html
  145746. *
  145747. */
  145748. export class ColorCorrectionPostProcess extends PostProcess {
  145749. private _colorTableTexture;
  145750. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  145751. }
  145752. }
  145753. declare module BABYLON {
  145754. /** @hidden */
  145755. export var convolutionPixelShader: {
  145756. name: string;
  145757. shader: string;
  145758. };
  145759. }
  145760. declare module BABYLON {
  145761. /**
  145762. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  145763. * input texture to perform effects such as edge detection or sharpening
  145764. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  145765. */
  145766. export class ConvolutionPostProcess extends PostProcess {
  145767. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  145768. kernel: number[];
  145769. /**
  145770. * Creates a new instance ConvolutionPostProcess
  145771. * @param name The name of the effect.
  145772. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  145773. * @param options The required width/height ratio to downsize to before computing the render pass.
  145774. * @param camera The camera to apply the render pass to.
  145775. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145776. * @param engine The engine which the post process will be applied. (default: current engine)
  145777. * @param reusable If the post process can be reused on the same frame. (default: false)
  145778. * @param textureType Type of textures used when performing the post process. (default: 0)
  145779. */
  145780. constructor(name: string,
  145781. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  145782. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  145783. /**
  145784. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145785. */
  145786. static EdgeDetect0Kernel: number[];
  145787. /**
  145788. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145789. */
  145790. static EdgeDetect1Kernel: number[];
  145791. /**
  145792. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145793. */
  145794. static EdgeDetect2Kernel: number[];
  145795. /**
  145796. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145797. */
  145798. static SharpenKernel: number[];
  145799. /**
  145800. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145801. */
  145802. static EmbossKernel: number[];
  145803. /**
  145804. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145805. */
  145806. static GaussianKernel: number[];
  145807. }
  145808. }
  145809. declare module BABYLON {
  145810. /**
  145811. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  145812. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  145813. * based on samples that have a large difference in distance than the center pixel.
  145814. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  145815. */
  145816. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  145817. direction: Vector2;
  145818. /**
  145819. * Creates a new instance CircleOfConfusionPostProcess
  145820. * @param name The name of the effect.
  145821. * @param scene The scene the effect belongs to.
  145822. * @param direction The direction the blur should be applied.
  145823. * @param kernel The size of the kernel used to blur.
  145824. * @param options The required width/height ratio to downsize to before computing the render pass.
  145825. * @param camera The camera to apply the render pass to.
  145826. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  145827. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  145828. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145829. * @param engine The engine which the post process will be applied. (default: current engine)
  145830. * @param reusable If the post process can be reused on the same frame. (default: false)
  145831. * @param textureType Type of textures used when performing the post process. (default: 0)
  145832. * @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)
  145833. */
  145834. 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);
  145835. }
  145836. }
  145837. declare module BABYLON {
  145838. /** @hidden */
  145839. export var depthOfFieldMergePixelShader: {
  145840. name: string;
  145841. shader: string;
  145842. };
  145843. }
  145844. declare module BABYLON {
  145845. /**
  145846. * Options to be set when merging outputs from the default pipeline.
  145847. */
  145848. export class DepthOfFieldMergePostProcessOptions {
  145849. /**
  145850. * The original image to merge on top of
  145851. */
  145852. originalFromInput: PostProcess;
  145853. /**
  145854. * Parameters to perform the merge of the depth of field effect
  145855. */
  145856. depthOfField?: {
  145857. circleOfConfusion: PostProcess;
  145858. blurSteps: Array<PostProcess>;
  145859. };
  145860. /**
  145861. * Parameters to perform the merge of bloom effect
  145862. */
  145863. bloom?: {
  145864. blurred: PostProcess;
  145865. weight: number;
  145866. };
  145867. }
  145868. /**
  145869. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  145870. */
  145871. export class DepthOfFieldMergePostProcess extends PostProcess {
  145872. private blurSteps;
  145873. /**
  145874. * Creates a new instance of DepthOfFieldMergePostProcess
  145875. * @param name The name of the effect.
  145876. * @param originalFromInput Post process which's input will be used for the merge.
  145877. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  145878. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  145879. * @param options The required width/height ratio to downsize to before computing the render pass.
  145880. * @param camera The camera to apply the render pass to.
  145881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145882. * @param engine The engine which the post process will be applied. (default: current engine)
  145883. * @param reusable If the post process can be reused on the same frame. (default: false)
  145884. * @param textureType Type of textures used when performing the post process. (default: 0)
  145885. * @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)
  145886. */
  145887. 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);
  145888. /**
  145889. * Updates the effect with the current post process compile time values and recompiles the shader.
  145890. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  145891. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  145892. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  145893. * @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
  145894. * @param onCompiled Called when the shader has been compiled.
  145895. * @param onError Called if there is an error when compiling a shader.
  145896. */
  145897. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  145898. }
  145899. }
  145900. declare module BABYLON {
  145901. /**
  145902. * Specifies the level of max blur that should be applied when using the depth of field effect
  145903. */
  145904. export enum DepthOfFieldEffectBlurLevel {
  145905. /**
  145906. * Subtle blur
  145907. */
  145908. Low = 0,
  145909. /**
  145910. * Medium blur
  145911. */
  145912. Medium = 1,
  145913. /**
  145914. * Large blur
  145915. */
  145916. High = 2
  145917. }
  145918. /**
  145919. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  145920. */
  145921. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  145922. private _circleOfConfusion;
  145923. /**
  145924. * @hidden Internal, blurs from high to low
  145925. */
  145926. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  145927. private _depthOfFieldBlurY;
  145928. private _dofMerge;
  145929. /**
  145930. * @hidden Internal post processes in depth of field effect
  145931. */
  145932. _effects: Array<PostProcess>;
  145933. /**
  145934. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  145935. */
  145936. set focalLength(value: number);
  145937. get focalLength(): number;
  145938. /**
  145939. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  145940. */
  145941. set fStop(value: number);
  145942. get fStop(): number;
  145943. /**
  145944. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  145945. */
  145946. set focusDistance(value: number);
  145947. get focusDistance(): number;
  145948. /**
  145949. * 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.
  145950. */
  145951. set lensSize(value: number);
  145952. get lensSize(): number;
  145953. /**
  145954. * Creates a new instance DepthOfFieldEffect
  145955. * @param scene The scene the effect belongs to.
  145956. * @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.
  145957. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  145958. * @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)
  145959. */
  145960. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  145961. /**
  145962. * Get the current class name of the current effet
  145963. * @returns "DepthOfFieldEffect"
  145964. */
  145965. getClassName(): string;
  145966. /**
  145967. * 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.
  145968. */
  145969. set depthTexture(value: RenderTargetTexture);
  145970. /**
  145971. * Disposes each of the internal effects for a given camera.
  145972. * @param camera The camera to dispose the effect on.
  145973. */
  145974. disposeEffects(camera: Camera): void;
  145975. /**
  145976. * @hidden Internal
  145977. */
  145978. _updateEffects(): void;
  145979. /**
  145980. * Internal
  145981. * @returns if all the contained post processes are ready.
  145982. * @hidden
  145983. */
  145984. _isReady(): boolean;
  145985. }
  145986. }
  145987. declare module BABYLON {
  145988. /** @hidden */
  145989. export var displayPassPixelShader: {
  145990. name: string;
  145991. shader: string;
  145992. };
  145993. }
  145994. declare module BABYLON {
  145995. /**
  145996. * DisplayPassPostProcess which produces an output the same as it's input
  145997. */
  145998. export class DisplayPassPostProcess extends PostProcess {
  145999. /**
  146000. * Creates the DisplayPassPostProcess
  146001. * @param name The name of the effect.
  146002. * @param options The required width/height ratio to downsize to before computing the render pass.
  146003. * @param camera The camera to apply the render pass to.
  146004. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146005. * @param engine The engine which the post process will be applied. (default: current engine)
  146006. * @param reusable If the post process can be reused on the same frame. (default: false)
  146007. */
  146008. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146009. }
  146010. }
  146011. declare module BABYLON {
  146012. /** @hidden */
  146013. export var filterPixelShader: {
  146014. name: string;
  146015. shader: string;
  146016. };
  146017. }
  146018. declare module BABYLON {
  146019. /**
  146020. * Applies a kernel filter to the image
  146021. */
  146022. export class FilterPostProcess extends PostProcess {
  146023. /** The matrix to be applied to the image */
  146024. kernelMatrix: Matrix;
  146025. /**
  146026. *
  146027. * @param name The name of the effect.
  146028. * @param kernelMatrix The matrix to be applied to the image
  146029. * @param options The required width/height ratio to downsize to before computing the render pass.
  146030. * @param camera The camera to apply the render pass to.
  146031. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146032. * @param engine The engine which the post process will be applied. (default: current engine)
  146033. * @param reusable If the post process can be reused on the same frame. (default: false)
  146034. */
  146035. constructor(name: string,
  146036. /** The matrix to be applied to the image */
  146037. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146038. }
  146039. }
  146040. declare module BABYLON {
  146041. /** @hidden */
  146042. export var fxaaPixelShader: {
  146043. name: string;
  146044. shader: string;
  146045. };
  146046. }
  146047. declare module BABYLON {
  146048. /** @hidden */
  146049. export var fxaaVertexShader: {
  146050. name: string;
  146051. shader: string;
  146052. };
  146053. }
  146054. declare module BABYLON {
  146055. /**
  146056. * Fxaa post process
  146057. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  146058. */
  146059. export class FxaaPostProcess extends PostProcess {
  146060. /** @hidden */
  146061. texelWidth: number;
  146062. /** @hidden */
  146063. texelHeight: number;
  146064. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146065. private _getDefines;
  146066. }
  146067. }
  146068. declare module BABYLON {
  146069. /** @hidden */
  146070. export var grainPixelShader: {
  146071. name: string;
  146072. shader: string;
  146073. };
  146074. }
  146075. declare module BABYLON {
  146076. /**
  146077. * The GrainPostProcess adds noise to the image at mid luminance levels
  146078. */
  146079. export class GrainPostProcess extends PostProcess {
  146080. /**
  146081. * The intensity of the grain added (default: 30)
  146082. */
  146083. intensity: number;
  146084. /**
  146085. * If the grain should be randomized on every frame
  146086. */
  146087. animated: boolean;
  146088. /**
  146089. * Creates a new instance of @see GrainPostProcess
  146090. * @param name The name of the effect.
  146091. * @param options The required width/height ratio to downsize to before computing the render pass.
  146092. * @param camera The camera to apply the render pass to.
  146093. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146094. * @param engine The engine which the post process will be applied. (default: current engine)
  146095. * @param reusable If the post process can be reused on the same frame. (default: false)
  146096. * @param textureType Type of textures used when performing the post process. (default: 0)
  146097. * @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)
  146098. */
  146099. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146100. }
  146101. }
  146102. declare module BABYLON {
  146103. /** @hidden */
  146104. export var highlightsPixelShader: {
  146105. name: string;
  146106. shader: string;
  146107. };
  146108. }
  146109. declare module BABYLON {
  146110. /**
  146111. * Extracts highlights from the image
  146112. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  146113. */
  146114. export class HighlightsPostProcess extends PostProcess {
  146115. /**
  146116. * Extracts highlights from the image
  146117. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  146118. * @param name The name of the effect.
  146119. * @param options The required width/height ratio to downsize to before computing the render pass.
  146120. * @param camera The camera to apply the render pass to.
  146121. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146122. * @param engine The engine which the post process will be applied. (default: current engine)
  146123. * @param reusable If the post process can be reused on the same frame. (default: false)
  146124. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  146125. */
  146126. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146127. }
  146128. }
  146129. declare module BABYLON {
  146130. /** @hidden */
  146131. export var mrtFragmentDeclaration: {
  146132. name: string;
  146133. shader: string;
  146134. };
  146135. }
  146136. declare module BABYLON {
  146137. /** @hidden */
  146138. export var geometryPixelShader: {
  146139. name: string;
  146140. shader: string;
  146141. };
  146142. }
  146143. declare module BABYLON {
  146144. /** @hidden */
  146145. export var geometryVertexShader: {
  146146. name: string;
  146147. shader: string;
  146148. };
  146149. }
  146150. declare module BABYLON {
  146151. /** @hidden */
  146152. interface ISavedTransformationMatrix {
  146153. world: Matrix;
  146154. viewProjection: Matrix;
  146155. }
  146156. /**
  146157. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  146158. */
  146159. export class GeometryBufferRenderer {
  146160. /**
  146161. * Constant used to retrieve the position texture index in the G-Buffer textures array
  146162. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  146163. */
  146164. static readonly POSITION_TEXTURE_TYPE: number;
  146165. /**
  146166. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  146167. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  146168. */
  146169. static readonly VELOCITY_TEXTURE_TYPE: number;
  146170. /**
  146171. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  146172. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  146173. */
  146174. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  146175. /**
  146176. * Dictionary used to store the previous transformation matrices of each rendered mesh
  146177. * in order to compute objects velocities when enableVelocity is set to "true"
  146178. * @hidden
  146179. */
  146180. _previousTransformationMatrices: {
  146181. [index: number]: ISavedTransformationMatrix;
  146182. };
  146183. /**
  146184. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  146185. * in order to compute objects velocities when enableVelocity is set to "true"
  146186. * @hidden
  146187. */
  146188. _previousBonesTransformationMatrices: {
  146189. [index: number]: Float32Array;
  146190. };
  146191. /**
  146192. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  146193. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  146194. */
  146195. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  146196. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  146197. renderTransparentMeshes: boolean;
  146198. private _scene;
  146199. private _multiRenderTarget;
  146200. private _ratio;
  146201. private _enablePosition;
  146202. private _enableVelocity;
  146203. private _enableReflectivity;
  146204. private _positionIndex;
  146205. private _velocityIndex;
  146206. private _reflectivityIndex;
  146207. protected _effect: Effect;
  146208. protected _cachedDefines: string;
  146209. /**
  146210. * Set the render list (meshes to be rendered) used in the G buffer.
  146211. */
  146212. set renderList(meshes: Mesh[]);
  146213. /**
  146214. * Gets wether or not G buffer are supported by the running hardware.
  146215. * This requires draw buffer supports
  146216. */
  146217. get isSupported(): boolean;
  146218. /**
  146219. * Returns the index of the given texture type in the G-Buffer textures array
  146220. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  146221. * @returns the index of the given texture type in the G-Buffer textures array
  146222. */
  146223. getTextureIndex(textureType: number): number;
  146224. /**
  146225. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  146226. */
  146227. get enablePosition(): boolean;
  146228. /**
  146229. * Sets whether or not objects positions are enabled for the G buffer.
  146230. */
  146231. set enablePosition(enable: boolean);
  146232. /**
  146233. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  146234. */
  146235. get enableVelocity(): boolean;
  146236. /**
  146237. * Sets wether or not objects velocities are enabled for the G buffer.
  146238. */
  146239. set enableVelocity(enable: boolean);
  146240. /**
  146241. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  146242. */
  146243. get enableReflectivity(): boolean;
  146244. /**
  146245. * Sets wether or not objects roughness are enabled for the G buffer.
  146246. */
  146247. set enableReflectivity(enable: boolean);
  146248. /**
  146249. * Gets the scene associated with the buffer.
  146250. */
  146251. get scene(): Scene;
  146252. /**
  146253. * Gets the ratio used by the buffer during its creation.
  146254. * How big is the buffer related to the main canvas.
  146255. */
  146256. get ratio(): number;
  146257. /** @hidden */
  146258. static _SceneComponentInitialization: (scene: Scene) => void;
  146259. /**
  146260. * Creates a new G Buffer for the scene
  146261. * @param scene The scene the buffer belongs to
  146262. * @param ratio How big is the buffer related to the main canvas.
  146263. */
  146264. constructor(scene: Scene, ratio?: number);
  146265. /**
  146266. * Checks wether everything is ready to render a submesh to the G buffer.
  146267. * @param subMesh the submesh to check readiness for
  146268. * @param useInstances is the mesh drawn using instance or not
  146269. * @returns true if ready otherwise false
  146270. */
  146271. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  146272. /**
  146273. * Gets the current underlying G Buffer.
  146274. * @returns the buffer
  146275. */
  146276. getGBuffer(): MultiRenderTarget;
  146277. /**
  146278. * Gets the number of samples used to render the buffer (anti aliasing).
  146279. */
  146280. get samples(): number;
  146281. /**
  146282. * Sets the number of samples used to render the buffer (anti aliasing).
  146283. */
  146284. set samples(value: number);
  146285. /**
  146286. * Disposes the renderer and frees up associated resources.
  146287. */
  146288. dispose(): void;
  146289. protected _createRenderTargets(): void;
  146290. private _copyBonesTransformationMatrices;
  146291. }
  146292. }
  146293. declare module BABYLON {
  146294. interface Scene {
  146295. /** @hidden (Backing field) */
  146296. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  146297. /**
  146298. * Gets or Sets the current geometry buffer associated to the scene.
  146299. */
  146300. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  146301. /**
  146302. * Enables a GeometryBufferRender and associates it with the scene
  146303. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  146304. * @returns the GeometryBufferRenderer
  146305. */
  146306. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  146307. /**
  146308. * Disables the GeometryBufferRender associated with the scene
  146309. */
  146310. disableGeometryBufferRenderer(): void;
  146311. }
  146312. /**
  146313. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  146314. * in several rendering techniques.
  146315. */
  146316. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  146317. /**
  146318. * The component name helpful to identify the component in the list of scene components.
  146319. */
  146320. readonly name: string;
  146321. /**
  146322. * The scene the component belongs to.
  146323. */
  146324. scene: Scene;
  146325. /**
  146326. * Creates a new instance of the component for the given scene
  146327. * @param scene Defines the scene to register the component in
  146328. */
  146329. constructor(scene: Scene);
  146330. /**
  146331. * Registers the component in a given scene
  146332. */
  146333. register(): void;
  146334. /**
  146335. * Rebuilds the elements related to this component in case of
  146336. * context lost for instance.
  146337. */
  146338. rebuild(): void;
  146339. /**
  146340. * Disposes the component and the associated ressources
  146341. */
  146342. dispose(): void;
  146343. private _gatherRenderTargets;
  146344. }
  146345. }
  146346. declare module BABYLON {
  146347. /** @hidden */
  146348. export var motionBlurPixelShader: {
  146349. name: string;
  146350. shader: string;
  146351. };
  146352. }
  146353. declare module BABYLON {
  146354. /**
  146355. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  146356. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  146357. * As an example, all you have to do is to create the post-process:
  146358. * var mb = new BABYLON.MotionBlurPostProcess(
  146359. * 'mb', // The name of the effect.
  146360. * scene, // The scene containing the objects to blur according to their velocity.
  146361. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  146362. * camera // The camera to apply the render pass to.
  146363. * );
  146364. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  146365. */
  146366. export class MotionBlurPostProcess extends PostProcess {
  146367. /**
  146368. * Defines how much the image is blurred by the movement. Default value is equal to 1
  146369. */
  146370. motionStrength: number;
  146371. /**
  146372. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  146373. */
  146374. get motionBlurSamples(): number;
  146375. /**
  146376. * Sets the number of iterations to be used for motion blur quality
  146377. */
  146378. set motionBlurSamples(samples: number);
  146379. private _motionBlurSamples;
  146380. private _geometryBufferRenderer;
  146381. /**
  146382. * Creates a new instance MotionBlurPostProcess
  146383. * @param name The name of the effect.
  146384. * @param scene The scene containing the objects to blur according to their velocity.
  146385. * @param options The required width/height ratio to downsize to before computing the render pass.
  146386. * @param camera The camera to apply the render pass to.
  146387. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146388. * @param engine The engine which the post process will be applied. (default: current engine)
  146389. * @param reusable If the post process can be reused on the same frame. (default: false)
  146390. * @param textureType Type of textures used when performing the post process. (default: 0)
  146391. * @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)
  146392. */
  146393. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146394. /**
  146395. * Excludes the given skinned mesh from computing bones velocities.
  146396. * 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.
  146397. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  146398. */
  146399. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  146400. /**
  146401. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  146402. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  146403. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  146404. */
  146405. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  146406. /**
  146407. * Disposes the post process.
  146408. * @param camera The camera to dispose the post process on.
  146409. */
  146410. dispose(camera?: Camera): void;
  146411. }
  146412. }
  146413. declare module BABYLON {
  146414. /** @hidden */
  146415. export var refractionPixelShader: {
  146416. name: string;
  146417. shader: string;
  146418. };
  146419. }
  146420. declare module BABYLON {
  146421. /**
  146422. * Post process which applies a refractin texture
  146423. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  146424. */
  146425. export class RefractionPostProcess extends PostProcess {
  146426. /** the base color of the refraction (used to taint the rendering) */
  146427. color: Color3;
  146428. /** simulated refraction depth */
  146429. depth: number;
  146430. /** the coefficient of the base color (0 to remove base color tainting) */
  146431. colorLevel: number;
  146432. private _refTexture;
  146433. private _ownRefractionTexture;
  146434. /**
  146435. * Gets or sets the refraction texture
  146436. * Please note that you are responsible for disposing the texture if you set it manually
  146437. */
  146438. get refractionTexture(): Texture;
  146439. set refractionTexture(value: Texture);
  146440. /**
  146441. * Initializes the RefractionPostProcess
  146442. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  146443. * @param name The name of the effect.
  146444. * @param refractionTextureUrl Url of the refraction texture to use
  146445. * @param color the base color of the refraction (used to taint the rendering)
  146446. * @param depth simulated refraction depth
  146447. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  146448. * @param camera The camera to apply the render pass to.
  146449. * @param options The required width/height ratio to downsize to before computing the render pass.
  146450. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146451. * @param engine The engine which the post process will be applied. (default: current engine)
  146452. * @param reusable If the post process can be reused on the same frame. (default: false)
  146453. */
  146454. constructor(name: string, refractionTextureUrl: string,
  146455. /** the base color of the refraction (used to taint the rendering) */
  146456. color: Color3,
  146457. /** simulated refraction depth */
  146458. depth: number,
  146459. /** the coefficient of the base color (0 to remove base color tainting) */
  146460. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146461. /**
  146462. * Disposes of the post process
  146463. * @param camera Camera to dispose post process on
  146464. */
  146465. dispose(camera: Camera): void;
  146466. }
  146467. }
  146468. declare module BABYLON {
  146469. /** @hidden */
  146470. export var sharpenPixelShader: {
  146471. name: string;
  146472. shader: string;
  146473. };
  146474. }
  146475. declare module BABYLON {
  146476. /**
  146477. * The SharpenPostProcess applies a sharpen kernel to every pixel
  146478. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  146479. */
  146480. export class SharpenPostProcess extends PostProcess {
  146481. /**
  146482. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  146483. */
  146484. colorAmount: number;
  146485. /**
  146486. * How much sharpness should be applied (default: 0.3)
  146487. */
  146488. edgeAmount: number;
  146489. /**
  146490. * Creates a new instance ConvolutionPostProcess
  146491. * @param name The name of the effect.
  146492. * @param options The required width/height ratio to downsize to before computing the render pass.
  146493. * @param camera The camera to apply the render pass to.
  146494. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146495. * @param engine The engine which the post process will be applied. (default: current engine)
  146496. * @param reusable If the post process can be reused on the same frame. (default: false)
  146497. * @param textureType Type of textures used when performing the post process. (default: 0)
  146498. * @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)
  146499. */
  146500. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146501. }
  146502. }
  146503. declare module BABYLON {
  146504. /**
  146505. * PostProcessRenderPipeline
  146506. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146507. */
  146508. export class PostProcessRenderPipeline {
  146509. private engine;
  146510. private _renderEffects;
  146511. private _renderEffectsForIsolatedPass;
  146512. /**
  146513. * List of inspectable custom properties (used by the Inspector)
  146514. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  146515. */
  146516. inspectableCustomProperties: IInspectable[];
  146517. /**
  146518. * @hidden
  146519. */
  146520. protected _cameras: Camera[];
  146521. /** @hidden */
  146522. _name: string;
  146523. /**
  146524. * Gets pipeline name
  146525. */
  146526. get name(): string;
  146527. /** Gets the list of attached cameras */
  146528. get cameras(): Camera[];
  146529. /**
  146530. * Initializes a PostProcessRenderPipeline
  146531. * @param engine engine to add the pipeline to
  146532. * @param name name of the pipeline
  146533. */
  146534. constructor(engine: Engine, name: string);
  146535. /**
  146536. * Gets the class name
  146537. * @returns "PostProcessRenderPipeline"
  146538. */
  146539. getClassName(): string;
  146540. /**
  146541. * If all the render effects in the pipeline are supported
  146542. */
  146543. get isSupported(): boolean;
  146544. /**
  146545. * Adds an effect to the pipeline
  146546. * @param renderEffect the effect to add
  146547. */
  146548. addEffect(renderEffect: PostProcessRenderEffect): void;
  146549. /** @hidden */
  146550. _rebuild(): void;
  146551. /** @hidden */
  146552. _enableEffect(renderEffectName: string, cameras: Camera): void;
  146553. /** @hidden */
  146554. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  146555. /** @hidden */
  146556. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  146557. /** @hidden */
  146558. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  146559. /** @hidden */
  146560. _attachCameras(cameras: Camera, unique: boolean): void;
  146561. /** @hidden */
  146562. _attachCameras(cameras: Camera[], unique: boolean): void;
  146563. /** @hidden */
  146564. _detachCameras(cameras: Camera): void;
  146565. /** @hidden */
  146566. _detachCameras(cameras: Nullable<Camera[]>): void;
  146567. /** @hidden */
  146568. _update(): void;
  146569. /** @hidden */
  146570. _reset(): void;
  146571. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  146572. /**
  146573. * Disposes of the pipeline
  146574. */
  146575. dispose(): void;
  146576. }
  146577. }
  146578. declare module BABYLON {
  146579. /**
  146580. * PostProcessRenderPipelineManager class
  146581. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146582. */
  146583. export class PostProcessRenderPipelineManager {
  146584. private _renderPipelines;
  146585. /**
  146586. * Initializes a PostProcessRenderPipelineManager
  146587. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146588. */
  146589. constructor();
  146590. /**
  146591. * Gets the list of supported render pipelines
  146592. */
  146593. get supportedPipelines(): PostProcessRenderPipeline[];
  146594. /**
  146595. * Adds a pipeline to the manager
  146596. * @param renderPipeline The pipeline to add
  146597. */
  146598. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  146599. /**
  146600. * Attaches a camera to the pipeline
  146601. * @param renderPipelineName The name of the pipeline to attach to
  146602. * @param cameras the camera to attach
  146603. * @param unique if the camera can be attached multiple times to the pipeline
  146604. */
  146605. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  146606. /**
  146607. * Detaches a camera from the pipeline
  146608. * @param renderPipelineName The name of the pipeline to detach from
  146609. * @param cameras the camera to detach
  146610. */
  146611. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  146612. /**
  146613. * Enables an effect by name on a pipeline
  146614. * @param renderPipelineName the name of the pipeline to enable the effect in
  146615. * @param renderEffectName the name of the effect to enable
  146616. * @param cameras the cameras that the effect should be enabled on
  146617. */
  146618. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  146619. /**
  146620. * Disables an effect by name on a pipeline
  146621. * @param renderPipelineName the name of the pipeline to disable the effect in
  146622. * @param renderEffectName the name of the effect to disable
  146623. * @param cameras the cameras that the effect should be disabled on
  146624. */
  146625. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  146626. /**
  146627. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  146628. */
  146629. update(): void;
  146630. /** @hidden */
  146631. _rebuild(): void;
  146632. /**
  146633. * Disposes of the manager and pipelines
  146634. */
  146635. dispose(): void;
  146636. }
  146637. }
  146638. declare module BABYLON {
  146639. interface Scene {
  146640. /** @hidden (Backing field) */
  146641. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  146642. /**
  146643. * Gets the postprocess render pipeline manager
  146644. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146645. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  146646. */
  146647. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  146648. }
  146649. /**
  146650. * Defines the Render Pipeline scene component responsible to rendering pipelines
  146651. */
  146652. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  146653. /**
  146654. * The component name helpfull to identify the component in the list of scene components.
  146655. */
  146656. readonly name: string;
  146657. /**
  146658. * The scene the component belongs to.
  146659. */
  146660. scene: Scene;
  146661. /**
  146662. * Creates a new instance of the component for the given scene
  146663. * @param scene Defines the scene to register the component in
  146664. */
  146665. constructor(scene: Scene);
  146666. /**
  146667. * Registers the component in a given scene
  146668. */
  146669. register(): void;
  146670. /**
  146671. * Rebuilds the elements related to this component in case of
  146672. * context lost for instance.
  146673. */
  146674. rebuild(): void;
  146675. /**
  146676. * Disposes the component and the associated ressources
  146677. */
  146678. dispose(): void;
  146679. private _gatherRenderTargets;
  146680. }
  146681. }
  146682. declare module BABYLON {
  146683. /**
  146684. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  146685. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  146686. */
  146687. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  146688. private _scene;
  146689. private _camerasToBeAttached;
  146690. /**
  146691. * ID of the sharpen post process,
  146692. */
  146693. private readonly SharpenPostProcessId;
  146694. /**
  146695. * @ignore
  146696. * ID of the image processing post process;
  146697. */
  146698. readonly ImageProcessingPostProcessId: string;
  146699. /**
  146700. * @ignore
  146701. * ID of the Fast Approximate Anti-Aliasing post process;
  146702. */
  146703. readonly FxaaPostProcessId: string;
  146704. /**
  146705. * ID of the chromatic aberration post process,
  146706. */
  146707. private readonly ChromaticAberrationPostProcessId;
  146708. /**
  146709. * ID of the grain post process
  146710. */
  146711. private readonly GrainPostProcessId;
  146712. /**
  146713. * Sharpen post process which will apply a sharpen convolution to enhance edges
  146714. */
  146715. sharpen: SharpenPostProcess;
  146716. private _sharpenEffect;
  146717. private bloom;
  146718. /**
  146719. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  146720. */
  146721. depthOfField: DepthOfFieldEffect;
  146722. /**
  146723. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  146724. */
  146725. fxaa: FxaaPostProcess;
  146726. /**
  146727. * Image post processing pass used to perform operations such as tone mapping or color grading.
  146728. */
  146729. imageProcessing: ImageProcessingPostProcess;
  146730. /**
  146731. * Chromatic aberration post process which will shift rgb colors in the image
  146732. */
  146733. chromaticAberration: ChromaticAberrationPostProcess;
  146734. private _chromaticAberrationEffect;
  146735. /**
  146736. * Grain post process which add noise to the image
  146737. */
  146738. grain: GrainPostProcess;
  146739. private _grainEffect;
  146740. /**
  146741. * Glow post process which adds a glow to emissive areas of the image
  146742. */
  146743. private _glowLayer;
  146744. /**
  146745. * Animations which can be used to tweak settings over a period of time
  146746. */
  146747. animations: Animation[];
  146748. private _imageProcessingConfigurationObserver;
  146749. private _sharpenEnabled;
  146750. private _bloomEnabled;
  146751. private _depthOfFieldEnabled;
  146752. private _depthOfFieldBlurLevel;
  146753. private _fxaaEnabled;
  146754. private _imageProcessingEnabled;
  146755. private _defaultPipelineTextureType;
  146756. private _bloomScale;
  146757. private _chromaticAberrationEnabled;
  146758. private _grainEnabled;
  146759. private _buildAllowed;
  146760. /**
  146761. * Gets active scene
  146762. */
  146763. get scene(): Scene;
  146764. /**
  146765. * Enable or disable the sharpen process from the pipeline
  146766. */
  146767. set sharpenEnabled(enabled: boolean);
  146768. get sharpenEnabled(): boolean;
  146769. private _resizeObserver;
  146770. private _hardwareScaleLevel;
  146771. private _bloomKernel;
  146772. /**
  146773. * Specifies the size of the bloom blur kernel, relative to the final output size
  146774. */
  146775. get bloomKernel(): number;
  146776. set bloomKernel(value: number);
  146777. /**
  146778. * Specifies the weight of the bloom in the final rendering
  146779. */
  146780. private _bloomWeight;
  146781. /**
  146782. * Specifies the luma threshold for the area that will be blurred by the bloom
  146783. */
  146784. private _bloomThreshold;
  146785. private _hdr;
  146786. /**
  146787. * The strength of the bloom.
  146788. */
  146789. set bloomWeight(value: number);
  146790. get bloomWeight(): number;
  146791. /**
  146792. * The strength of the bloom.
  146793. */
  146794. set bloomThreshold(value: number);
  146795. get bloomThreshold(): number;
  146796. /**
  146797. * The scale of the bloom, lower value will provide better performance.
  146798. */
  146799. set bloomScale(value: number);
  146800. get bloomScale(): number;
  146801. /**
  146802. * Enable or disable the bloom from the pipeline
  146803. */
  146804. set bloomEnabled(enabled: boolean);
  146805. get bloomEnabled(): boolean;
  146806. private _rebuildBloom;
  146807. /**
  146808. * If the depth of field is enabled.
  146809. */
  146810. get depthOfFieldEnabled(): boolean;
  146811. set depthOfFieldEnabled(enabled: boolean);
  146812. /**
  146813. * Blur level of the depth of field effect. (Higher blur will effect performance)
  146814. */
  146815. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  146816. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  146817. /**
  146818. * If the anti aliasing is enabled.
  146819. */
  146820. set fxaaEnabled(enabled: boolean);
  146821. get fxaaEnabled(): boolean;
  146822. private _samples;
  146823. /**
  146824. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  146825. */
  146826. set samples(sampleCount: number);
  146827. get samples(): number;
  146828. /**
  146829. * If image processing is enabled.
  146830. */
  146831. set imageProcessingEnabled(enabled: boolean);
  146832. get imageProcessingEnabled(): boolean;
  146833. /**
  146834. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  146835. */
  146836. set glowLayerEnabled(enabled: boolean);
  146837. get glowLayerEnabled(): boolean;
  146838. /**
  146839. * Gets the glow layer (or null if not defined)
  146840. */
  146841. get glowLayer(): Nullable<GlowLayer>;
  146842. /**
  146843. * Enable or disable the chromaticAberration process from the pipeline
  146844. */
  146845. set chromaticAberrationEnabled(enabled: boolean);
  146846. get chromaticAberrationEnabled(): boolean;
  146847. /**
  146848. * Enable or disable the grain process from the pipeline
  146849. */
  146850. set grainEnabled(enabled: boolean);
  146851. get grainEnabled(): boolean;
  146852. /**
  146853. * @constructor
  146854. * @param name - The rendering pipeline name (default: "")
  146855. * @param hdr - If high dynamic range textures should be used (default: true)
  146856. * @param scene - The scene linked to this pipeline (default: the last created scene)
  146857. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  146858. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  146859. */
  146860. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  146861. /**
  146862. * Get the class name
  146863. * @returns "DefaultRenderingPipeline"
  146864. */
  146865. getClassName(): string;
  146866. /**
  146867. * Force the compilation of the entire pipeline.
  146868. */
  146869. prepare(): void;
  146870. private _hasCleared;
  146871. private _prevPostProcess;
  146872. private _prevPrevPostProcess;
  146873. private _setAutoClearAndTextureSharing;
  146874. private _depthOfFieldSceneObserver;
  146875. private _buildPipeline;
  146876. private _disposePostProcesses;
  146877. /**
  146878. * Adds a camera to the pipeline
  146879. * @param camera the camera to be added
  146880. */
  146881. addCamera(camera: Camera): void;
  146882. /**
  146883. * Removes a camera from the pipeline
  146884. * @param camera the camera to remove
  146885. */
  146886. removeCamera(camera: Camera): void;
  146887. /**
  146888. * Dispose of the pipeline and stop all post processes
  146889. */
  146890. dispose(): void;
  146891. /**
  146892. * Serialize the rendering pipeline (Used when exporting)
  146893. * @returns the serialized object
  146894. */
  146895. serialize(): any;
  146896. /**
  146897. * Parse the serialized pipeline
  146898. * @param source Source pipeline.
  146899. * @param scene The scene to load the pipeline to.
  146900. * @param rootUrl The URL of the serialized pipeline.
  146901. * @returns An instantiated pipeline from the serialized object.
  146902. */
  146903. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  146904. }
  146905. }
  146906. declare module BABYLON {
  146907. /** @hidden */
  146908. export var lensHighlightsPixelShader: {
  146909. name: string;
  146910. shader: string;
  146911. };
  146912. }
  146913. declare module BABYLON {
  146914. /** @hidden */
  146915. export var depthOfFieldPixelShader: {
  146916. name: string;
  146917. shader: string;
  146918. };
  146919. }
  146920. declare module BABYLON {
  146921. /**
  146922. * BABYLON.JS Chromatic Aberration GLSL Shader
  146923. * Author: Olivier Guyot
  146924. * Separates very slightly R, G and B colors on the edges of the screen
  146925. * Inspired by Francois Tarlier & Martins Upitis
  146926. */
  146927. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  146928. /**
  146929. * @ignore
  146930. * The chromatic aberration PostProcess id in the pipeline
  146931. */
  146932. LensChromaticAberrationEffect: string;
  146933. /**
  146934. * @ignore
  146935. * The highlights enhancing PostProcess id in the pipeline
  146936. */
  146937. HighlightsEnhancingEffect: string;
  146938. /**
  146939. * @ignore
  146940. * The depth-of-field PostProcess id in the pipeline
  146941. */
  146942. LensDepthOfFieldEffect: string;
  146943. private _scene;
  146944. private _depthTexture;
  146945. private _grainTexture;
  146946. private _chromaticAberrationPostProcess;
  146947. private _highlightsPostProcess;
  146948. private _depthOfFieldPostProcess;
  146949. private _edgeBlur;
  146950. private _grainAmount;
  146951. private _chromaticAberration;
  146952. private _distortion;
  146953. private _highlightsGain;
  146954. private _highlightsThreshold;
  146955. private _dofDistance;
  146956. private _dofAperture;
  146957. private _dofDarken;
  146958. private _dofPentagon;
  146959. private _blurNoise;
  146960. /**
  146961. * @constructor
  146962. *
  146963. * Effect parameters are as follow:
  146964. * {
  146965. * chromatic_aberration: number; // from 0 to x (1 for realism)
  146966. * edge_blur: number; // from 0 to x (1 for realism)
  146967. * distortion: number; // from 0 to x (1 for realism)
  146968. * grain_amount: number; // from 0 to 1
  146969. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  146970. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  146971. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  146972. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  146973. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  146974. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  146975. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  146976. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  146977. * }
  146978. * Note: if an effect parameter is unset, effect is disabled
  146979. *
  146980. * @param name The rendering pipeline name
  146981. * @param parameters - An object containing all parameters (see above)
  146982. * @param scene The scene linked to this pipeline
  146983. * @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)
  146984. * @param cameras The array of cameras that the rendering pipeline will be attached to
  146985. */
  146986. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  146987. /**
  146988. * Get the class name
  146989. * @returns "LensRenderingPipeline"
  146990. */
  146991. getClassName(): string;
  146992. /**
  146993. * Gets associated scene
  146994. */
  146995. get scene(): Scene;
  146996. /**
  146997. * Gets or sets the edge blur
  146998. */
  146999. get edgeBlur(): number;
  147000. set edgeBlur(value: number);
  147001. /**
  147002. * Gets or sets the grain amount
  147003. */
  147004. get grainAmount(): number;
  147005. set grainAmount(value: number);
  147006. /**
  147007. * Gets or sets the chromatic aberration amount
  147008. */
  147009. get chromaticAberration(): number;
  147010. set chromaticAberration(value: number);
  147011. /**
  147012. * Gets or sets the depth of field aperture
  147013. */
  147014. get dofAperture(): number;
  147015. set dofAperture(value: number);
  147016. /**
  147017. * Gets or sets the edge distortion
  147018. */
  147019. get edgeDistortion(): number;
  147020. set edgeDistortion(value: number);
  147021. /**
  147022. * Gets or sets the depth of field distortion
  147023. */
  147024. get dofDistortion(): number;
  147025. set dofDistortion(value: number);
  147026. /**
  147027. * Gets or sets the darken out of focus amount
  147028. */
  147029. get darkenOutOfFocus(): number;
  147030. set darkenOutOfFocus(value: number);
  147031. /**
  147032. * Gets or sets a boolean indicating if blur noise is enabled
  147033. */
  147034. get blurNoise(): boolean;
  147035. set blurNoise(value: boolean);
  147036. /**
  147037. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  147038. */
  147039. get pentagonBokeh(): boolean;
  147040. set pentagonBokeh(value: boolean);
  147041. /**
  147042. * Gets or sets the highlight grain amount
  147043. */
  147044. get highlightsGain(): number;
  147045. set highlightsGain(value: number);
  147046. /**
  147047. * Gets or sets the highlight threshold
  147048. */
  147049. get highlightsThreshold(): number;
  147050. set highlightsThreshold(value: number);
  147051. /**
  147052. * Sets the amount of blur at the edges
  147053. * @param amount blur amount
  147054. */
  147055. setEdgeBlur(amount: number): void;
  147056. /**
  147057. * Sets edge blur to 0
  147058. */
  147059. disableEdgeBlur(): void;
  147060. /**
  147061. * Sets the amout of grain
  147062. * @param amount Amount of grain
  147063. */
  147064. setGrainAmount(amount: number): void;
  147065. /**
  147066. * Set grain amount to 0
  147067. */
  147068. disableGrain(): void;
  147069. /**
  147070. * Sets the chromatic aberration amount
  147071. * @param amount amount of chromatic aberration
  147072. */
  147073. setChromaticAberration(amount: number): void;
  147074. /**
  147075. * Sets chromatic aberration amount to 0
  147076. */
  147077. disableChromaticAberration(): void;
  147078. /**
  147079. * Sets the EdgeDistortion amount
  147080. * @param amount amount of EdgeDistortion
  147081. */
  147082. setEdgeDistortion(amount: number): void;
  147083. /**
  147084. * Sets edge distortion to 0
  147085. */
  147086. disableEdgeDistortion(): void;
  147087. /**
  147088. * Sets the FocusDistance amount
  147089. * @param amount amount of FocusDistance
  147090. */
  147091. setFocusDistance(amount: number): void;
  147092. /**
  147093. * Disables depth of field
  147094. */
  147095. disableDepthOfField(): void;
  147096. /**
  147097. * Sets the Aperture amount
  147098. * @param amount amount of Aperture
  147099. */
  147100. setAperture(amount: number): void;
  147101. /**
  147102. * Sets the DarkenOutOfFocus amount
  147103. * @param amount amount of DarkenOutOfFocus
  147104. */
  147105. setDarkenOutOfFocus(amount: number): void;
  147106. private _pentagonBokehIsEnabled;
  147107. /**
  147108. * Creates a pentagon bokeh effect
  147109. */
  147110. enablePentagonBokeh(): void;
  147111. /**
  147112. * Disables the pentagon bokeh effect
  147113. */
  147114. disablePentagonBokeh(): void;
  147115. /**
  147116. * Enables noise blur
  147117. */
  147118. enableNoiseBlur(): void;
  147119. /**
  147120. * Disables noise blur
  147121. */
  147122. disableNoiseBlur(): void;
  147123. /**
  147124. * Sets the HighlightsGain amount
  147125. * @param amount amount of HighlightsGain
  147126. */
  147127. setHighlightsGain(amount: number): void;
  147128. /**
  147129. * Sets the HighlightsThreshold amount
  147130. * @param amount amount of HighlightsThreshold
  147131. */
  147132. setHighlightsThreshold(amount: number): void;
  147133. /**
  147134. * Disables highlights
  147135. */
  147136. disableHighlights(): void;
  147137. /**
  147138. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  147139. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  147140. */
  147141. dispose(disableDepthRender?: boolean): void;
  147142. private _createChromaticAberrationPostProcess;
  147143. private _createHighlightsPostProcess;
  147144. private _createDepthOfFieldPostProcess;
  147145. private _createGrainTexture;
  147146. }
  147147. }
  147148. declare module BABYLON {
  147149. /** @hidden */
  147150. export var ssao2PixelShader: {
  147151. name: string;
  147152. shader: string;
  147153. };
  147154. }
  147155. declare module BABYLON {
  147156. /** @hidden */
  147157. export var ssaoCombinePixelShader: {
  147158. name: string;
  147159. shader: string;
  147160. };
  147161. }
  147162. declare module BABYLON {
  147163. /**
  147164. * Render pipeline to produce ssao effect
  147165. */
  147166. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  147167. /**
  147168. * @ignore
  147169. * The PassPostProcess id in the pipeline that contains the original scene color
  147170. */
  147171. SSAOOriginalSceneColorEffect: string;
  147172. /**
  147173. * @ignore
  147174. * The SSAO PostProcess id in the pipeline
  147175. */
  147176. SSAORenderEffect: string;
  147177. /**
  147178. * @ignore
  147179. * The horizontal blur PostProcess id in the pipeline
  147180. */
  147181. SSAOBlurHRenderEffect: string;
  147182. /**
  147183. * @ignore
  147184. * The vertical blur PostProcess id in the pipeline
  147185. */
  147186. SSAOBlurVRenderEffect: string;
  147187. /**
  147188. * @ignore
  147189. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  147190. */
  147191. SSAOCombineRenderEffect: string;
  147192. /**
  147193. * The output strength of the SSAO post-process. Default value is 1.0.
  147194. */
  147195. totalStrength: number;
  147196. /**
  147197. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  147198. */
  147199. maxZ: number;
  147200. /**
  147201. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  147202. */
  147203. minZAspect: number;
  147204. private _samples;
  147205. /**
  147206. * Number of samples used for the SSAO calculations. Default value is 8
  147207. */
  147208. set samples(n: number);
  147209. get samples(): number;
  147210. private _textureSamples;
  147211. /**
  147212. * Number of samples to use for antialiasing
  147213. */
  147214. set textureSamples(n: number);
  147215. get textureSamples(): number;
  147216. /**
  147217. * Ratio object used for SSAO ratio and blur ratio
  147218. */
  147219. private _ratio;
  147220. /**
  147221. * Dynamically generated sphere sampler.
  147222. */
  147223. private _sampleSphere;
  147224. /**
  147225. * Blur filter offsets
  147226. */
  147227. private _samplerOffsets;
  147228. private _expensiveBlur;
  147229. /**
  147230. * If bilateral blur should be used
  147231. */
  147232. set expensiveBlur(b: boolean);
  147233. get expensiveBlur(): boolean;
  147234. /**
  147235. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  147236. */
  147237. radius: number;
  147238. /**
  147239. * The base color of the SSAO post-process
  147240. * The final result is "base + ssao" between [0, 1]
  147241. */
  147242. base: number;
  147243. /**
  147244. * Support test.
  147245. */
  147246. static get IsSupported(): boolean;
  147247. private _scene;
  147248. private _depthTexture;
  147249. private _normalTexture;
  147250. private _randomTexture;
  147251. private _originalColorPostProcess;
  147252. private _ssaoPostProcess;
  147253. private _blurHPostProcess;
  147254. private _blurVPostProcess;
  147255. private _ssaoCombinePostProcess;
  147256. /**
  147257. * Gets active scene
  147258. */
  147259. get scene(): Scene;
  147260. /**
  147261. * @constructor
  147262. * @param name The rendering pipeline name
  147263. * @param scene The scene linked to this pipeline
  147264. * @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 }
  147265. * @param cameras The array of cameras that the rendering pipeline will be attached to
  147266. */
  147267. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  147268. /**
  147269. * Get the class name
  147270. * @returns "SSAO2RenderingPipeline"
  147271. */
  147272. getClassName(): string;
  147273. /**
  147274. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  147275. */
  147276. dispose(disableGeometryBufferRenderer?: boolean): void;
  147277. private _createBlurPostProcess;
  147278. /** @hidden */
  147279. _rebuild(): void;
  147280. private _bits;
  147281. private _radicalInverse_VdC;
  147282. private _hammersley;
  147283. private _hemisphereSample_uniform;
  147284. private _generateHemisphere;
  147285. private _createSSAOPostProcess;
  147286. private _createSSAOCombinePostProcess;
  147287. private _createRandomTexture;
  147288. /**
  147289. * Serialize the rendering pipeline (Used when exporting)
  147290. * @returns the serialized object
  147291. */
  147292. serialize(): any;
  147293. /**
  147294. * Parse the serialized pipeline
  147295. * @param source Source pipeline.
  147296. * @param scene The scene to load the pipeline to.
  147297. * @param rootUrl The URL of the serialized pipeline.
  147298. * @returns An instantiated pipeline from the serialized object.
  147299. */
  147300. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  147301. }
  147302. }
  147303. declare module BABYLON {
  147304. /** @hidden */
  147305. export var ssaoPixelShader: {
  147306. name: string;
  147307. shader: string;
  147308. };
  147309. }
  147310. declare module BABYLON {
  147311. /**
  147312. * Render pipeline to produce ssao effect
  147313. */
  147314. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  147315. /**
  147316. * @ignore
  147317. * The PassPostProcess id in the pipeline that contains the original scene color
  147318. */
  147319. SSAOOriginalSceneColorEffect: string;
  147320. /**
  147321. * @ignore
  147322. * The SSAO PostProcess id in the pipeline
  147323. */
  147324. SSAORenderEffect: string;
  147325. /**
  147326. * @ignore
  147327. * The horizontal blur PostProcess id in the pipeline
  147328. */
  147329. SSAOBlurHRenderEffect: string;
  147330. /**
  147331. * @ignore
  147332. * The vertical blur PostProcess id in the pipeline
  147333. */
  147334. SSAOBlurVRenderEffect: string;
  147335. /**
  147336. * @ignore
  147337. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  147338. */
  147339. SSAOCombineRenderEffect: string;
  147340. /**
  147341. * The output strength of the SSAO post-process. Default value is 1.0.
  147342. */
  147343. totalStrength: number;
  147344. /**
  147345. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  147346. */
  147347. radius: number;
  147348. /**
  147349. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  147350. * Must not be equal to fallOff and superior to fallOff.
  147351. * Default value is 0.0075
  147352. */
  147353. area: number;
  147354. /**
  147355. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  147356. * Must not be equal to area and inferior to area.
  147357. * Default value is 0.000001
  147358. */
  147359. fallOff: number;
  147360. /**
  147361. * The base color of the SSAO post-process
  147362. * The final result is "base + ssao" between [0, 1]
  147363. */
  147364. base: number;
  147365. private _scene;
  147366. private _depthTexture;
  147367. private _randomTexture;
  147368. private _originalColorPostProcess;
  147369. private _ssaoPostProcess;
  147370. private _blurHPostProcess;
  147371. private _blurVPostProcess;
  147372. private _ssaoCombinePostProcess;
  147373. private _firstUpdate;
  147374. /**
  147375. * Gets active scene
  147376. */
  147377. get scene(): Scene;
  147378. /**
  147379. * @constructor
  147380. * @param name - The rendering pipeline name
  147381. * @param scene - The scene linked to this pipeline
  147382. * @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 }
  147383. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  147384. */
  147385. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  147386. /**
  147387. * Get the class name
  147388. * @returns "SSAORenderingPipeline"
  147389. */
  147390. getClassName(): string;
  147391. /**
  147392. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  147393. */
  147394. dispose(disableDepthRender?: boolean): void;
  147395. private _createBlurPostProcess;
  147396. /** @hidden */
  147397. _rebuild(): void;
  147398. private _createSSAOPostProcess;
  147399. private _createSSAOCombinePostProcess;
  147400. private _createRandomTexture;
  147401. }
  147402. }
  147403. declare module BABYLON {
  147404. /** @hidden */
  147405. export var screenSpaceReflectionPixelShader: {
  147406. name: string;
  147407. shader: string;
  147408. };
  147409. }
  147410. declare module BABYLON {
  147411. /**
  147412. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  147413. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  147414. */
  147415. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  147416. /**
  147417. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  147418. */
  147419. threshold: number;
  147420. /**
  147421. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  147422. */
  147423. strength: number;
  147424. /**
  147425. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  147426. */
  147427. reflectionSpecularFalloffExponent: number;
  147428. /**
  147429. * 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]
  147430. */
  147431. step: number;
  147432. /**
  147433. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  147434. */
  147435. roughnessFactor: number;
  147436. private _geometryBufferRenderer;
  147437. private _enableSmoothReflections;
  147438. private _reflectionSamples;
  147439. private _smoothSteps;
  147440. /**
  147441. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  147442. * @param name The name of the effect.
  147443. * @param scene The scene containing the objects to calculate reflections.
  147444. * @param options The required width/height ratio to downsize to before computing the render pass.
  147445. * @param camera The camera to apply the render pass to.
  147446. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147447. * @param engine The engine which the post process will be applied. (default: current engine)
  147448. * @param reusable If the post process can be reused on the same frame. (default: false)
  147449. * @param textureType Type of textures used when performing the post process. (default: 0)
  147450. * @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)
  147451. */
  147452. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147453. /**
  147454. * Gets wether or not smoothing reflections is enabled.
  147455. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  147456. */
  147457. get enableSmoothReflections(): boolean;
  147458. /**
  147459. * Sets wether or not smoothing reflections is enabled.
  147460. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  147461. */
  147462. set enableSmoothReflections(enabled: boolean);
  147463. /**
  147464. * Gets the number of samples taken while computing reflections. More samples count is high,
  147465. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  147466. */
  147467. get reflectionSamples(): number;
  147468. /**
  147469. * Sets the number of samples taken while computing reflections. More samples count is high,
  147470. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  147471. */
  147472. set reflectionSamples(samples: number);
  147473. /**
  147474. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  147475. * more the post-process will require GPU power and can generate a drop in FPS.
  147476. * Default value (5.0) work pretty well in all cases but can be adjusted.
  147477. */
  147478. get smoothSteps(): number;
  147479. set smoothSteps(steps: number);
  147480. private _updateEffectDefines;
  147481. }
  147482. }
  147483. declare module BABYLON {
  147484. /** @hidden */
  147485. export var standardPixelShader: {
  147486. name: string;
  147487. shader: string;
  147488. };
  147489. }
  147490. declare module BABYLON {
  147491. /**
  147492. * Standard rendering pipeline
  147493. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  147494. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  147495. */
  147496. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  147497. /**
  147498. * Public members
  147499. */
  147500. /**
  147501. * Post-process which contains the original scene color before the pipeline applies all the effects
  147502. */
  147503. originalPostProcess: Nullable<PostProcess>;
  147504. /**
  147505. * Post-process used to down scale an image x4
  147506. */
  147507. downSampleX4PostProcess: Nullable<PostProcess>;
  147508. /**
  147509. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  147510. */
  147511. brightPassPostProcess: Nullable<PostProcess>;
  147512. /**
  147513. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  147514. */
  147515. blurHPostProcesses: PostProcess[];
  147516. /**
  147517. * Post-process array storing all the vertical blur post-processes used by the pipeline
  147518. */
  147519. blurVPostProcesses: PostProcess[];
  147520. /**
  147521. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  147522. */
  147523. textureAdderPostProcess: Nullable<PostProcess>;
  147524. /**
  147525. * Post-process used to create volumetric lighting effect
  147526. */
  147527. volumetricLightPostProcess: Nullable<PostProcess>;
  147528. /**
  147529. * Post-process used to smooth the previous volumetric light post-process on the X axis
  147530. */
  147531. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  147532. /**
  147533. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  147534. */
  147535. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  147536. /**
  147537. * Post-process used to merge the volumetric light effect and the real scene color
  147538. */
  147539. volumetricLightMergePostProces: Nullable<PostProcess>;
  147540. /**
  147541. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  147542. */
  147543. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  147544. /**
  147545. * Base post-process used to calculate the average luminance of the final image for HDR
  147546. */
  147547. luminancePostProcess: Nullable<PostProcess>;
  147548. /**
  147549. * Post-processes used to create down sample post-processes in order to get
  147550. * the average luminance of the final image for HDR
  147551. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  147552. */
  147553. luminanceDownSamplePostProcesses: PostProcess[];
  147554. /**
  147555. * Post-process used to create a HDR effect (light adaptation)
  147556. */
  147557. hdrPostProcess: Nullable<PostProcess>;
  147558. /**
  147559. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  147560. */
  147561. textureAdderFinalPostProcess: Nullable<PostProcess>;
  147562. /**
  147563. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  147564. */
  147565. lensFlareFinalPostProcess: Nullable<PostProcess>;
  147566. /**
  147567. * Post-process used to merge the final HDR post-process and the real scene color
  147568. */
  147569. hdrFinalPostProcess: Nullable<PostProcess>;
  147570. /**
  147571. * Post-process used to create a lens flare effect
  147572. */
  147573. lensFlarePostProcess: Nullable<PostProcess>;
  147574. /**
  147575. * Post-process that merges the result of the lens flare post-process and the real scene color
  147576. */
  147577. lensFlareComposePostProcess: Nullable<PostProcess>;
  147578. /**
  147579. * Post-process used to create a motion blur effect
  147580. */
  147581. motionBlurPostProcess: Nullable<PostProcess>;
  147582. /**
  147583. * Post-process used to create a depth of field effect
  147584. */
  147585. depthOfFieldPostProcess: Nullable<PostProcess>;
  147586. /**
  147587. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  147588. */
  147589. fxaaPostProcess: Nullable<FxaaPostProcess>;
  147590. /**
  147591. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  147592. */
  147593. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  147594. /**
  147595. * Represents the brightness threshold in order to configure the illuminated surfaces
  147596. */
  147597. brightThreshold: number;
  147598. /**
  147599. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  147600. */
  147601. blurWidth: number;
  147602. /**
  147603. * Sets if the blur for highlighted surfaces must be only horizontal
  147604. */
  147605. horizontalBlur: boolean;
  147606. /**
  147607. * Gets the overall exposure used by the pipeline
  147608. */
  147609. get exposure(): number;
  147610. /**
  147611. * Sets the overall exposure used by the pipeline
  147612. */
  147613. set exposure(value: number);
  147614. /**
  147615. * Texture used typically to simulate "dirty" on camera lens
  147616. */
  147617. lensTexture: Nullable<Texture>;
  147618. /**
  147619. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  147620. */
  147621. volumetricLightCoefficient: number;
  147622. /**
  147623. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  147624. */
  147625. volumetricLightPower: number;
  147626. /**
  147627. * Used the set the blur intensity to smooth the volumetric lights
  147628. */
  147629. volumetricLightBlurScale: number;
  147630. /**
  147631. * Light (spot or directional) used to generate the volumetric lights rays
  147632. * The source light must have a shadow generate so the pipeline can get its
  147633. * depth map
  147634. */
  147635. sourceLight: Nullable<SpotLight | DirectionalLight>;
  147636. /**
  147637. * For eye adaptation, represents the minimum luminance the eye can see
  147638. */
  147639. hdrMinimumLuminance: number;
  147640. /**
  147641. * For eye adaptation, represents the decrease luminance speed
  147642. */
  147643. hdrDecreaseRate: number;
  147644. /**
  147645. * For eye adaptation, represents the increase luminance speed
  147646. */
  147647. hdrIncreaseRate: number;
  147648. /**
  147649. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  147650. */
  147651. get hdrAutoExposure(): boolean;
  147652. /**
  147653. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  147654. */
  147655. set hdrAutoExposure(value: boolean);
  147656. /**
  147657. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  147658. */
  147659. lensColorTexture: Nullable<Texture>;
  147660. /**
  147661. * The overall strengh for the lens flare effect
  147662. */
  147663. lensFlareStrength: number;
  147664. /**
  147665. * Dispersion coefficient for lens flare ghosts
  147666. */
  147667. lensFlareGhostDispersal: number;
  147668. /**
  147669. * Main lens flare halo width
  147670. */
  147671. lensFlareHaloWidth: number;
  147672. /**
  147673. * Based on the lens distortion effect, defines how much the lens flare result
  147674. * is distorted
  147675. */
  147676. lensFlareDistortionStrength: number;
  147677. /**
  147678. * Configures the blur intensity used for for lens flare (halo)
  147679. */
  147680. lensFlareBlurWidth: number;
  147681. /**
  147682. * Lens star texture must be used to simulate rays on the flares and is available
  147683. * in the documentation
  147684. */
  147685. lensStarTexture: Nullable<Texture>;
  147686. /**
  147687. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  147688. * flare effect by taking account of the dirt texture
  147689. */
  147690. lensFlareDirtTexture: Nullable<Texture>;
  147691. /**
  147692. * Represents the focal length for the depth of field effect
  147693. */
  147694. depthOfFieldDistance: number;
  147695. /**
  147696. * Represents the blur intensity for the blurred part of the depth of field effect
  147697. */
  147698. depthOfFieldBlurWidth: number;
  147699. /**
  147700. * Gets how much the image is blurred by the movement while using the motion blur post-process
  147701. */
  147702. get motionStrength(): number;
  147703. /**
  147704. * Sets how much the image is blurred by the movement while using the motion blur post-process
  147705. */
  147706. set motionStrength(strength: number);
  147707. /**
  147708. * Gets wether or not the motion blur post-process is object based or screen based.
  147709. */
  147710. get objectBasedMotionBlur(): boolean;
  147711. /**
  147712. * Sets wether or not the motion blur post-process should be object based or screen based
  147713. */
  147714. set objectBasedMotionBlur(value: boolean);
  147715. /**
  147716. * List of animations for the pipeline (IAnimatable implementation)
  147717. */
  147718. animations: Animation[];
  147719. /**
  147720. * Private members
  147721. */
  147722. private _scene;
  147723. private _currentDepthOfFieldSource;
  147724. private _basePostProcess;
  147725. private _fixedExposure;
  147726. private _currentExposure;
  147727. private _hdrAutoExposure;
  147728. private _hdrCurrentLuminance;
  147729. private _motionStrength;
  147730. private _isObjectBasedMotionBlur;
  147731. private _floatTextureType;
  147732. private _camerasToBeAttached;
  147733. private _ratio;
  147734. private _bloomEnabled;
  147735. private _depthOfFieldEnabled;
  147736. private _vlsEnabled;
  147737. private _lensFlareEnabled;
  147738. private _hdrEnabled;
  147739. private _motionBlurEnabled;
  147740. private _fxaaEnabled;
  147741. private _screenSpaceReflectionsEnabled;
  147742. private _motionBlurSamples;
  147743. private _volumetricLightStepsCount;
  147744. private _samples;
  147745. /**
  147746. * @ignore
  147747. * Specifies if the bloom pipeline is enabled
  147748. */
  147749. get BloomEnabled(): boolean;
  147750. set BloomEnabled(enabled: boolean);
  147751. /**
  147752. * @ignore
  147753. * Specifies if the depth of field pipeline is enabed
  147754. */
  147755. get DepthOfFieldEnabled(): boolean;
  147756. set DepthOfFieldEnabled(enabled: boolean);
  147757. /**
  147758. * @ignore
  147759. * Specifies if the lens flare pipeline is enabed
  147760. */
  147761. get LensFlareEnabled(): boolean;
  147762. set LensFlareEnabled(enabled: boolean);
  147763. /**
  147764. * @ignore
  147765. * Specifies if the HDR pipeline is enabled
  147766. */
  147767. get HDREnabled(): boolean;
  147768. set HDREnabled(enabled: boolean);
  147769. /**
  147770. * @ignore
  147771. * Specifies if the volumetric lights scattering effect is enabled
  147772. */
  147773. get VLSEnabled(): boolean;
  147774. set VLSEnabled(enabled: boolean);
  147775. /**
  147776. * @ignore
  147777. * Specifies if the motion blur effect is enabled
  147778. */
  147779. get MotionBlurEnabled(): boolean;
  147780. set MotionBlurEnabled(enabled: boolean);
  147781. /**
  147782. * Specifies if anti-aliasing is enabled
  147783. */
  147784. get fxaaEnabled(): boolean;
  147785. set fxaaEnabled(enabled: boolean);
  147786. /**
  147787. * Specifies if screen space reflections are enabled.
  147788. */
  147789. get screenSpaceReflectionsEnabled(): boolean;
  147790. set screenSpaceReflectionsEnabled(enabled: boolean);
  147791. /**
  147792. * Specifies the number of steps used to calculate the volumetric lights
  147793. * Typically in interval [50, 200]
  147794. */
  147795. get volumetricLightStepsCount(): number;
  147796. set volumetricLightStepsCount(count: number);
  147797. /**
  147798. * Specifies the number of samples used for the motion blur effect
  147799. * Typically in interval [16, 64]
  147800. */
  147801. get motionBlurSamples(): number;
  147802. set motionBlurSamples(samples: number);
  147803. /**
  147804. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  147805. */
  147806. get samples(): number;
  147807. set samples(sampleCount: number);
  147808. /**
  147809. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  147810. * @constructor
  147811. * @param name The rendering pipeline name
  147812. * @param scene The scene linked to this pipeline
  147813. * @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)
  147814. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  147815. * @param cameras The array of cameras that the rendering pipeline will be attached to
  147816. */
  147817. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  147818. private _buildPipeline;
  147819. private _createDownSampleX4PostProcess;
  147820. private _createBrightPassPostProcess;
  147821. private _createBlurPostProcesses;
  147822. private _createTextureAdderPostProcess;
  147823. private _createVolumetricLightPostProcess;
  147824. private _createLuminancePostProcesses;
  147825. private _createHdrPostProcess;
  147826. private _createLensFlarePostProcess;
  147827. private _createDepthOfFieldPostProcess;
  147828. private _createMotionBlurPostProcess;
  147829. private _getDepthTexture;
  147830. private _disposePostProcesses;
  147831. /**
  147832. * Dispose of the pipeline and stop all post processes
  147833. */
  147834. dispose(): void;
  147835. /**
  147836. * Serialize the rendering pipeline (Used when exporting)
  147837. * @returns the serialized object
  147838. */
  147839. serialize(): any;
  147840. /**
  147841. * Parse the serialized pipeline
  147842. * @param source Source pipeline.
  147843. * @param scene The scene to load the pipeline to.
  147844. * @param rootUrl The URL of the serialized pipeline.
  147845. * @returns An instantiated pipeline from the serialized object.
  147846. */
  147847. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  147848. /**
  147849. * Luminance steps
  147850. */
  147851. static LuminanceSteps: number;
  147852. }
  147853. }
  147854. declare module BABYLON {
  147855. /** @hidden */
  147856. export var stereoscopicInterlacePixelShader: {
  147857. name: string;
  147858. shader: string;
  147859. };
  147860. }
  147861. declare module BABYLON {
  147862. /**
  147863. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  147864. */
  147865. export class StereoscopicInterlacePostProcessI extends PostProcess {
  147866. private _stepSize;
  147867. private _passedProcess;
  147868. /**
  147869. * Initializes a StereoscopicInterlacePostProcessI
  147870. * @param name The name of the effect.
  147871. * @param rigCameras The rig cameras to be appled to the post process
  147872. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  147873. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  147874. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147875. * @param engine The engine which the post process will be applied. (default: current engine)
  147876. * @param reusable If the post process can be reused on the same frame. (default: false)
  147877. */
  147878. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147879. }
  147880. /**
  147881. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  147882. */
  147883. export class StereoscopicInterlacePostProcess extends PostProcess {
  147884. private _stepSize;
  147885. private _passedProcess;
  147886. /**
  147887. * Initializes a StereoscopicInterlacePostProcess
  147888. * @param name The name of the effect.
  147889. * @param rigCameras The rig cameras to be appled to the post process
  147890. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  147891. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147892. * @param engine The engine which the post process will be applied. (default: current engine)
  147893. * @param reusable If the post process can be reused on the same frame. (default: false)
  147894. */
  147895. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147896. }
  147897. }
  147898. declare module BABYLON {
  147899. /** @hidden */
  147900. export var tonemapPixelShader: {
  147901. name: string;
  147902. shader: string;
  147903. };
  147904. }
  147905. declare module BABYLON {
  147906. /** Defines operator used for tonemapping */
  147907. export enum TonemappingOperator {
  147908. /** Hable */
  147909. Hable = 0,
  147910. /** Reinhard */
  147911. Reinhard = 1,
  147912. /** HejiDawson */
  147913. HejiDawson = 2,
  147914. /** Photographic */
  147915. Photographic = 3
  147916. }
  147917. /**
  147918. * Defines a post process to apply tone mapping
  147919. */
  147920. export class TonemapPostProcess extends PostProcess {
  147921. private _operator;
  147922. /** Defines the required exposure adjustement */
  147923. exposureAdjustment: number;
  147924. /**
  147925. * Creates a new TonemapPostProcess
  147926. * @param name defines the name of the postprocess
  147927. * @param _operator defines the operator to use
  147928. * @param exposureAdjustment defines the required exposure adjustement
  147929. * @param camera defines the camera to use (can be null)
  147930. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  147931. * @param engine defines the hosting engine (can be ignore if camera is set)
  147932. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  147933. */
  147934. constructor(name: string, _operator: TonemappingOperator,
  147935. /** Defines the required exposure adjustement */
  147936. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  147937. }
  147938. }
  147939. declare module BABYLON {
  147940. /** @hidden */
  147941. export var volumetricLightScatteringPixelShader: {
  147942. name: string;
  147943. shader: string;
  147944. };
  147945. }
  147946. declare module BABYLON {
  147947. /** @hidden */
  147948. export var volumetricLightScatteringPassVertexShader: {
  147949. name: string;
  147950. shader: string;
  147951. };
  147952. }
  147953. declare module BABYLON {
  147954. /** @hidden */
  147955. export var volumetricLightScatteringPassPixelShader: {
  147956. name: string;
  147957. shader: string;
  147958. };
  147959. }
  147960. declare module BABYLON {
  147961. /**
  147962. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  147963. */
  147964. export class VolumetricLightScatteringPostProcess extends PostProcess {
  147965. private _volumetricLightScatteringPass;
  147966. private _volumetricLightScatteringRTT;
  147967. private _viewPort;
  147968. private _screenCoordinates;
  147969. private _cachedDefines;
  147970. /**
  147971. * If not undefined, the mesh position is computed from the attached node position
  147972. */
  147973. attachedNode: {
  147974. position: Vector3;
  147975. };
  147976. /**
  147977. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  147978. */
  147979. customMeshPosition: Vector3;
  147980. /**
  147981. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  147982. */
  147983. useCustomMeshPosition: boolean;
  147984. /**
  147985. * If the post-process should inverse the light scattering direction
  147986. */
  147987. invert: boolean;
  147988. /**
  147989. * The internal mesh used by the post-process
  147990. */
  147991. mesh: Mesh;
  147992. /**
  147993. * @hidden
  147994. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  147995. */
  147996. get useDiffuseColor(): boolean;
  147997. set useDiffuseColor(useDiffuseColor: boolean);
  147998. /**
  147999. * Array containing the excluded meshes not rendered in the internal pass
  148000. */
  148001. excludedMeshes: AbstractMesh[];
  148002. /**
  148003. * Controls the overall intensity of the post-process
  148004. */
  148005. exposure: number;
  148006. /**
  148007. * Dissipates each sample's contribution in range [0, 1]
  148008. */
  148009. decay: number;
  148010. /**
  148011. * Controls the overall intensity of each sample
  148012. */
  148013. weight: number;
  148014. /**
  148015. * Controls the density of each sample
  148016. */
  148017. density: number;
  148018. /**
  148019. * @constructor
  148020. * @param name The post-process name
  148021. * @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)
  148022. * @param camera The camera that the post-process will be attached to
  148023. * @param mesh The mesh used to create the light scattering
  148024. * @param samples The post-process quality, default 100
  148025. * @param samplingModeThe post-process filtering mode
  148026. * @param engine The babylon engine
  148027. * @param reusable If the post-process is reusable
  148028. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  148029. */
  148030. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  148031. /**
  148032. * Returns the string "VolumetricLightScatteringPostProcess"
  148033. * @returns "VolumetricLightScatteringPostProcess"
  148034. */
  148035. getClassName(): string;
  148036. private _isReady;
  148037. /**
  148038. * Sets the new light position for light scattering effect
  148039. * @param position The new custom light position
  148040. */
  148041. setCustomMeshPosition(position: Vector3): void;
  148042. /**
  148043. * Returns the light position for light scattering effect
  148044. * @return Vector3 The custom light position
  148045. */
  148046. getCustomMeshPosition(): Vector3;
  148047. /**
  148048. * Disposes the internal assets and detaches the post-process from the camera
  148049. */
  148050. dispose(camera: Camera): void;
  148051. /**
  148052. * Returns the render target texture used by the post-process
  148053. * @return the render target texture used by the post-process
  148054. */
  148055. getPass(): RenderTargetTexture;
  148056. private _meshExcluded;
  148057. private _createPass;
  148058. private _updateMeshScreenCoordinates;
  148059. /**
  148060. * Creates a default mesh for the Volumeric Light Scattering post-process
  148061. * @param name The mesh name
  148062. * @param scene The scene where to create the mesh
  148063. * @return the default mesh
  148064. */
  148065. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  148066. }
  148067. }
  148068. declare module BABYLON {
  148069. interface Scene {
  148070. /** @hidden (Backing field) */
  148071. _boundingBoxRenderer: BoundingBoxRenderer;
  148072. /** @hidden (Backing field) */
  148073. _forceShowBoundingBoxes: boolean;
  148074. /**
  148075. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  148076. */
  148077. forceShowBoundingBoxes: boolean;
  148078. /**
  148079. * Gets the bounding box renderer associated with the scene
  148080. * @returns a BoundingBoxRenderer
  148081. */
  148082. getBoundingBoxRenderer(): BoundingBoxRenderer;
  148083. }
  148084. interface AbstractMesh {
  148085. /** @hidden (Backing field) */
  148086. _showBoundingBox: boolean;
  148087. /**
  148088. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  148089. */
  148090. showBoundingBox: boolean;
  148091. }
  148092. /**
  148093. * Component responsible of rendering the bounding box of the meshes in a scene.
  148094. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  148095. */
  148096. export class BoundingBoxRenderer implements ISceneComponent {
  148097. /**
  148098. * The component name helpfull to identify the component in the list of scene components.
  148099. */
  148100. readonly name: string;
  148101. /**
  148102. * The scene the component belongs to.
  148103. */
  148104. scene: Scene;
  148105. /**
  148106. * Color of the bounding box lines placed in front of an object
  148107. */
  148108. frontColor: Color3;
  148109. /**
  148110. * Color of the bounding box lines placed behind an object
  148111. */
  148112. backColor: Color3;
  148113. /**
  148114. * Defines if the renderer should show the back lines or not
  148115. */
  148116. showBackLines: boolean;
  148117. /**
  148118. * Observable raised before rendering a bounding box
  148119. */
  148120. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  148121. /**
  148122. * Observable raised after rendering a bounding box
  148123. */
  148124. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  148125. /**
  148126. * @hidden
  148127. */
  148128. renderList: SmartArray<BoundingBox>;
  148129. private _colorShader;
  148130. private _vertexBuffers;
  148131. private _indexBuffer;
  148132. private _fillIndexBuffer;
  148133. private _fillIndexData;
  148134. /**
  148135. * Instantiates a new bounding box renderer in a scene.
  148136. * @param scene the scene the renderer renders in
  148137. */
  148138. constructor(scene: Scene);
  148139. /**
  148140. * Registers the component in a given scene
  148141. */
  148142. register(): void;
  148143. private _evaluateSubMesh;
  148144. private _activeMesh;
  148145. private _prepareRessources;
  148146. private _createIndexBuffer;
  148147. /**
  148148. * Rebuilds the elements related to this component in case of
  148149. * context lost for instance.
  148150. */
  148151. rebuild(): void;
  148152. /**
  148153. * @hidden
  148154. */
  148155. reset(): void;
  148156. /**
  148157. * Render the bounding boxes of a specific rendering group
  148158. * @param renderingGroupId defines the rendering group to render
  148159. */
  148160. render(renderingGroupId: number): void;
  148161. /**
  148162. * In case of occlusion queries, we can render the occlusion bounding box through this method
  148163. * @param mesh Define the mesh to render the occlusion bounding box for
  148164. */
  148165. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  148166. /**
  148167. * Dispose and release the resources attached to this renderer.
  148168. */
  148169. dispose(): void;
  148170. }
  148171. }
  148172. declare module BABYLON {
  148173. interface Scene {
  148174. /** @hidden (Backing field) */
  148175. _depthRenderer: {
  148176. [id: string]: DepthRenderer;
  148177. };
  148178. /**
  148179. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  148180. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  148181. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  148182. * @returns the created depth renderer
  148183. */
  148184. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  148185. /**
  148186. * Disables a depth renderer for a given camera
  148187. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  148188. */
  148189. disableDepthRenderer(camera?: Nullable<Camera>): void;
  148190. }
  148191. /**
  148192. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  148193. * in several rendering techniques.
  148194. */
  148195. export class DepthRendererSceneComponent implements ISceneComponent {
  148196. /**
  148197. * The component name helpfull to identify the component in the list of scene components.
  148198. */
  148199. readonly name: string;
  148200. /**
  148201. * The scene the component belongs to.
  148202. */
  148203. scene: Scene;
  148204. /**
  148205. * Creates a new instance of the component for the given scene
  148206. * @param scene Defines the scene to register the component in
  148207. */
  148208. constructor(scene: Scene);
  148209. /**
  148210. * Registers the component in a given scene
  148211. */
  148212. register(): void;
  148213. /**
  148214. * Rebuilds the elements related to this component in case of
  148215. * context lost for instance.
  148216. */
  148217. rebuild(): void;
  148218. /**
  148219. * Disposes the component and the associated ressources
  148220. */
  148221. dispose(): void;
  148222. private _gatherRenderTargets;
  148223. private _gatherActiveCameraRenderTargets;
  148224. }
  148225. }
  148226. declare module BABYLON {
  148227. /** @hidden */
  148228. export var outlinePixelShader: {
  148229. name: string;
  148230. shader: string;
  148231. };
  148232. }
  148233. declare module BABYLON {
  148234. /** @hidden */
  148235. export var outlineVertexShader: {
  148236. name: string;
  148237. shader: string;
  148238. };
  148239. }
  148240. declare module BABYLON {
  148241. interface Scene {
  148242. /** @hidden */
  148243. _outlineRenderer: OutlineRenderer;
  148244. /**
  148245. * Gets the outline renderer associated with the scene
  148246. * @returns a OutlineRenderer
  148247. */
  148248. getOutlineRenderer(): OutlineRenderer;
  148249. }
  148250. interface AbstractMesh {
  148251. /** @hidden (Backing field) */
  148252. _renderOutline: boolean;
  148253. /**
  148254. * Gets or sets a boolean indicating if the outline must be rendered as well
  148255. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  148256. */
  148257. renderOutline: boolean;
  148258. /** @hidden (Backing field) */
  148259. _renderOverlay: boolean;
  148260. /**
  148261. * Gets or sets a boolean indicating if the overlay must be rendered as well
  148262. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  148263. */
  148264. renderOverlay: boolean;
  148265. }
  148266. /**
  148267. * This class is responsible to draw bothe outline/overlay of meshes.
  148268. * It should not be used directly but through the available method on mesh.
  148269. */
  148270. export class OutlineRenderer implements ISceneComponent {
  148271. /**
  148272. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  148273. */
  148274. private static _StencilReference;
  148275. /**
  148276. * The name of the component. Each component must have a unique name.
  148277. */
  148278. name: string;
  148279. /**
  148280. * The scene the component belongs to.
  148281. */
  148282. scene: Scene;
  148283. /**
  148284. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  148285. */
  148286. zOffset: number;
  148287. private _engine;
  148288. private _effect;
  148289. private _cachedDefines;
  148290. private _savedDepthWrite;
  148291. /**
  148292. * Instantiates a new outline renderer. (There could be only one per scene).
  148293. * @param scene Defines the scene it belongs to
  148294. */
  148295. constructor(scene: Scene);
  148296. /**
  148297. * Register the component to one instance of a scene.
  148298. */
  148299. register(): void;
  148300. /**
  148301. * Rebuilds the elements related to this component in case of
  148302. * context lost for instance.
  148303. */
  148304. rebuild(): void;
  148305. /**
  148306. * Disposes the component and the associated ressources.
  148307. */
  148308. dispose(): void;
  148309. /**
  148310. * Renders the outline in the canvas.
  148311. * @param subMesh Defines the sumesh to render
  148312. * @param batch Defines the batch of meshes in case of instances
  148313. * @param useOverlay Defines if the rendering is for the overlay or the outline
  148314. */
  148315. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  148316. /**
  148317. * Returns whether or not the outline renderer is ready for a given submesh.
  148318. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  148319. * @param subMesh Defines the submesh to check readyness for
  148320. * @param useInstances Defines wheter wee are trying to render instances or not
  148321. * @returns true if ready otherwise false
  148322. */
  148323. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  148324. private _beforeRenderingMesh;
  148325. private _afterRenderingMesh;
  148326. }
  148327. }
  148328. declare module BABYLON {
  148329. /**
  148330. * Defines the basic options interface of a Sprite Frame Source Size.
  148331. */
  148332. export interface ISpriteJSONSpriteSourceSize {
  148333. /**
  148334. * number of the original width of the Frame
  148335. */
  148336. w: number;
  148337. /**
  148338. * number of the original height of the Frame
  148339. */
  148340. h: number;
  148341. }
  148342. /**
  148343. * Defines the basic options interface of a Sprite Frame Data.
  148344. */
  148345. export interface ISpriteJSONSpriteFrameData {
  148346. /**
  148347. * number of the x offset of the Frame
  148348. */
  148349. x: number;
  148350. /**
  148351. * number of the y offset of the Frame
  148352. */
  148353. y: number;
  148354. /**
  148355. * number of the width of the Frame
  148356. */
  148357. w: number;
  148358. /**
  148359. * number of the height of the Frame
  148360. */
  148361. h: number;
  148362. }
  148363. /**
  148364. * Defines the basic options interface of a JSON Sprite.
  148365. */
  148366. export interface ISpriteJSONSprite {
  148367. /**
  148368. * string name of the Frame
  148369. */
  148370. filename: string;
  148371. /**
  148372. * ISpriteJSONSpriteFrame basic object of the frame data
  148373. */
  148374. frame: ISpriteJSONSpriteFrameData;
  148375. /**
  148376. * boolean to flag is the frame was rotated.
  148377. */
  148378. rotated: boolean;
  148379. /**
  148380. * boolean to flag is the frame was trimmed.
  148381. */
  148382. trimmed: boolean;
  148383. /**
  148384. * ISpriteJSONSpriteFrame basic object of the source data
  148385. */
  148386. spriteSourceSize: ISpriteJSONSpriteFrameData;
  148387. /**
  148388. * ISpriteJSONSpriteFrame basic object of the source data
  148389. */
  148390. sourceSize: ISpriteJSONSpriteSourceSize;
  148391. }
  148392. /**
  148393. * Defines the basic options interface of a JSON atlas.
  148394. */
  148395. export interface ISpriteJSONAtlas {
  148396. /**
  148397. * Array of objects that contain the frame data.
  148398. */
  148399. frames: Array<ISpriteJSONSprite>;
  148400. /**
  148401. * object basic object containing the sprite meta data.
  148402. */
  148403. meta?: object;
  148404. }
  148405. }
  148406. declare module BABYLON {
  148407. /** @hidden */
  148408. export var spriteMapPixelShader: {
  148409. name: string;
  148410. shader: string;
  148411. };
  148412. }
  148413. declare module BABYLON {
  148414. /** @hidden */
  148415. export var spriteMapVertexShader: {
  148416. name: string;
  148417. shader: string;
  148418. };
  148419. }
  148420. declare module BABYLON {
  148421. /**
  148422. * Defines the basic options interface of a SpriteMap
  148423. */
  148424. export interface ISpriteMapOptions {
  148425. /**
  148426. * Vector2 of the number of cells in the grid.
  148427. */
  148428. stageSize?: Vector2;
  148429. /**
  148430. * Vector2 of the size of the output plane in World Units.
  148431. */
  148432. outputSize?: Vector2;
  148433. /**
  148434. * Vector3 of the position of the output plane in World Units.
  148435. */
  148436. outputPosition?: Vector3;
  148437. /**
  148438. * Vector3 of the rotation of the output plane.
  148439. */
  148440. outputRotation?: Vector3;
  148441. /**
  148442. * number of layers that the system will reserve in resources.
  148443. */
  148444. layerCount?: number;
  148445. /**
  148446. * number of max animation frames a single cell will reserve in resources.
  148447. */
  148448. maxAnimationFrames?: number;
  148449. /**
  148450. * number cell index of the base tile when the system compiles.
  148451. */
  148452. baseTile?: number;
  148453. /**
  148454. * boolean flip the sprite after its been repositioned by the framing data.
  148455. */
  148456. flipU?: boolean;
  148457. /**
  148458. * Vector3 scalar of the global RGB values of the SpriteMap.
  148459. */
  148460. colorMultiply?: Vector3;
  148461. }
  148462. /**
  148463. * Defines the IDisposable interface in order to be cleanable from resources.
  148464. */
  148465. export interface ISpriteMap extends IDisposable {
  148466. /**
  148467. * String name of the SpriteMap.
  148468. */
  148469. name: string;
  148470. /**
  148471. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  148472. */
  148473. atlasJSON: ISpriteJSONAtlas;
  148474. /**
  148475. * Texture of the SpriteMap.
  148476. */
  148477. spriteSheet: Texture;
  148478. /**
  148479. * The parameters to initialize the SpriteMap with.
  148480. */
  148481. options: ISpriteMapOptions;
  148482. }
  148483. /**
  148484. * Class used to manage a grid restricted sprite deployment on an Output plane.
  148485. */
  148486. export class SpriteMap implements ISpriteMap {
  148487. /** The Name of the spriteMap */
  148488. name: string;
  148489. /** The JSON file with the frame and meta data */
  148490. atlasJSON: ISpriteJSONAtlas;
  148491. /** The systems Sprite Sheet Texture */
  148492. spriteSheet: Texture;
  148493. /** Arguments passed with the Constructor */
  148494. options: ISpriteMapOptions;
  148495. /** Public Sprite Storage array, parsed from atlasJSON */
  148496. sprites: Array<ISpriteJSONSprite>;
  148497. /** Returns the Number of Sprites in the System */
  148498. get spriteCount(): number;
  148499. /** Returns the Position of Output Plane*/
  148500. get position(): Vector3;
  148501. /** Returns the Position of Output Plane*/
  148502. set position(v: Vector3);
  148503. /** Returns the Rotation of Output Plane*/
  148504. get rotation(): Vector3;
  148505. /** Returns the Rotation of Output Plane*/
  148506. set rotation(v: Vector3);
  148507. /** Sets the AnimationMap*/
  148508. get animationMap(): RawTexture;
  148509. /** Sets the AnimationMap*/
  148510. set animationMap(v: RawTexture);
  148511. /** Scene that the SpriteMap was created in */
  148512. private _scene;
  148513. /** Texture Buffer of Float32 that holds tile frame data*/
  148514. private _frameMap;
  148515. /** Texture Buffers of Float32 that holds tileMap data*/
  148516. private _tileMaps;
  148517. /** Texture Buffer of Float32 that holds Animation Data*/
  148518. private _animationMap;
  148519. /** Custom ShaderMaterial Central to the System*/
  148520. private _material;
  148521. /** Custom ShaderMaterial Central to the System*/
  148522. private _output;
  148523. /** Systems Time Ticker*/
  148524. private _time;
  148525. /**
  148526. * Creates a new SpriteMap
  148527. * @param name defines the SpriteMaps Name
  148528. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  148529. * @param spriteSheet is the Texture that the Sprites are on.
  148530. * @param options a basic deployment configuration
  148531. * @param scene The Scene that the map is deployed on
  148532. */
  148533. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  148534. /**
  148535. * Returns tileID location
  148536. * @returns Vector2 the cell position ID
  148537. */
  148538. getTileID(): Vector2;
  148539. /**
  148540. * Gets the UV location of the mouse over the SpriteMap.
  148541. * @returns Vector2 the UV position of the mouse interaction
  148542. */
  148543. getMousePosition(): Vector2;
  148544. /**
  148545. * Creates the "frame" texture Buffer
  148546. * -------------------------------------
  148547. * Structure of frames
  148548. * "filename": "Falling-Water-2.png",
  148549. * "frame": {"x":69,"y":103,"w":24,"h":32},
  148550. * "rotated": true,
  148551. * "trimmed": true,
  148552. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  148553. * "sourceSize": {"w":32,"h":32}
  148554. * @returns RawTexture of the frameMap
  148555. */
  148556. private _createFrameBuffer;
  148557. /**
  148558. * Creates the tileMap texture Buffer
  148559. * @param buffer normally and array of numbers, or a false to generate from scratch
  148560. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  148561. * @returns RawTexture of the tileMap
  148562. */
  148563. private _createTileBuffer;
  148564. /**
  148565. * Modifies the data of the tileMaps
  148566. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  148567. * @param pos is the iVector2 Coordinates of the Tile
  148568. * @param tile The SpriteIndex of the new Tile
  148569. */
  148570. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  148571. /**
  148572. * Creates the animationMap texture Buffer
  148573. * @param buffer normally and array of numbers, or a false to generate from scratch
  148574. * @returns RawTexture of the animationMap
  148575. */
  148576. private _createTileAnimationBuffer;
  148577. /**
  148578. * Modifies the data of the animationMap
  148579. * @param cellID is the Index of the Sprite
  148580. * @param _frame is the target Animation frame
  148581. * @param toCell is the Target Index of the next frame of the animation
  148582. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  148583. * @param speed is a global scalar of the time variable on the map.
  148584. */
  148585. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  148586. /**
  148587. * Exports the .tilemaps file
  148588. */
  148589. saveTileMaps(): void;
  148590. /**
  148591. * Imports the .tilemaps file
  148592. * @param url of the .tilemaps file
  148593. */
  148594. loadTileMaps(url: string): void;
  148595. /**
  148596. * Release associated resources
  148597. */
  148598. dispose(): void;
  148599. }
  148600. }
  148601. declare module BABYLON {
  148602. /**
  148603. * Class used to manage multiple sprites of different sizes on the same spritesheet
  148604. * @see http://doc.babylonjs.com/babylon101/sprites
  148605. */
  148606. export class SpritePackedManager extends SpriteManager {
  148607. /** defines the packed manager's name */
  148608. name: string;
  148609. /**
  148610. * Creates a new sprite manager from a packed sprite sheet
  148611. * @param name defines the manager's name
  148612. * @param imgUrl defines the sprite sheet url
  148613. * @param capacity defines the maximum allowed number of sprites
  148614. * @param scene defines the hosting scene
  148615. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  148616. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  148617. * @param samplingMode defines the smapling mode to use with spritesheet
  148618. * @param fromPacked set to true; do not alter
  148619. */
  148620. constructor(
  148621. /** defines the packed manager's name */
  148622. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  148623. }
  148624. }
  148625. declare module BABYLON {
  148626. /**
  148627. * Defines the list of states available for a task inside a AssetsManager
  148628. */
  148629. export enum AssetTaskState {
  148630. /**
  148631. * Initialization
  148632. */
  148633. INIT = 0,
  148634. /**
  148635. * Running
  148636. */
  148637. RUNNING = 1,
  148638. /**
  148639. * Done
  148640. */
  148641. DONE = 2,
  148642. /**
  148643. * Error
  148644. */
  148645. ERROR = 3
  148646. }
  148647. /**
  148648. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  148649. */
  148650. export abstract class AbstractAssetTask {
  148651. /**
  148652. * Task name
  148653. */ name: string;
  148654. /**
  148655. * Callback called when the task is successful
  148656. */
  148657. onSuccess: (task: any) => void;
  148658. /**
  148659. * Callback called when the task is not successful
  148660. */
  148661. onError: (task: any, message?: string, exception?: any) => void;
  148662. /**
  148663. * Creates a new AssetsManager
  148664. * @param name defines the name of the task
  148665. */
  148666. constructor(
  148667. /**
  148668. * Task name
  148669. */ name: string);
  148670. private _isCompleted;
  148671. private _taskState;
  148672. private _errorObject;
  148673. /**
  148674. * Get if the task is completed
  148675. */
  148676. get isCompleted(): boolean;
  148677. /**
  148678. * Gets the current state of the task
  148679. */
  148680. get taskState(): AssetTaskState;
  148681. /**
  148682. * Gets the current error object (if task is in error)
  148683. */
  148684. get errorObject(): {
  148685. message?: string;
  148686. exception?: any;
  148687. };
  148688. /**
  148689. * Internal only
  148690. * @hidden
  148691. */
  148692. _setErrorObject(message?: string, exception?: any): void;
  148693. /**
  148694. * Execute the current task
  148695. * @param scene defines the scene where you want your assets to be loaded
  148696. * @param onSuccess is a callback called when the task is successfully executed
  148697. * @param onError is a callback called if an error occurs
  148698. */
  148699. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148700. /**
  148701. * Execute the current task
  148702. * @param scene defines the scene where you want your assets to be loaded
  148703. * @param onSuccess is a callback called when the task is successfully executed
  148704. * @param onError is a callback called if an error occurs
  148705. */
  148706. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148707. /**
  148708. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  148709. * This can be used with failed tasks that have the reason for failure fixed.
  148710. */
  148711. reset(): void;
  148712. private onErrorCallback;
  148713. private onDoneCallback;
  148714. }
  148715. /**
  148716. * Define the interface used by progress events raised during assets loading
  148717. */
  148718. export interface IAssetsProgressEvent {
  148719. /**
  148720. * Defines the number of remaining tasks to process
  148721. */
  148722. remainingCount: number;
  148723. /**
  148724. * Defines the total number of tasks
  148725. */
  148726. totalCount: number;
  148727. /**
  148728. * Defines the task that was just processed
  148729. */
  148730. task: AbstractAssetTask;
  148731. }
  148732. /**
  148733. * Class used to share progress information about assets loading
  148734. */
  148735. export class AssetsProgressEvent implements IAssetsProgressEvent {
  148736. /**
  148737. * Defines the number of remaining tasks to process
  148738. */
  148739. remainingCount: number;
  148740. /**
  148741. * Defines the total number of tasks
  148742. */
  148743. totalCount: number;
  148744. /**
  148745. * Defines the task that was just processed
  148746. */
  148747. task: AbstractAssetTask;
  148748. /**
  148749. * Creates a AssetsProgressEvent
  148750. * @param remainingCount defines the number of remaining tasks to process
  148751. * @param totalCount defines the total number of tasks
  148752. * @param task defines the task that was just processed
  148753. */
  148754. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  148755. }
  148756. /**
  148757. * Define a task used by AssetsManager to load meshes
  148758. */
  148759. export class MeshAssetTask extends AbstractAssetTask {
  148760. /**
  148761. * Defines the name of the task
  148762. */
  148763. name: string;
  148764. /**
  148765. * Defines the list of mesh's names you want to load
  148766. */
  148767. meshesNames: any;
  148768. /**
  148769. * Defines the root url to use as a base to load your meshes and associated resources
  148770. */
  148771. rootUrl: string;
  148772. /**
  148773. * Defines the filename or File of the scene to load from
  148774. */
  148775. sceneFilename: string | File;
  148776. /**
  148777. * Gets the list of loaded meshes
  148778. */
  148779. loadedMeshes: Array<AbstractMesh>;
  148780. /**
  148781. * Gets the list of loaded particle systems
  148782. */
  148783. loadedParticleSystems: Array<IParticleSystem>;
  148784. /**
  148785. * Gets the list of loaded skeletons
  148786. */
  148787. loadedSkeletons: Array<Skeleton>;
  148788. /**
  148789. * Gets the list of loaded animation groups
  148790. */
  148791. loadedAnimationGroups: Array<AnimationGroup>;
  148792. /**
  148793. * Callback called when the task is successful
  148794. */
  148795. onSuccess: (task: MeshAssetTask) => void;
  148796. /**
  148797. * Callback called when the task is successful
  148798. */
  148799. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  148800. /**
  148801. * Creates a new MeshAssetTask
  148802. * @param name defines the name of the task
  148803. * @param meshesNames defines the list of mesh's names you want to load
  148804. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  148805. * @param sceneFilename defines the filename or File of the scene to load from
  148806. */
  148807. constructor(
  148808. /**
  148809. * Defines the name of the task
  148810. */
  148811. name: string,
  148812. /**
  148813. * Defines the list of mesh's names you want to load
  148814. */
  148815. meshesNames: any,
  148816. /**
  148817. * Defines the root url to use as a base to load your meshes and associated resources
  148818. */
  148819. rootUrl: string,
  148820. /**
  148821. * Defines the filename or File of the scene to load from
  148822. */
  148823. sceneFilename: string | File);
  148824. /**
  148825. * Execute the current task
  148826. * @param scene defines the scene where you want your assets to be loaded
  148827. * @param onSuccess is a callback called when the task is successfully executed
  148828. * @param onError is a callback called if an error occurs
  148829. */
  148830. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148831. }
  148832. /**
  148833. * Define a task used by AssetsManager to load text content
  148834. */
  148835. export class TextFileAssetTask extends AbstractAssetTask {
  148836. /**
  148837. * Defines the name of the task
  148838. */
  148839. name: string;
  148840. /**
  148841. * Defines the location of the file to load
  148842. */
  148843. url: string;
  148844. /**
  148845. * Gets the loaded text string
  148846. */
  148847. text: string;
  148848. /**
  148849. * Callback called when the task is successful
  148850. */
  148851. onSuccess: (task: TextFileAssetTask) => void;
  148852. /**
  148853. * Callback called when the task is successful
  148854. */
  148855. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  148856. /**
  148857. * Creates a new TextFileAssetTask object
  148858. * @param name defines the name of the task
  148859. * @param url defines the location of the file to load
  148860. */
  148861. constructor(
  148862. /**
  148863. * Defines the name of the task
  148864. */
  148865. name: string,
  148866. /**
  148867. * Defines the location of the file to load
  148868. */
  148869. url: string);
  148870. /**
  148871. * Execute the current task
  148872. * @param scene defines the scene where you want your assets to be loaded
  148873. * @param onSuccess is a callback called when the task is successfully executed
  148874. * @param onError is a callback called if an error occurs
  148875. */
  148876. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148877. }
  148878. /**
  148879. * Define a task used by AssetsManager to load binary data
  148880. */
  148881. export class BinaryFileAssetTask extends AbstractAssetTask {
  148882. /**
  148883. * Defines the name of the task
  148884. */
  148885. name: string;
  148886. /**
  148887. * Defines the location of the file to load
  148888. */
  148889. url: string;
  148890. /**
  148891. * Gets the lodaded data (as an array buffer)
  148892. */
  148893. data: ArrayBuffer;
  148894. /**
  148895. * Callback called when the task is successful
  148896. */
  148897. onSuccess: (task: BinaryFileAssetTask) => void;
  148898. /**
  148899. * Callback called when the task is successful
  148900. */
  148901. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  148902. /**
  148903. * Creates a new BinaryFileAssetTask object
  148904. * @param name defines the name of the new task
  148905. * @param url defines the location of the file to load
  148906. */
  148907. constructor(
  148908. /**
  148909. * Defines the name of the task
  148910. */
  148911. name: string,
  148912. /**
  148913. * Defines the location of the file to load
  148914. */
  148915. url: string);
  148916. /**
  148917. * Execute the current task
  148918. * @param scene defines the scene where you want your assets to be loaded
  148919. * @param onSuccess is a callback called when the task is successfully executed
  148920. * @param onError is a callback called if an error occurs
  148921. */
  148922. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148923. }
  148924. /**
  148925. * Define a task used by AssetsManager to load images
  148926. */
  148927. export class ImageAssetTask extends AbstractAssetTask {
  148928. /**
  148929. * Defines the name of the task
  148930. */
  148931. name: string;
  148932. /**
  148933. * Defines the location of the image to load
  148934. */
  148935. url: string;
  148936. /**
  148937. * Gets the loaded images
  148938. */
  148939. image: HTMLImageElement;
  148940. /**
  148941. * Callback called when the task is successful
  148942. */
  148943. onSuccess: (task: ImageAssetTask) => void;
  148944. /**
  148945. * Callback called when the task is successful
  148946. */
  148947. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  148948. /**
  148949. * Creates a new ImageAssetTask
  148950. * @param name defines the name of the task
  148951. * @param url defines the location of the image to load
  148952. */
  148953. constructor(
  148954. /**
  148955. * Defines the name of the task
  148956. */
  148957. name: string,
  148958. /**
  148959. * Defines the location of the image to load
  148960. */
  148961. url: string);
  148962. /**
  148963. * Execute the current task
  148964. * @param scene defines the scene where you want your assets to be loaded
  148965. * @param onSuccess is a callback called when the task is successfully executed
  148966. * @param onError is a callback called if an error occurs
  148967. */
  148968. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148969. }
  148970. /**
  148971. * Defines the interface used by texture loading tasks
  148972. */
  148973. export interface ITextureAssetTask<TEX extends BaseTexture> {
  148974. /**
  148975. * Gets the loaded texture
  148976. */
  148977. texture: TEX;
  148978. }
  148979. /**
  148980. * Define a task used by AssetsManager to load 2D textures
  148981. */
  148982. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  148983. /**
  148984. * Defines the name of the task
  148985. */
  148986. name: string;
  148987. /**
  148988. * Defines the location of the file to load
  148989. */
  148990. url: string;
  148991. /**
  148992. * Defines if mipmap should not be generated (default is false)
  148993. */
  148994. noMipmap?: boolean | undefined;
  148995. /**
  148996. * Defines if texture must be inverted on Y axis (default is true)
  148997. */
  148998. invertY: boolean;
  148999. /**
  149000. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  149001. */
  149002. samplingMode: number;
  149003. /**
  149004. * Gets the loaded texture
  149005. */
  149006. texture: Texture;
  149007. /**
  149008. * Callback called when the task is successful
  149009. */
  149010. onSuccess: (task: TextureAssetTask) => void;
  149011. /**
  149012. * Callback called when the task is successful
  149013. */
  149014. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  149015. /**
  149016. * Creates a new TextureAssetTask object
  149017. * @param name defines the name of the task
  149018. * @param url defines the location of the file to load
  149019. * @param noMipmap defines if mipmap should not be generated (default is false)
  149020. * @param invertY defines if texture must be inverted on Y axis (default is true)
  149021. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  149022. */
  149023. constructor(
  149024. /**
  149025. * Defines the name of the task
  149026. */
  149027. name: string,
  149028. /**
  149029. * Defines the location of the file to load
  149030. */
  149031. url: string,
  149032. /**
  149033. * Defines if mipmap should not be generated (default is false)
  149034. */
  149035. noMipmap?: boolean | undefined,
  149036. /**
  149037. * Defines if texture must be inverted on Y axis (default is true)
  149038. */
  149039. invertY?: boolean,
  149040. /**
  149041. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  149042. */
  149043. samplingMode?: number);
  149044. /**
  149045. * Execute the current task
  149046. * @param scene defines the scene where you want your assets to be loaded
  149047. * @param onSuccess is a callback called when the task is successfully executed
  149048. * @param onError is a callback called if an error occurs
  149049. */
  149050. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149051. }
  149052. /**
  149053. * Define a task used by AssetsManager to load cube textures
  149054. */
  149055. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  149056. /**
  149057. * Defines the name of the task
  149058. */
  149059. name: string;
  149060. /**
  149061. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  149062. */
  149063. url: string;
  149064. /**
  149065. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  149066. */
  149067. extensions?: string[] | undefined;
  149068. /**
  149069. * Defines if mipmaps should not be generated (default is false)
  149070. */
  149071. noMipmap?: boolean | undefined;
  149072. /**
  149073. * Defines the explicit list of files (undefined by default)
  149074. */
  149075. files?: string[] | undefined;
  149076. /**
  149077. * Gets the loaded texture
  149078. */
  149079. texture: CubeTexture;
  149080. /**
  149081. * Callback called when the task is successful
  149082. */
  149083. onSuccess: (task: CubeTextureAssetTask) => void;
  149084. /**
  149085. * Callback called when the task is successful
  149086. */
  149087. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  149088. /**
  149089. * Creates a new CubeTextureAssetTask
  149090. * @param name defines the name of the task
  149091. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  149092. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  149093. * @param noMipmap defines if mipmaps should not be generated (default is false)
  149094. * @param files defines the explicit list of files (undefined by default)
  149095. */
  149096. constructor(
  149097. /**
  149098. * Defines the name of the task
  149099. */
  149100. name: string,
  149101. /**
  149102. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  149103. */
  149104. url: string,
  149105. /**
  149106. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  149107. */
  149108. extensions?: string[] | undefined,
  149109. /**
  149110. * Defines if mipmaps should not be generated (default is false)
  149111. */
  149112. noMipmap?: boolean | undefined,
  149113. /**
  149114. * Defines the explicit list of files (undefined by default)
  149115. */
  149116. files?: string[] | undefined);
  149117. /**
  149118. * Execute the current task
  149119. * @param scene defines the scene where you want your assets to be loaded
  149120. * @param onSuccess is a callback called when the task is successfully executed
  149121. * @param onError is a callback called if an error occurs
  149122. */
  149123. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149124. }
  149125. /**
  149126. * Define a task used by AssetsManager to load HDR cube textures
  149127. */
  149128. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  149129. /**
  149130. * Defines the name of the task
  149131. */
  149132. name: string;
  149133. /**
  149134. * Defines the location of the file to load
  149135. */
  149136. url: string;
  149137. /**
  149138. * Defines the desired size (the more it increases the longer the generation will be)
  149139. */
  149140. size: number;
  149141. /**
  149142. * Defines if mipmaps should not be generated (default is false)
  149143. */
  149144. noMipmap: boolean;
  149145. /**
  149146. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  149147. */
  149148. generateHarmonics: boolean;
  149149. /**
  149150. * 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)
  149151. */
  149152. gammaSpace: boolean;
  149153. /**
  149154. * Internal Use Only
  149155. */
  149156. reserved: boolean;
  149157. /**
  149158. * Gets the loaded texture
  149159. */
  149160. texture: HDRCubeTexture;
  149161. /**
  149162. * Callback called when the task is successful
  149163. */
  149164. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  149165. /**
  149166. * Callback called when the task is successful
  149167. */
  149168. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  149169. /**
  149170. * Creates a new HDRCubeTextureAssetTask object
  149171. * @param name defines the name of the task
  149172. * @param url defines the location of the file to load
  149173. * @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.
  149174. * @param noMipmap defines if mipmaps should not be generated (default is false)
  149175. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  149176. * @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)
  149177. * @param reserved Internal use only
  149178. */
  149179. constructor(
  149180. /**
  149181. * Defines the name of the task
  149182. */
  149183. name: string,
  149184. /**
  149185. * Defines the location of the file to load
  149186. */
  149187. url: string,
  149188. /**
  149189. * Defines the desired size (the more it increases the longer the generation will be)
  149190. */
  149191. size: number,
  149192. /**
  149193. * Defines if mipmaps should not be generated (default is false)
  149194. */
  149195. noMipmap?: boolean,
  149196. /**
  149197. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  149198. */
  149199. generateHarmonics?: boolean,
  149200. /**
  149201. * 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)
  149202. */
  149203. gammaSpace?: boolean,
  149204. /**
  149205. * Internal Use Only
  149206. */
  149207. reserved?: boolean);
  149208. /**
  149209. * Execute the current task
  149210. * @param scene defines the scene where you want your assets to be loaded
  149211. * @param onSuccess is a callback called when the task is successfully executed
  149212. * @param onError is a callback called if an error occurs
  149213. */
  149214. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149215. }
  149216. /**
  149217. * Define a task used by AssetsManager to load Equirectangular cube textures
  149218. */
  149219. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  149220. /**
  149221. * Defines the name of the task
  149222. */
  149223. name: string;
  149224. /**
  149225. * Defines the location of the file to load
  149226. */
  149227. url: string;
  149228. /**
  149229. * Defines the desired size (the more it increases the longer the generation will be)
  149230. */
  149231. size: number;
  149232. /**
  149233. * Defines if mipmaps should not be generated (default is false)
  149234. */
  149235. noMipmap: boolean;
  149236. /**
  149237. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  149238. * but the standard material would require them in Gamma space) (default is true)
  149239. */
  149240. gammaSpace: boolean;
  149241. /**
  149242. * Gets the loaded texture
  149243. */
  149244. texture: EquiRectangularCubeTexture;
  149245. /**
  149246. * Callback called when the task is successful
  149247. */
  149248. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  149249. /**
  149250. * Callback called when the task is successful
  149251. */
  149252. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  149253. /**
  149254. * Creates a new EquiRectangularCubeTextureAssetTask object
  149255. * @param name defines the name of the task
  149256. * @param url defines the location of the file to load
  149257. * @param size defines the desired size (the more it increases the longer the generation will be)
  149258. * If the size is omitted this implies you are using a preprocessed cubemap.
  149259. * @param noMipmap defines if mipmaps should not be generated (default is false)
  149260. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  149261. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  149262. * (default is true)
  149263. */
  149264. constructor(
  149265. /**
  149266. * Defines the name of the task
  149267. */
  149268. name: string,
  149269. /**
  149270. * Defines the location of the file to load
  149271. */
  149272. url: string,
  149273. /**
  149274. * Defines the desired size (the more it increases the longer the generation will be)
  149275. */
  149276. size: number,
  149277. /**
  149278. * Defines if mipmaps should not be generated (default is false)
  149279. */
  149280. noMipmap?: boolean,
  149281. /**
  149282. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  149283. * but the standard material would require them in Gamma space) (default is true)
  149284. */
  149285. gammaSpace?: boolean);
  149286. /**
  149287. * Execute the current task
  149288. * @param scene defines the scene where you want your assets to be loaded
  149289. * @param onSuccess is a callback called when the task is successfully executed
  149290. * @param onError is a callback called if an error occurs
  149291. */
  149292. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149293. }
  149294. /**
  149295. * This class can be used to easily import assets into a scene
  149296. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  149297. */
  149298. export class AssetsManager {
  149299. private _scene;
  149300. private _isLoading;
  149301. protected _tasks: AbstractAssetTask[];
  149302. protected _waitingTasksCount: number;
  149303. protected _totalTasksCount: number;
  149304. /**
  149305. * Callback called when all tasks are processed
  149306. */
  149307. onFinish: (tasks: AbstractAssetTask[]) => void;
  149308. /**
  149309. * Callback called when a task is successful
  149310. */
  149311. onTaskSuccess: (task: AbstractAssetTask) => void;
  149312. /**
  149313. * Callback called when a task had an error
  149314. */
  149315. onTaskError: (task: AbstractAssetTask) => void;
  149316. /**
  149317. * Callback called when a task is done (whatever the result is)
  149318. */
  149319. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  149320. /**
  149321. * Observable called when all tasks are processed
  149322. */
  149323. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  149324. /**
  149325. * Observable called when a task had an error
  149326. */
  149327. onTaskErrorObservable: Observable<AbstractAssetTask>;
  149328. /**
  149329. * Observable called when all tasks were executed
  149330. */
  149331. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  149332. /**
  149333. * Observable called when a task is done (whatever the result is)
  149334. */
  149335. onProgressObservable: Observable<IAssetsProgressEvent>;
  149336. /**
  149337. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  149338. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  149339. */
  149340. useDefaultLoadingScreen: boolean;
  149341. /**
  149342. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  149343. * when all assets have been downloaded.
  149344. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  149345. */
  149346. autoHideLoadingUI: boolean;
  149347. /**
  149348. * Creates a new AssetsManager
  149349. * @param scene defines the scene to work on
  149350. */
  149351. constructor(scene: Scene);
  149352. /**
  149353. * Add a MeshAssetTask to the list of active tasks
  149354. * @param taskName defines the name of the new task
  149355. * @param meshesNames defines the name of meshes to load
  149356. * @param rootUrl defines the root url to use to locate files
  149357. * @param sceneFilename defines the filename of the scene file
  149358. * @returns a new MeshAssetTask object
  149359. */
  149360. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  149361. /**
  149362. * Add a TextFileAssetTask to the list of active tasks
  149363. * @param taskName defines the name of the new task
  149364. * @param url defines the url of the file to load
  149365. * @returns a new TextFileAssetTask object
  149366. */
  149367. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  149368. /**
  149369. * Add a BinaryFileAssetTask to the list of active tasks
  149370. * @param taskName defines the name of the new task
  149371. * @param url defines the url of the file to load
  149372. * @returns a new BinaryFileAssetTask object
  149373. */
  149374. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  149375. /**
  149376. * Add a ImageAssetTask to the list of active tasks
  149377. * @param taskName defines the name of the new task
  149378. * @param url defines the url of the file to load
  149379. * @returns a new ImageAssetTask object
  149380. */
  149381. addImageTask(taskName: string, url: string): ImageAssetTask;
  149382. /**
  149383. * Add a TextureAssetTask to the list of active tasks
  149384. * @param taskName defines the name of the new task
  149385. * @param url defines the url of the file to load
  149386. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  149387. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  149388. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  149389. * @returns a new TextureAssetTask object
  149390. */
  149391. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  149392. /**
  149393. * Add a CubeTextureAssetTask to the list of active tasks
  149394. * @param taskName defines the name of the new task
  149395. * @param url defines the url of the file to load
  149396. * @param extensions defines the extension to use to load the cube map (can be null)
  149397. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  149398. * @param files defines the list of files to load (can be null)
  149399. * @returns a new CubeTextureAssetTask object
  149400. */
  149401. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  149402. /**
  149403. *
  149404. * Add a HDRCubeTextureAssetTask to the list of active tasks
  149405. * @param taskName defines the name of the new task
  149406. * @param url defines the url of the file to load
  149407. * @param size defines the size you want for the cubemap (can be null)
  149408. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  149409. * @param generateHarmonics defines if you want to automatically generate (true by default)
  149410. * @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)
  149411. * @param reserved Internal use only
  149412. * @returns a new HDRCubeTextureAssetTask object
  149413. */
  149414. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  149415. /**
  149416. *
  149417. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  149418. * @param taskName defines the name of the new task
  149419. * @param url defines the url of the file to load
  149420. * @param size defines the size you want for the cubemap (can be null)
  149421. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  149422. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  149423. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  149424. * @returns a new EquiRectangularCubeTextureAssetTask object
  149425. */
  149426. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  149427. /**
  149428. * Remove a task from the assets manager.
  149429. * @param task the task to remove
  149430. */
  149431. removeTask(task: AbstractAssetTask): void;
  149432. private _decreaseWaitingTasksCount;
  149433. private _runTask;
  149434. /**
  149435. * Reset the AssetsManager and remove all tasks
  149436. * @return the current instance of the AssetsManager
  149437. */
  149438. reset(): AssetsManager;
  149439. /**
  149440. * Start the loading process
  149441. * @return the current instance of the AssetsManager
  149442. */
  149443. load(): AssetsManager;
  149444. /**
  149445. * Start the loading process as an async operation
  149446. * @return a promise returning the list of failed tasks
  149447. */
  149448. loadAsync(): Promise<void>;
  149449. }
  149450. }
  149451. declare module BABYLON {
  149452. /**
  149453. * Wrapper class for promise with external resolve and reject.
  149454. */
  149455. export class Deferred<T> {
  149456. /**
  149457. * The promise associated with this deferred object.
  149458. */
  149459. readonly promise: Promise<T>;
  149460. private _resolve;
  149461. private _reject;
  149462. /**
  149463. * The resolve method of the promise associated with this deferred object.
  149464. */
  149465. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  149466. /**
  149467. * The reject method of the promise associated with this deferred object.
  149468. */
  149469. get reject(): (reason?: any) => void;
  149470. /**
  149471. * Constructor for this deferred object.
  149472. */
  149473. constructor();
  149474. }
  149475. }
  149476. declare module BABYLON {
  149477. /**
  149478. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  149479. */
  149480. export class MeshExploder {
  149481. private _centerMesh;
  149482. private _meshes;
  149483. private _meshesOrigins;
  149484. private _toCenterVectors;
  149485. private _scaledDirection;
  149486. private _newPosition;
  149487. private _centerPosition;
  149488. /**
  149489. * Explodes meshes from a center mesh.
  149490. * @param meshes The meshes to explode.
  149491. * @param centerMesh The mesh to be center of explosion.
  149492. */
  149493. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  149494. private _setCenterMesh;
  149495. /**
  149496. * Get class name
  149497. * @returns "MeshExploder"
  149498. */
  149499. getClassName(): string;
  149500. /**
  149501. * "Exploded meshes"
  149502. * @returns Array of meshes with the centerMesh at index 0.
  149503. */
  149504. getMeshes(): Array<Mesh>;
  149505. /**
  149506. * Explodes meshes giving a specific direction
  149507. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  149508. */
  149509. explode(direction?: number): void;
  149510. }
  149511. }
  149512. declare module BABYLON {
  149513. /**
  149514. * Class used to help managing file picking and drag'n'drop
  149515. */
  149516. export class FilesInput {
  149517. /**
  149518. * List of files ready to be loaded
  149519. */
  149520. static get FilesToLoad(): {
  149521. [key: string]: File;
  149522. };
  149523. /**
  149524. * Callback called when a file is processed
  149525. */
  149526. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  149527. private _engine;
  149528. private _currentScene;
  149529. private _sceneLoadedCallback;
  149530. private _progressCallback;
  149531. private _additionalRenderLoopLogicCallback;
  149532. private _textureLoadingCallback;
  149533. private _startingProcessingFilesCallback;
  149534. private _onReloadCallback;
  149535. private _errorCallback;
  149536. private _elementToMonitor;
  149537. private _sceneFileToLoad;
  149538. private _filesToLoad;
  149539. /**
  149540. * Creates a new FilesInput
  149541. * @param engine defines the rendering engine
  149542. * @param scene defines the hosting scene
  149543. * @param sceneLoadedCallback callback called when scene is loaded
  149544. * @param progressCallback callback called to track progress
  149545. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  149546. * @param textureLoadingCallback callback called when a texture is loading
  149547. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  149548. * @param onReloadCallback callback called when a reload is requested
  149549. * @param errorCallback callback call if an error occurs
  149550. */
  149551. 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);
  149552. private _dragEnterHandler;
  149553. private _dragOverHandler;
  149554. private _dropHandler;
  149555. /**
  149556. * Calls this function to listen to drag'n'drop events on a specific DOM element
  149557. * @param elementToMonitor defines the DOM element to track
  149558. */
  149559. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  149560. /**
  149561. * Release all associated resources
  149562. */
  149563. dispose(): void;
  149564. private renderFunction;
  149565. private drag;
  149566. private drop;
  149567. private _traverseFolder;
  149568. private _processFiles;
  149569. /**
  149570. * Load files from a drop event
  149571. * @param event defines the drop event to use as source
  149572. */
  149573. loadFiles(event: any): void;
  149574. private _processReload;
  149575. /**
  149576. * Reload the current scene from the loaded files
  149577. */
  149578. reload(): void;
  149579. }
  149580. }
  149581. declare module BABYLON {
  149582. /**
  149583. * Defines the root class used to create scene optimization to use with SceneOptimizer
  149584. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149585. */
  149586. export class SceneOptimization {
  149587. /**
  149588. * Defines the priority of this optimization (0 by default which means first in the list)
  149589. */
  149590. priority: number;
  149591. /**
  149592. * Gets a string describing the action executed by the current optimization
  149593. * @returns description string
  149594. */
  149595. getDescription(): string;
  149596. /**
  149597. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149598. * @param scene defines the current scene where to apply this optimization
  149599. * @param optimizer defines the current optimizer
  149600. * @returns true if everything that can be done was applied
  149601. */
  149602. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149603. /**
  149604. * Creates the SceneOptimization object
  149605. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  149606. * @param desc defines the description associated with the optimization
  149607. */
  149608. constructor(
  149609. /**
  149610. * Defines the priority of this optimization (0 by default which means first in the list)
  149611. */
  149612. priority?: number);
  149613. }
  149614. /**
  149615. * Defines an optimization used to reduce the size of render target textures
  149616. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149617. */
  149618. export class TextureOptimization extends SceneOptimization {
  149619. /**
  149620. * Defines the priority of this optimization (0 by default which means first in the list)
  149621. */
  149622. priority: number;
  149623. /**
  149624. * 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
  149625. */
  149626. maximumSize: number;
  149627. /**
  149628. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  149629. */
  149630. step: number;
  149631. /**
  149632. * Gets a string describing the action executed by the current optimization
  149633. * @returns description string
  149634. */
  149635. getDescription(): string;
  149636. /**
  149637. * Creates the TextureOptimization object
  149638. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  149639. * @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
  149640. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  149641. */
  149642. constructor(
  149643. /**
  149644. * Defines the priority of this optimization (0 by default which means first in the list)
  149645. */
  149646. priority?: number,
  149647. /**
  149648. * 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
  149649. */
  149650. maximumSize?: number,
  149651. /**
  149652. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  149653. */
  149654. step?: number);
  149655. /**
  149656. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149657. * @param scene defines the current scene where to apply this optimization
  149658. * @param optimizer defines the current optimizer
  149659. * @returns true if everything that can be done was applied
  149660. */
  149661. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149662. }
  149663. /**
  149664. * Defines an optimization used to increase or decrease the rendering resolution
  149665. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149666. */
  149667. export class HardwareScalingOptimization extends SceneOptimization {
  149668. /**
  149669. * Defines the priority of this optimization (0 by default which means first in the list)
  149670. */
  149671. priority: number;
  149672. /**
  149673. * Defines the maximum scale to use (2 by default)
  149674. */
  149675. maximumScale: number;
  149676. /**
  149677. * Defines the step to use between two passes (0.5 by default)
  149678. */
  149679. step: number;
  149680. private _currentScale;
  149681. private _directionOffset;
  149682. /**
  149683. * Gets a string describing the action executed by the current optimization
  149684. * @return description string
  149685. */
  149686. getDescription(): string;
  149687. /**
  149688. * Creates the HardwareScalingOptimization object
  149689. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  149690. * @param maximumScale defines the maximum scale to use (2 by default)
  149691. * @param step defines the step to use between two passes (0.5 by default)
  149692. */
  149693. constructor(
  149694. /**
  149695. * Defines the priority of this optimization (0 by default which means first in the list)
  149696. */
  149697. priority?: number,
  149698. /**
  149699. * Defines the maximum scale to use (2 by default)
  149700. */
  149701. maximumScale?: number,
  149702. /**
  149703. * Defines the step to use between two passes (0.5 by default)
  149704. */
  149705. step?: number);
  149706. /**
  149707. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149708. * @param scene defines the current scene where to apply this optimization
  149709. * @param optimizer defines the current optimizer
  149710. * @returns true if everything that can be done was applied
  149711. */
  149712. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149713. }
  149714. /**
  149715. * Defines an optimization used to remove shadows
  149716. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149717. */
  149718. export class ShadowsOptimization extends SceneOptimization {
  149719. /**
  149720. * Gets a string describing the action executed by the current optimization
  149721. * @return description string
  149722. */
  149723. getDescription(): string;
  149724. /**
  149725. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149726. * @param scene defines the current scene where to apply this optimization
  149727. * @param optimizer defines the current optimizer
  149728. * @returns true if everything that can be done was applied
  149729. */
  149730. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149731. }
  149732. /**
  149733. * Defines an optimization used to turn post-processes off
  149734. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149735. */
  149736. export class PostProcessesOptimization extends SceneOptimization {
  149737. /**
  149738. * Gets a string describing the action executed by the current optimization
  149739. * @return description string
  149740. */
  149741. getDescription(): string;
  149742. /**
  149743. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149744. * @param scene defines the current scene where to apply this optimization
  149745. * @param optimizer defines the current optimizer
  149746. * @returns true if everything that can be done was applied
  149747. */
  149748. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149749. }
  149750. /**
  149751. * Defines an optimization used to turn lens flares off
  149752. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149753. */
  149754. export class LensFlaresOptimization extends SceneOptimization {
  149755. /**
  149756. * Gets a string describing the action executed by the current optimization
  149757. * @return description string
  149758. */
  149759. getDescription(): string;
  149760. /**
  149761. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149762. * @param scene defines the current scene where to apply this optimization
  149763. * @param optimizer defines the current optimizer
  149764. * @returns true if everything that can be done was applied
  149765. */
  149766. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149767. }
  149768. /**
  149769. * Defines an optimization based on user defined callback.
  149770. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149771. */
  149772. export class CustomOptimization extends SceneOptimization {
  149773. /**
  149774. * Callback called to apply the custom optimization.
  149775. */
  149776. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  149777. /**
  149778. * Callback called to get custom description
  149779. */
  149780. onGetDescription: () => string;
  149781. /**
  149782. * Gets a string describing the action executed by the current optimization
  149783. * @returns description string
  149784. */
  149785. getDescription(): string;
  149786. /**
  149787. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149788. * @param scene defines the current scene where to apply this optimization
  149789. * @param optimizer defines the current optimizer
  149790. * @returns true if everything that can be done was applied
  149791. */
  149792. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149793. }
  149794. /**
  149795. * Defines an optimization used to turn particles off
  149796. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149797. */
  149798. export class ParticlesOptimization extends SceneOptimization {
  149799. /**
  149800. * Gets a string describing the action executed by the current optimization
  149801. * @return description string
  149802. */
  149803. getDescription(): string;
  149804. /**
  149805. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149806. * @param scene defines the current scene where to apply this optimization
  149807. * @param optimizer defines the current optimizer
  149808. * @returns true if everything that can be done was applied
  149809. */
  149810. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149811. }
  149812. /**
  149813. * Defines an optimization used to turn render targets off
  149814. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149815. */
  149816. export class RenderTargetsOptimization extends SceneOptimization {
  149817. /**
  149818. * Gets a string describing the action executed by the current optimization
  149819. * @return description string
  149820. */
  149821. getDescription(): string;
  149822. /**
  149823. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149824. * @param scene defines the current scene where to apply this optimization
  149825. * @param optimizer defines the current optimizer
  149826. * @returns true if everything that can be done was applied
  149827. */
  149828. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149829. }
  149830. /**
  149831. * Defines an optimization used to merge meshes with compatible materials
  149832. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149833. */
  149834. export class MergeMeshesOptimization extends SceneOptimization {
  149835. private static _UpdateSelectionTree;
  149836. /**
  149837. * Gets or sets a boolean which defines if optimization octree has to be updated
  149838. */
  149839. static get UpdateSelectionTree(): boolean;
  149840. /**
  149841. * Gets or sets a boolean which defines if optimization octree has to be updated
  149842. */
  149843. static set UpdateSelectionTree(value: boolean);
  149844. /**
  149845. * Gets a string describing the action executed by the current optimization
  149846. * @return description string
  149847. */
  149848. getDescription(): string;
  149849. private _canBeMerged;
  149850. /**
  149851. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149852. * @param scene defines the current scene where to apply this optimization
  149853. * @param optimizer defines the current optimizer
  149854. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  149855. * @returns true if everything that can be done was applied
  149856. */
  149857. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  149858. }
  149859. /**
  149860. * Defines a list of options used by SceneOptimizer
  149861. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149862. */
  149863. export class SceneOptimizerOptions {
  149864. /**
  149865. * Defines the target frame rate to reach (60 by default)
  149866. */
  149867. targetFrameRate: number;
  149868. /**
  149869. * Defines the interval between two checkes (2000ms by default)
  149870. */
  149871. trackerDuration: number;
  149872. /**
  149873. * Gets the list of optimizations to apply
  149874. */
  149875. optimizations: SceneOptimization[];
  149876. /**
  149877. * Creates a new list of options used by SceneOptimizer
  149878. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  149879. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  149880. */
  149881. constructor(
  149882. /**
  149883. * Defines the target frame rate to reach (60 by default)
  149884. */
  149885. targetFrameRate?: number,
  149886. /**
  149887. * Defines the interval between two checkes (2000ms by default)
  149888. */
  149889. trackerDuration?: number);
  149890. /**
  149891. * Add a new optimization
  149892. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  149893. * @returns the current SceneOptimizerOptions
  149894. */
  149895. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  149896. /**
  149897. * Add a new custom optimization
  149898. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  149899. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  149900. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  149901. * @returns the current SceneOptimizerOptions
  149902. */
  149903. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  149904. /**
  149905. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  149906. * @param targetFrameRate defines the target frame rate (60 by default)
  149907. * @returns a SceneOptimizerOptions object
  149908. */
  149909. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  149910. /**
  149911. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  149912. * @param targetFrameRate defines the target frame rate (60 by default)
  149913. * @returns a SceneOptimizerOptions object
  149914. */
  149915. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  149916. /**
  149917. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  149918. * @param targetFrameRate defines the target frame rate (60 by default)
  149919. * @returns a SceneOptimizerOptions object
  149920. */
  149921. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  149922. }
  149923. /**
  149924. * Class used to run optimizations in order to reach a target frame rate
  149925. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149926. */
  149927. export class SceneOptimizer implements IDisposable {
  149928. private _isRunning;
  149929. private _options;
  149930. private _scene;
  149931. private _currentPriorityLevel;
  149932. private _targetFrameRate;
  149933. private _trackerDuration;
  149934. private _currentFrameRate;
  149935. private _sceneDisposeObserver;
  149936. private _improvementMode;
  149937. /**
  149938. * Defines an observable called when the optimizer reaches the target frame rate
  149939. */
  149940. onSuccessObservable: Observable<SceneOptimizer>;
  149941. /**
  149942. * Defines an observable called when the optimizer enables an optimization
  149943. */
  149944. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  149945. /**
  149946. * Defines an observable called when the optimizer is not able to reach the target frame rate
  149947. */
  149948. onFailureObservable: Observable<SceneOptimizer>;
  149949. /**
  149950. * Gets a boolean indicating if the optimizer is in improvement mode
  149951. */
  149952. get isInImprovementMode(): boolean;
  149953. /**
  149954. * Gets the current priority level (0 at start)
  149955. */
  149956. get currentPriorityLevel(): number;
  149957. /**
  149958. * Gets the current frame rate checked by the SceneOptimizer
  149959. */
  149960. get currentFrameRate(): number;
  149961. /**
  149962. * Gets or sets the current target frame rate (60 by default)
  149963. */
  149964. get targetFrameRate(): number;
  149965. /**
  149966. * Gets or sets the current target frame rate (60 by default)
  149967. */
  149968. set targetFrameRate(value: number);
  149969. /**
  149970. * Gets or sets the current interval between two checks (every 2000ms by default)
  149971. */
  149972. get trackerDuration(): number;
  149973. /**
  149974. * Gets or sets the current interval between two checks (every 2000ms by default)
  149975. */
  149976. set trackerDuration(value: number);
  149977. /**
  149978. * Gets the list of active optimizations
  149979. */
  149980. get optimizations(): SceneOptimization[];
  149981. /**
  149982. * Creates a new SceneOptimizer
  149983. * @param scene defines the scene to work on
  149984. * @param options defines the options to use with the SceneOptimizer
  149985. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  149986. * @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)
  149987. */
  149988. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  149989. /**
  149990. * Stops the current optimizer
  149991. */
  149992. stop(): void;
  149993. /**
  149994. * Reset the optimizer to initial step (current priority level = 0)
  149995. */
  149996. reset(): void;
  149997. /**
  149998. * Start the optimizer. By default it will try to reach a specific framerate
  149999. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  150000. */
  150001. start(): void;
  150002. private _checkCurrentState;
  150003. /**
  150004. * Release all resources
  150005. */
  150006. dispose(): void;
  150007. /**
  150008. * Helper function to create a SceneOptimizer with one single line of code
  150009. * @param scene defines the scene to work on
  150010. * @param options defines the options to use with the SceneOptimizer
  150011. * @param onSuccess defines a callback to call on success
  150012. * @param onFailure defines a callback to call on failure
  150013. * @returns the new SceneOptimizer object
  150014. */
  150015. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  150016. }
  150017. }
  150018. declare module BABYLON {
  150019. /**
  150020. * Class used to serialize a scene into a string
  150021. */
  150022. export class SceneSerializer {
  150023. /**
  150024. * Clear cache used by a previous serialization
  150025. */
  150026. static ClearCache(): void;
  150027. /**
  150028. * Serialize a scene into a JSON compatible object
  150029. * @param scene defines the scene to serialize
  150030. * @returns a JSON compatible object
  150031. */
  150032. static Serialize(scene: Scene): any;
  150033. /**
  150034. * Serialize a mesh into a JSON compatible object
  150035. * @param toSerialize defines the mesh to serialize
  150036. * @param withParents defines if parents must be serialized as well
  150037. * @param withChildren defines if children must be serialized as well
  150038. * @returns a JSON compatible object
  150039. */
  150040. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  150041. }
  150042. }
  150043. declare module BABYLON {
  150044. /**
  150045. * Class used to host texture specific utilities
  150046. */
  150047. export class TextureTools {
  150048. /**
  150049. * Uses the GPU to create a copy texture rescaled at a given size
  150050. * @param texture Texture to copy from
  150051. * @param width defines the desired width
  150052. * @param height defines the desired height
  150053. * @param useBilinearMode defines if bilinear mode has to be used
  150054. * @return the generated texture
  150055. */
  150056. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  150057. }
  150058. }
  150059. declare module BABYLON {
  150060. /**
  150061. * This represents the different options available for the video capture.
  150062. */
  150063. export interface VideoRecorderOptions {
  150064. /** Defines the mime type of the video. */
  150065. mimeType: string;
  150066. /** Defines the FPS the video should be recorded at. */
  150067. fps: number;
  150068. /** Defines the chunk size for the recording data. */
  150069. recordChunckSize: number;
  150070. /** The audio tracks to attach to the recording. */
  150071. audioTracks?: MediaStreamTrack[];
  150072. }
  150073. /**
  150074. * This can help with recording videos from BabylonJS.
  150075. * This is based on the available WebRTC functionalities of the browser.
  150076. *
  150077. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  150078. */
  150079. export class VideoRecorder {
  150080. private static readonly _defaultOptions;
  150081. /**
  150082. * Returns whether or not the VideoRecorder is available in your browser.
  150083. * @param engine Defines the Babylon Engine.
  150084. * @returns true if supported otherwise false.
  150085. */
  150086. static IsSupported(engine: Engine): boolean;
  150087. private readonly _options;
  150088. private _canvas;
  150089. private _mediaRecorder;
  150090. private _recordedChunks;
  150091. private _fileName;
  150092. private _resolve;
  150093. private _reject;
  150094. /**
  150095. * True when a recording is already in progress.
  150096. */
  150097. get isRecording(): boolean;
  150098. /**
  150099. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  150100. * @param engine Defines the BabylonJS Engine you wish to record.
  150101. * @param options Defines options that can be used to customize the capture.
  150102. */
  150103. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  150104. /**
  150105. * Stops the current recording before the default capture timeout passed in the startRecording function.
  150106. */
  150107. stopRecording(): void;
  150108. /**
  150109. * Starts recording the canvas for a max duration specified in parameters.
  150110. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  150111. * If null no automatic download will start and you can rely on the promise to get the data back.
  150112. * @param maxDuration Defines the maximum recording time in seconds.
  150113. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  150114. * @return A promise callback at the end of the recording with the video data in Blob.
  150115. */
  150116. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  150117. /**
  150118. * Releases internal resources used during the recording.
  150119. */
  150120. dispose(): void;
  150121. private _handleDataAvailable;
  150122. private _handleError;
  150123. private _handleStop;
  150124. }
  150125. }
  150126. declare module BABYLON {
  150127. /**
  150128. * Class containing a set of static utilities functions for screenshots
  150129. */
  150130. export class ScreenshotTools {
  150131. /**
  150132. * Captures a screenshot of the current rendering
  150133. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  150134. * @param engine defines the rendering engine
  150135. * @param camera defines the source camera
  150136. * @param size This parameter can be set to a single number or to an object with the
  150137. * following (optional) properties: precision, width, height. If a single number is passed,
  150138. * it will be used for both width and height. If an object is passed, the screenshot size
  150139. * will be derived from the parameters. The precision property is a multiplier allowing
  150140. * rendering at a higher or lower resolution
  150141. * @param successCallback defines the callback receives a single parameter which contains the
  150142. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  150143. * src parameter of an <img> to display it
  150144. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  150145. * Check your browser for supported MIME types
  150146. */
  150147. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  150148. /**
  150149. * Captures a screenshot of the current rendering
  150150. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  150151. * @param engine defines the rendering engine
  150152. * @param camera defines the source camera
  150153. * @param size This parameter can be set to a single number or to an object with the
  150154. * following (optional) properties: precision, width, height. If a single number is passed,
  150155. * it will be used for both width and height. If an object is passed, the screenshot size
  150156. * will be derived from the parameters. The precision property is a multiplier allowing
  150157. * rendering at a higher or lower resolution
  150158. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  150159. * Check your browser for supported MIME types
  150160. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  150161. * to the src parameter of an <img> to display it
  150162. */
  150163. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  150164. /**
  150165. * Generates an image screenshot from the specified camera.
  150166. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  150167. * @param engine The engine to use for rendering
  150168. * @param camera The camera to use for rendering
  150169. * @param size This parameter can be set to a single number or to an object with the
  150170. * following (optional) properties: precision, width, height. If a single number is passed,
  150171. * it will be used for both width and height. If an object is passed, the screenshot size
  150172. * will be derived from the parameters. The precision property is a multiplier allowing
  150173. * rendering at a higher or lower resolution
  150174. * @param successCallback The callback receives a single parameter which contains the
  150175. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  150176. * src parameter of an <img> to display it
  150177. * @param mimeType The MIME type of the screenshot image (default: image/png).
  150178. * Check your browser for supported MIME types
  150179. * @param samples Texture samples (default: 1)
  150180. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  150181. * @param fileName A name for for the downloaded file.
  150182. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  150183. */
  150184. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  150185. /**
  150186. * Generates an image screenshot from the specified camera.
  150187. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  150188. * @param engine The engine to use for rendering
  150189. * @param camera The camera to use for rendering
  150190. * @param size This parameter can be set to a single number or to an object with the
  150191. * following (optional) properties: precision, width, height. If a single number is passed,
  150192. * it will be used for both width and height. If an object is passed, the screenshot size
  150193. * will be derived from the parameters. The precision property is a multiplier allowing
  150194. * rendering at a higher or lower resolution
  150195. * @param mimeType The MIME type of the screenshot image (default: image/png).
  150196. * Check your browser for supported MIME types
  150197. * @param samples Texture samples (default: 1)
  150198. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  150199. * @param fileName A name for for the downloaded file.
  150200. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  150201. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  150202. * to the src parameter of an <img> to display it
  150203. */
  150204. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  150205. /**
  150206. * Gets height and width for screenshot size
  150207. * @private
  150208. */
  150209. private static _getScreenshotSize;
  150210. }
  150211. }
  150212. declare module BABYLON {
  150213. /**
  150214. * Interface for a data buffer
  150215. */
  150216. export interface IDataBuffer {
  150217. /**
  150218. * Reads bytes from the data buffer.
  150219. * @param byteOffset The byte offset to read
  150220. * @param byteLength The byte length to read
  150221. * @returns A promise that resolves when the bytes are read
  150222. */
  150223. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  150224. /**
  150225. * The byte length of the buffer.
  150226. */
  150227. readonly byteLength: number;
  150228. }
  150229. /**
  150230. * Utility class for reading from a data buffer
  150231. */
  150232. export class DataReader {
  150233. /**
  150234. * The data buffer associated with this data reader.
  150235. */
  150236. readonly buffer: IDataBuffer;
  150237. /**
  150238. * The current byte offset from the beginning of the data buffer.
  150239. */
  150240. byteOffset: number;
  150241. private _dataView;
  150242. private _dataByteOffset;
  150243. /**
  150244. * Constructor
  150245. * @param buffer The buffer to read
  150246. */
  150247. constructor(buffer: IDataBuffer);
  150248. /**
  150249. * Loads the given byte length.
  150250. * @param byteLength The byte length to load
  150251. * @returns A promise that resolves when the load is complete
  150252. */
  150253. loadAsync(byteLength: number): Promise<void>;
  150254. /**
  150255. * Read a unsigned 32-bit integer from the currently loaded data range.
  150256. * @returns The 32-bit integer read
  150257. */
  150258. readUint32(): number;
  150259. /**
  150260. * Read a byte array from the currently loaded data range.
  150261. * @param byteLength The byte length to read
  150262. * @returns The byte array read
  150263. */
  150264. readUint8Array(byteLength: number): Uint8Array;
  150265. /**
  150266. * Read a string from the currently loaded data range.
  150267. * @param byteLength The byte length to read
  150268. * @returns The string read
  150269. */
  150270. readString(byteLength: number): string;
  150271. /**
  150272. * Skips the given byte length the currently loaded data range.
  150273. * @param byteLength The byte length to skip
  150274. */
  150275. skipBytes(byteLength: number): void;
  150276. }
  150277. }
  150278. declare module BABYLON {
  150279. /**
  150280. * Class for storing data to local storage if available or in-memory storage otherwise
  150281. */
  150282. export class DataStorage {
  150283. private static _Storage;
  150284. private static _GetStorage;
  150285. /**
  150286. * Reads a string from the data storage
  150287. * @param key The key to read
  150288. * @param defaultValue The value if the key doesn't exist
  150289. * @returns The string value
  150290. */
  150291. static ReadString(key: string, defaultValue: string): string;
  150292. /**
  150293. * Writes a string to the data storage
  150294. * @param key The key to write
  150295. * @param value The value to write
  150296. */
  150297. static WriteString(key: string, value: string): void;
  150298. /**
  150299. * Reads a boolean from the data storage
  150300. * @param key The key to read
  150301. * @param defaultValue The value if the key doesn't exist
  150302. * @returns The boolean value
  150303. */
  150304. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  150305. /**
  150306. * Writes a boolean to the data storage
  150307. * @param key The key to write
  150308. * @param value The value to write
  150309. */
  150310. static WriteBoolean(key: string, value: boolean): void;
  150311. /**
  150312. * Reads a number from the data storage
  150313. * @param key The key to read
  150314. * @param defaultValue The value if the key doesn't exist
  150315. * @returns The number value
  150316. */
  150317. static ReadNumber(key: string, defaultValue: number): number;
  150318. /**
  150319. * Writes a number to the data storage
  150320. * @param key The key to write
  150321. * @param value The value to write
  150322. */
  150323. static WriteNumber(key: string, value: number): void;
  150324. }
  150325. }
  150326. declare module BABYLON {
  150327. /**
  150328. * An interface for all Hit test features
  150329. */
  150330. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  150331. /**
  150332. * Triggered when new babylon (transformed) hit test results are available
  150333. */
  150334. onHitTestResultObservable: Observable<T[]>;
  150335. }
  150336. /**
  150337. * Options used for hit testing
  150338. */
  150339. export interface IWebXRLegacyHitTestOptions {
  150340. /**
  150341. * Only test when user interacted with the scene. Default - hit test every frame
  150342. */
  150343. testOnPointerDownOnly?: boolean;
  150344. /**
  150345. * The node to use to transform the local results to world coordinates
  150346. */
  150347. worldParentNode?: TransformNode;
  150348. }
  150349. /**
  150350. * Interface defining the babylon result of raycasting/hit-test
  150351. */
  150352. export interface IWebXRLegacyHitResult {
  150353. /**
  150354. * Transformation matrix that can be applied to a node that will put it in the hit point location
  150355. */
  150356. transformationMatrix: Matrix;
  150357. /**
  150358. * The native hit test result
  150359. */
  150360. xrHitResult: XRHitResult | XRHitTestResult;
  150361. }
  150362. /**
  150363. * The currently-working hit-test module.
  150364. * Hit test (or Ray-casting) is used to interact with the real world.
  150365. * For further information read here - https://github.com/immersive-web/hit-test
  150366. */
  150367. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  150368. /**
  150369. * options to use when constructing this feature
  150370. */
  150371. readonly options: IWebXRLegacyHitTestOptions;
  150372. private _direction;
  150373. private _mat;
  150374. private _onSelectEnabled;
  150375. private _origin;
  150376. /**
  150377. * The module's name
  150378. */
  150379. static readonly Name: string;
  150380. /**
  150381. * The (Babylon) version of this module.
  150382. * This is an integer representing the implementation version.
  150383. * This number does not correspond to the WebXR specs version
  150384. */
  150385. static readonly Version: number;
  150386. /**
  150387. * Populated with the last native XR Hit Results
  150388. */
  150389. lastNativeXRHitResults: XRHitResult[];
  150390. /**
  150391. * Triggered when new babylon (transformed) hit test results are available
  150392. */
  150393. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  150394. /**
  150395. * Creates a new instance of the (legacy version) hit test feature
  150396. * @param _xrSessionManager an instance of WebXRSessionManager
  150397. * @param options options to use when constructing this feature
  150398. */
  150399. constructor(_xrSessionManager: WebXRSessionManager,
  150400. /**
  150401. * options to use when constructing this feature
  150402. */
  150403. options?: IWebXRLegacyHitTestOptions);
  150404. /**
  150405. * execute a hit test with an XR Ray
  150406. *
  150407. * @param xrSession a native xrSession that will execute this hit test
  150408. * @param xrRay the ray (position and direction) to use for ray-casting
  150409. * @param referenceSpace native XR reference space to use for the hit-test
  150410. * @param filter filter function that will filter the results
  150411. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  150412. */
  150413. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  150414. /**
  150415. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  150416. * @param event the (select) event to use to select with
  150417. * @param referenceSpace the reference space to use for this hit test
  150418. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  150419. */
  150420. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  150421. /**
  150422. * attach this feature
  150423. * Will usually be called by the features manager
  150424. *
  150425. * @returns true if successful.
  150426. */
  150427. attach(): boolean;
  150428. /**
  150429. * detach this feature.
  150430. * Will usually be called by the features manager
  150431. *
  150432. * @returns true if successful.
  150433. */
  150434. detach(): boolean;
  150435. /**
  150436. * Dispose this feature and all of the resources attached
  150437. */
  150438. dispose(): void;
  150439. protected _onXRFrame(frame: XRFrame): void;
  150440. private _onHitTestResults;
  150441. private _onSelect;
  150442. }
  150443. }
  150444. declare module BABYLON {
  150445. /**
  150446. * Options used for hit testing (version 2)
  150447. */
  150448. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  150449. /**
  150450. * Do not create a permanent hit test. Will usually be used when only
  150451. * transient inputs are needed.
  150452. */
  150453. disablePermanentHitTest?: boolean;
  150454. /**
  150455. * Enable transient (for example touch-based) hit test inspections
  150456. */
  150457. enableTransientHitTest?: boolean;
  150458. /**
  150459. * Offset ray for the permanent hit test
  150460. */
  150461. offsetRay?: Vector3;
  150462. /**
  150463. * Offset ray for the transient hit test
  150464. */
  150465. transientOffsetRay?: Vector3;
  150466. /**
  150467. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  150468. */
  150469. useReferenceSpace?: boolean;
  150470. }
  150471. /**
  150472. * Interface defining the babylon result of hit-test
  150473. */
  150474. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  150475. /**
  150476. * The input source that generated this hit test (if transient)
  150477. */
  150478. inputSource?: XRInputSource;
  150479. /**
  150480. * Is this a transient hit test
  150481. */
  150482. isTransient?: boolean;
  150483. /**
  150484. * Position of the hit test result
  150485. */
  150486. position: Vector3;
  150487. /**
  150488. * Rotation of the hit test result
  150489. */
  150490. rotationQuaternion: Quaternion;
  150491. /**
  150492. * The native hit test result
  150493. */
  150494. xrHitResult: XRHitTestResult;
  150495. }
  150496. /**
  150497. * The currently-working hit-test module.
  150498. * Hit test (or Ray-casting) is used to interact with the real world.
  150499. * For further information read here - https://github.com/immersive-web/hit-test
  150500. *
  150501. * Tested on chrome (mobile) 80.
  150502. */
  150503. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  150504. /**
  150505. * options to use when constructing this feature
  150506. */
  150507. readonly options: IWebXRHitTestOptions;
  150508. private _tmpMat;
  150509. private _tmpPos;
  150510. private _tmpQuat;
  150511. private _transientXrHitTestSource;
  150512. private _xrHitTestSource;
  150513. private initHitTestSource;
  150514. /**
  150515. * The module's name
  150516. */
  150517. static readonly Name: string;
  150518. /**
  150519. * The (Babylon) version of this module.
  150520. * This is an integer representing the implementation version.
  150521. * This number does not correspond to the WebXR specs version
  150522. */
  150523. static readonly Version: number;
  150524. /**
  150525. * When set to true, each hit test will have its own position/rotation objects
  150526. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  150527. * the developers will clone them or copy them as they see fit.
  150528. */
  150529. autoCloneTransformation: boolean;
  150530. /**
  150531. * Triggered when new babylon (transformed) hit test results are available
  150532. */
  150533. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  150534. /**
  150535. * Use this to temporarily pause hit test checks.
  150536. */
  150537. paused: boolean;
  150538. /**
  150539. * Creates a new instance of the hit test feature
  150540. * @param _xrSessionManager an instance of WebXRSessionManager
  150541. * @param options options to use when constructing this feature
  150542. */
  150543. constructor(_xrSessionManager: WebXRSessionManager,
  150544. /**
  150545. * options to use when constructing this feature
  150546. */
  150547. options?: IWebXRHitTestOptions);
  150548. /**
  150549. * attach this feature
  150550. * Will usually be called by the features manager
  150551. *
  150552. * @returns true if successful.
  150553. */
  150554. attach(): boolean;
  150555. /**
  150556. * detach this feature.
  150557. * Will usually be called by the features manager
  150558. *
  150559. * @returns true if successful.
  150560. */
  150561. detach(): boolean;
  150562. /**
  150563. * Dispose this feature and all of the resources attached
  150564. */
  150565. dispose(): void;
  150566. protected _onXRFrame(frame: XRFrame): void;
  150567. private _processWebXRHitTestResult;
  150568. }
  150569. }
  150570. declare module BABYLON {
  150571. /**
  150572. * Configuration options of the anchor system
  150573. */
  150574. export interface IWebXRAnchorSystemOptions {
  150575. /**
  150576. * a node that will be used to convert local to world coordinates
  150577. */
  150578. worldParentNode?: TransformNode;
  150579. /**
  150580. * If set to true a reference of the created anchors will be kept until the next session starts
  150581. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  150582. */
  150583. doNotRemoveAnchorsOnSessionEnded?: boolean;
  150584. }
  150585. /**
  150586. * A babylon container for an XR Anchor
  150587. */
  150588. export interface IWebXRAnchor {
  150589. /**
  150590. * A babylon-assigned ID for this anchor
  150591. */
  150592. id: number;
  150593. /**
  150594. * Transformation matrix to apply to an object attached to this anchor
  150595. */
  150596. transformationMatrix: Matrix;
  150597. /**
  150598. * The native anchor object
  150599. */
  150600. xrAnchor: XRAnchor;
  150601. /**
  150602. * if defined, this object will be constantly updated by the anchor's position and rotation
  150603. */
  150604. attachedNode?: TransformNode;
  150605. }
  150606. /**
  150607. * An implementation of the anchor system for WebXR.
  150608. * For further information see https://github.com/immersive-web/anchors/
  150609. */
  150610. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  150611. private _options;
  150612. private _lastFrameDetected;
  150613. private _trackedAnchors;
  150614. private _referenceSpaceForFrameAnchors;
  150615. private _futureAnchors;
  150616. /**
  150617. * The module's name
  150618. */
  150619. static readonly Name: string;
  150620. /**
  150621. * The (Babylon) version of this module.
  150622. * This is an integer representing the implementation version.
  150623. * This number does not correspond to the WebXR specs version
  150624. */
  150625. static readonly Version: number;
  150626. /**
  150627. * Observers registered here will be executed when a new anchor was added to the session
  150628. */
  150629. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  150630. /**
  150631. * Observers registered here will be executed when an anchor was removed from the session
  150632. */
  150633. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  150634. /**
  150635. * Observers registered here will be executed when an existing anchor updates
  150636. * This can execute N times every frame
  150637. */
  150638. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  150639. /**
  150640. * Set the reference space to use for anchor creation, when not using a hit test.
  150641. * Will default to the session's reference space if not defined
  150642. */
  150643. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  150644. /**
  150645. * constructs a new anchor system
  150646. * @param _xrSessionManager an instance of WebXRSessionManager
  150647. * @param _options configuration object for this feature
  150648. */
  150649. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  150650. private _tmpVector;
  150651. private _tmpQuaternion;
  150652. private _populateTmpTransformation;
  150653. /**
  150654. * Create a new anchor point using a hit test result at a specific point in the scene
  150655. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  150656. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  150657. *
  150658. * @param hitTestResult The hit test result to use for this anchor creation
  150659. * @param position an optional position offset for this anchor
  150660. * @param rotationQuaternion an optional rotation offset for this anchor
  150661. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  150662. */
  150663. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  150664. /**
  150665. * Add a new anchor at a specific position and rotation
  150666. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  150667. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  150668. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  150669. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  150670. *
  150671. * @param position the position in which to add an anchor
  150672. * @param rotationQuaternion an optional rotation for the anchor transformation
  150673. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  150674. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  150675. */
  150676. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  150677. /**
  150678. * detach this feature.
  150679. * Will usually be called by the features manager
  150680. *
  150681. * @returns true if successful.
  150682. */
  150683. detach(): boolean;
  150684. /**
  150685. * Dispose this feature and all of the resources attached
  150686. */
  150687. dispose(): void;
  150688. protected _onXRFrame(frame: XRFrame): void;
  150689. /**
  150690. * avoiding using Array.find for global support.
  150691. * @param xrAnchor the plane to find in the array
  150692. */
  150693. private _findIndexInAnchorArray;
  150694. private _updateAnchorWithXRFrame;
  150695. private _createAnchorAtTransformation;
  150696. }
  150697. }
  150698. declare module BABYLON {
  150699. /**
  150700. * Options used in the plane detector module
  150701. */
  150702. export interface IWebXRPlaneDetectorOptions {
  150703. /**
  150704. * The node to use to transform the local results to world coordinates
  150705. */
  150706. worldParentNode?: TransformNode;
  150707. /**
  150708. * If set to true a reference of the created planes will be kept until the next session starts
  150709. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  150710. */
  150711. doNotRemovePlanesOnSessionEnded?: boolean;
  150712. }
  150713. /**
  150714. * A babylon interface for a WebXR plane.
  150715. * A Plane is actually a polygon, built from N points in space
  150716. *
  150717. * Supported in chrome 79, not supported in canary 81 ATM
  150718. */
  150719. export interface IWebXRPlane {
  150720. /**
  150721. * a babylon-assigned ID for this polygon
  150722. */
  150723. id: number;
  150724. /**
  150725. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  150726. */
  150727. polygonDefinition: Array<Vector3>;
  150728. /**
  150729. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  150730. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  150731. */
  150732. transformationMatrix: Matrix;
  150733. /**
  150734. * the native xr-plane object
  150735. */
  150736. xrPlane: XRPlane;
  150737. }
  150738. /**
  150739. * The plane detector is used to detect planes in the real world when in AR
  150740. * For more information see https://github.com/immersive-web/real-world-geometry/
  150741. */
  150742. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  150743. private _options;
  150744. private _detectedPlanes;
  150745. private _enabled;
  150746. private _lastFrameDetected;
  150747. /**
  150748. * The module's name
  150749. */
  150750. static readonly Name: string;
  150751. /**
  150752. * The (Babylon) version of this module.
  150753. * This is an integer representing the implementation version.
  150754. * This number does not correspond to the WebXR specs version
  150755. */
  150756. static readonly Version: number;
  150757. /**
  150758. * Observers registered here will be executed when a new plane was added to the session
  150759. */
  150760. onPlaneAddedObservable: Observable<IWebXRPlane>;
  150761. /**
  150762. * Observers registered here will be executed when a plane is no longer detected in the session
  150763. */
  150764. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  150765. /**
  150766. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  150767. * This can execute N times every frame
  150768. */
  150769. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  150770. /**
  150771. * construct a new Plane Detector
  150772. * @param _xrSessionManager an instance of xr Session manager
  150773. * @param _options configuration to use when constructing this feature
  150774. */
  150775. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  150776. /**
  150777. * detach this feature.
  150778. * Will usually be called by the features manager
  150779. *
  150780. * @returns true if successful.
  150781. */
  150782. detach(): boolean;
  150783. /**
  150784. * Dispose this feature and all of the resources attached
  150785. */
  150786. dispose(): void;
  150787. protected _onXRFrame(frame: XRFrame): void;
  150788. private _init;
  150789. private _updatePlaneWithXRPlane;
  150790. /**
  150791. * avoiding using Array.find for global support.
  150792. * @param xrPlane the plane to find in the array
  150793. */
  150794. private findIndexInPlaneArray;
  150795. }
  150796. }
  150797. declare module BABYLON {
  150798. /**
  150799. * Options interface for the background remover plugin
  150800. */
  150801. export interface IWebXRBackgroundRemoverOptions {
  150802. /**
  150803. * Further background meshes to disable when entering AR
  150804. */
  150805. backgroundMeshes?: AbstractMesh[];
  150806. /**
  150807. * flags to configure the removal of the environment helper.
  150808. * If not set, the entire background will be removed. If set, flags should be set as well.
  150809. */
  150810. environmentHelperRemovalFlags?: {
  150811. /**
  150812. * Should the skybox be removed (default false)
  150813. */
  150814. skyBox?: boolean;
  150815. /**
  150816. * Should the ground be removed (default false)
  150817. */
  150818. ground?: boolean;
  150819. };
  150820. /**
  150821. * don't disable the environment helper
  150822. */
  150823. ignoreEnvironmentHelper?: boolean;
  150824. }
  150825. /**
  150826. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  150827. */
  150828. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  150829. /**
  150830. * read-only options to be used in this module
  150831. */
  150832. readonly options: IWebXRBackgroundRemoverOptions;
  150833. /**
  150834. * The module's name
  150835. */
  150836. static readonly Name: string;
  150837. /**
  150838. * The (Babylon) version of this module.
  150839. * This is an integer representing the implementation version.
  150840. * This number does not correspond to the WebXR specs version
  150841. */
  150842. static readonly Version: number;
  150843. /**
  150844. * registered observers will be triggered when the background state changes
  150845. */
  150846. onBackgroundStateChangedObservable: Observable<boolean>;
  150847. /**
  150848. * constructs a new background remover module
  150849. * @param _xrSessionManager the session manager for this module
  150850. * @param options read-only options to be used in this module
  150851. */
  150852. constructor(_xrSessionManager: WebXRSessionManager,
  150853. /**
  150854. * read-only options to be used in this module
  150855. */
  150856. options?: IWebXRBackgroundRemoverOptions);
  150857. /**
  150858. * attach this feature
  150859. * Will usually be called by the features manager
  150860. *
  150861. * @returns true if successful.
  150862. */
  150863. attach(): boolean;
  150864. /**
  150865. * detach this feature.
  150866. * Will usually be called by the features manager
  150867. *
  150868. * @returns true if successful.
  150869. */
  150870. detach(): boolean;
  150871. /**
  150872. * Dispose this feature and all of the resources attached
  150873. */
  150874. dispose(): void;
  150875. protected _onXRFrame(_xrFrame: XRFrame): void;
  150876. private _setBackgroundState;
  150877. }
  150878. }
  150879. declare module BABYLON {
  150880. /**
  150881. * Options for the controller physics feature
  150882. */
  150883. export class IWebXRControllerPhysicsOptions {
  150884. /**
  150885. * Should the headset get its own impostor
  150886. */
  150887. enableHeadsetImpostor?: boolean;
  150888. /**
  150889. * Optional parameters for the headset impostor
  150890. */
  150891. headsetImpostorParams?: {
  150892. /**
  150893. * The type of impostor to create. Default is sphere
  150894. */
  150895. impostorType: number;
  150896. /**
  150897. * the size of the impostor. Defaults to 10cm
  150898. */
  150899. impostorSize?: number | {
  150900. width: number;
  150901. height: number;
  150902. depth: number;
  150903. };
  150904. /**
  150905. * Friction definitions
  150906. */
  150907. friction?: number;
  150908. /**
  150909. * Restitution
  150910. */
  150911. restitution?: number;
  150912. };
  150913. /**
  150914. * The physics properties of the future impostors
  150915. */
  150916. physicsProperties?: {
  150917. /**
  150918. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  150919. * Note that this requires a physics engine that supports mesh impostors!
  150920. */
  150921. useControllerMesh?: boolean;
  150922. /**
  150923. * The type of impostor to create. Default is sphere
  150924. */
  150925. impostorType?: number;
  150926. /**
  150927. * the size of the impostor. Defaults to 10cm
  150928. */
  150929. impostorSize?: number | {
  150930. width: number;
  150931. height: number;
  150932. depth: number;
  150933. };
  150934. /**
  150935. * Friction definitions
  150936. */
  150937. friction?: number;
  150938. /**
  150939. * Restitution
  150940. */
  150941. restitution?: number;
  150942. };
  150943. /**
  150944. * the xr input to use with this pointer selection
  150945. */
  150946. xrInput: WebXRInput;
  150947. }
  150948. /**
  150949. * Add physics impostor to your webxr controllers,
  150950. * including naive calculation of their linear and angular velocity
  150951. */
  150952. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  150953. private readonly _options;
  150954. private _attachController;
  150955. private _controllers;
  150956. private _debugMode;
  150957. private _delta;
  150958. private _headsetImpostor?;
  150959. private _headsetMesh?;
  150960. private _lastTimestamp;
  150961. private _tmpQuaternion;
  150962. private _tmpVector;
  150963. /**
  150964. * The module's name
  150965. */
  150966. static readonly Name: string;
  150967. /**
  150968. * The (Babylon) version of this module.
  150969. * This is an integer representing the implementation version.
  150970. * This number does not correspond to the webxr specs version
  150971. */
  150972. static readonly Version: number;
  150973. /**
  150974. * Construct a new Controller Physics Feature
  150975. * @param _xrSessionManager the corresponding xr session manager
  150976. * @param _options options to create this feature with
  150977. */
  150978. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  150979. /**
  150980. * @hidden
  150981. * enable debugging - will show console outputs and the impostor mesh
  150982. */
  150983. _enablePhysicsDebug(): void;
  150984. /**
  150985. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  150986. * @param xrController the controller to add
  150987. */
  150988. addController(xrController: WebXRInputSource): void;
  150989. /**
  150990. * attach this feature
  150991. * Will usually be called by the features manager
  150992. *
  150993. * @returns true if successful.
  150994. */
  150995. attach(): boolean;
  150996. /**
  150997. * detach this feature.
  150998. * Will usually be called by the features manager
  150999. *
  151000. * @returns true if successful.
  151001. */
  151002. detach(): boolean;
  151003. /**
  151004. * Get the headset impostor, if enabled
  151005. * @returns the impostor
  151006. */
  151007. getHeadsetImpostor(): PhysicsImpostor | undefined;
  151008. /**
  151009. * Get the physics impostor of a specific controller.
  151010. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  151011. * @param controller the controller or the controller id of which to get the impostor
  151012. * @returns the impostor or null
  151013. */
  151014. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  151015. /**
  151016. * Update the physics properties provided in the constructor
  151017. * @param newProperties the new properties object
  151018. */
  151019. setPhysicsProperties(newProperties: {
  151020. impostorType?: number;
  151021. impostorSize?: number | {
  151022. width: number;
  151023. height: number;
  151024. depth: number;
  151025. };
  151026. friction?: number;
  151027. restitution?: number;
  151028. }): void;
  151029. protected _onXRFrame(_xrFrame: any): void;
  151030. private _detachController;
  151031. }
  151032. }
  151033. declare module BABYLON {
  151034. /**
  151035. * The motion controller class for all microsoft mixed reality controllers
  151036. */
  151037. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  151038. protected readonly _mapping: {
  151039. defaultButton: {
  151040. valueNodeName: string;
  151041. unpressedNodeName: string;
  151042. pressedNodeName: string;
  151043. };
  151044. defaultAxis: {
  151045. valueNodeName: string;
  151046. minNodeName: string;
  151047. maxNodeName: string;
  151048. };
  151049. buttons: {
  151050. "xr-standard-trigger": {
  151051. rootNodeName: string;
  151052. componentProperty: string;
  151053. states: string[];
  151054. };
  151055. "xr-standard-squeeze": {
  151056. rootNodeName: string;
  151057. componentProperty: string;
  151058. states: string[];
  151059. };
  151060. "xr-standard-touchpad": {
  151061. rootNodeName: string;
  151062. labelAnchorNodeName: string;
  151063. touchPointNodeName: string;
  151064. };
  151065. "xr-standard-thumbstick": {
  151066. rootNodeName: string;
  151067. componentProperty: string;
  151068. states: string[];
  151069. };
  151070. };
  151071. axes: {
  151072. "xr-standard-touchpad": {
  151073. "x-axis": {
  151074. rootNodeName: string;
  151075. };
  151076. "y-axis": {
  151077. rootNodeName: string;
  151078. };
  151079. };
  151080. "xr-standard-thumbstick": {
  151081. "x-axis": {
  151082. rootNodeName: string;
  151083. };
  151084. "y-axis": {
  151085. rootNodeName: string;
  151086. };
  151087. };
  151088. };
  151089. };
  151090. /**
  151091. * The base url used to load the left and right controller models
  151092. */
  151093. static MODEL_BASE_URL: string;
  151094. /**
  151095. * The name of the left controller model file
  151096. */
  151097. static MODEL_LEFT_FILENAME: string;
  151098. /**
  151099. * The name of the right controller model file
  151100. */
  151101. static MODEL_RIGHT_FILENAME: string;
  151102. profileId: string;
  151103. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  151104. protected _getFilenameAndPath(): {
  151105. filename: string;
  151106. path: string;
  151107. };
  151108. protected _getModelLoadingConstraints(): boolean;
  151109. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  151110. protected _setRootMesh(meshes: AbstractMesh[]): void;
  151111. protected _updateModel(): void;
  151112. }
  151113. }
  151114. declare module BABYLON {
  151115. /**
  151116. * The motion controller class for oculus touch (quest, rift).
  151117. * This class supports legacy mapping as well the standard xr mapping
  151118. */
  151119. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  151120. private _forceLegacyControllers;
  151121. private _modelRootNode;
  151122. /**
  151123. * The base url used to load the left and right controller models
  151124. */
  151125. static MODEL_BASE_URL: string;
  151126. /**
  151127. * The name of the left controller model file
  151128. */
  151129. static MODEL_LEFT_FILENAME: string;
  151130. /**
  151131. * The name of the right controller model file
  151132. */
  151133. static MODEL_RIGHT_FILENAME: string;
  151134. /**
  151135. * Base Url for the Quest controller model.
  151136. */
  151137. static QUEST_MODEL_BASE_URL: string;
  151138. profileId: string;
  151139. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  151140. protected _getFilenameAndPath(): {
  151141. filename: string;
  151142. path: string;
  151143. };
  151144. protected _getModelLoadingConstraints(): boolean;
  151145. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  151146. protected _setRootMesh(meshes: AbstractMesh[]): void;
  151147. protected _updateModel(): void;
  151148. /**
  151149. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  151150. * between the touch and touch 2.
  151151. */
  151152. private _isQuest;
  151153. }
  151154. }
  151155. declare module BABYLON {
  151156. /**
  151157. * The motion controller class for the standard HTC-Vive controllers
  151158. */
  151159. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  151160. private _modelRootNode;
  151161. /**
  151162. * The base url used to load the left and right controller models
  151163. */
  151164. static MODEL_BASE_URL: string;
  151165. /**
  151166. * File name for the controller model.
  151167. */
  151168. static MODEL_FILENAME: string;
  151169. profileId: string;
  151170. /**
  151171. * Create a new Vive motion controller object
  151172. * @param scene the scene to use to create this controller
  151173. * @param gamepadObject the corresponding gamepad object
  151174. * @param handedness the handedness of the controller
  151175. */
  151176. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  151177. protected _getFilenameAndPath(): {
  151178. filename: string;
  151179. path: string;
  151180. };
  151181. protected _getModelLoadingConstraints(): boolean;
  151182. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  151183. protected _setRootMesh(meshes: AbstractMesh[]): void;
  151184. protected _updateModel(): void;
  151185. }
  151186. }
  151187. declare module BABYLON {
  151188. /**
  151189. * A cursor which tracks a point on a path
  151190. */
  151191. export class PathCursor {
  151192. private path;
  151193. /**
  151194. * Stores path cursor callbacks for when an onchange event is triggered
  151195. */
  151196. private _onchange;
  151197. /**
  151198. * The value of the path cursor
  151199. */
  151200. value: number;
  151201. /**
  151202. * The animation array of the path cursor
  151203. */
  151204. animations: Animation[];
  151205. /**
  151206. * Initializes the path cursor
  151207. * @param path The path to track
  151208. */
  151209. constructor(path: Path2);
  151210. /**
  151211. * Gets the cursor point on the path
  151212. * @returns A point on the path cursor at the cursor location
  151213. */
  151214. getPoint(): Vector3;
  151215. /**
  151216. * Moves the cursor ahead by the step amount
  151217. * @param step The amount to move the cursor forward
  151218. * @returns This path cursor
  151219. */
  151220. moveAhead(step?: number): PathCursor;
  151221. /**
  151222. * Moves the cursor behind by the step amount
  151223. * @param step The amount to move the cursor back
  151224. * @returns This path cursor
  151225. */
  151226. moveBack(step?: number): PathCursor;
  151227. /**
  151228. * Moves the cursor by the step amount
  151229. * If the step amount is greater than one, an exception is thrown
  151230. * @param step The amount to move the cursor
  151231. * @returns This path cursor
  151232. */
  151233. move(step: number): PathCursor;
  151234. /**
  151235. * Ensures that the value is limited between zero and one
  151236. * @returns This path cursor
  151237. */
  151238. private ensureLimits;
  151239. /**
  151240. * Runs onchange callbacks on change (used by the animation engine)
  151241. * @returns This path cursor
  151242. */
  151243. private raiseOnChange;
  151244. /**
  151245. * Executes a function on change
  151246. * @param f A path cursor onchange callback
  151247. * @returns This path cursor
  151248. */
  151249. onchange(f: (cursor: PathCursor) => void): PathCursor;
  151250. }
  151251. }
  151252. declare module BABYLON {
  151253. /** @hidden */
  151254. export var blurPixelShader: {
  151255. name: string;
  151256. shader: string;
  151257. };
  151258. }
  151259. declare module BABYLON {
  151260. /** @hidden */
  151261. export var pointCloudVertexDeclaration: {
  151262. name: string;
  151263. shader: string;
  151264. };
  151265. }
  151266. // Mixins
  151267. interface Window {
  151268. mozIndexedDB: IDBFactory;
  151269. webkitIndexedDB: IDBFactory;
  151270. msIndexedDB: IDBFactory;
  151271. webkitURL: typeof URL;
  151272. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  151273. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  151274. WebGLRenderingContext: WebGLRenderingContext;
  151275. MSGesture: MSGesture;
  151276. CANNON: any;
  151277. AudioContext: AudioContext;
  151278. webkitAudioContext: AudioContext;
  151279. PointerEvent: any;
  151280. Math: Math;
  151281. Uint8Array: Uint8ArrayConstructor;
  151282. Float32Array: Float32ArrayConstructor;
  151283. mozURL: typeof URL;
  151284. msURL: typeof URL;
  151285. VRFrameData: any; // WebVR, from specs 1.1
  151286. DracoDecoderModule: any;
  151287. setImmediate(handler: (...args: any[]) => void): number;
  151288. }
  151289. interface HTMLCanvasElement {
  151290. requestPointerLock(): void;
  151291. msRequestPointerLock?(): void;
  151292. mozRequestPointerLock?(): void;
  151293. webkitRequestPointerLock?(): void;
  151294. /** Track wether a record is in progress */
  151295. isRecording: boolean;
  151296. /** Capture Stream method defined by some browsers */
  151297. captureStream(fps?: number): MediaStream;
  151298. }
  151299. interface CanvasRenderingContext2D {
  151300. msImageSmoothingEnabled: boolean;
  151301. }
  151302. interface MouseEvent {
  151303. mozMovementX: number;
  151304. mozMovementY: number;
  151305. webkitMovementX: number;
  151306. webkitMovementY: number;
  151307. msMovementX: number;
  151308. msMovementY: number;
  151309. }
  151310. interface Navigator {
  151311. mozGetVRDevices: (any: any) => any;
  151312. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  151313. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  151314. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  151315. webkitGetGamepads(): Gamepad[];
  151316. msGetGamepads(): Gamepad[];
  151317. webkitGamepads(): Gamepad[];
  151318. }
  151319. interface HTMLVideoElement {
  151320. mozSrcObject: any;
  151321. }
  151322. interface Math {
  151323. fround(x: number): number;
  151324. imul(a: number, b: number): number;
  151325. }
  151326. interface WebGLRenderingContext {
  151327. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  151328. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  151329. vertexAttribDivisor(index: number, divisor: number): void;
  151330. createVertexArray(): any;
  151331. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  151332. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  151333. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  151334. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  151335. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  151336. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  151337. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  151338. // Queries
  151339. createQuery(): WebGLQuery;
  151340. deleteQuery(query: WebGLQuery): void;
  151341. beginQuery(target: number, query: WebGLQuery): void;
  151342. endQuery(target: number): void;
  151343. getQueryParameter(query: WebGLQuery, pname: number): any;
  151344. getQuery(target: number, pname: number): any;
  151345. MAX_SAMPLES: number;
  151346. RGBA8: number;
  151347. READ_FRAMEBUFFER: number;
  151348. DRAW_FRAMEBUFFER: number;
  151349. UNIFORM_BUFFER: number;
  151350. HALF_FLOAT_OES: number;
  151351. RGBA16F: number;
  151352. RGBA32F: number;
  151353. R32F: number;
  151354. RG32F: number;
  151355. RGB32F: number;
  151356. R16F: number;
  151357. RG16F: number;
  151358. RGB16F: number;
  151359. RED: number;
  151360. RG: number;
  151361. R8: number;
  151362. RG8: number;
  151363. UNSIGNED_INT_24_8: number;
  151364. DEPTH24_STENCIL8: number;
  151365. MIN: number;
  151366. MAX: number;
  151367. /* Multiple Render Targets */
  151368. drawBuffers(buffers: number[]): void;
  151369. readBuffer(src: number): void;
  151370. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  151371. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  151372. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  151373. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  151374. // Occlusion Query
  151375. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  151376. ANY_SAMPLES_PASSED: number;
  151377. QUERY_RESULT_AVAILABLE: number;
  151378. QUERY_RESULT: number;
  151379. }
  151380. interface WebGLProgram {
  151381. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  151382. }
  151383. interface EXT_disjoint_timer_query {
  151384. QUERY_COUNTER_BITS_EXT: number;
  151385. TIME_ELAPSED_EXT: number;
  151386. TIMESTAMP_EXT: number;
  151387. GPU_DISJOINT_EXT: number;
  151388. QUERY_RESULT_EXT: number;
  151389. QUERY_RESULT_AVAILABLE_EXT: number;
  151390. queryCounterEXT(query: WebGLQuery, target: number): void;
  151391. createQueryEXT(): WebGLQuery;
  151392. beginQueryEXT(target: number, query: WebGLQuery): void;
  151393. endQueryEXT(target: number): void;
  151394. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  151395. deleteQueryEXT(query: WebGLQuery): void;
  151396. }
  151397. interface WebGLUniformLocation {
  151398. _currentState: any;
  151399. }
  151400. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  151401. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  151402. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  151403. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  151404. interface WebGLRenderingContext {
  151405. readonly RASTERIZER_DISCARD: number;
  151406. readonly DEPTH_COMPONENT24: number;
  151407. readonly TEXTURE_3D: number;
  151408. readonly TEXTURE_2D_ARRAY: number;
  151409. readonly TEXTURE_COMPARE_FUNC: number;
  151410. readonly TEXTURE_COMPARE_MODE: number;
  151411. readonly COMPARE_REF_TO_TEXTURE: number;
  151412. readonly TEXTURE_WRAP_R: number;
  151413. readonly HALF_FLOAT: number;
  151414. readonly RGB8: number;
  151415. readonly RED_INTEGER: number;
  151416. readonly RG_INTEGER: number;
  151417. readonly RGB_INTEGER: number;
  151418. readonly RGBA_INTEGER: number;
  151419. readonly R8_SNORM: number;
  151420. readonly RG8_SNORM: number;
  151421. readonly RGB8_SNORM: number;
  151422. readonly RGBA8_SNORM: number;
  151423. readonly R8I: number;
  151424. readonly RG8I: number;
  151425. readonly RGB8I: number;
  151426. readonly RGBA8I: number;
  151427. readonly R8UI: number;
  151428. readonly RG8UI: number;
  151429. readonly RGB8UI: number;
  151430. readonly RGBA8UI: number;
  151431. readonly R16I: number;
  151432. readonly RG16I: number;
  151433. readonly RGB16I: number;
  151434. readonly RGBA16I: number;
  151435. readonly R16UI: number;
  151436. readonly RG16UI: number;
  151437. readonly RGB16UI: number;
  151438. readonly RGBA16UI: number;
  151439. readonly R32I: number;
  151440. readonly RG32I: number;
  151441. readonly RGB32I: number;
  151442. readonly RGBA32I: number;
  151443. readonly R32UI: number;
  151444. readonly RG32UI: number;
  151445. readonly RGB32UI: number;
  151446. readonly RGBA32UI: number;
  151447. readonly RGB10_A2UI: number;
  151448. readonly R11F_G11F_B10F: number;
  151449. readonly RGB9_E5: number;
  151450. readonly RGB10_A2: number;
  151451. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  151452. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  151453. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  151454. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  151455. readonly DEPTH_COMPONENT32F: number;
  151456. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  151457. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  151458. 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;
  151459. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  151460. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  151461. readonly TRANSFORM_FEEDBACK: number;
  151462. readonly INTERLEAVED_ATTRIBS: number;
  151463. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  151464. createTransformFeedback(): WebGLTransformFeedback;
  151465. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  151466. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  151467. beginTransformFeedback(primitiveMode: number): void;
  151468. endTransformFeedback(): void;
  151469. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  151470. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  151471. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  151472. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  151473. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  151474. }
  151475. interface ImageBitmap {
  151476. readonly width: number;
  151477. readonly height: number;
  151478. close(): void;
  151479. }
  151480. interface WebGLQuery extends WebGLObject {
  151481. }
  151482. declare var WebGLQuery: {
  151483. prototype: WebGLQuery;
  151484. new(): WebGLQuery;
  151485. };
  151486. interface WebGLSampler extends WebGLObject {
  151487. }
  151488. declare var WebGLSampler: {
  151489. prototype: WebGLSampler;
  151490. new(): WebGLSampler;
  151491. };
  151492. interface WebGLSync extends WebGLObject {
  151493. }
  151494. declare var WebGLSync: {
  151495. prototype: WebGLSync;
  151496. new(): WebGLSync;
  151497. };
  151498. interface WebGLTransformFeedback extends WebGLObject {
  151499. }
  151500. declare var WebGLTransformFeedback: {
  151501. prototype: WebGLTransformFeedback;
  151502. new(): WebGLTransformFeedback;
  151503. };
  151504. interface WebGLVertexArrayObject extends WebGLObject {
  151505. }
  151506. declare var WebGLVertexArrayObject: {
  151507. prototype: WebGLVertexArrayObject;
  151508. new(): WebGLVertexArrayObject;
  151509. };
  151510. // Type definitions for WebVR API
  151511. // Project: https://w3c.github.io/webvr/
  151512. // Definitions by: six a <https://github.com/lostfictions>
  151513. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  151514. interface VRDisplay extends EventTarget {
  151515. /**
  151516. * Dictionary of capabilities describing the VRDisplay.
  151517. */
  151518. readonly capabilities: VRDisplayCapabilities;
  151519. /**
  151520. * z-depth defining the far plane of the eye view frustum
  151521. * enables mapping of values in the render target depth
  151522. * attachment to scene coordinates. Initially set to 10000.0.
  151523. */
  151524. depthFar: number;
  151525. /**
  151526. * z-depth defining the near plane of the eye view frustum
  151527. * enables mapping of values in the render target depth
  151528. * attachment to scene coordinates. Initially set to 0.01.
  151529. */
  151530. depthNear: number;
  151531. /**
  151532. * An identifier for this distinct VRDisplay. Used as an
  151533. * association point in the Gamepad API.
  151534. */
  151535. readonly displayId: number;
  151536. /**
  151537. * A display name, a user-readable name identifying it.
  151538. */
  151539. readonly displayName: string;
  151540. readonly isConnected: boolean;
  151541. readonly isPresenting: boolean;
  151542. /**
  151543. * If this VRDisplay supports room-scale experiences, the optional
  151544. * stage attribute contains details on the room-scale parameters.
  151545. */
  151546. readonly stageParameters: VRStageParameters | null;
  151547. /**
  151548. * Passing the value returned by `requestAnimationFrame` to
  151549. * `cancelAnimationFrame` will unregister the callback.
  151550. * @param handle Define the hanle of the request to cancel
  151551. */
  151552. cancelAnimationFrame(handle: number): void;
  151553. /**
  151554. * Stops presenting to the VRDisplay.
  151555. * @returns a promise to know when it stopped
  151556. */
  151557. exitPresent(): Promise<void>;
  151558. /**
  151559. * Return the current VREyeParameters for the given eye.
  151560. * @param whichEye Define the eye we want the parameter for
  151561. * @returns the eye parameters
  151562. */
  151563. getEyeParameters(whichEye: string): VREyeParameters;
  151564. /**
  151565. * Populates the passed VRFrameData with the information required to render
  151566. * the current frame.
  151567. * @param frameData Define the data structure to populate
  151568. * @returns true if ok otherwise false
  151569. */
  151570. getFrameData(frameData: VRFrameData): boolean;
  151571. /**
  151572. * Get the layers currently being presented.
  151573. * @returns the list of VR layers
  151574. */
  151575. getLayers(): VRLayer[];
  151576. /**
  151577. * Return a VRPose containing the future predicted pose of the VRDisplay
  151578. * when the current frame will be presented. The value returned will not
  151579. * change until JavaScript has returned control to the browser.
  151580. *
  151581. * The VRPose will contain the position, orientation, velocity,
  151582. * and acceleration of each of these properties.
  151583. * @returns the pose object
  151584. */
  151585. getPose(): VRPose;
  151586. /**
  151587. * Return the current instantaneous pose of the VRDisplay, with no
  151588. * prediction applied.
  151589. * @returns the current instantaneous pose
  151590. */
  151591. getImmediatePose(): VRPose;
  151592. /**
  151593. * The callback passed to `requestAnimationFrame` will be called
  151594. * any time a new frame should be rendered. When the VRDisplay is
  151595. * presenting the callback will be called at the native refresh
  151596. * rate of the HMD. When not presenting this function acts
  151597. * identically to how window.requestAnimationFrame acts. Content should
  151598. * make no assumptions of frame rate or vsync behavior as the HMD runs
  151599. * asynchronously from other displays and at differing refresh rates.
  151600. * @param callback Define the eaction to run next frame
  151601. * @returns the request handle it
  151602. */
  151603. requestAnimationFrame(callback: FrameRequestCallback): number;
  151604. /**
  151605. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  151606. * Repeat calls while already presenting will update the VRLayers being displayed.
  151607. * @param layers Define the list of layer to present
  151608. * @returns a promise to know when the request has been fulfilled
  151609. */
  151610. requestPresent(layers: VRLayer[]): Promise<void>;
  151611. /**
  151612. * Reset the pose for this display, treating its current position and
  151613. * orientation as the "origin/zero" values. VRPose.position,
  151614. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  151615. * updated when calling resetPose(). This should be called in only
  151616. * sitting-space experiences.
  151617. */
  151618. resetPose(): void;
  151619. /**
  151620. * The VRLayer provided to the VRDisplay will be captured and presented
  151621. * in the HMD. Calling this function has the same effect on the source
  151622. * canvas as any other operation that uses its source image, and canvases
  151623. * created without preserveDrawingBuffer set to true will be cleared.
  151624. * @param pose Define the pose to submit
  151625. */
  151626. submitFrame(pose?: VRPose): void;
  151627. }
  151628. declare var VRDisplay: {
  151629. prototype: VRDisplay;
  151630. new(): VRDisplay;
  151631. };
  151632. interface VRLayer {
  151633. leftBounds?: number[] | Float32Array | null;
  151634. rightBounds?: number[] | Float32Array | null;
  151635. source?: HTMLCanvasElement | null;
  151636. }
  151637. interface VRDisplayCapabilities {
  151638. readonly canPresent: boolean;
  151639. readonly hasExternalDisplay: boolean;
  151640. readonly hasOrientation: boolean;
  151641. readonly hasPosition: boolean;
  151642. readonly maxLayers: number;
  151643. }
  151644. interface VREyeParameters {
  151645. /** @deprecated */
  151646. readonly fieldOfView: VRFieldOfView;
  151647. readonly offset: Float32Array;
  151648. readonly renderHeight: number;
  151649. readonly renderWidth: number;
  151650. }
  151651. interface VRFieldOfView {
  151652. readonly downDegrees: number;
  151653. readonly leftDegrees: number;
  151654. readonly rightDegrees: number;
  151655. readonly upDegrees: number;
  151656. }
  151657. interface VRFrameData {
  151658. readonly leftProjectionMatrix: Float32Array;
  151659. readonly leftViewMatrix: Float32Array;
  151660. readonly pose: VRPose;
  151661. readonly rightProjectionMatrix: Float32Array;
  151662. readonly rightViewMatrix: Float32Array;
  151663. readonly timestamp: number;
  151664. }
  151665. interface VRPose {
  151666. readonly angularAcceleration: Float32Array | null;
  151667. readonly angularVelocity: Float32Array | null;
  151668. readonly linearAcceleration: Float32Array | null;
  151669. readonly linearVelocity: Float32Array | null;
  151670. readonly orientation: Float32Array | null;
  151671. readonly position: Float32Array | null;
  151672. readonly timestamp: number;
  151673. }
  151674. interface VRStageParameters {
  151675. sittingToStandingTransform?: Float32Array;
  151676. sizeX?: number;
  151677. sizeY?: number;
  151678. }
  151679. interface Navigator {
  151680. getVRDisplays(): Promise<VRDisplay[]>;
  151681. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  151682. }
  151683. interface Window {
  151684. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  151685. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  151686. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  151687. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  151688. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  151689. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  151690. }
  151691. interface Gamepad {
  151692. readonly displayId: number;
  151693. }
  151694. type XRSessionMode =
  151695. | "inline"
  151696. | "immersive-vr"
  151697. | "immersive-ar";
  151698. type XRReferenceSpaceType =
  151699. | "viewer"
  151700. | "local"
  151701. | "local-floor"
  151702. | "bounded-floor"
  151703. | "unbounded";
  151704. type XREnvironmentBlendMode =
  151705. | "opaque"
  151706. | "additive"
  151707. | "alpha-blend";
  151708. type XRVisibilityState =
  151709. | "visible"
  151710. | "visible-blurred"
  151711. | "hidden";
  151712. type XRHandedness =
  151713. | "none"
  151714. | "left"
  151715. | "right";
  151716. type XRTargetRayMode =
  151717. | "gaze"
  151718. | "tracked-pointer"
  151719. | "screen";
  151720. type XREye =
  151721. | "none"
  151722. | "left"
  151723. | "right";
  151724. type XREventType =
  151725. | "devicechange"
  151726. | "visibilitychange"
  151727. | "end"
  151728. | "inputsourceschange"
  151729. | "select"
  151730. | "selectstart"
  151731. | "selectend"
  151732. | "squeeze"
  151733. | "squeezestart"
  151734. | "squeezeend"
  151735. | "reset";
  151736. interface XRSpace extends EventTarget {
  151737. }
  151738. interface XRRenderState {
  151739. depthNear?: number;
  151740. depthFar?: number;
  151741. inlineVerticalFieldOfView?: number;
  151742. baseLayer?: XRWebGLLayer;
  151743. }
  151744. interface XRInputSource {
  151745. handedness: XRHandedness;
  151746. targetRayMode: XRTargetRayMode;
  151747. targetRaySpace: XRSpace;
  151748. gripSpace: XRSpace | undefined;
  151749. gamepad: Gamepad | undefined;
  151750. profiles: Array<string>;
  151751. }
  151752. interface XRSessionInit {
  151753. optionalFeatures?: string[];
  151754. requiredFeatures?: string[];
  151755. }
  151756. interface XRSession {
  151757. addEventListener: Function;
  151758. removeEventListener: Function;
  151759. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  151760. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  151761. requestAnimationFrame: Function;
  151762. end(): Promise<void>;
  151763. renderState: XRRenderState;
  151764. inputSources: Array<XRInputSource>;
  151765. // hit test
  151766. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  151767. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  151768. // legacy AR hit test
  151769. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  151770. // legacy plane detection
  151771. updateWorldTrackingState(options: {
  151772. planeDetectionState?: { enabled: boolean; }
  151773. }): void;
  151774. }
  151775. interface XRReferenceSpace extends XRSpace {
  151776. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  151777. onreset: any;
  151778. }
  151779. type XRPlaneSet = Set<XRPlane>;
  151780. type XRAnchorSet = Set<XRAnchor>;
  151781. interface XRFrame {
  151782. session: XRSession;
  151783. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  151784. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  151785. // AR
  151786. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  151787. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  151788. // Anchors
  151789. trackedAnchors?: XRAnchorSet;
  151790. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  151791. // Planes
  151792. worldInformation: {
  151793. detectedPlanes?: XRPlaneSet;
  151794. };
  151795. }
  151796. interface XRViewerPose extends XRPose {
  151797. views: Array<XRView>;
  151798. }
  151799. interface XRPose {
  151800. transform: XRRigidTransform;
  151801. emulatedPosition: boolean;
  151802. }
  151803. interface XRWebGLLayerOptions {
  151804. antialias?: boolean;
  151805. depth?: boolean;
  151806. stencil?: boolean;
  151807. alpha?: boolean;
  151808. multiview?: boolean;
  151809. framebufferScaleFactor?: number;
  151810. }
  151811. declare var XRWebGLLayer: {
  151812. prototype: XRWebGLLayer;
  151813. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  151814. };
  151815. interface XRWebGLLayer {
  151816. framebuffer: WebGLFramebuffer;
  151817. framebufferWidth: number;
  151818. framebufferHeight: number;
  151819. getViewport: Function;
  151820. }
  151821. declare class XRRigidTransform {
  151822. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  151823. position: DOMPointReadOnly;
  151824. orientation: DOMPointReadOnly;
  151825. matrix: Float32Array;
  151826. inverse: XRRigidTransform;
  151827. }
  151828. interface XRView {
  151829. eye: XREye;
  151830. projectionMatrix: Float32Array;
  151831. transform: XRRigidTransform;
  151832. }
  151833. interface XRInputSourceChangeEvent {
  151834. session: XRSession;
  151835. removed: Array<XRInputSource>;
  151836. added: Array<XRInputSource>;
  151837. }
  151838. interface XRInputSourceEvent extends Event {
  151839. readonly frame: XRFrame;
  151840. readonly inputSource: XRInputSource;
  151841. }
  151842. // Experimental(er) features
  151843. declare class XRRay {
  151844. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  151845. origin: DOMPointReadOnly;
  151846. direction: DOMPointReadOnly;
  151847. matrix: Float32Array;
  151848. }
  151849. declare enum XRHitTestTrackableType {
  151850. "point",
  151851. "plane"
  151852. }
  151853. interface XRHitResult {
  151854. hitMatrix: Float32Array;
  151855. }
  151856. interface XRTransientInputHitTestResult {
  151857. readonly inputSource: XRInputSource;
  151858. readonly results: Array<XRHitTestResult>;
  151859. }
  151860. interface XRHitTestResult {
  151861. getPose(baseSpace: XRSpace): XRPose | undefined;
  151862. // When anchor system is enabled
  151863. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  151864. }
  151865. interface XRHitTestSource {
  151866. cancel(): void;
  151867. }
  151868. interface XRTransientInputHitTestSource {
  151869. cancel(): void;
  151870. }
  151871. interface XRHitTestOptionsInit {
  151872. space: XRSpace;
  151873. entityTypes?: Array<XRHitTestTrackableType>;
  151874. offsetRay?: XRRay;
  151875. }
  151876. interface XRTransientInputHitTestOptionsInit {
  151877. profile: string;
  151878. entityTypes?: Array<XRHitTestTrackableType>;
  151879. offsetRay?: XRRay;
  151880. }
  151881. interface XRAnchor {
  151882. anchorSpace: XRSpace;
  151883. delete(): void;
  151884. }
  151885. interface XRPlane {
  151886. orientation: "Horizontal" | "Vertical";
  151887. planeSpace: XRSpace;
  151888. polygon: Array<DOMPointReadOnly>;
  151889. lastChangedTime: number;
  151890. }